Merge pull request #1093 from cclauss/print-function
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Use print() function in both Python2 and Python 3
authored by David Lord · committed by GitHub · parents 9a7dd7b, 82a8ea4 · Browse files · 12 files·+22 added−11 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
12 files+22 added−11 removed
- other:+22 added−11 removed
Provenance
- Commit
4c95c5f- Tree
07887e8- Author
David Lord <davidism@gmail.com>- Committer
GitHub <noreply@github.com>- Parent 1
9a7dd7b- Parent 2
82a8ea4
12 files changed+22 added−11 removed
modified:examples/basic/cycle.py+3 added-2 removed
1+from __future__ import print_function2 from jinja2 import Environment3 4 5 env = Environment(line_statement_prefix="#", variable_start_string="${", variable_end_string="}")6 7 7-print env.from_string("""\8+print(env.from_string("""\9 <ul>10 # for item in range(10)11 <li class="${loop.cycle('odd', 'even')}">${item}</li>12 # endfor13 </ul>\13-""").render()14+""").render())modified:examples/basic/debugger.py+2 added-1 removed
1+from __future__ import print_function2 from jinja2 import Environment3 from jinja2.loaders import FileSystemLoader4 5 env = Environment(loader=FileSystemLoader('templates'))6 7 tmpl = env.get_template('broken.html')7-print tmpl.render(seq=[3, 2, 4, 5, 3, 2, 0, 2, 1])8+print(tmpl.render(seq=[3, 2, 4, 5, 3, 2, 0, 2, 1]))modified:examples/basic/inheritance.py+2 added-1 removed
1+from __future__ import print_function2 from jinja2 import Environment3 from jinja2.loaders import DictLoader4 5 3 unmodified lines9 'c': '''{% extends 'b' %}{% block body %}###{{ super() }}###{% endblock %}'''10 }))11 12 12-print env.get_template('c').render()13+print(env.get_template('c').render())modified:examples/basic/test_filter_and_linestatements.py+1 added
1+from __future__ import print_function2 from jinja2 import Environment3 4 5 env = Environment(line_statement_prefix='%', variable_start_string="${", variable_end_string="}")21 unmodified linesmodified:examples/basic/test_loop_filter.py+1 added
1+from __future__ import print_function2 from jinja2 import Environment3 4 tmpl = Environment().from_string("""\5 <ul>8 unmodified linesmodified:examples/basic/test.py+1 added
1+from __future__ import print_function2 from jinja2 import Environment3 from jinja2.loaders import DictLoader4 5 env = Environment(loader=DictLoader({23 unmodified linesmodified:examples/basic/translate.py+3 added-2 removed
1+from __future__ import print_function2 from jinja2 import Environment3 4 env = Environment(extensions=['jinja2.ext.i18n'])5 env.globals['gettext'] = {2 unmodified lines8 env.globals['ngettext'] = lambda s, p, n: {9 '%(count)s user': '%(count)d Benutzer',10 '%(count)s users': '%(count)d Benutzer'11 }[n == 1 and s or p]11-print env.from_string("""\12+print(env.from_string("""\13 {% trans %}Hello {{ user }}!{% endtrans %}14 {% trans count=users|count %}{{ count }} user{% pluralize %}{{ count }} users{% endtrans %}14-""").render(user="someone", users=[1, 2, 3])15+""").render(user="someone", users=[1, 2, 3]))modified:examples/rwbench/rwbench.py+2 added-1 removed
8 unmodified lines9 10 :copyright: (c) 2009 by the Jinja Team.11 :license: BSD.12 """13+from __future__ import print_function14 import sys15 from os.path import join, dirname, abspath16 try:17 from cProfile import Profile86 unmodified lines104 sys.stdout.flush()105 sys.stdout.write('\r %-20s%.4f seconds\n' % (test, t.timeit(number=200) / 200))106 107 if '-p' in sys.argv:107- print 'Jinja profile'108+ print('Jinja profile')109 p = Profile()110 p.runcall(test_jinja)111 stats = Stats(p)112 stats.sort_stats('time', 'calls')1 unmodified linemodified:examples/profile.py+2 added-1 removed
1+from __future__ import print_function2 try:3 from cProfile import Profile4 except ImportError:5 from profile import Profile36 unmodified lines42 line_statement_prefix='%',43 variable_start_string="${",44 variable_end_string="}"45 ).from_string(source)45-print jinja_template.environment.compile(source, raw=True)46+print(jinja_template.environment.compile(source, raw=True))47 48 49 p = Profile()50 p.runcall(lambda: jinja_template.render(context))3 unmodified linesmodified:ext/django2jinja/django2jinja.py+3 added-2 removed
66 unmodified lines67 68 :copyright: (c) 2009 by the Jinja Team.69 :license: BSD.70 """71+from __future__ import print_function72 import re73 import os74 import sys75 from jinja2.defaults import *52 unmodified lines128 writer.stream = original129 130 if callback is None:131 def callback(template):131- print template132+ print(template)133 134 for directory in settings.TEMPLATE_DIRS:135 for dirname, _, files in os.walk(directory):136 dirname = dirname[len(directory) + 1:]171 unmodified lines308 """Prints a warning to the error stream."""309 if node is not None and hasattr(node, 'source'):310 filename, lineno = self.get_location(*node.source)311 message = '[%s:%d] %s' % (filename, lineno, message)311- print >> self.error_stream, message312+ print(message, file=self.error_stream)313 314 def translate_variable_name(self, var):315 """Performs variable name translation."""316 if self.in_loop and var == 'forloop' or var.startswith('forloop.'):453 unmodified linesmodified:ext/djangojinja2.py+1 added-1 removed
51 unmodified lines52 def get_template(template_name, globals=None):53 """Load a template."""54 try:55 return get_env().get_template(template_name, globals=globals)56- except TemplateNotFound, e:56+ except TemplateNotFound as e:57 raise TemplateDoesNotExist(str(e))58 59 60 def select_template(templates, globals=None):26 unmodified linesmodified:scripts/jinja2-debug.py+1 added
7 unmodified lines8 9 :copyright: Copyright 2010 by Armin Ronacher.10 :license: BSD.11 """12+from __future__ import print_function13 import sys14 import jinja215 from werkzeug import script16 28 unmodified lines