Loading README.rst +0 −2 Original line number Diff line number Diff line Loading @@ -79,8 +79,6 @@ at: https://www.shore.co.il/git/. TODO ---- - Fix unicode strings in Python 2.7 only doctests in :code:`load_json`. - Fix combining dictionaries test. - Fix Travis CI test on Python 3.2 (https://travis-ci.org/adarnimrod/template/jobs/187388235). - Release on tagged commits to PyPI in Travis CI (https://docs.travis-ci.com/user/deployment/pypi/ and Loading setup.py +1 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ setup( ], keywords='config configuration jinja template environment', packages=find_packages(), install_requires=['Jinja2', 'PyYAML'], install_requires=['Jinja2', 'PyYAML', 'six'], extras_require={ 'dev': ['tox'], }, entry_points={ Loading template/filters.py +13 −12 Original line number Diff line number Diff line #!/usr/bin/env python from __future__ import (absolute_import, division, print_function, unicode_literals) import six # noqa: F401 def to_yaml(value): Loading Loading @@ -46,10 +47,10 @@ def from_json(value): >>> from_json('[1, 2, 3]') [1, 2, 3] >>> from_json('"a"') u'a' >>> from_json('{"1": {"a": [1, 2, 3]}}') {u'1': {u'a': [1, 2, 3]}} >>> from_json('"a"') == six.text_type(u'a') True >>> from_json('{"1": {"a": [1, 2, 3]}}') == {u'1': {u'a': [1, 2, 3]}} True ''' from json import loads return loads(value) Loading Loading @@ -77,8 +78,13 @@ def pprint(value): Examples: >>> pprint(1) '1' >>> pprint([{'first_name': 'John', 'last_name': 'Doe'}, {'first_name': 'Jane', 'last_name': 'Doe'}]) # noqa: E501 "[{'first_name': 'John', 'last_name': 'Doe'},\\n {'first_name': 'Jane', 'last_name': 'Doe'}]" >>> output = pprint([{'first_name': 'John', 'last_name': 'Doe'}, {'first_name': 'Jane', 'last_name': 'Doe'}]) # noqa: E501 >>> if six.PY3: ... output == "[{'first_name': 'John', 'last_name': 'Doe'},\\n {'first_name': 'Jane', 'last_name': 'Doe'}]" ... elif six.PY2: ... output == "[{u'first_name': u'John', u'last_name': u'Doe'},\\n {u'first_name': u'Jane', u'last_name': u'Doe'}]" ... True ''' from pprint import pformat return pformat(value) Loading @@ -89,12 +95,7 @@ def combine(default, override): Returns a combined dictionary of the 2 dictionaries given (with the 2nd overriding the 1st). Examples: >>> combined = combine({'a': 1, 'b': 2}, {'b': 3, 'c': 4}) >>> 'a' in combined True >>> 'c' in combined True >>> combined['b'] == 3 >>> combine({'a': 1, 'b': 2}, {'b': 3, 'c': 4}) == {'a': 1, 'b': 3, 'c': 4} True ''' combined = default.copy() Loading Loading
README.rst +0 −2 Original line number Diff line number Diff line Loading @@ -79,8 +79,6 @@ at: https://www.shore.co.il/git/. TODO ---- - Fix unicode strings in Python 2.7 only doctests in :code:`load_json`. - Fix combining dictionaries test. - Fix Travis CI test on Python 3.2 (https://travis-ci.org/adarnimrod/template/jobs/187388235). - Release on tagged commits to PyPI in Travis CI (https://docs.travis-ci.com/user/deployment/pypi/ and Loading
setup.py +1 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ setup( ], keywords='config configuration jinja template environment', packages=find_packages(), install_requires=['Jinja2', 'PyYAML'], install_requires=['Jinja2', 'PyYAML', 'six'], extras_require={ 'dev': ['tox'], }, entry_points={ Loading
template/filters.py +13 −12 Original line number Diff line number Diff line #!/usr/bin/env python from __future__ import (absolute_import, division, print_function, unicode_literals) import six # noqa: F401 def to_yaml(value): Loading Loading @@ -46,10 +47,10 @@ def from_json(value): >>> from_json('[1, 2, 3]') [1, 2, 3] >>> from_json('"a"') u'a' >>> from_json('{"1": {"a": [1, 2, 3]}}') {u'1': {u'a': [1, 2, 3]}} >>> from_json('"a"') == six.text_type(u'a') True >>> from_json('{"1": {"a": [1, 2, 3]}}') == {u'1': {u'a': [1, 2, 3]}} True ''' from json import loads return loads(value) Loading Loading @@ -77,8 +78,13 @@ def pprint(value): Examples: >>> pprint(1) '1' >>> pprint([{'first_name': 'John', 'last_name': 'Doe'}, {'first_name': 'Jane', 'last_name': 'Doe'}]) # noqa: E501 "[{'first_name': 'John', 'last_name': 'Doe'},\\n {'first_name': 'Jane', 'last_name': 'Doe'}]" >>> output = pprint([{'first_name': 'John', 'last_name': 'Doe'}, {'first_name': 'Jane', 'last_name': 'Doe'}]) # noqa: E501 >>> if six.PY3: ... output == "[{'first_name': 'John', 'last_name': 'Doe'},\\n {'first_name': 'Jane', 'last_name': 'Doe'}]" ... elif six.PY2: ... output == "[{u'first_name': u'John', u'last_name': u'Doe'},\\n {u'first_name': u'Jane', u'last_name': u'Doe'}]" ... True ''' from pprint import pformat return pformat(value) Loading @@ -89,12 +95,7 @@ def combine(default, override): Returns a combined dictionary of the 2 dictionaries given (with the 2nd overriding the 1st). Examples: >>> combined = combine({'a': 1, 'b': 2}, {'b': 3, 'c': 4}) >>> 'a' in combined True >>> 'c' in combined True >>> combined['b'] == 3 >>> combine({'a': 1, 'b': 2}, {'b': 3, 'c': 4}) == {'a': 1, 'b': 3, 'c': 4} True ''' combined = default.copy() Loading