diff -Nru mako-0.9.0/CHANGES mako-0.9.1/CHANGES --- mako-0.9.0/CHANGES 2013-08-27 18:57:37.000000000 +0000 +++ mako-0.9.1/CHANGES 2013-12-26 23:37:02.000000000 +0000 @@ -1,3 +1,22 @@ +0.9.1 +- [bug] Fixed bug in Babel plugin where translator comments + would be lost if intervening text nodes were encountered. + Fix courtesy Ned Batchelder. [ticket:225] + +- [bug] Fixed TGPlugin.render method to support unicode template + names in Py2K - courtesy Vladimir Magamedov. + +- [bug] Fixed an AST issue that was preventing correct operation + under alpha versions of Python 3.4. Pullreq courtesy Zer0-. + +- [bug] Changed the format of the "source encoding" header output + by the code generator to use the format ``# -*- coding:%s -*-`` + instead of ``# -*- encoding:%s -*-``; the former is more common + and compatible with emacs. Courtesy Martin Geisler. + +- [bug] Fixed issue where an old lexer rule prevented a template line + which looked like "#*" from being correctly parsed. [ticket:224] + 0.9.0 - [bug] The Context.locals_() method becomes a private underscored method, as this method has a specific internal use. The purpose diff -Nru mako-0.9.0/Mako.egg-info/PKG-INFO mako-0.9.1/Mako.egg-info/PKG-INFO --- mako-0.9.0/Mako.egg-info/PKG-INFO 2013-08-27 18:59:08.000000000 +0000 +++ mako-0.9.1/Mako.egg-info/PKG-INFO 2013-12-26 23:40:19.000000000 +0000 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: Mako -Version: 0.9.0 +Version: 0.9.1 Summary: A super-fast templating language that borrows the best ideas from the existing templating languages. Home-page: http://www.makotemplates.org/ Author: Mike Bayer diff -Nru mako-0.9.0/PKG-INFO mako-0.9.1/PKG-INFO --- mako-0.9.0/PKG-INFO 2013-08-27 18:59:08.000000000 +0000 +++ mako-0.9.1/PKG-INFO 2013-12-26 23:40:19.000000000 +0000 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: Mako -Version: 0.9.0 +Version: 0.9.1 Summary: A super-fast templating language that borrows the best ideas from the existing templating languages. Home-page: http://www.makotemplates.org/ Author: Mike Bayer diff -Nru mako-0.9.0/debian/changelog mako-0.9.1/debian/changelog --- mako-0.9.0/debian/changelog 2013-08-31 09:59:01.000000000 +0000 +++ mako-0.9.1/debian/changelog 2013-12-29 10:59:57.000000000 +0000 @@ -1,3 +1,10 @@ +mako (0.9.1-1) unstable; urgency=low + + * New upstream release + * Standards-Version bumped to 3.9.5 (no changes needed) + + -- Piotr Ożarowski Sun, 29 Dec 2013 11:57:23 +0100 + mako (0.9.0-1) unstable; urgency=low * New upstream release diff -Nru mako-0.9.0/debian/control mako-0.9.1/debian/control --- mako-0.9.0/debian/control 2013-05-05 19:30:02.000000000 +0000 +++ mako-0.9.1/debian/control 2013-12-29 10:59:00.000000000 +0000 @@ -10,10 +10,9 @@ python-sphinx, # for tests: python-nose, python-markupsafe -Standards-Version: 3.9.4 +Standards-Version: 3.9.5 Homepage: http://www.makotemplates.org/ X-Python-Version: >= 2.4 -X-Python3-Version: >= 3.0 Vcs-Svn: svn://anonscm.debian.org/python-modules/packages/mako/trunk/ Vcs-Browser: http://anonscm.debian.org/viewvc/python-modules/packages/mako/trunk/ @@ -22,7 +21,6 @@ Depends: ${python:Depends}, ${misc:Depends} Suggests: python-beaker (>= 1.1), python-mako-doc Enhances: python-pylons, python-turbogears, python-pygments -XB-Python-Version: ${python:Versions} Description: fast and lightweight templating for the Python platform Mako is a template library written in Python. It provides a familiar, non-XML syntax which compiles into Python modules for maximum performance. Mako's diff -Nru mako-0.9.0/debian/rules mako-0.9.1/debian/rules --- mako-0.9.0/debian/rules 2012-03-31 18:04:51.000000000 +0000 +++ mako-0.9.1/debian/rules 2013-12-29 10:59:22.000000000 +0000 @@ -64,7 +64,7 @@ dh_installdeb -i dh_gencontrol -i dh_md5sums -i - dh_builddeb -i -- -Z bzip2 + dh_builddeb -i binary-arch: diff -Nru mako-0.9.0/doc/_sources/unicode.txt mako-0.9.1/doc/_sources/unicode.txt --- mako-0.9.0/doc/_sources/unicode.txt 2013-08-27 18:57:37.000000000 +0000 +++ mako-0.9.1/doc/_sources/unicode.txt 2013-12-26 23:37:02.000000000 +0000 @@ -285,7 +285,7 @@ .. sourcecode:: python - # -*- encoding:utf-8 -*- + # -*- coding:utf-8 -*- from mako.template import Template t = Template("drôle de petite voix m’a réveillé.", disable_unicode=True, input_encoding='utf-8') @@ -299,7 +299,7 @@ .. sourcecode:: python - # -*- encoding:utf-8 -*- + # -*- coding:utf-8 -*- # ...more generated code ... def render_body(context,**pageargs): diff -Nru mako-0.9.0/doc/build/builder/builders.py mako-0.9.1/doc/build/builder/builders.py --- mako-0.9.0/doc/build/builder/builders.py 2013-08-27 18:57:37.000000000 +0000 +++ mako-0.9.1/doc/build/builder/builders.py 2013-12-26 23:37:02.000000000 +0000 @@ -27,7 +27,8 @@ directories=builder.config.templates_path, imports=[ "from builder import util" - ] + ], + #format_exceptions=True, ) def render(self, template, context): @@ -37,7 +38,7 @@ # RTD layout if rtd: - # add variables if not present, such + # add variables if not present, such # as if local test of READTHEDOCS variable if 'MEDIA_URL' not in context: context['MEDIA_URL'] = "http://media.readthedocs.org/" @@ -93,5 +94,4 @@ # lexer here so that the latest syntax is available app.add_lexer('mako', MakoLexer()) app.add_config_value('site_base', "", True) - - \ No newline at end of file + diff -Nru mako-0.9.0/doc/build/templates/base.mako mako-0.9.1/doc/build/templates/base.mako --- mako-0.9.0/doc/build/templates/base.mako 2013-08-27 18:57:37.000000000 +0000 +++ mako-0.9.1/doc/build/templates/base.mako 2013-12-26 23:37:02.000000000 +0000 @@ -3,9 +3,15 @@ <%block name="head_title">Mako Templates for Python</%block> + + +% for cssfile in self.attr.default_css_files + css_files: + +% endfor + + <%block name="headers"> - @@ -29,8 +35,6 @@
Home   |   - Trac -   |   Community   |   Documentation diff -Nru mako-0.9.0/doc/build/templates/layout.mako mako-0.9.1/doc/build/templates/layout.mako --- mako-0.9.0/doc/build/templates/layout.mako 2013-08-27 18:57:37.000000000 +0000 +++ mako-0.9.1/doc/build/templates/layout.mako 2013-12-26 23:37:02.000000000 +0000 @@ -1,12 +1,19 @@ ## coding: utf-8 <%! local_script_files = [] + + default_css_files = [ + '_static/pygments.css', + '_static/docs.css', + '_static/site.css' + ] %> + <%doc> Structural elements are all prefixed with "docs-" - to prevent conflicts when the structure is integrated into the + to prevent conflicts when the structure is integrated into the main site. - + docs-container -> docs-header -> docs-search @@ -29,7 +36,7 @@ <%block name="head_title"> % if current_page_name != 'index': - ${capture(self.show_title) | util.striptags} — + ${capture(self.show_title) | util.striptags} — % endif ${docstitle|h} @@ -38,8 +45,7 @@
<%block name="headers"> - - + ${parent.headers()} - - - -##{% if using_theme %} -## -##{% endif %} - - - + var static_root = "${pathto('_static', 1)}" + + // copied from: + // https://github.com/rtfd/readthedocs.org/commit/edbbb4c753454cf20c128d4eb2fef60d740debaa#diff-2f70e8d9361202bfe3f378d2ff2c510bR8 + var READTHEDOCS_DATA = { + project: "${slug}", + version: "${current_version}", + page: "${pagename}", + theme: "${html_theme or ''}" + }; + + + + + ${parent.headers()} + + ${next.body()} <%block name="footer"> ${parent.footer()} - -## Keep this here, so that the RTD logo doesn't stomp on the bottom of the theme. -
-
-
- - - - - - -% if analytics_code: - - -% endif - diff -Nru mako-0.9.0/doc/build/unicode.rst mako-0.9.1/doc/build/unicode.rst --- mako-0.9.0/doc/build/unicode.rst 2013-08-27 18:57:37.000000000 +0000 +++ mako-0.9.1/doc/build/unicode.rst 2013-12-26 23:37:02.000000000 +0000 @@ -285,7 +285,7 @@ .. sourcecode:: python - # -*- encoding:utf-8 -*- + # -*- coding:utf-8 -*- from mako.template import Template t = Template("drôle de petite voix m’a réveillé.", disable_unicode=True, input_encoding='utf-8') @@ -299,7 +299,7 @@ .. sourcecode:: python - # -*- encoding:utf-8 -*- + # -*- coding:utf-8 -*- # ...more generated code ... def render_body(context,**pageargs): diff -Nru mako-0.9.0/doc/caching.html mako-0.9.1/doc/caching.html --- mako-0.9.0/doc/caching.html 2013-08-27 18:57:45.000000000 +0000 +++ mako-0.9.1/doc/caching.html 2013-12-26 23:37:18.000000000 +0000 @@ -5,17 +5,24 @@ Caching - — - Mako 0.9.0 Documentation + — + Mako 0.9.1 Documentation + + + + + + + - + - @@ -58,12 +64,13 @@ +
-

Mako 0.9.0 Documentation

+

Mako 0.9.1 Documentation

- Release: 0.9.0 + Release: 0.9.1
@@ -97,10 +104,10 @@
- Mako 0.9.0 Documentation + Mako 0.9.1 Documentation » Caching - +

@@ -357,7 +364,7 @@

dogpile.cache is a new replacement for Beaker. It provides a modernized, slimmed down interface and is generally easier to use than Beaker. As of this writing it has not yet been released. dogpile.cache -includes its own Mako cache plugin – see dogpile.cache.plugins.mako_cache in the +includes its own Mako cache plugin – see dogpile.cache.plugins.mako_cache in the dogpile.cache documentation.

@@ -762,7 +769,7 @@
diff -Nru mako-0.9.0/doc/defs.html mako-0.9.1/doc/defs.html --- mako-0.9.0/doc/defs.html 2013-08-27 18:57:45.000000000 +0000 +++ mako-0.9.1/doc/defs.html 2013-12-26 23:37:18.000000000 +0000 @@ -5,17 +5,24 @@ Defs and Blocks - — - Mako 0.9.0 Documentation + — + Mako 0.9.1 Documentation + + + + + + + - + - @@ -59,12 +65,13 @@ +
-

Mako 0.9.0 Documentation

+

Mako 0.9.1 Documentation

- Release: 0.9.0 + Release: 0.9.1
@@ -101,10 +108,10 @@
- Mako 0.9.0 Documentation + Mako 0.9.1 Documentation » Defs and Blocks - +

@@ -708,7 +715,7 @@

diff -Nru mako-0.9.0/doc/filtering.html mako-0.9.1/doc/filtering.html --- mako-0.9.0/doc/filtering.html 2013-08-27 18:57:45.000000000 +0000 +++ mako-0.9.1/doc/filtering.html 2013-12-26 23:37:18.000000000 +0000 @@ -5,17 +5,24 @@ Filtering and Buffering - — - Mako 0.9.0 Documentation + — + Mako 0.9.1 Documentation + + + + + + + - + - @@ -59,12 +65,13 @@ +
-

Mako 0.9.0 Documentation

+

Mako 0.9.1 Documentation

- Release: 0.9.0 + Release: 0.9.1
@@ -101,10 +108,10 @@
- Mako 0.9.0 Documentation + Mako 0.9.1 Documentation » Filtering and Buffering - +

@@ -459,7 +466,7 @@

diff -Nru mako-0.9.0/doc/genindex.html mako-0.9.1/doc/genindex.html --- mako-0.9.0/doc/genindex.html 2013-08-27 18:57:46.000000000 +0000 +++ mako-0.9.1/doc/genindex.html 2013-12-26 23:37:19.000000000 +0000 @@ -5,17 +5,24 @@ Index - — - Mako 0.9.0 Documentation + — + Mako 0.9.1 Documentation + + + + + + + - + - @@ -57,12 +63,13 @@ +
-

Mako 0.9.0 Documentation

+

Mako 0.9.1 Documentation

- Release: 0.9.0 + Release: 0.9.1
@@ -92,10 +99,10 @@
- Mako 0.9.0 Documentation + Mako 0.9.1 Documentation » Index - +

@@ -887,7 +894,7 @@

diff -Nru mako-0.9.0/doc/index.html mako-0.9.1/doc/index.html --- mako-0.9.0/doc/index.html 2013-08-27 18:57:45.000000000 +0000 +++ mako-0.9.1/doc/index.html 2013-12-26 23:37:18.000000000 +0000 @@ -3,16 +3,23 @@ - Mako 0.9.0 Documentation + Mako 0.9.1 Documentation + + + + + + + - + - @@ -55,12 +61,13 @@ +
-

Mako 0.9.0 Documentation

+

Mako 0.9.1 Documentation

- Release: 0.9.0 + Release: 0.9.1
@@ -94,7 +101,7 @@
- Mako 0.9.0 Documentation + Mako 0.9.1 Documentation

@@ -210,7 +217,7 @@

diff -Nru mako-0.9.0/doc/inheritance.html mako-0.9.1/doc/inheritance.html --- mako-0.9.0/doc/inheritance.html 2013-08-27 18:57:46.000000000 +0000 +++ mako-0.9.1/doc/inheritance.html 2013-12-26 23:37:18.000000000 +0000 @@ -5,17 +5,24 @@ Inheritance - — - Mako 0.9.0 Documentation + — + Mako 0.9.1 Documentation + + + + + + + - + - @@ -59,12 +65,13 @@ +
-

Mako 0.9.0 Documentation

+

Mako 0.9.1 Documentation

- Release: 0.9.0 + Release: 0.9.1
@@ -101,10 +108,10 @@
- Mako 0.9.0 Documentation + Mako 0.9.1 Documentation » Inheritance - +

@@ -657,7 +664,7 @@

diff -Nru mako-0.9.0/doc/namespaces.html mako-0.9.1/doc/namespaces.html --- mako-0.9.0/doc/namespaces.html 2013-08-27 18:57:46.000000000 +0000 +++ mako-0.9.1/doc/namespaces.html 2013-12-26 23:37:19.000000000 +0000 @@ -5,17 +5,24 @@ Namespaces - — - Mako 0.9.0 Documentation + — + Mako 0.9.1 Documentation + + + + + + + - + - @@ -59,12 +65,13 @@ +
-

Mako 0.9.0 Documentation

+

Mako 0.9.1 Documentation

- Release: 0.9.0 + Release: 0.9.1
@@ -101,10 +108,10 @@
- Mako 0.9.0 Documentation + Mako 0.9.1 Documentation » Namespaces - +

@@ -751,7 +758,7 @@

diff -Nru mako-0.9.0/doc/runtime.html mako-0.9.1/doc/runtime.html --- mako-0.9.0/doc/runtime.html 2013-08-27 18:57:46.000000000 +0000 +++ mako-0.9.1/doc/runtime.html 2013-12-26 23:37:19.000000000 +0000 @@ -5,17 +5,24 @@ The Mako Runtime Environment - — - Mako 0.9.0 Documentation + — + Mako 0.9.1 Documentation + + + + + + + - + - @@ -59,12 +65,13 @@ +
-

Mako 0.9.0 Documentation

+

Mako 0.9.1 Documentation

- Release: 0.9.0 + Release: 0.9.1
@@ -101,10 +108,10 @@
- Mako 0.9.0 Documentation + Mako 0.9.1 Documentation » The Mako Runtime Environment - +

@@ -698,7 +705,7 @@

diff -Nru mako-0.9.0/doc/search.html mako-0.9.1/doc/search.html --- mako-0.9.0/doc/search.html 2013-08-27 18:57:46.000000000 +0000 +++ mako-0.9.1/doc/search.html 2013-12-26 23:37:19.000000000 +0000 @@ -5,17 +5,24 @@ Search - — - Mako 0.9.0 Documentation + — + Mako 0.9.1 Documentation + + + + + + + - + - @@ -58,12 +64,13 @@ +
-

Mako 0.9.0 Documentation

+

Mako 0.9.1 Documentation

- Release: 0.9.0 + Release: 0.9.1
@@ -93,10 +100,10 @@
- Mako 0.9.0 Documentation + Mako 0.9.1 Documentation » Search - +

@@ -138,7 +145,7 @@

diff -Nru mako-0.9.0/doc/syntax.html mako-0.9.1/doc/syntax.html --- mako-0.9.0/doc/syntax.html 2013-08-27 18:57:46.000000000 +0000 +++ mako-0.9.1/doc/syntax.html 2013-12-26 23:37:19.000000000 +0000 @@ -5,17 +5,24 @@ Syntax - — - Mako 0.9.0 Documentation + — + Mako 0.9.1 Documentation + + + + + + + - + - @@ -59,12 +65,13 @@ +
-

Mako 0.9.0 Documentation

+

Mako 0.9.1 Documentation

- Release: 0.9.0 + Release: 0.9.1
@@ -101,10 +108,10 @@
- Mako 0.9.0 Documentation + Mako 0.9.1 Documentation » Syntax - +

@@ -578,7 +585,7 @@

diff -Nru mako-0.9.0/doc/unicode.html mako-0.9.1/doc/unicode.html --- mako-0.9.0/doc/unicode.html 2013-08-27 18:57:46.000000000 +0000 +++ mako-0.9.1/doc/unicode.html 2013-12-26 23:37:19.000000000 +0000 @@ -5,17 +5,24 @@ The Unicode Chapter - — - Mako 0.9.0 Documentation + — + Mako 0.9.1 Documentation + + + + + + + - + - @@ -59,12 +65,13 @@ +
-

Mako 0.9.0 Documentation

+

Mako 0.9.1 Documentation

- Release: 0.9.0 + Release: 0.9.1
@@ -101,10 +108,10 @@
- Mako 0.9.0 Documentation + Mako 0.9.1 Documentation » The Unicode Chapter - +

@@ -387,7 +394,7 @@ generally perform slightly faster than unicode objects in Python. For these users, assuming they’re sticking with Python 2, they can hit the disable_unicode=True flag as so:

-
# -*- encoding:utf-8 -*-
+
# -*- coding:utf-8 -*-
 from mako.template import Template
 
 t = Template("drôle de petite voix m’a réveillé.", disable_unicode=True, input_encoding='utf-8')
@@ -398,7 +405,7 @@
 not supported at all in Python 3.

The generated module source code will contain elements like these:

-
# -*- encoding:utf-8 -*-
+
# -*- coding:utf-8 -*-
 #  ...more generated code ...
 
 def render_body(context,**pageargs):
@@ -456,7 +463,7 @@
 
     
 
diff -Nru mako-0.9.0/doc/usage.html mako-0.9.1/doc/usage.html --- mako-0.9.0/doc/usage.html 2013-08-27 18:57:46.000000000 +0000 +++ mako-0.9.1/doc/usage.html 2013-12-26 23:37:19.000000000 +0000 @@ -5,17 +5,24 @@ Usage - — - Mako 0.9.0 Documentation + — + Mako 0.9.1 Documentation + + + + + + + - + - @@ -59,12 +65,13 @@ +
-

Mako 0.9.0 Documentation

+

Mako 0.9.1 Documentation

- Release: 0.9.0 + Release: 0.9.1
@@ -101,10 +108,10 @@
- Mako 0.9.0 Documentation + Mako 0.9.1 Documentation » Usage - +

@@ -1056,7 +1063,7 @@

diff -Nru mako-0.9.0/mako/__init__.py mako-0.9.1/mako/__init__.py --- mako-0.9.0/mako/__init__.py 2013-08-27 18:57:37.000000000 +0000 +++ mako-0.9.1/mako/__init__.py 2013-12-26 23:37:02.000000000 +0000 @@ -5,5 +5,5 @@ # the MIT License: http://www.opensource.org/licenses/mit-license.php -__version__ = '0.9.0' +__version__ = '0.9.1' diff -Nru mako-0.9.0/mako/_ast_util.py mako-0.9.1/mako/_ast_util.py --- mako-0.9.0/mako/_ast_util.py 2013-08-27 18:57:37.000000000 +0000 +++ mako-0.9.1/mako/_ast_util.py 2013-12-26 23:37:02.000000000 +0000 @@ -31,7 +31,7 @@ :license: Python License. """ from _ast import * - +from mako.compat import arg_stringname BOOLOP_SYMBOLS = { And: 'and', @@ -403,10 +403,10 @@ self.visit(default) if node.vararg is not None: write_comma() - self.write('*' + node.vararg) + self.write('*' + arg_stringname(node.vararg)) if node.kwarg is not None: write_comma() - self.write('**' + node.kwarg) + self.write('**' + arg_stringname(node.kwarg)) def decorators(self, node): for decorator in node.decorator_list: @@ -659,6 +659,9 @@ def visit_Name(self, node): self.write(node.id) + def visit_NameConstant(self, node): + self.write(str(node.value)) + def visit_arg(self, node): self.write(node.arg) diff -Nru mako-0.9.0/mako/ast.py mako-0.9.1/mako/ast.py --- mako-0.9.0/mako/ast.py 2013-08-27 18:57:37.000000000 +0000 +++ mako-0.9.1/mako/ast.py 2013-12-26 23:37:02.000000000 +0000 @@ -8,6 +8,7 @@ code, as well as generating Python from AST nodes""" from mako import exceptions, pyparser, compat +from mako.compat import arg_stringname import re class PythonCode(object): @@ -126,10 +127,10 @@ for arg in argnames: default = None if kwargs: - arg = "**" + arg + arg = "**" + arg_stringname(arg) kwargs = False elif varargs: - arg = "*" + arg + arg = "*" + arg_stringname(arg) varargs = False else: default = len(defaults) and defaults.pop() or None diff -Nru mako-0.9.0/mako/codegen.py mako-0.9.1/mako/codegen.py --- mako-0.9.0/mako/codegen.py 2013-08-27 18:57:37.000000000 +0000 +++ mako-0.9.1/mako/codegen.py 2013-12-26 23:37:02.000000000 +0000 @@ -188,7 +188,7 @@ # module-level names, python code if self.compiler.generate_magic_comment and \ self.compiler.source_encoding: - self.printer.writeline("# -*- encoding:%s -*-" % + self.printer.writeline("# -*- coding:%s -*-" % self.compiler.source_encoding) if self.compiler.future_imports: diff -Nru mako-0.9.0/mako/compat.py mako-0.9.1/mako/compat.py --- mako-0.9.0/mako/compat.py 2013-08-27 18:57:37.000000000 +0000 +++ mako-0.9.1/mako/compat.py 2013-12-26 23:37:02.000000000 +0000 @@ -155,3 +155,13 @@ return meta("%sBase" % meta.__name__, (base,), {}) ################################################ + +def arg_stringname(func_arg): + """Gets the string name of a kwarg or vararg + In Python3.4 a function's args are + of _ast.arg type not _ast.name + """ + if hasattr(func_arg, 'arg'): + return func_arg.arg + else: + return str(func_arg) diff -Nru mako-0.9.0/mako/ext/babelplugin.py mako-0.9.1/mako/ext/babelplugin.py --- mako-0.9.0/mako/ext/babelplugin.py 2013-08-27 18:57:37.000000000 +0000 +++ mako-0.9.1/mako/ext/babelplugin.py 2013-12-26 23:37:02.000000000 +0000 @@ -80,41 +80,37 @@ child_nodes = node.nodes elif isinstance(node, parsetree.ControlLine): if node.isend: - translator_comments = [] in_translator_comments = False continue code = node.text elif isinstance(node, parsetree.Code): - # <% and <%! blocks would provide their own translator comments - translator_comments = [] in_translator_comments = False - code = node.code.code elif isinstance(node, parsetree.Expression): code = node.code.code else: - translator_comments = [] - in_translator_comments = False continue # Comments don't apply unless they immediately preceed the message if translator_comments and \ translator_comments[-1][0] < node.lineno - 1: translator_comments = [] - else: - translator_comments = \ - [comment[1] for comment in translator_comments] + + translator_strings = [comment[1] for comment in translator_comments] if isinstance(code, compat.text_type): code = code.encode('ascii', 'backslashreplace') + used_translator_comments = False code = compat.byte_buffer(code) for lineno, funcname, messages, python_translator_comments \ in extract_python(code, keywords, comment_tags, options): yield (node.lineno + (lineno - 1), funcname, messages, - translator_comments + python_translator_comments) + translator_strings + python_translator_comments) + used_translator_comments = True - translator_comments = [] + if used_translator_comments: + translator_comments = [] in_translator_comments = False if child_nodes: diff -Nru mako-0.9.0/mako/ext/turbogears.py mako-0.9.1/mako/ext/turbogears.py --- mako-0.9.0/mako/ext/turbogears.py 2013-08-27 18:57:37.000000000 +0000 +++ mako-0.9.1/mako/ext/turbogears.py 2013-12-26 23:37:02.000000000 +0000 @@ -4,7 +4,8 @@ # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php -import re, inspect +import inspect +from mako import compat from mako.lookup import TemplateLookup from mako.template import Template @@ -25,7 +26,7 @@ elif k in ['directories', 'filesystem_checks', 'module_directory']: lookup_options[k] = v self.lookup = TemplateLookup(**lookup_options) - + self.tmpl_options = {} # transfer lookup args to template args, based on those available # in getargspec @@ -46,7 +47,7 @@ return self.lookup.get_template(templatename) def render(self, info, format="html", fragment=False, template=None): - if isinstance(template, str): + if isinstance(template, compat.string_types): template = self.load_template(template) # Load extra vars func if provided diff -Nru mako-0.9.0/mako/lexer.py mako-0.9.1/mako/lexer.py --- mako-0.9.0/mako/lexer.py 2013-08-27 18:57:37.000000000 +0000 +++ mako-0.9.1/mako/lexer.py 2013-12-26 23:37:02.000000000 +0000 @@ -345,8 +345,6 @@ | (?=\${) # an expression | - (?=\#\*) # multiline comment - | (?= diff -Nru mako-0.9.0/test/templates/chs_unicode_py3k.html mako-0.9.1/test/templates/chs_unicode_py3k.html --- mako-0.9.0/test/templates/chs_unicode_py3k.html 2013-08-27 18:57:37.000000000 +0000 +++ mako-0.9.1/test/templates/chs_unicode_py3k.html 2013-12-26 23:37:02.000000000 +0000 @@ -1,4 +1,4 @@ -## -*- encoding:utf8 -*- +## -*- coding:utf-8 -*- <% msg = '新中国的主席' %> diff -Nru mako-0.9.0/test/templates/chs_utf8.html mako-0.9.1/test/templates/chs_utf8.html --- mako-0.9.0/test/templates/chs_utf8.html 2013-08-27 18:57:37.000000000 +0000 +++ mako-0.9.1/test/templates/chs_utf8.html 2013-12-26 23:37:02.000000000 +0000 @@ -1,4 +1,4 @@ -## -*- encoding:utf8 -*- +## -*- coding:utf-8 -*- <% msg = '新中国的主席' %> diff -Nru mako-0.9.0/test/templates/gettext.mako mako-0.9.1/test/templates/gettext.mako --- mako-0.9.0/test/templates/gettext.mako 2013-08-27 18:57:37.000000000 +0000 +++ mako-0.9.1/test/templates/gettext.mako 2013-12-26 23:37:02.000000000 +0000 @@ -88,3 +88,12 @@ +## TRANSLATOR:

tag is ok? +

${_("Inside a p tag")}

+ +## TRANSLATOR: also this +

${even_with_other_code_first()} - ${_("Later in a p tag")}

+ +## TRANSLATOR: we still ignore comments too far from the string + +

${_("No action at a distance.")}

diff -Nru mako-0.9.0/test/test_babelplugin.py mako-0.9.1/test/test_babelplugin.py --- mako-0.9.0/test/test_babelplugin.py 2013-08-27 18:57:37.000000000 +0000 +++ mako-0.9.1/test/test_babelplugin.py 2013-12-26 23:37:02.000000000 +0000 @@ -13,8 +13,8 @@ class ExtractMakoTestCase(TemplateTest): - @skip_if(lambda: not babel, 'babel not installed: skipping babelplugin test') + @skip_if(lambda: not babel, 'babel not installed: skipping babelplugin test') def test_extract(self): mako_tmpl = open(os.path.join(template_base, 'gettext.mako')) messages = list(extract(mako_tmpl, {'_': None, 'gettext': None, @@ -40,7 +40,10 @@ (77, '_', 'Top', []), (83, '_', 'foo', []), (83, '_', 'hoho', []), - (85, '_', 'bar', []) + (85, '_', 'bar', []), + (92, '_', 'Inside a p tag', ['TRANSLATOR:

tag is ok?']), + (95, '_', 'Later in a p tag', ['TRANSLATOR: also this']), + (99, '_', 'No action at a distance.', []), ] self.assertEqual(expected, messages) diff -Nru mako-0.9.0/test/test_exceptions.py mako-0.9.1/test/test_exceptions.py --- mako-0.9.0/test/test_exceptions.py 2013-08-27 18:57:37.000000000 +0000 +++ mako-0.9.1/test/test_exceptions.py 2013-12-26 23:37:02.000000000 +0000 @@ -57,7 +57,7 @@ @requires_pygments_14 def test_utf8_html_error_template_pygments(self): - """test the html_error_template with a Template containing utf8 + """test the html_error_template with a Template containing UTF-8 chars""" if compat.py3k: @@ -105,7 +105,7 @@ @requires_no_pygments_exceptions def test_utf8_html_error_template_no_pygments(self): - """test the html_error_template with a Template containing utf8 + """test the html_error_template with a Template containing UTF-8 chars""" if compat.py3k: diff -Nru mako-0.9.0/test/test_lexer.py mako-0.9.1/test/test_lexer.py --- mako-0.9.0/test/test_lexer.py 2013-08-27 18:57:37.000000000 +0000 +++ mako-0.9.1/test/test_lexer.py 2013-12-26 23:37:02.000000000 +0000 @@ -155,6 +155,12 @@ ControlLine('if', 'endif', True, (7, 1)), Text(' ', (8, 1))])) + def test_old_multiline_comment(self): + template = """#*""" + node = Lexer(template).parse() + self._compare(node, TemplateNode({}, [Text('''#*''', (1, 1))])) + + def test_text_tag(self): template = \ """ diff -Nru mako-0.9.0/test/test_template.py mako-0.9.1/test/test_template.py --- mako-0.9.0/test/test_template.py 2013-08-27 18:57:37.000000000 +0000 +++ mako-0.9.1/test/test_template.py 2013-12-26 23:37:02.000000000 +0000 @@ -13,6 +13,16 @@ requires_python_26_or_greater, assert_raises, assert_raises_message, \ requires_python_2 +class ctx(object): + def __init__(self, a, b): + pass + + def __enter__(self): + return self + + def __exit__(self, *arg): + pass + class EncodingTest(TemplateTest): def test_escapes_html_tags(self): from mako.exceptions import html_error_template @@ -875,11 +885,12 @@ def test_blank_control_8(self): self._do_memory_test( """ - % with open('x', 'w') as fp: + % with ctx('x', 'w') as fp: % endwith """, "", - filters=lambda s:s.strip() + filters=lambda s: s.strip(), + template_args={"ctx": ctx} ) def test_commented_blank_control_1(self): @@ -973,12 +984,13 @@ def test_commented_blank_control_8(self): self._do_memory_test( """ - % with open('x', 'w') as fp: + % with ctx('x', 'w') as fp: ## comment % endwith """, "", - filters=lambda s:s.strip() + filters=lambda s: s.strip(), + template_args={"ctx": ctx} ) def test_multiline_control(self): diff -Nru mako-0.9.0/test/test_tgplugin.py mako-0.9.1/test/test_tgplugin.py --- mako-0.9.0/test/test_tgplugin.py 2013-08-27 18:57:37.000000000 +0000 +++ mako-0.9.1/test/test_tgplugin.py 2013-12-26 23:37:02.000000000 +0000 @@ -1,8 +1,7 @@ -import unittest - from mako.ext.turbogears import TGPlugin -from test.util import flatten_result, result_lines +from test.util import result_lines from test import TemplateTest, template_base +from mako import compat tl = TGPlugin(options=dict(directories=[template_base]), extension='html') @@ -40,3 +39,11 @@ def test_string(self): t = tl.load_template('foo', "hello world") assert t.render() == "hello world" + + def test_render(self): + assert result_lines(tl.render({}, template='/index.html')) == [ + "this is index" + ] + assert result_lines(tl.render({}, template=compat.u('/index.html'))) == [ + "this is index" + ]