all repos — py-vite @ 7036c57fb3c5150a618ebd2e8e934dbf4bd8d31b

the original vite, written in python

style: follow flake8
icyphox icyph0x@protonmail.com
Sat, 17 Mar 2018 18:21:42 +0530
commit

7036c57fb3c5150a618ebd2e8e934dbf4bd8d31b

parent

694271d5ee33a09cd8144f190be54562aeb0ce23

1 files changed, 12 insertions(+), 5 deletions(-)

jump to
M vite.pyvite.py

@@ -4,12 +4,13 @@ """

import sys import argparse -import errno import pathlib import os import importlib -parser = argparse.ArgumentParser(description='A simple and mnml static site generator.') +parser = argparse.ArgumentParser(description=""" + A simple and minimal static site generator. + """) parser.add_argument('action', choices=['new', 'build']) # TODO: add help for each action parser.add_argument('path', nargs='*')

@@ -21,6 +22,7 @@

args = parser.parse_args() project_path = args.path[0] + def create_project(path): try: abs_path = pathlib.Path(path).resolve()

@@ -29,11 +31,13 @@ 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(os.path.join(cur_path, 'make.py'), os.path.join(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') + def create_config(path): with open(path + '/config.py', 'w') as f: f.write("""# config.py - Vite's configuration script

@@ -43,6 +47,7 @@ author = ''

header = '' footer = '' """) + def build_project(path): try:

@@ -51,11 +56,13 @@ importlib.import_module('make')

except FileNotFoundError as e: print('Error: no such file or directory: %s' % (path)) + def main(): - if(args.action == 'new'): + if args.action == 'new': create_project(project_path) - elif(args.action == 'build'): + elif args.action == 'build': build_project(project_path) + if __name__ == "__main__": main()