Skip to content
Myr

Use print() function in both Python2 and Python 3

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by cclauss · committed by cclauss · parent 9a7dd7b · 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

12 files+22 added−11 removed

modified:examples/basic/cycle.py+3 added-2 removed
1from __future__ import print_function2from jinja2 import Environment345env = Environment(line_statement_prefix="#", variable_start_string="${", variable_end_string="}")677print env.from_string("""\8print(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
1from __future__ import print_function2from jinja2 import Environment3from jinja2.loaders import FileSystemLoader45env = Environment(loader=FileSystemLoader('templates'))67tmpl = env.get_template('broken.html')7print tmpl.render(seq=[3, 2, 4, 5, 3, 2, 0, 2, 1])8print(tmpl.render(seq=[3, 2, 4, 5, 3, 2, 0, 2, 1]))
modified:examples/basic/inheritance.py+2 added-1 removed
1from __future__ import print_function2from jinja2 import Environment3from jinja2.loaders import DictLoader45
3 unmodified lines
9'c': '''{% extends 'b' %}{% block body %}###{{ super() }}###{% endblock %}'''10}))111212print env.get_template('c').render()13print(env.get_template('c').render())
modified:examples/basic/test_filter_and_linestatements.py+1 added
1from __future__ import print_function2from jinja2 import Environment345env = Environment(line_statement_prefix='%', variable_start_string="${", variable_end_string="}")
21 unmodified lines
modified:examples/basic/test_loop_filter.py+1 added
1from __future__ import print_function2from jinja2 import Environment34tmpl = Environment().from_string("""\5<ul>
8 unmodified lines
modified:examples/basic/test.py+1 added
1from __future__ import print_function2from jinja2 import Environment3from jinja2.loaders import DictLoader45env = Environment(loader=DictLoader({
23 unmodified lines
modified:examples/basic/translate.py+3 added-2 removed
1from __future__ import print_function2from jinja2 import Environment34env = Environment(extensions=['jinja2.ext.i18n'])5env.globals['gettext'] = {
2 unmodified lines
8env.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]11print env.from_string("""\12print(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 lines
910 :copyright: (c) 2009 by the Jinja Team.11 :license: BSD.12"""13from __future__ import print_function14import sys15from os.path import join, dirname, abspath16try:17 from cProfile import Profile
86 unmodified lines
104 sys.stdout.flush()105 sys.stdout.write('\r %-20s%.4f seconds\n' % (test, t.timeit(number=200) / 200))106107 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 line
modified:examples/profile.py+2 added-1 removed
1from __future__ import print_function2try:3 from cProfile import Profile4except ImportError:5 from profile import Profile
36 unmodified lines
42 line_statement_prefix='%',43 variable_start_string="${",44 variable_end_string="}"45).from_string(source)45print jinja_template.environment.compile(source, raw=True)46print(jinja_template.environment.compile(source, raw=True))474849p = Profile()50p.runcall(lambda: jinja_template.render(context))
3 unmodified lines
modified:ext/django2jinja/django2jinja.py+3 added-2 removed
66 unmodified lines
6768 :copyright: (c) 2009 by the Jinja Team.69 :license: BSD.70"""71from __future__ import print_function72import re73import os74import sys75from jinja2.defaults import *
52 unmodified lines
128 writer.stream = original129130 if callback is None:131 def callback(template):131 print template132 print(template)133134 for directory in settings.TEMPLATE_DIRS:135 for dirname, _, files in os.walk(directory):136 dirname = dirname[len(directory) + 1:]
171 unmodified lines
308 """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)313314 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 lines
modified:ext/djangojinja2.py+1 added-1 removed
51 unmodified lines
52def 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))585960def select_template(templates, globals=None):
26 unmodified lines
modified:scripts/jinja2-debug.py+1 added
7 unmodified lines
89 :copyright: Copyright 2010 by Armin Ronacher.10 :license: BSD.11"""12from __future__ import print_function13import sys14import jinja215from werkzeug import script16
28 unmodified lines