Skip to content

Commit

Permalink
Merge pull request #3 from zopefoundation/py36
Browse files Browse the repository at this point in the history
Add Python 3.4/5/6, drop 3.3 and 2.6
  • Loading branch information
jamadden committed Oct 17, 2017
2 parents edf8d2f + cbb3267 commit 23de512
Show file tree
Hide file tree
Showing 18 changed files with 184 additions and 105 deletions.
11 changes: 11 additions & 0 deletions .coveragerc
@@ -0,0 +1,11 @@
[run]
source = z3c.macro

[report]
precision = 2
exclude_lines =
pragma: no cover
if __name__ == '__main__':
raise NotImplementedError
self.fail
raise AssertionError
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -9,3 +9,5 @@ bin
develop-eggs
docs
parts
.coverage
htmlcov/
17 changes: 13 additions & 4 deletions .travis.yml
@@ -1,11 +1,20 @@
language: python
sudo: false
python:
- 2.6
- 2.7
- 3.3
- 3.4
- 3.5
- 3.6
- pypy
- pypy3
install:
- pip install .
- pip install -U pip setuptools
- pip install -U coverage coveralls
- pip install -U -e .[test]
script:
- python setup.py test -q
- coverage run -m zope.testrunner --test-path=src
after_success:
- coveralls
notifications:
email: false
cache: pip
8 changes: 5 additions & 3 deletions CHANGES.txt → CHANGES.rst
Expand Up @@ -2,16 +2,18 @@
CHANGES
=======

2.0.1 (unreleased)
2.1.0 (unreleased)
------------------

- Nothing changed yet.
- Drop support for Python 2.6 and 3.3.
- Add support for Python 3.4, 3.5 and 3.6.
- Add support for PyPy.


2.0.0 (2015-11-09)
------------------

- Standardize namespace __init__
- Standardize namespace ``__init__``.


2.0.0a1 (2013-02-25)
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Expand Up @@ -3,6 +3,8 @@ include *.txt
include *.py
include buildout.cfg
include tox.ini
include .travis.yml
include .coveragerc

recursive-include src *

Expand Down
16 changes: 16 additions & 0 deletions README.rst
@@ -0,0 +1,16 @@
.. image:: https://img.shields.io/pypi/v/z3c.macro.svg
:target: https://pypi.python.org/pypi/z3c.macro/
:alt: Latest release

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

.. image:: https://travis-ci.org/zopefoundation/z3c.macro.svg?branch=master
:target: https://travis-ci.org/zopefoundation/z3c.macro

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

This package provides an adapter and a TALES expression for a more explicit and
more flexible macro handling using the adapter registry for macros.
2 changes: 0 additions & 2 deletions README.txt

This file was deleted.

2 changes: 2 additions & 0 deletions setup.cfg
@@ -0,0 +1,2 @@
[bdist_wheel]
universal = 1
87 changes: 44 additions & 43 deletions setup.py
Expand Up @@ -17,62 +17,69 @@
from setuptools import setup, find_packages

def read(*rnames):
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
with open(os.path.join(os.path.dirname(__file__), *rnames)) as f:
return f.read()

CHAMELEON_REQUIRES = [
'z3c.pt >= 2.1',
'z3c.ptcompat >= 1.0',
]

TESTS_REQUIRE = CHAMELEON_REQUIRES + [
'z3c.template',
'zope.browserpage >= 3.12',
'zope.testing',
'zope.testrunner',
]

setup(
name='z3c.macro',
version='2.0.1.dev0',
author = "Roger Ineichen and the Zope Community",
author_email = "zope-dev@zope.org",
description = "Simpler definition of ZPT macros.",
version='2.1.0.dev0',
author="Roger Ineichen and the Zope Community",
author_email="zope-dev@zope.org",
description="Simpler definition of ZPT macros.",
long_description=(
read('README.txt')
read('README.rst')
+ '\n\n' +
'Detailed Documentation\n'
'======================\n'
+ '\n\n' +
read('src', 'z3c', 'macro', 'README.txt')
read('src', 'z3c', 'macro', 'README.rst')
+ '\n\n' +
read('src', 'z3c', 'macro', 'zcml.txt')
read('src', 'z3c', 'macro', 'zcml.rst')
+ '\n\n' +
read('CHANGES.txt')
read('CHANGES.rst')
),
license = "ZPL 2.1",
keywords = "zope3 macro pagetemplate zpt",
classifiers = [
license="ZPL 2.1",
keywords="zope3 macro pagetemplate zpt",
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: Zope Public License',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'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/z3c.macro',
packages = find_packages('src'),
package_dir = {'':'src'},
namespace_packages = ['z3c'],
extras_require = dict(
test = [
'z3c.pt >= 2.1',
'z3c.ptcompat>=1.0',
'z3c.template',
'zope.browserpage>=3.12',
'zope.testing',
],
chameleon = [
'z3c.pt >= 2.1',
'z3c.ptcompat>=1.0',
],
),
install_requires = [
'Framework :: Zope3',
],
url='https://github.com/zopefoundation/z3c.macro',
packages=find_packages('src'),
package_dir={'':'src'},
namespace_packages=['z3c'],
extras_require={
'test': TESTS_REQUIRE,
'chameleon': CHAMELEON_REQUIRES,
},
install_requires=[
'setuptools',
'zope.component',
'zope.configuration',
Expand All @@ -82,14 +89,8 @@ def read(*rnames):
'zope.schema',
'zope.tales',
],
tests_require=[
'z3c.pt >= 2.1',
'z3c.ptcompat>=1.0',
'z3c.template',
'zope.browserpage>=3.12',
'zope.testing',
],
tests_require=TESTS_REQUIRE,
test_suite='z3c.macro.tests.test_suite',
include_package_data = True,
zip_safe = False,
)
include_package_data=True,
zip_safe=False,
)
8 changes: 1 addition & 7 deletions src/z3c/__init__.py
@@ -1,7 +1 @@
# this is a namespace package
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
__import__('pkg_resources').declare_namespace(__name__)
File renamed without changes.
9 changes: 6 additions & 3 deletions src/z3c/macro/__init__.py
Expand Up @@ -12,17 +12,20 @@
#
##############################################################################
"""
$Id$
z3c.macro package.
Importing this package has the side-effect of registering the 'macro' expression
type in Chameleon (if z3c.pt is installed)
"""

try:
# register chameleon ``macro`` tales expression for BaseTemplate
# there is not adapter or other registration support built in in
# there is not adapter or other registration support built in in
# z3c.pt and apply our tales expression to any page template or
# offer a custom PageTemplate is no option
from z3c.macro import tales
import z3c.pt.pagetemplate
z3c.pt.pagetemplate.BaseTemplate.expression_types['macro'] = tales.MacroExpr
except ImportError:
except ImportError: # pragma: no cover
# we do not support z3c.pt
pass
6 changes: 3 additions & 3 deletions src/z3c/macro/interfaces.py
Expand Up @@ -12,7 +12,7 @@
#
##############################################################################
"""
$Id$
Interfaces for z3c.macro.
"""

from zope.tales import interfaces
Expand Down Expand Up @@ -40,8 +40,8 @@ class IMacroExpression(interfaces.ITALESExpression):
this content get replaced by the defined macro
</metal:block>
The ``macro:`` TALES expression calles a named adapter adapting
The ``macro:`` TALES expression calles a named adapter adapting
(context, request) or (context, request, view), depending on the usage
of the view attribute in the macro directive. A macro provides the
of the view attribute in the macro directive. A macro provides the
interface IMacroTemplate.
"""
18 changes: 8 additions & 10 deletions src/z3c/macro/tales.py
Expand Up @@ -13,11 +13,10 @@
##############################################################################
"""Provider tales expression registrations
$Id$
"""
__docformat__ = 'restructuredtext'

import re

import zope.component
import zope.interface
Expand All @@ -39,10 +38,10 @@ def __call__(self, econtext):
request = econtext.vars['request']
view = econtext.vars['view']
return get_macro_template(context, view, request, name)

try:
# define chameleon ``macro`` expression

from chameleon.tales import StringExpr
from chameleon.astutil import Static
from chameleon.astutil import Symbol
Expand All @@ -60,16 +59,15 @@ class MacroExpr(StringExpr):
traverser = Static(
template("cls()", cls=Symbol(MacroGetter), mode="eval")
)

def __call__(self, target, engine):
assignment = super(MacroExpr, self).__call__(target, engine)

return assignment + \
template(

return assignment + template(
"target = traverse(context, request, view, target.strip())",
target=target,
traverse=self.traverser,
)
)

except ImportError:
except ImportError: # pragma: no cover
pass
35 changes: 29 additions & 6 deletions src/z3c/macro/tests.py
Expand Up @@ -15,10 +15,14 @@
"""
import doctest
import itertools
import re
import unittest

import zope.component.testing
from zope.configuration import xmlconfig

from zope.testing import renormalizing

import z3c.macro.tales
import z3c.macro.zcml

Expand Down Expand Up @@ -47,15 +51,34 @@ def tearDown(test):
zope.component.testing.tearDown(test)


checker = renormalizing.RENormalizing([
(re.compile("u('.*?')"), r"\1"),
(re.compile('u(".*?")'), r"\1"),
# Python 3 adds module name to exceptions;
# The output of this one is too complex for IGNORE_EXCEPTION_MODULE_IN_PYTHON2
(re.compile('zope.configuration.xmlconfig.ZopeXMLConfigurationError'),
'ZopeXMLConfigurationError'),
])

def test_suite():
tests = ((
doctest.DocFileSuite('README.txt',
doctest.DocFileSuite(
'README.rst',
setUp=setUp, tearDown=tearDown,
checker=checker,
optionflags=(doctest.NORMALIZE_WHITESPACE
| doctest.ELLIPSIS
| renormalizing.IGNORE_EXCEPTION_MODULE_IN_PYTHON2),
),
doctest.DocFileSuite(
'zcml.rst',
setUp=setUp, tearDown=tearDown,
optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
),
doctest.DocFileSuite('zcml.txt', setUp=setUp, tearDown=tearDown,
optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,),
) for setUp in (setUpZ3CPT, setUpZPT))
checker=checker,
optionflags=(doctest.NORMALIZE_WHITESPACE
| doctest.ELLIPSIS
| renormalizing.IGNORE_EXCEPTION_MODULE_IN_PYTHON2),
)
) for setUp in (setUpZ3CPT, setUpZPT))

return unittest.TestSuite(itertools.chain(*tests))

Expand Down

0 comments on commit 23de512

Please sign in to comment.