summaryrefslogtreecommitdiffstats
path: root/third_party/python/jinja2_time
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /third_party/python/jinja2_time
parentInitial commit. (diff)
downloadfirefox-e51783d008170d9ab27d25da98ca3a38b0a41b67.tar.xz
firefox-e51783d008170d9ab27d25da98ca3a38b0a41b67.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/python/jinja2_time')
-rw-r--r--third_party/python/jinja2_time/jinja2_time-0.2.0.dist-info/DESCRIPTION.rst147
-rw-r--r--third_party/python/jinja2_time/jinja2_time-0.2.0.dist-info/METADATA174
-rw-r--r--third_party/python/jinja2_time/jinja2_time-0.2.0.dist-info/RECORD8
-rw-r--r--third_party/python/jinja2_time/jinja2_time-0.2.0.dist-info/WHEEL6
-rw-r--r--third_party/python/jinja2_time/jinja2_time-0.2.0.dist-info/metadata.json1
-rw-r--r--third_party/python/jinja2_time/jinja2_time-0.2.0.dist-info/top_level.txt1
-rw-r--r--third_party/python/jinja2_time/jinja2_time/__init__.py10
-rw-r--r--third_party/python/jinja2_time/jinja2_time/jinja2_time.py65
8 files changed, 412 insertions, 0 deletions
diff --git a/third_party/python/jinja2_time/jinja2_time-0.2.0.dist-info/DESCRIPTION.rst b/third_party/python/jinja2_time/jinja2_time-0.2.0.dist-info/DESCRIPTION.rst
new file mode 100644
index 0000000000..a56fcb8b14
--- /dev/null
+++ b/third_party/python/jinja2_time/jinja2_time-0.2.0.dist-info/DESCRIPTION.rst
@@ -0,0 +1,147 @@
+===========
+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()
+
+Time Offset
+~~~~~~~~~~~
+
+**jinja2-time** implements a convenient interface to modify ``now`` by a
+relative time offset:
+
+.. code-block:: python
+
+ # Examples for now "2015-12-09 23:33:01"
+
+ # "Thu, 10 Dec 2015 01:33:31"
+ "{% now 'utc' + 'hours=2, seconds=30' %}"
+
+ # "Wed, 09 Dec 2015 23:22:01"
+ "{% now 'utc' - 'minutes=11' %}"
+
+ # "07 Dec 2015 23:00:00"
+ "{% now 'utc' - 'days=2, minutes=33, seconds=1', '%d %b %Y %H:%M:%S' %}"
+
+Further documentation on the underlying functionality can be found in the
+`arrow replace docs`_.
+
+.. _`arrow replace docs`: http://arrow.readthedocs.io/en/latest/#replace-shift
+
+
+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
+
+.. image:: https://opensource.org/trademarks/osi-certified/web/osi-certified-120x100.png
+ :align: left
+ :alt: OSI certified
+ :target: https://opensource.org/
+
+.. _`MIT`: http://opensource.org/licenses/MIT
+
+
diff --git a/third_party/python/jinja2_time/jinja2_time-0.2.0.dist-info/METADATA b/third_party/python/jinja2_time/jinja2_time-0.2.0.dist-info/METADATA
new file mode 100644
index 0000000000..3714572a78
--- /dev/null
+++ b/third_party/python/jinja2_time/jinja2_time-0.2.0.dist-info/METADATA
@@ -0,0 +1,174 @@
+Metadata-Version: 2.0
+Name: jinja2-time
+Version: 0.2.0
+Summary: Jinja2 Extension for Dates and Times
+Home-page: https://github.com/hackebrot/jinja2-time
+Author: Raphael Pierzina
+Author-email: raphael@hackebrot.de
+License: 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
+Requires-Dist: jinja2
+Requires-Dist: arrow
+
+===========
+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()
+
+Time Offset
+~~~~~~~~~~~
+
+**jinja2-time** implements a convenient interface to modify ``now`` by a
+relative time offset:
+
+.. code-block:: python
+
+ # Examples for now "2015-12-09 23:33:01"
+
+ # "Thu, 10 Dec 2015 01:33:31"
+ "{% now 'utc' + 'hours=2, seconds=30' %}"
+
+ # "Wed, 09 Dec 2015 23:22:01"
+ "{% now 'utc' - 'minutes=11' %}"
+
+ # "07 Dec 2015 23:00:00"
+ "{% now 'utc' - 'days=2, minutes=33, seconds=1', '%d %b %Y %H:%M:%S' %}"
+
+Further documentation on the underlying functionality can be found in the
+`arrow replace docs`_.
+
+.. _`arrow replace docs`: http://arrow.readthedocs.io/en/latest/#replace-shift
+
+
+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
+
+.. image:: https://opensource.org/trademarks/osi-certified/web/osi-certified-120x100.png
+ :align: left
+ :alt: OSI certified
+ :target: https://opensource.org/
+
+.. _`MIT`: http://opensource.org/licenses/MIT
+
+
diff --git a/third_party/python/jinja2_time/jinja2_time-0.2.0.dist-info/RECORD b/third_party/python/jinja2_time/jinja2_time-0.2.0.dist-info/RECORD
new file mode 100644
index 0000000000..e647ee3726
--- /dev/null
+++ b/third_party/python/jinja2_time/jinja2_time-0.2.0.dist-info/RECORD
@@ -0,0 +1,8 @@
+jinja2_time/__init__.py,sha256=M48p6Z1Rsv5OOL-q7kTRog1JPSquiRYOOxkhO3jJcrE,184
+jinja2_time/jinja2_time.py,sha256=MbBuzEMYSU_fHdx9M7ZfGGvEwdAnDOstQviU6GNPUpE,2080
+jinja2_time-0.2.0.dist-info/DESCRIPTION.rst,sha256=ATjmUYtQxCdXoMkTixBnyyF9lU1AhshfMJxY5ZrJkqo,4109
+jinja2_time-0.2.0.dist-info/METADATA,sha256=9nhHvQYAYZcafV5VigNdV_FB1btn5xLSY-kAOvt7bUk,5135
+jinja2_time-0.2.0.dist-info/metadata.json,sha256=i6xJP3_vGVQGUno_3vOjK9gFRtyFuyTnMy2k76rf1Js,1140
+jinja2_time-0.2.0.dist-info/RECORD,,
+jinja2_time-0.2.0.dist-info/top_level.txt,sha256=oQxkTcv8SKoVYEKSYSrhkn5AsQR1-p1rAqo-Ouu0mNA,12
+jinja2_time-0.2.0.dist-info/WHEEL,sha256=AvR0WeTpDaxT645bl5FQxUK6NPsTls2ttpcGJg3j1Xg,110
diff --git a/third_party/python/jinja2_time/jinja2_time-0.2.0.dist-info/WHEEL b/third_party/python/jinja2_time/jinja2_time-0.2.0.dist-info/WHEEL
new file mode 100644
index 0000000000..9dff69d861
--- /dev/null
+++ b/third_party/python/jinja2_time/jinja2_time-0.2.0.dist-info/WHEEL
@@ -0,0 +1,6 @@
+Wheel-Version: 1.0
+Generator: bdist_wheel (0.24.0)
+Root-Is-Purelib: true
+Tag: py2-none-any
+Tag: py3-none-any
+
diff --git a/third_party/python/jinja2_time/jinja2_time-0.2.0.dist-info/metadata.json b/third_party/python/jinja2_time/jinja2_time-0.2.0.dist-info/metadata.json
new file mode 100644
index 0000000000..d1de0ed870
--- /dev/null
+++ b/third_party/python/jinja2_time/jinja2_time-0.2.0.dist-info/metadata.json
@@ -0,0 +1 @@
+{"extras": [], "run_requires": [{"requires": ["jinja2", "arrow"]}], "version": "0.2.0", "keywords": ["jinja2", "extension", "time"], "license": "MIT", "summary": "Jinja2 Extension for Dates and Times", "generator": "bdist_wheel (0.24.0)", "metadata_version": "2.0", "name": "jinja2-time", "extensions": {"python.details": {"contacts": [{"email": "raphael@hackebrot.de", "name": "Raphael Pierzina", "role": "author"}], "project_urls": {"Home": "https://github.com/hackebrot/jinja2-time"}, "document_names": {"description": "DESCRIPTION.rst"}}}, "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"]} \ No newline at end of file
diff --git a/third_party/python/jinja2_time/jinja2_time-0.2.0.dist-info/top_level.txt b/third_party/python/jinja2_time/jinja2_time-0.2.0.dist-info/top_level.txt
new file mode 100644
index 0000000000..5ac870f1f9
--- /dev/null
+++ b/third_party/python/jinja2_time/jinja2_time-0.2.0.dist-info/top_level.txt
@@ -0,0 +1 @@
+jinja2_time
diff --git a/third_party/python/jinja2_time/jinja2_time/__init__.py b/third_party/python/jinja2_time/jinja2_time/__init__.py
new file mode 100644
index 0000000000..d813a7b741
--- /dev/null
+++ b/third_party/python/jinja2_time/jinja2_time/__init__.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+
+from .jinja2_time import TimeExtension
+
+__author__ = 'Raphael Pierzina'
+__email__ = 'raphael@hackebrot.de'
+__version__ = '0.2.0'
+
+
+__all__ = ['TimeExtension']
diff --git a/third_party/python/jinja2_time/jinja2_time/jinja2_time.py b/third_party/python/jinja2_time/jinja2_time/jinja2_time.py
new file mode 100644
index 0000000000..ce713cbdc2
--- /dev/null
+++ b/third_party/python/jinja2_time/jinja2_time/jinja2_time.py
@@ -0,0 +1,65 @@
+# -*- 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 _datetime(self, timezone, operator, offset, datetime_format):
+ d = arrow.now(timezone)
+
+ # Parse replace kwargs from offset and include operator
+ replace_params = {}
+ for param in offset.split(','):
+ interval, value = param.split('=')
+ replace_params[interval.strip()] = float(operator + value.strip())
+ d = d.replace(**replace_params)
+
+ if datetime_format is None:
+ datetime_format = self.environment.datetime_format
+ return d.strftime(datetime_format)
+
+ def _now(self, timezone, datetime_format):
+ if datetime_format is None:
+ datetime_format = self.environment.datetime_format
+ return arrow.now(timezone).strftime(datetime_format)
+
+ def parse(self, parser):
+ lineno = next(parser.stream).lineno
+
+ node = parser.parse_expression()
+
+ if parser.stream.skip_if('comma'):
+ datetime_format = parser.parse_expression()
+ else:
+ datetime_format = nodes.Const(None)
+
+ if isinstance(node, nodes.Add):
+ call_method = self.call_method(
+ '_datetime',
+ [node.left, nodes.Const('+'), node.right, datetime_format],
+ lineno=lineno,
+ )
+ elif isinstance(node, nodes.Sub):
+ call_method = self.call_method(
+ '_datetime',
+ [node.left, nodes.Const('-'), node.right, datetime_format],
+ lineno=lineno,
+ )
+ else:
+ call_method = self.call_method(
+ '_now',
+ [node, datetime_format],
+ lineno=lineno,
+ )
+ return nodes.Output([call_method], lineno=lineno)