Skip to content

Commit 462c12f

Browse files
inclementFeralBytes
authored andcommitted
Made build.py compatible with python3
1 parent 6c27ac9 commit 462c12f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+10801
-11
lines changed

src/build.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
from os.path import dirname, join, isfile, realpath, relpath, split
44
from zipfile import ZipFile
55
import sys
6-
sys.path.insert(0, 'buildlib/jinja2.egg')
6+
7+
python_major_version = sys.version_info[0]
8+
9+
sys.path.insert(0, 'buildlib/jinja2-py{}.egg'.format(python_major_version))
710
sys.path.insert(0, 'buildlib')
811

912
from fnmatch import fnmatch
@@ -67,10 +70,14 @@ def render(template, dest, **kwargs):
6770

6871
template = environment.get_template(template)
6972
text = template.render(**kwargs)
73+
if python_major_version == 2:
74+
text = text.encode('utf-8')
75+
else:
76+
text = bytes(text, 'utf-8')
7077

71-
f = file(dest, 'wb')
72-
f.write(text.encode('utf-8'))
73-
f.close()
78+
with open(dest, 'wb') as fileh:
79+
fileh.write(text)
80+
fileh.close()
7481

7582

7683
def compile_dir(dfn):
@@ -183,7 +190,7 @@ def select(fn):
183190
tf = tarfile.open(tfn, 'w:gz', format=tarfile.USTAR_FORMAT)
184191
dirs = []
185192
for fn, afn in files:
186-
print '%s: %s' % (tfn, fn)
193+
print('%s: %s' % (tfn, fn))
187194
dn = dirname(afn)
188195
if dn not in dirs:
189196
# create every dirs first if not exist yet
@@ -219,7 +226,9 @@ def make_package(args):
219226

220227
args.numeric_version = str(version_code)
221228

222-
args.name = args.name.decode('utf-8')
229+
if python_major_version == 2:
230+
args.name = args.name.decode('utf-8')
231+
223232
if args.icon_name:
224233
args.icon_name = args.icon_name.decode('utf-8')
225234

@@ -301,8 +310,8 @@ def make_package(args):
301310
subprocess.call([ANDROID, 'update', 'project', '-p', '.', '-t',
302311
'android-{}'.format(args.sdk_version)])
303312
except (OSError, IOError):
304-
print 'An error occured while calling', ANDROID, 'update'
305-
print 'Your PATH must include android tools.'
313+
print('An error occured while calling', ANDROID, 'update')
314+
print('Your PATH must include android tools.')
306315
sys.exit(-1)
307316

308317
# Delete the old assets.
@@ -341,7 +350,7 @@ def make_package(args):
341350
if args.add_jar:
342351
for jarname in args.add_jar:
343352
if not os.path.exists(jarname):
344-
print 'Requested jar does not exist: {}'.format(jarname)
353+
print('Requested jar does not exist: {}'.format(jarname))
345354
sys.exit(-1)
346355
shutil.copy(jarname, 'libs')
347356

@@ -350,8 +359,8 @@ def make_package(args):
350359
for arg in args.command:
351360
subprocess.check_call([ANT, arg])
352361
except (OSError, IOError):
353-
print 'An error occured while calling', ANT
354-
print 'Did you install ant on your system ?'
362+
print('An error occured while calling', ANT)
363+
print('Did you install ant on your system ?')
355364
sys.exit(-1)
356365

357366
if __name__ == '__main__':
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
Metadata-Version: 1.1
2+
Name: Jinja2
3+
Version: 2.7.2
4+
Summary: A small but fast and easy to use stand-alone template engine written in pure python.
5+
Home-page: http://jinja.pocoo.org/
6+
Author: Armin Ronacher
7+
Author-email: armin.ronacher@active-4.com
8+
License: BSD
9+
Description:
10+
Jinja2
11+
~~~~~~
12+
13+
Jinja2 is a template engine written in pure Python. It provides a
14+
`Django`_ inspired non-XML syntax but supports inline expressions and
15+
an optional `sandboxed`_ environment.
16+
17+
Nutshell
18+
--------
19+
20+
Here a small example of a Jinja template::
21+
22+
{% extends 'base.html' %}
23+
{% block title %}Memberlist{% endblock %}
24+
{% block content %}
25+
<ul>
26+
{% for user in users %}
27+
<li><a href="{{ user.url }}">{{ user.username }}</a></li>
28+
{% endfor %}
29+
</ul>
30+
{% endblock %}
31+
32+
Philosophy
33+
----------
34+
35+
Application logic is for the controller but don't try to make the life
36+
for the template designer too hard by giving him too few functionality.
37+
38+
For more informations visit the new `Jinja2 webpage`_ and `documentation`_.
39+
40+
.. _sandboxed: http://en.wikipedia.org/wiki/Sandbox_(computer_security)
41+
.. _Django: http://www.djangoproject.com/
42+
.. _Jinja2 webpage: http://jinja.pocoo.org/
43+
.. _documentation: http://jinja.pocoo.org/2/documentation/
44+
45+
Platform: UNKNOWN
46+
Classifier: Development Status :: 5 - Production/Stable
47+
Classifier: Environment :: Web Environment
48+
Classifier: Intended Audience :: Developers
49+
Classifier: License :: OSI Approved :: BSD License
50+
Classifier: Operating System :: OS Independent
51+
Classifier: Programming Language :: Python
52+
Classifier: Programming Language :: Python :: 3
53+
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
54+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
55+
Classifier: Topic :: Text Processing :: Markup :: HTML
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
AUTHORS
2+
CHANGES
3+
LICENSE
4+
MANIFEST.in
5+
Makefile
6+
README.rst
7+
run-tests.py
8+
setup.cfg
9+
setup.py
10+
Jinja2.egg-info/PKG-INFO
11+
Jinja2.egg-info/SOURCES.txt
12+
Jinja2.egg-info/dependency_links.txt
13+
Jinja2.egg-info/entry_points.txt
14+
Jinja2.egg-info/not-zip-safe
15+
Jinja2.egg-info/requires.txt
16+
Jinja2.egg-info/top_level.txt
17+
artwork/jinjalogo.svg
18+
docs/Makefile
19+
docs/api.rst
20+
docs/cache_extension.py
21+
docs/changelog.rst
22+
docs/conf.py
23+
docs/contents.rst.inc
24+
docs/extensions.rst
25+
docs/faq.rst
26+
docs/index.rst
27+
docs/integration.rst
28+
docs/intro.rst
29+
docs/jinjaext.py
30+
docs/jinjastyle.sty
31+
docs/latexindex.rst
32+
docs/logo.pdf
33+
docs/sandbox.rst
34+
docs/switching.rst
35+
docs/templates.rst
36+
docs/tricks.rst
37+
docs/_static/.ignore
38+
docs/_static/jinja-small.png
39+
docs/_templates/sidebarintro.html
40+
docs/_templates/sidebarlogo.html
41+
docs/_themes/LICENSE
42+
docs/_themes/README
43+
docs/_themes/jinja/layout.html
44+
docs/_themes/jinja/relations.html
45+
docs/_themes/jinja/theme.conf
46+
docs/_themes/jinja/static/jinja.css_t
47+
examples/bench.py
48+
examples/profile.py
49+
examples/basic/cycle.py
50+
examples/basic/debugger.py
51+
examples/basic/inheritance.py
52+
examples/basic/test.py
53+
examples/basic/test_filter_and_linestatements.py
54+
examples/basic/test_loop_filter.py
55+
examples/basic/translate.py
56+
examples/basic/templates/broken.html
57+
examples/basic/templates/subbroken.html
58+
examples/rwbench/djangoext.py
59+
examples/rwbench/rwbench.py
60+
examples/rwbench/django/_form.html
61+
examples/rwbench/django/_input_field.html
62+
examples/rwbench/django/_textarea.html
63+
examples/rwbench/django/index.html
64+
examples/rwbench/django/layout.html
65+
examples/rwbench/genshi/helpers.html
66+
examples/rwbench/genshi/index.html
67+
examples/rwbench/genshi/layout.html
68+
examples/rwbench/jinja/helpers.html
69+
examples/rwbench/jinja/index.html
70+
examples/rwbench/jinja/layout.html
71+
examples/rwbench/mako/helpers.html
72+
examples/rwbench/mako/index.html
73+
examples/rwbench/mako/layout.html
74+
ext/djangojinja2.py
75+
ext/inlinegettext.py
76+
ext/jinja.el
77+
ext/Vim/jinja.vim
78+
ext/django2jinja/django2jinja.py
79+
ext/django2jinja/example.py
80+
ext/django2jinja/templates/index.html
81+
ext/django2jinja/templates/layout.html
82+
ext/django2jinja/templates/subtemplate.html
83+
jinja2/__init__.py
84+
jinja2/_compat.py
85+
jinja2/_stringdefs.py
86+
jinja2/bccache.py
87+
jinja2/compiler.py
88+
jinja2/constants.py
89+
jinja2/debug.py
90+
jinja2/defaults.py
91+
jinja2/environment.py
92+
jinja2/exceptions.py
93+
jinja2/ext.py
94+
jinja2/filters.py
95+
jinja2/lexer.py
96+
jinja2/loaders.py
97+
jinja2/meta.py
98+
jinja2/nodes.py
99+
jinja2/optimizer.py
100+
jinja2/parser.py
101+
jinja2/runtime.py
102+
jinja2/sandbox.py
103+
jinja2/tests.py
104+
jinja2/utils.py
105+
jinja2/visitor.py
106+
jinja2/testsuite/__init__.py
107+
jinja2/testsuite/api.py
108+
jinja2/testsuite/bytecode_cache.py
109+
jinja2/testsuite/core_tags.py
110+
jinja2/testsuite/debug.py
111+
jinja2/testsuite/doctests.py
112+
jinja2/testsuite/ext.py
113+
jinja2/testsuite/filters.py
114+
jinja2/testsuite/imports.py
115+
jinja2/testsuite/inheritance.py
116+
jinja2/testsuite/lexnparse.py
117+
jinja2/testsuite/loader.py
118+
jinja2/testsuite/regression.py
119+
jinja2/testsuite/security.py
120+
jinja2/testsuite/tests.py
121+
jinja2/testsuite/utils.py
122+
jinja2/testsuite/res/__init__.py
123+
jinja2/testsuite/res/templates/broken.html
124+
jinja2/testsuite/res/templates/syntaxerror.html
125+
jinja2/testsuite/res/templates/test.html
126+
jinja2/testsuite/res/templates/foo/test.html
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
[babel.extractors]
3+
jinja2 = jinja2.ext:babel_extract[i18n]
4+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
markupsafe
2+
3+
[i18n]
4+
Babel>=0.8
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
jinja2
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
jinja2
4+
~~~~~~
5+
6+
Jinja2 is a template engine written in pure Python. It provides a
7+
Django inspired non-XML syntax but supports inline expressions and
8+
an optional sandboxed environment.
9+
10+
Nutshell
11+
--------
12+
13+
Here a small example of a Jinja2 template::
14+
15+
{% extends 'base.html' %}
16+
{% block title %}Memberlist{% endblock %}
17+
{% block content %}
18+
<ul>
19+
{% for user in users %}
20+
<li><a href="{{ user.url }}">{{ user.username }}</a></li>
21+
{% endfor %}
22+
</ul>
23+
{% endblock %}
24+
25+
26+
:copyright: (c) 2010 by the Jinja Team.
27+
:license: BSD, see LICENSE for more details.
28+
"""
29+
__docformat__ = 'restructuredtext en'
30+
__version__ = '2.7.2'
31+
32+
# high level interface
33+
from jinja2.environment import Environment, Template
34+
35+
# loaders
36+
from jinja2.loaders import BaseLoader, FileSystemLoader, PackageLoader, \
37+
DictLoader, FunctionLoader, PrefixLoader, ChoiceLoader, \
38+
ModuleLoader
39+
40+
# bytecode caches
41+
from jinja2.bccache import BytecodeCache, FileSystemBytecodeCache, \
42+
MemcachedBytecodeCache
43+
44+
# undefined types
45+
from jinja2.runtime import Undefined, DebugUndefined, StrictUndefined
46+
47+
# exceptions
48+
from jinja2.exceptions import TemplateError, UndefinedError, \
49+
TemplateNotFound, TemplatesNotFound, TemplateSyntaxError, \
50+
TemplateAssertionError
51+
52+
# decorators and public utilities
53+
from jinja2.filters import environmentfilter, contextfilter, \
54+
evalcontextfilter
55+
from jinja2.utils import Markup, escape, clear_caches, \
56+
environmentfunction, evalcontextfunction, contextfunction, \
57+
is_undefined
58+
59+
__all__ = [
60+
'Environment', 'Template', 'BaseLoader', 'FileSystemLoader',
61+
'PackageLoader', 'DictLoader', 'FunctionLoader', 'PrefixLoader',
62+
'ChoiceLoader', 'BytecodeCache', 'FileSystemBytecodeCache',
63+
'MemcachedBytecodeCache', 'Undefined', 'DebugUndefined',
64+
'StrictUndefined', 'TemplateError', 'UndefinedError', 'TemplateNotFound',
65+
'TemplatesNotFound', 'TemplateSyntaxError', 'TemplateAssertionError',
66+
'ModuleLoader', 'environmentfilter', 'contextfilter', 'Markup', 'escape',
67+
'environmentfunction', 'contextfunction', 'clear_caches', 'is_undefined',
68+
'evalcontextfilter', 'evalcontextfunction'
69+
]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)