[Python-modules-commits] [jinja2-time] 01/06: Imported Upstream version 0.1.0
Vincent Bernat
bernat at moszumanska.debian.org
Thu May 26 09:38:23 UTC 2016
This is an automated email from the git hooks/post-receive script.
bernat pushed a commit to branch master
in repository jinja2-time.
commit 59991a56aed8b4195cfc4a498d8277c5c0a1fb62
Author: Vincent Bernat <bernat at debian.org>
Date: Thu May 26 11:04:46 2016 +0200
Imported Upstream version 0.1.0
---
AUTHORS.rst | 13 +++
CONTRIBUTING.rst | 6 ++
HISTORY.rst | 9 ++
LICENSE | 22 +++++
MANIFEST.in | 9 ++
PKG-INFO | 140 ++++++++++++++++++++++++++++++
README.rst | 115 ++++++++++++++++++++++++
jinja2_time.egg-info/PKG-INFO | 140 ++++++++++++++++++++++++++++++
jinja2_time.egg-info/SOURCES.txt | 17 ++++
jinja2_time.egg-info/dependency_links.txt | 1 +
jinja2_time.egg-info/not-zip-safe | 1 +
jinja2_time.egg-info/requires.txt | 2 +
jinja2_time.egg-info/top_level.txt | 1 +
jinja2_time/__init__.py | 9 ++
jinja2_time/jinja2_time.py | 36 ++++++++
setup.cfg | 18 ++++
setup.py | 53 +++++++++++
tests/test_now.py | 51 +++++++++++
18 files changed, 643 insertions(+)
diff --git a/AUTHORS.rst b/AUTHORS.rst
new file mode 100644
index 0000000..79a7bd8
--- /dev/null
+++ b/AUTHORS.rst
@@ -0,0 +1,13 @@
+=======
+Credits
+=======
+
+Development Lead
+----------------
+
+* Raphael Pierzina <raphael at hackebrot.de>
+
+Contributors
+------------
+
+None yet. Why not be the first?
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
new file mode 100644
index 0000000..0f699cd
--- /dev/null
+++ b/CONTRIBUTING.rst
@@ -0,0 +1,6 @@
+============
+Contributing
+============
+
+Contributions are welcome, and they are greatly appreciated! Every
+little bit helps, and credit will always be given.
diff --git a/HISTORY.rst b/HISTORY.rst
new file mode 100644
index 0000000..e51dcd7
--- /dev/null
+++ b/HISTORY.rst
@@ -0,0 +1,9 @@
+.. :changelog:
+
+History
+-------
+
+0.1.0 (2015-12-05)
+---------------------
+
+* First release on PyPI.
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..4ea17e5
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 Raphael Pierzina
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..612633b
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,9 @@
+include AUTHORS.rst
+include CONTRIBUTING.rst
+include HISTORY.rst
+include LICENSE
+include README.rst
+
+recursive-include tests *
+recursive-exclude * __pycache__
+recursive-exclude * *.py[co]
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..09a4413
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,140 @@
+Metadata-Version: 1.1
+Name: jinja2-time
+Version: 0.1.0
+Summary: Jinja2 Extension for Dates and Times
+Home-page: https://github.com/hackebrot/jinja2-time
+Author: Raphael Pierzina
+Author-email: raphael at hackebrot.de
+License: MIT
+Description: ===========
+ Jinja2 Time
+ ===========
+
+ |pypi| |pyversions| |license| |travis-ci|
+
+ Jinja2 Extension for Dates and Times
+
+ .. |pypi| image:: https://img.shields.io/pypi/v/jinja2-time.svg
+ :target: https://pypi.python.org/pypi/jinja2-time
+ :alt: PyPI Package
+
+ .. |pyversions| image:: https://img.shields.io/pypi/pyversions/jinja2-time.svg
+ :target: https://pypi.python.org/pypi/jinja2-time/
+ :alt: PyPI Python Versions
+
+ .. |license| image:: https://img.shields.io/pypi/l/jinja2-time.svg
+ :target: https://pypi.python.org/pypi/jinja2-time
+ :alt: PyPI Package License
+
+ .. |travis-ci| image:: https://travis-ci.org/hackebrot/jinja2-time.svg?branch=master
+ :target: https://travis-ci.org/hackebrot/jinja2-time
+ :alt: See Build Status on Travis CI
+
+ Installation
+ ------------
+
+ **jinja2-time** is available for download from `PyPI`_ via `pip`_::
+
+ $ pip install jinja2-time
+
+ It will automatically install `jinja2`_ along with `arrow`_.
+
+ .. _`jinja2`: https://github.com/mitsuhiko/jinja2
+ .. _`PyPI`: https://pypi.python.org/pypi
+ .. _`arrow`: https://github.com/crsmithdev/arrow
+ .. _`pip`: https://pypi.python.org/pypi/pip/
+
+ Usage
+ -----
+
+ Now Tag
+ ~~~~~~~
+
+ The extension comes with a ``now`` tag that provides convenient access to the
+ `arrow.now()`_ API from your templates.
+
+ You can control the output by specifying a format, that will be passed to
+ Python's `strftime()`_:
+
+ .. _`arrow.now()`: http://crsmithdev.com/arrow/#arrow.factory.ArrowFactory.now
+ .. _`strftime()`: https://docs.python.org/3.5/library/datetime.html#strftime-and-strptime-behavior
+
+ .. code-block:: python
+
+ from jinja2 import Environment
+
+ env = Environment(extensions=['jinja2_time.TimeExtension'])
+
+ # Timezone 'local', default format -> "2015-12-10"
+ template = env.from_string("{% now 'local' %}")
+
+ # Timezone 'utc', explicit format -> "Thu, 10 Dec 2015 15:49:01"
+ template = env.from_string("{% now 'utc', '%a, %d %b %Y %H:%M:%S' %}")
+
+ # Timezone 'Europe/Berlin', explicit format -> "CET +0100"
+ template = env.from_string("{% now 'Europe/Berlin', '%Z %z' %}")
+
+ # Timezone 'utc', explicit format -> "2015"
+ template = env.from_string("{% now 'utc', '%Y' %}")
+
+ template.render()
+
+ Default Datetime Format
+ ~~~~~~~~~~~~~~~~~~~~~~~
+
+ **TimeExtension** extends the environment with a ``datetime_format`` attribute.
+
+ It is used as a fallback if you omit the format for ``now``.
+
+ .. code-block:: python
+
+ from jinja2 import Environment
+
+ env = Environment(extensions=['jinja2_time.TimeExtension'])
+
+ env.datetime_format = '%a, %d %b %Y %H:%M:%S'
+
+ # Timezone 'utc', default format -> "Thu, 10 Dec 2015 15:49:01"
+ template = env.from_string("{% now 'utc' %}")
+
+ template.render()
+
+ Issues
+ ------
+
+ If you encounter any problems, please `file an issue`_ along with a detailed description.
+
+ .. _`file an issue`: https://github.com/hackebrot/jinja2-time/issues
+
+
+ Code of Conduct
+ ---------------
+
+ Everyone interacting in the jinja2-time project's codebases, issue trackers, chat
+ rooms, and mailing lists is expected to follow the `PyPA Code of Conduct`_.
+
+ .. _`PyPA Code of Conduct`: https://www.pypa.io/en/latest/code-of-conduct/
+
+ License
+ -------
+
+ Distributed under the terms of the `MIT`_ license, jinja2-time is free and open source software
+
+ .. _`MIT`: http://opensource.org/licenses/MIT
+
+Keywords: jinja2,extension,time
+Platform: UNKNOWN
+Classifier: Development Status :: 3 - Alpha
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Natural Language :: English
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: Implementation :: CPython
+Classifier: Programming Language :: Python :: Implementation :: PyPy
+Classifier: Programming Language :: Python
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..6aa7a55
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,115 @@
+===========
+Jinja2 Time
+===========
+
+|pypi| |pyversions| |license| |travis-ci|
+
+Jinja2 Extension for Dates and Times
+
+.. |pypi| image:: https://img.shields.io/pypi/v/jinja2-time.svg
+ :target: https://pypi.python.org/pypi/jinja2-time
+ :alt: PyPI Package
+
+.. |pyversions| image:: https://img.shields.io/pypi/pyversions/jinja2-time.svg
+ :target: https://pypi.python.org/pypi/jinja2-time/
+ :alt: PyPI Python Versions
+
+.. |license| image:: https://img.shields.io/pypi/l/jinja2-time.svg
+ :target: https://pypi.python.org/pypi/jinja2-time
+ :alt: PyPI Package License
+
+.. |travis-ci| image:: https://travis-ci.org/hackebrot/jinja2-time.svg?branch=master
+ :target: https://travis-ci.org/hackebrot/jinja2-time
+ :alt: See Build Status on Travis CI
+
+Installation
+------------
+
+**jinja2-time** is available for download from `PyPI`_ via `pip`_::
+
+ $ pip install jinja2-time
+
+It will automatically install `jinja2`_ along with `arrow`_.
+
+.. _`jinja2`: https://github.com/mitsuhiko/jinja2
+.. _`PyPI`: https://pypi.python.org/pypi
+.. _`arrow`: https://github.com/crsmithdev/arrow
+.. _`pip`: https://pypi.python.org/pypi/pip/
+
+Usage
+-----
+
+Now Tag
+~~~~~~~
+
+The extension comes with a ``now`` tag that provides convenient access to the
+`arrow.now()`_ API from your templates.
+
+You can control the output by specifying a format, that will be passed to
+Python's `strftime()`_:
+
+.. _`arrow.now()`: http://crsmithdev.com/arrow/#arrow.factory.ArrowFactory.now
+.. _`strftime()`: https://docs.python.org/3.5/library/datetime.html#strftime-and-strptime-behavior
+
+.. code-block:: python
+
+ from jinja2 import Environment
+
+ env = Environment(extensions=['jinja2_time.TimeExtension'])
+
+ # Timezone 'local', default format -> "2015-12-10"
+ template = env.from_string("{% now 'local' %}")
+
+ # Timezone 'utc', explicit format -> "Thu, 10 Dec 2015 15:49:01"
+ template = env.from_string("{% now 'utc', '%a, %d %b %Y %H:%M:%S' %}")
+
+ # Timezone 'Europe/Berlin', explicit format -> "CET +0100"
+ template = env.from_string("{% now 'Europe/Berlin', '%Z %z' %}")
+
+ # Timezone 'utc', explicit format -> "2015"
+ template = env.from_string("{% now 'utc', '%Y' %}")
+
+ template.render()
+
+Default Datetime Format
+~~~~~~~~~~~~~~~~~~~~~~~
+
+**TimeExtension** extends the environment with a ``datetime_format`` attribute.
+
+It is used as a fallback if you omit the format for ``now``.
+
+.. code-block:: python
+
+ from jinja2 import Environment
+
+ env = Environment(extensions=['jinja2_time.TimeExtension'])
+
+ env.datetime_format = '%a, %d %b %Y %H:%M:%S'
+
+ # Timezone 'utc', default format -> "Thu, 10 Dec 2015 15:49:01"
+ template = env.from_string("{% now 'utc' %}")
+
+ template.render()
+
+Issues
+------
+
+If you encounter any problems, please `file an issue`_ along with a detailed description.
+
+.. _`file an issue`: https://github.com/hackebrot/jinja2-time/issues
+
+
+Code of Conduct
+---------------
+
+Everyone interacting in the jinja2-time project's codebases, issue trackers, chat
+rooms, and mailing lists is expected to follow the `PyPA Code of Conduct`_.
+
+.. _`PyPA Code of Conduct`: https://www.pypa.io/en/latest/code-of-conduct/
+
+License
+-------
+
+Distributed under the terms of the `MIT`_ license, jinja2-time is free and open source software
+
+.. _`MIT`: http://opensource.org/licenses/MIT
diff --git a/jinja2_time.egg-info/PKG-INFO b/jinja2_time.egg-info/PKG-INFO
new file mode 100644
index 0000000..09a4413
--- /dev/null
+++ b/jinja2_time.egg-info/PKG-INFO
@@ -0,0 +1,140 @@
+Metadata-Version: 1.1
+Name: jinja2-time
+Version: 0.1.0
+Summary: Jinja2 Extension for Dates and Times
+Home-page: https://github.com/hackebrot/jinja2-time
+Author: Raphael Pierzina
+Author-email: raphael at hackebrot.de
+License: MIT
+Description: ===========
+ Jinja2 Time
+ ===========
+
+ |pypi| |pyversions| |license| |travis-ci|
+
+ Jinja2 Extension for Dates and Times
+
+ .. |pypi| image:: https://img.shields.io/pypi/v/jinja2-time.svg
+ :target: https://pypi.python.org/pypi/jinja2-time
+ :alt: PyPI Package
+
+ .. |pyversions| image:: https://img.shields.io/pypi/pyversions/jinja2-time.svg
+ :target: https://pypi.python.org/pypi/jinja2-time/
+ :alt: PyPI Python Versions
+
+ .. |license| image:: https://img.shields.io/pypi/l/jinja2-time.svg
+ :target: https://pypi.python.org/pypi/jinja2-time
+ :alt: PyPI Package License
+
+ .. |travis-ci| image:: https://travis-ci.org/hackebrot/jinja2-time.svg?branch=master
+ :target: https://travis-ci.org/hackebrot/jinja2-time
+ :alt: See Build Status on Travis CI
+
+ Installation
+ ------------
+
+ **jinja2-time** is available for download from `PyPI`_ via `pip`_::
+
+ $ pip install jinja2-time
+
+ It will automatically install `jinja2`_ along with `arrow`_.
+
+ .. _`jinja2`: https://github.com/mitsuhiko/jinja2
+ .. _`PyPI`: https://pypi.python.org/pypi
+ .. _`arrow`: https://github.com/crsmithdev/arrow
+ .. _`pip`: https://pypi.python.org/pypi/pip/
+
+ Usage
+ -----
+
+ Now Tag
+ ~~~~~~~
+
+ The extension comes with a ``now`` tag that provides convenient access to the
+ `arrow.now()`_ API from your templates.
+
+ You can control the output by specifying a format, that will be passed to
+ Python's `strftime()`_:
+
+ .. _`arrow.now()`: http://crsmithdev.com/arrow/#arrow.factory.ArrowFactory.now
+ .. _`strftime()`: https://docs.python.org/3.5/library/datetime.html#strftime-and-strptime-behavior
+
+ .. code-block:: python
+
+ from jinja2 import Environment
+
+ env = Environment(extensions=['jinja2_time.TimeExtension'])
+
+ # Timezone 'local', default format -> "2015-12-10"
+ template = env.from_string("{% now 'local' %}")
+
+ # Timezone 'utc', explicit format -> "Thu, 10 Dec 2015 15:49:01"
+ template = env.from_string("{% now 'utc', '%a, %d %b %Y %H:%M:%S' %}")
+
+ # Timezone 'Europe/Berlin', explicit format -> "CET +0100"
+ template = env.from_string("{% now 'Europe/Berlin', '%Z %z' %}")
+
+ # Timezone 'utc', explicit format -> "2015"
+ template = env.from_string("{% now 'utc', '%Y' %}")
+
+ template.render()
+
+ Default Datetime Format
+ ~~~~~~~~~~~~~~~~~~~~~~~
+
+ **TimeExtension** extends the environment with a ``datetime_format`` attribute.
+
+ It is used as a fallback if you omit the format for ``now``.
+
+ .. code-block:: python
+
+ from jinja2 import Environment
+
+ env = Environment(extensions=['jinja2_time.TimeExtension'])
+
+ env.datetime_format = '%a, %d %b %Y %H:%M:%S'
+
+ # Timezone 'utc', default format -> "Thu, 10 Dec 2015 15:49:01"
+ template = env.from_string("{% now 'utc' %}")
+
+ template.render()
+
+ Issues
+ ------
+
+ If you encounter any problems, please `file an issue`_ along with a detailed description.
+
+ .. _`file an issue`: https://github.com/hackebrot/jinja2-time/issues
+
+
+ Code of Conduct
+ ---------------
+
+ Everyone interacting in the jinja2-time project's codebases, issue trackers, chat
+ rooms, and mailing lists is expected to follow the `PyPA Code of Conduct`_.
+
+ .. _`PyPA Code of Conduct`: https://www.pypa.io/en/latest/code-of-conduct/
+
+ License
+ -------
+
+ Distributed under the terms of the `MIT`_ license, jinja2-time is free and open source software
+
+ .. _`MIT`: http://opensource.org/licenses/MIT
+
+Keywords: jinja2,extension,time
+Platform: UNKNOWN
+Classifier: Development Status :: 3 - Alpha
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Natural Language :: English
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: Implementation :: CPython
+Classifier: Programming Language :: Python :: Implementation :: PyPy
+Classifier: Programming Language :: Python
diff --git a/jinja2_time.egg-info/SOURCES.txt b/jinja2_time.egg-info/SOURCES.txt
new file mode 100644
index 0000000..d2377b9
--- /dev/null
+++ b/jinja2_time.egg-info/SOURCES.txt
@@ -0,0 +1,17 @@
+AUTHORS.rst
+CONTRIBUTING.rst
+HISTORY.rst
+LICENSE
+MANIFEST.in
+README.rst
+setup.cfg
+setup.py
+jinja2_time/__init__.py
+jinja2_time/jinja2_time.py
+jinja2_time.egg-info/PKG-INFO
+jinja2_time.egg-info/SOURCES.txt
+jinja2_time.egg-info/dependency_links.txt
+jinja2_time.egg-info/not-zip-safe
+jinja2_time.egg-info/requires.txt
+jinja2_time.egg-info/top_level.txt
+tests/test_now.py
\ No newline at end of file
diff --git a/jinja2_time.egg-info/dependency_links.txt b/jinja2_time.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/jinja2_time.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/jinja2_time.egg-info/not-zip-safe b/jinja2_time.egg-info/not-zip-safe
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/jinja2_time.egg-info/not-zip-safe
@@ -0,0 +1 @@
+
diff --git a/jinja2_time.egg-info/requires.txt b/jinja2_time.egg-info/requires.txt
new file mode 100644
index 0000000..ab6d1c8
--- /dev/null
+++ b/jinja2_time.egg-info/requires.txt
@@ -0,0 +1,2 @@
+jinja2
+arrow
diff --git a/jinja2_time.egg-info/top_level.txt b/jinja2_time.egg-info/top_level.txt
new file mode 100644
index 0000000..5ac870f
--- /dev/null
+++ b/jinja2_time.egg-info/top_level.txt
@@ -0,0 +1 @@
+jinja2_time
diff --git a/jinja2_time/__init__.py b/jinja2_time/__init__.py
new file mode 100755
index 0000000..1947395
--- /dev/null
+++ b/jinja2_time/__init__.py
@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+
+__author__ = 'Raphael Pierzina'
+__email__ = 'raphael at hackebrot.de'
+__version__ = '0.1.0'
+
+from .jinja2_time import TimeExtension
+
+__all__ = ['TimeExtension']
diff --git a/jinja2_time/jinja2_time.py b/jinja2_time/jinja2_time.py
new file mode 100755
index 0000000..281a151
--- /dev/null
+++ b/jinja2_time/jinja2_time.py
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+
+import arrow
+
+from jinja2 import nodes
+from jinja2.ext import Extension
+
+
+class TimeExtension(Extension):
+ tags = set(['now'])
+
+ def __init__(self, environment):
+ super(TimeExtension, self).__init__(environment)
+
+ # add the defaults to the environment
+ environment.extend(
+ datetime_format='%Y-%m-%d',
+ )
+
+ def _now(self, timezone, datetime_format):
+ datetime_format = datetime_format or self.environment.datetime_format
+ return arrow.now(timezone).strftime(datetime_format)
+
+ def parse(self, parser):
+ lineno = next(parser.stream).lineno
+
+ args = [parser.parse_expression()]
+
+ if parser.stream.skip_if('comma'):
+ args.append(parser.parse_expression())
+ else:
+ args.append(nodes.Const(None))
+
+ call = self.call_method('_now', args, lineno=lineno)
+
+ return nodes.Output([call], lineno=lineno)
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..d20bcf3
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,18 @@
+[bumpversion]
+current_version = 0.1.0
+commit = True
+tag = True
+tag_name = {new_version}
+
+[bumpversion:file:setup.py]
+
+[bumpversion:file:jinja2_time/__init__.py]
+
+[wheel]
+universal = 1
+
+[egg_info]
+tag_build =
+tag_date = 0
+tag_svn_revision = 0
+
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..a87af9b
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import codecs
+import os
+
+from setuptools import setup
+
+
+def read(fname):
+ file_path = os.path.join(os.path.dirname(__file__), fname)
+ return codecs.open(file_path, encoding='utf-8').read()
+
+
+setup(
+ name='jinja2-time',
+ version='0.1.0',
+ author='Raphael Pierzina',
+ author_email='raphael at hackebrot.de',
+ maintainer='Raphael Pierzina',
+ maintainer_email='raphael at hackebrot.de',
+ license='MIT',
+ url='https://github.com/hackebrot/jinja2-time',
+ description='Jinja2 Extension for Dates and Times',
+ long_description=read('README.rst'),
+ packages=[
+ 'jinja2_time',
+ ],
+ package_dir={'jinja2_time': 'jinja2_time'},
+ include_package_data=True,
+ zip_safe=False,
+ install_requires=[
+ 'jinja2',
+ 'arrow'
+ ],
+ classifiers=[
+ 'Development Status :: 3 - Alpha',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: MIT License',
+ 'Natural Language :: English',
+ 'Operating System :: OS Independent',
+ 'Programming Language :: Python :: 2',
+ 'Programming Language :: Python :: 2.7',
+ 'Programming Language :: Python :: 3',
+ 'Programming Language :: Python :: 3.3',
+ 'Programming Language :: Python :: 3.4',
+ 'Programming Language :: Python :: 3.5',
+ 'Programming Language :: Python :: Implementation :: CPython',
+ 'Programming Language :: Python :: Implementation :: PyPy',
+ 'Programming Language :: Python',
+ ],
+ keywords=['jinja2', 'extension', 'time'],
+)
diff --git a/tests/test_now.py b/tests/test_now.py
new file mode 100644
index 0000000..52858a0
--- /dev/null
+++ b/tests/test_now.py
@@ -0,0 +1,51 @@
+# -*- coding: utf-8 -*-
+
+import pytest
+
+from freezegun import freeze_time
+from jinja2 import Environment, exceptions
+
+
+ at pytest.fixture
+def environment():
+ return Environment(extensions=['jinja2_time.TimeExtension'])
+
+
+ at pytest.yield_fixture(autouse=True)
+def freeze():
+ freezer = freeze_time("2015-12-09 23:33:01")
+ freezer.start()
+ yield
+ freezer.stop()
+
+
+def test_tz_is_required(environment):
+ with pytest.raises(exceptions.TemplateSyntaxError):
+ environment.from_string('{% now %}')
+
+
+def test_utc_default_datetime_format(environment):
+ template = environment.from_string("{% now 'utc' %}")
+
+ assert template.render() == "2015-12-09"
+
+
+ at pytest.fixture(params=['utc', 'local', 'Europe/Berlin'])
+def valid_tz(request):
+ return request.param
+
+
+def test_accept_valid_timezones(environment, valid_tz):
+ template = environment.from_string(
+ "{% now '" + valid_tz + "', '%Y-%m' %}"
+ )
+
+ assert template.render() == '2015-12'
+
+
+def test_environment_datetime_format(environment):
+ environment.datetime_format = '%a, %d %b %Y %H:%M:%S'
+
+ template = environment.from_string("{% now 'utc' %}")
+
+ assert template.render() == "Wed, 09 Dec 2015 23:33:01"
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/jinja2-time.git
More information about the Python-modules-commits
mailing list