From 0bef8775493e64463768f1cced6babb03233cef4 Mon Sep 17 00:00:00 2001 From: Lakshmi Vyasarajan Date: Sat, 18 Dec 2010 00:53:05 +0530 Subject: [PATCH] Fixed init statement. Added setup.py --- .gitignore | 3 +++ hyde/engine.py | 8 +++--- hyde/tests/test_initialize.py | 6 +++++ hyde/tests/test_jinja2template.py | 4 +-- hyde/main.py => main.py | 6 ++++- setup.py | 41 +++++++++++++++++++++++++++++++ 6 files changed, 61 insertions(+), 7 deletions(-) rename hyde/main.py => main.py (70%) create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index a26b00e..7f06cd8 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,7 @@ deploy/* pylint* *.tmproj test_site +dist +build +*egg* diff --git a/hyde/engine.py b/hyde/engine.py index d66df27..9064d8a 100644 --- a/hyde/engine.py +++ b/hyde/engine.py @@ -5,7 +5,7 @@ Implements the hyde entry point commands from commando import * from hyde.exceptions import HydeException from hyde.fs import File, Folder -from hyde.layout import Layout +from hyde.layout import Layout, HYDE_DATA from hyde.version import __version__ import os @@ -42,9 +42,9 @@ class Engine(Application): if sitepath.exists and not args.overwrite: raise HydeException("The given site path[%s] is not empty" % sitepath) layout = Layout.find_layout(args.layout) - if not layout.exists: + if not layout or not layout.exists: raise HydeException( "The given layout is invalid. Please check if you have the `layout` " - "is in the right place and the environment variable has been setup" - "properly") + "in the right place and the environment variable(%s) has been setup " + "properly if you are using custom path for layouts" % HYDE_DATA) layout.copy_to(args.sitepath) \ No newline at end of file diff --git a/hyde/tests/test_initialize.py b/hyde/tests/test_initialize.py index ce0667d..7e5613e 100644 --- a/hyde/tests/test_initialize.py +++ b/hyde/tests/test_initialize.py @@ -43,3 +43,9 @@ def test_ensure_no_exception_when_sitepath_does_not_exist(): assert TEST_SITE.child_folder('layout').exists assert File(TEST_SITE.child('info.yaml')).exists +@raises(HydeException) +@with_setup(create_test_site, delete_test_site) +def test_ensure_exception_when_layout_is_invalid(): + e = Engine() + e.run(e.parse(['-s', str(TEST_SITE), 'init', '-l', 'junk'])) + diff --git a/hyde/tests/test_jinja2template.py b/hyde/tests/test_jinja2template.py index 8d419ae..c9e8346 100644 --- a/hyde/tests/test_jinja2template.py +++ b/hyde/tests/test_jinja2template.py @@ -55,8 +55,8 @@ def test_render(): """ Uses pyquery to test the html structure for validity """ - t = Jinja2Template() - t.configure(JINJA2.path, None) + t = Jinja2Template(JINJA2.path) + t.configure(None) t.env.filters['dateformat'] = dateformat html = t.render('index.html', context) from pyquery import PyQuery diff --git a/hyde/main.py b/main.py similarity index 70% rename from hyde/main.py rename to main.py index c5b10ac..7ce4f36 100644 --- a/hyde/main.py +++ b/main.py @@ -5,5 +5,9 @@ The hyde executable """ from hyde.engine import Engine +def main(): + """Main""" + Engine().run() + if __name__ == "__main__": - Engine().run() \ No newline at end of file + main() \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..8ab93c9 --- /dev/null +++ b/setup.py @@ -0,0 +1,41 @@ +from setuptools import setup, find_packages +from hyde.version import __version__ + +setup(name='hyde', + version=__version__, + description='hyde is a pythonic static website generator', + author='Lakshmi Vyas', + author_email='lakshmi.vyas@gmail.com', + url='http://ringce.com/hyde', + packages=find_packages(), + install_requires=( + 'commando', + 'jinja2', + 'pyYAML', + 'markdown' + ), + scripts=['main.py'], + entry_points={ + 'console_scripts': [ + 'hyde = main:main' + ] + }, + license='MIT', + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Environment :: Console', + 'Intended Audience :: End Users/Desktop', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'License :: OSI Approved :: MIT License', + 'Operating System :: MacOS :: MacOS X', + 'Operating System :: Unix', + 'Operating System :: POSIX', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2.7', + 'Topic :: Software Development', + 'Topic :: Software Development :: Build Tools', + 'Topic :: Software Development :: Websites', + 'Topic :: Software Development :: Static Websites', + ], +)