Skip to content

Commit

Permalink
Merge a965738 into 5a8637b
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Howitz committed Dec 5, 2018
2 parents 5a8637b + a965738 commit 5113426
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 245 deletions.
10 changes: 6 additions & 4 deletions .travis.yml
@@ -1,15 +1,17 @@
language: python
sudo: false
python:
- 2.7
- 3.4
- 3.5
- 3.6
- pypy
- pypy3
install:
matrix:
include:
- python: "3.7"
dist: xenial
before_install:
- pip install -U pip setuptools
- pip install -U coverage coveralls
install:
- pip install -U -e .[test]
script:
- coverage run -m zope.testrunner --test-path=src
Expand Down
5 changes: 4 additions & 1 deletion CHANGES.rst
Expand Up @@ -5,7 +5,10 @@ CHANGES
2.2.1 (unreleased)
------------------

- Nothing changed yet.
- Fix list of supported Python versions in Trove classifiers: The currently
supported Python versions are 2.7, 3.6, 3.7, PyPy2 and PyPy3.

- Flake8 the code.


2.2.0 (2018-11-13)
Expand Down
10 changes: 4 additions & 6 deletions MANIFEST.in
@@ -1,11 +1,9 @@
include *.rst
include *.txt
include *.py
include .coveragerc
include .travis.yml
include buildout.cfg
include tox.ini
include .travis.yml
include .coveragerc

recursive-include src *

global-exclude *.pyc
recursive-include src *.rst
recursive-include src *.zcml
210 changes: 0 additions & 210 deletions bootstrap.py

This file was deleted.

11 changes: 6 additions & 5 deletions setup.py
Expand Up @@ -16,10 +16,12 @@
import os
from setuptools import setup, find_packages


def read(*rnames):
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',
Expand Down Expand Up @@ -49,7 +51,7 @@ def read(*rnames):
read('src', 'z3c', 'macro', 'zcml.rst')
+ '\n\n' +
read('CHANGES.rst')
),
),
license="ZPL 2.1",
keywords="zope3 macro pagetemplate zpt",
classifiers=[
Expand All @@ -61,9 +63,8 @@ def read(*rnames):
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Natural Language :: English',
Expand All @@ -73,7 +74,7 @@ def read(*rnames):
],
url='https://github.com/zopefoundation/z3c.macro',
packages=find_packages('src'),
package_dir={'':'src'},
package_dir={'': 'src'},
namespace_packages=['z3c'],
extras_require={
'test': TESTS_REQUIRE,
Expand All @@ -88,7 +89,7 @@ def read(*rnames):
'zope.publisher',
'zope.schema',
'zope.tales',
],
],
tests_require=TESTS_REQUIRE,
test_suite='z3c.macro.tests.test_suite',
include_package_data=True,
Expand Down
9 changes: 5 additions & 4 deletions src/z3c/macro/__init__.py
Expand Up @@ -14,8 +14,8 @@
"""
z3c.macro package.
Importing this package has the side-effect of registering the 'macro' expression
type in Chameleon (if z3c.pt is installed)
Importing this package has the side-effect of registering the 'macro'
expression type in Chameleon (if z3c.pt is installed)
"""

try:
Expand All @@ -25,7 +25,8 @@
# 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: # pragma: no cover
z3c.pt.pagetemplate.BaseTemplate.expression_types[
'macro'] = tales.MacroExpr
except ImportError: # pragma: no cover
# we do not support z3c.pt
pass
17 changes: 9 additions & 8 deletions src/z3c/macro/tales.py
Expand Up @@ -13,20 +13,20 @@
##############################################################################
"""Provider tales expression registrations
"""
__docformat__ = 'restructuredtext'


import zope.component
import zope.interface
from zope.tales import expressions

from z3c.macro import interfaces


def get_macro_template(context, view, request, name):
return zope.component.getMultiAdapter(
(context, view, request), interface=interfaces.IMacroTemplate, name=name)
(context, view, request),
interface=interfaces.IMacroTemplate,
name=name)


@zope.interface.implementer(interfaces.IMacroExpression)
class MacroExpression(expressions.StringExpr):
Expand All @@ -39,6 +39,7 @@ def __call__(self, econtext):
view = econtext.vars['view']
return get_macro_template(context, view, request, name)


try:
# define chameleon ``macro`` expression

Expand All @@ -48,7 +49,7 @@ def __call__(self, econtext):
from chameleon.codegen import template

class MacroGetter(object):
"""Collect named IMacroTemplate via a TAL namespace called ``macro``."""
"""Collect named IMacroTemplate via TAL namespace called ``macro``."""

def __call__(self, context, request, view, name):
return zope.component.getMultiAdapter(
Expand All @@ -58,7 +59,7 @@ def __call__(self, context, request, view, name):
class MacroExpr(StringExpr):
traverser = Static(
template("cls()", cls=Symbol(MacroGetter), mode="eval")
)
)

def __call__(self, target, engine):
assignment = super(MacroExpr, self).__call__(target, engine)
Expand All @@ -69,5 +70,5 @@ def __call__(self, target, engine):
traverse=self.traverser,
)

except ImportError: # pragma: no cover
except ImportError: # pragma: no cover
pass

0 comments on commit 5113426

Please sign in to comment.