diff --git a/.gitignore b/.gitignore index 7df4fed60df69e0da2b91fde6a034c144c78b614..115ab0ade121b5c5d14fda49c269449460ce8e92 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ __pycache__/ build/ dist/ *.egg-info +.tox/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 72a191b5c7b4482691ac3bf20ab30a52187b92d8..563ca007dcf2e8364c5327d8c01e3aab109b739a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,7 @@ test: script: - python setup.py test - pip install tox flake8 # you can also use tox - - tox -e py36,flake8 + - tox run: script: diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000000000000000000000000000000000000..1fe4f2bb7df0cd43abff8ac587ea41e38afd02c9 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,9 @@ +# Include the license file +include LICENSE.txt + +# Include the data files +recursive-include test *.html +recursive-include test *.py + +exclude .gitlab-ci.yml + diff --git a/setup.py b/setup.py index 83c9d3f67a455f80af1322e7644d2eaab6f1335b..9b4fdfd8863153bbb5a925ff58d59d5b613ef3d6 100755 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ # Based on the setuptools example ## -from setuptools import setup, find_packages +from setuptools import setup from codecs import open from os import path @@ -13,25 +13,26 @@ here = path.abspath(path.dirname(__file__)) with open(path.join(here, 'README.rst'), encoding='utf-8') as f: long_description = f.read() -setup(name='j2static', - version='0.1', - description='static templating engine', - long_description=long_description, - author='FOSS Galaxy', - author_email='software@fossgalaxy.com', - url='https://www.fossgalaxy.com', - install_requires=[ - 'jinja2', - ], - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Programming Language :: Python :: 3' - ], - packages=['j2static',], - package_dir={'j2static': 'src/j2static'}, - entry_points={ +setup( + name='j2static', + version='0.1', + description='static templating engine', + long_description=long_description, + author='FOSS Galaxy', + author_email='software@fossgalaxy.com', + url='https://www.fossgalaxy.com', + install_requires=[ + 'jinja2', + ], + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Programming Language :: Python :: 3' + ], + packages=['j2static', ], + package_dir={'j2static': 'src/j2static'}, + entry_points={ 'console_scripts': [ 'j2static=j2static:main', ], - }, - ) + }, +) diff --git a/src/j2static/main.py b/src/j2static/main.py index 2adceead2ee369011b7f3ee95ef02ecd10d81645..9f2e2ded69701f4cfce291f1c2da55d149f4bc93 100644 --- a/src/j2static/main.py +++ b/src/j2static/main.py @@ -1,17 +1,19 @@ #! /usr/bin/env python3 -TEMPLATE_DIR = "templates" - from jinja2 import Environment, PackageLoader, select_autoescape +TEMPLATE_DIR = "templates" + env = Environment( - loader=PackageLoader('test', TEMPLATE_DIR), - autoescape=select_autoescape(['html', 'xml']) + loader=PackageLoader('test', TEMPLATE_DIR), + autoescape=select_autoescape(['html', 'xml']) ) + def render(name): - template = env.get_template(name) - return template.render() + template = env.get_template(name) + return template.render() + def main(): print("test") diff --git a/src/j2static/webserver.py b/src/j2static/webserver.py index 032ba7f3f7b55886dfa4ff53325f73a6958b7bf2..5a19bcd05a02e7f6950160dac9d236751f7c0e62 100644 --- a/src/j2static/webserver.py +++ b/src/j2static/webserver.py @@ -2,7 +2,8 @@ ## # Dynamic server mode # -# This is useful for development because you can see the changes made in real time +# This is useful for development because you can see the changes made +# in real time. ## import main @@ -12,17 +13,19 @@ import socketserver PORT = 8082 + class TemplateHTTPServer(BaseHTTPRequestHandler): def do_GET(self): self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() - + data = main.render('index.html') self.wfile.write(data.encode()) + Handler = TemplateHTTPServer -httpd = socketserver.TCPServer( ("", PORT), Handler) +httpd = socketserver.TCPServer(("", PORT), Handler) httpd.serve_forever() httpd.close() diff --git a/test/__init__.py b/test/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/test/templates/_base.html b/test/templates/_base.html deleted file mode 100644 index d4544a9ca1a428c42b104085969dd9812d2c1a7b..0000000000000000000000000000000000000000 --- a/test/templates/_base.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - {% block content %} - {% endblock %} - - diff --git a/test/templates/index.html b/test/templates/index.html deleted file mode 100644 index 0d8a71bd5eaa73cf29d54c3df7a8494a24952194..0000000000000000000000000000000000000000 --- a/test/templates/index.html +++ /dev/null @@ -1,3 +0,0 @@ -{% extends "_base.html" %} - -{% block content %}test{% endblock %} diff --git a/tests/test_simple.py b/tests/test_simple.py new file mode 100644 index 0000000000000000000000000000000000000000..b7491accbdb488d17e39d6105f04d6ee5b9c4047 --- /dev/null +++ b/tests/test_simple.py @@ -0,0 +1,5 @@ +# Fake test case to check that tox works + + +def test_success(): + return True diff --git a/tox.ini b/tox.ini index b3f7fa58b089b1713a66a06d06710ec48747ea9a..997888d7ffa39aee3f741bcf197a6ba9c28499a2 100644 --- a/tox.ini +++ b/tox.ini @@ -11,13 +11,10 @@ # and also to help confirm pull requests to this project. [tox] -envlist = py{27,34,35,36} +envlist = py36 [testenv] basepython = - py27: python2.7 - py34: python3.4 - py35: python3.5 py36: python3.6 deps = check-manifest