Skip to content

Commit

Permalink
Merge 8fe62ef into 938467f
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Aug 25, 2017
2 parents 938467f + 8fe62ef commit d923f96
Show file tree
Hide file tree
Showing 14 changed files with 587 additions and 243 deletions.
12 changes: 12 additions & 0 deletions .coveragerc
@@ -0,0 +1,12 @@
[run]
source = zope.tales

[report]
precision = 2
exclude_lines =
pragma: no cover
if __name__ == '__main__':
raise NotImplementedError
self.fail
raise AssertionError
raise unittest.Skip
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -10,3 +10,5 @@ bin
build
develop-eggs
parts
.coverage
htmlcov/
19 changes: 14 additions & 5 deletions .travis.yml
Expand Up @@ -2,14 +2,23 @@ language: python
sudo: false
python:
- 2.7
- 3.3
- 3.4
- 3.5
- pypy
- pypy3
- 3.6
# Force a newer PyPy on the old 'precise' CI image
# in order to install 'cryptography' needed for coveralls
# After September 2017 this should be the default and the version
# pin can be removed.
- pypy-5.6.0
- pypy3.5-5.8.0
install:
- pip install .
- pip install -U pip setuptools
- pip install -U coverage coveralls
- pip install -U -e .[test]
script:
- python setup.py -q test -q
- coverage run -m zope.testrunner --test-path=src
after_success:
- coveralls
notifications:
email: false
cache: pip
36 changes: 20 additions & 16 deletions CHANGES.rst
@@ -1,22 +1,26 @@
Changes
=======
=========
Changes
=========

4.2.0 (unreleased)
------------------
==================

- Add support for Python 3.5.
- Add support for Python 3.5 and 3.6.

- Drop support for Python 2.6 and 3.2.
- Drop support for Python 2.6, 3.2 and 3.3.

- Drop support for ``python setup.py test``.

- Reach 100% test coverage and maintain it via tox.ini and Travis CI.

4.1.1 (2015-06-06)
------------------
==================

- Add support for Python 3.2 and PyPy3.


4.1.0 (2014-12-29)
------------------
==================

.. note::

Expand All @@ -29,19 +33,19 @@ Changes


4.0.2 (2013-11-12)
------------------
==================

- Add missing ``six`` dependency


4.0.1 (2013-02-22)
------------------
==================

- Fix a previously untested Python 3.3 compatibility problem.


4.0.0 (2013-02-14)
------------------
==================

- Remove hard dependency on ``zope.tal``, which was already conditionalized
but required via ``setup.py``.
Expand All @@ -57,34 +61,34 @@ Changes


3.5.2 (2012-05-23)
------------------
==================

- Subexpressions of a 'string:' expression can be only path expressions.
https://bugs.launchpad.net/zope.tales/+bug/1002242


3.5.1 (2010-04-30)
------------------
==================

- Remove use of ``zope.testing.doctestunit`` in favor of stdlib's 'doctest.


3.5.0 (2010-01-01)
------------------
==================

- Port the lazy expression from ``Products.PageTemplates``.


3.4.0 (2007-10-03)
------------------
==================

- Update package setup.

- Initial release outside the Zope 3 trunk.


3.2.0 (2006-01-05)
------------------
==================

- Corresponds to the verison of the zope.tales package shipped as part of
the Zope 3.2.0 release.
Expand All @@ -93,7 +97,7 @@ Changes


3.0.0 (2004-11-07)
------------------
==================

- Corresponds to the verison of the zope.tales package shipped as part of
the Zope X3.0.0 release.
2 changes: 2 additions & 0 deletions MANIFEST.in
Expand Up @@ -3,6 +3,8 @@ include *.txt
include tox.ini
include bootstrap.py
include buildout.cfg
include .travis.yml
include .coveragerc

recursive-include src *

Expand Down
18 changes: 15 additions & 3 deletions README.rst
@@ -1,12 +1,24 @@
``zope.tales``
==============
================
``zope.tales``
================

.. image:: https://img.shields.io/pypi/v/zope.tales.svg
:target: https://pypi.python.org/pypi/zope.tales/
:alt: Latest release

.. image:: https://img.shields.io/pypi/pyversions/zope.tales.svg
:target: https://pypi.org/project/zope.tales/
:alt: Supported Python versions

.. image:: https://travis-ci.org/zopefoundation/zope.tales.png?branch=master
:target: https://travis-ci.org/zopefoundation/zope.tales

.. image:: https://coveralls.io/repos/github/zopefoundation/zope.tales/badge.svg?branch=master
:target: https://coveralls.io/github/zopefoundation/zope.tales?branch=master

Template Attribute Language - Expression Syntax

See
See

* http://web.archive.org/web/20120814103624/http://wiki.zope.org:80/ZPT/TALESSpecification13
* https://docs.zope.org/zope2/zope2book/AppendixC.html#tales-overview
2 changes: 2 additions & 0 deletions setup.cfg
@@ -0,0 +1,2 @@
[bdist_wheel]
universal = 1
40 changes: 16 additions & 24 deletions setup.py
Expand Up @@ -26,21 +26,10 @@ def read(*rnames):
with open(os.path.join(os.path.dirname(__file__), *rnames)) as f:
return f.read()


def alltests():
import os
import sys
import unittest
# use the zope.testrunner machinery to find all the
# test suites we've put under ourselves
import zope.testrunner.find
import zope.testrunner.options
here = os.path.abspath(os.path.join(os.path.dirname(__file__), 'src'))
args = sys.argv[:]
defaults = ["--test-path", here]
options = zope.testrunner.options.get_options(args, defaults)
suites = list(zope.testrunner.find.find_suites(options))
return unittest.TestSuite(suites)
TESTS_REQUIRE = [
'zope.testing',
'zope.testrunner',
]

setup(name='zope.tales',
version='4.2.0.dev0',
Expand All @@ -63,29 +52,32 @@ def alltests():
'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 :: 3.6',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Natural Language :: English',
'Operating System :: OS Independent',
'Topic :: Internet :: WWW/HTTP',
'Framework :: Zope3'],
url='http://pypi.python.org/pypi/zope.tales',
url='http://github.com/zopefoundation/zope.tales',
license='ZPL 2.1',
packages=find_packages('src'),
package_dir={'': 'src'},
namespace_packages=['zope'],
extras_require=dict(
test=['zope.testing'],
tal=['zope.tal']),
extras_require={
'test': TESTS_REQUIRE,
'tal': [
'zope.tal',
],
},
install_requires=[
'setuptools',
'zope.interface',
'six'],
tests_require=['zope.testing', 'zope.testrunner'],
test_suite='__main__.alltests',
'six',
],
tests_require=TESTS_REQUIRE,
include_package_data=True,
zip_safe=False,
)
)
13 changes: 6 additions & 7 deletions src/zope/tales/expressions.py
Expand Up @@ -90,7 +90,6 @@ def __init__(self, path, traverser, engine):
compiledpath.append(tuple(currentpath))

first = compiledpath[0]
base = first[0]

if callable(first):
# check for initial function
Expand All @@ -101,6 +100,7 @@ def __init__(self, path, traverser, engine):
raise engine.getCompilerError()(
'Dynamic name specified in first subpath element')

base = first[0]
if base and not _valid_name(base):
raise engine.getCompilerError()(
'Invalid variable name "%s"' % element)
Expand Down Expand Up @@ -211,9 +211,7 @@ def _eval(self, econtext):
# __call__.
if getattr(ob, '__call__', _marker) is not _marker:
return ob()
if PY2 and isinstance(ob, types.ClassType):
return ob()
return ob
return ob() if PY2 and isinstance(ob, types.ClassType) else ob

def __call__(self, econtext):
if self._name == 'exists':
Expand All @@ -229,8 +227,8 @@ def __repr__(self):


_interp = re.compile(
r'\$(%(n)s)|\${(%(n)s(?:/[^}|]*)*(?:\|%(n)s(?:/[^}|]*)*)*)}'
% {'n': NAME_RE})
r'\$(%(n)s)|\${(%(n)s(?:/[^}|]*)*(?:\|%(n)s(?:/[^}|]*)*)*)}'
% {'n': NAME_RE})

@implementer(ITALESExpression)
class StringExpr(object):
Expand Down Expand Up @@ -318,9 +316,10 @@ def __repr__(self):
class LazyWrapper(DeferWrapper):
"""Wrapper for lazy: expression
"""
_result = _marker

def __init__(self, expr, econtext):
DeferWrapper.__init__(self, expr, econtext)
self._result = _marker

def __call__(self):
r = self._result
Expand Down

0 comments on commit d923f96

Please sign in to comment.