all repos — py-vite @ 694271d5ee33a09cd8144f190be54562aeb0ce23

the original vite, written in python

refactor: use os instead of pathlib
icyphox icyph0x@protonmail.com
Sat, 17 Mar 2018 17:46:22 +0530
commit

694271d5ee33a09cd8144f190be54562aeb0ce23

parent

db4bfe77b2ebfb81d7a8aa9f9dfff56880b91d16

1 files changed, 6 insertions(+), 6 deletions(-)

jump to
M vite.pyvite.py

@@ -7,6 +7,7 @@ import argparse

import errno import pathlib import os +import importlib parser = argparse.ArgumentParser(description='A simple and mnml static site generator.') parser.add_argument('action', choices=['new', 'build'])

@@ -24,11 +25,11 @@ def create_project(path):

try: abs_path = pathlib.Path(path).resolve() cur_path = pathlib.Path('.').resolve() - pathlib.Path(path + '/pages').mkdir(parents=True, exist_ok=False) - pathlib.Path(path + '/build').mkdir(exist_ok=False) - pathlib.Path(path + '/templates').mkdir(exist_ok=False) + os.makedirs(os.path.join(path, 'build')) + os.mkdir(os.path.join(path, 'pages')) + os.mkdir(os.path.join(path, 'templates')) create_config(path) - os.symlink(cur_path / 'make.py', abs_path / 'make.py') + os.symlink(os.path.join(cur_path, 'make.py'), os.path.join(abs_path, 'make.py')) print('Created project directory at %s.' % (abs_path)) except FileExistsError: print('Error: specified path exists')

@@ -45,9 +46,8 @@ """)

def build_project(path): try: - sys.path.append(path) os.chdir(path) - import make + importlib.import_module('make') except FileNotFoundError as e: print('Error: no such file or directory: %s' % (path))