From 7ef7dee28cea56b5376814e0f03c662bdc67fb82 Mon Sep 17 00:00:00 2001 From: Hugo Lefeuvre Date: Fri, 28 Apr 2017 12:30:18 +0200 Subject: [PATCH] Fix installation. --- juliet.py | 45 -------------------------------------------- juliet/FileParser.py | 4 ++-- juliet/__init__.py | 40 +++++++++++++++++++++++++++++++++++++++ setup.py | 8 +++++++- 4 files changed, 49 insertions(+), 48 deletions(-) delete mode 100755 juliet.py diff --git a/juliet.py b/juliet.py deleted file mode 100755 index c77f3ff..0000000 --- a/juliet.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/python3 - -import argparse -from juliet import Configurator, Builder, Loader - -def main(): - """ Parse command line arguments and execute passed subcommands. """ - - # Parse subcommand - parser = argparse.ArgumentParser(description='The lightweight static website generator') - subparsers = parser.add_subparsers(dest="sp", help="sub-command to be executed") - - parser_build = subparsers.add_parser('build', help="Build static site from local directory to the directory specified in config.yml") - - args = parser.parse_args() - - # Execute passed sub-command or return error - if(args.sp == "build"): - build(args) - -def build(args): - """ Build website to configured location. """ - - # Parse configuration - config = {"site": Configurator.getConfig()} - - # Load articles and pages from the files - config["posts"] = Loader.getFromFolder("posts/", config) - config["pages"] = Loader.getFromFolder("pages/", config) - - # Configure Jinja2 environment - jinjaEnv = Configurator.configureJinja(config["site"]) - - # Build statics - Builder.buildStatics(config, jinjaEnv) - - # Build posts and pages - Builder.buildPosts(config, jinjaEnv) - Builder.buildPages(config, jinjaEnv) - - # Install remaining data - Builder.installData(config) - -if __name__ == "__main__": - main() diff --git a/juliet/FileParser.py b/juliet/FileParser.py index 9ea0df1..29faa1e 100644 --- a/juliet/FileParser.py +++ b/juliet/FileParser.py @@ -8,7 +8,7 @@ from pygments.formatters import HtmlFormatter def _processPygments(splittedBody): - """ Parse and replace highlight blocks in passed body.""" + """ Parse and replace highlight blocks in passed body. """ HIGHLIGHT = re.compile("{%\s*?highlight (\w+)\s*?%}") ENDHIGHLIGHT = re.compile("{%\s*?endhighlight\s*?%}") @@ -64,7 +64,7 @@ def _processBody(splittedBody, baseurl): def _getHeaderLimit(splittedFile): """ Return the position of header limiter "---". Return -1 if there's no - header, None if passed file is bad formatted.""" + header, None if passed file is bad formatted. """ if(not splittedFile or splittedFile[0] != "---"): # File is empty or doesn't start by a header limiter diff --git a/juliet/__init__.py b/juliet/__init__.py index e69de29..c4c9f12 100644 --- a/juliet/__init__.py +++ b/juliet/__init__.py @@ -0,0 +1,40 @@ +import argparse +from juliet import Configurator, Builder, Loader + +def main(): + """ Parse command line arguments and execute passed subcommands. """ + + # Parse subcommand + parser = argparse.ArgumentParser(description='The lightweight static website generator') + subparsers = parser.add_subparsers(dest="sp", help="sub-command to be executed") + + parser_build = subparsers.add_parser('build', help="Build static site from local directory to the directory specified in config.yml") + + args = parser.parse_args() + + # Execute passed sub-command or return error + if(args.sp == "build"): + build(args) + +def build(args): + """ Build website to configured location. """ + + # Parse configuration + config = {"site": Configurator.getConfig()} + + # Load articles and pages from the files + config["posts"] = Loader.getFromFolder("posts/", config) + config["pages"] = Loader.getFromFolder("pages/", config) + + # Configure Jinja2 environment + jinjaEnv = Configurator.configureJinja(config["site"]) + + # Build statics + Builder.buildStatics(config, jinjaEnv) + + # Build posts and pages + Builder.buildPosts(config, jinjaEnv) + Builder.buildPages(config, jinjaEnv) + + # Install remaining data + Builder.installData(config) diff --git a/setup.py b/setup.py index fbcf226..98e56df 100755 --- a/setup.py +++ b/setup.py @@ -10,7 +10,13 @@ author_email='hle@owl.eu.com', license='MIT', packages=['juliet'], - scripts=['juliet.py'], + entry_points={ + 'console_scripts': [ + 'juliet = juliet:main' + ] + }, zip_safe=False, + install_requires = ['jinja2', 'pygments', 'pyyaml', 'markdown', + 'python-slugify'], test_suite='nose.collector', tests_require=['nose'])