Propably delaying release for better python 3 support. Started working on
Before adoption: this commit came in with the history the project adopted, so no landing records it.
that. --HG-- branch : trunk
authored by Armin Ronacher · committed by Armin Ronacher · parent 0319c66 · Browse files · 10 files·+45 added−62 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
10 files+45 added−62 removed
- other:+45 added−62 removed
Provenance
- Commit
0faa861- Tree
4bea11c- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
0319c66
10 files changed+45 added−62 removed
added:custom_fixers/__init__.py
added:custom_fixers/fix_alt_unicode.py+24 added
1+from lib2to3 import fixer_base2+from lib2to3.fixer_util import Name, BlankLine3+4+5+class FixAltUnicode(fixer_base.BaseFix):6+ PATTERN = """7+ func=funcdef< 'def' name=NAME8+ parameters< '(' NAME ')' > any+ >9+ """10+11+ run_order = 512+13+ def transform(self, node, results):14+ name = results['name']15+16+ # rename __unicode__ to __str__17+ if name.value == '__unicode__':18+ name.replace(Name('__str__', prefix=name.prefix))19+20+ # get rid of other __str__'s21+ elif name.value == '__str__':22+ next = BlankLine()23+ next.prefix = results['func'].prefix24+ return nextdeleted:jinja2/_ipysupport.py-40 removed
1-# -*- coding: utf-8 -*-2-"""3- jinja2._ipysupport4- ~~~~~~~~~~~~~~~~~~5-6- IronPython support library. This library exports functionality from7- the CLR to Python that is normally available in the standard library.8-9- :copyright: (c) 2010 by the Jinja Team.10- :license: BSD.11-"""12-from System import DateTime13-from System.IO import Path, File, FileInfo14-15-16-epoch = DateTime(1970, 1, 1)17-18-19-class _PathModule(object):20- """A minimal path module."""21-22- sep = str(Path.DirectorySeparatorChar)23- altsep = str(Path.AltDirectorySeparatorChar)24- pardir = '..'25-26- def join(self, path, *args):27- args = list(args[::-1])28- while args:29- path = Path.Combine(path, args.pop())30- return path31-32- def isfile(self, filename):33- return File.Exists(filename)34-35- def getmtime(self, filename):36- info = FileInfo(filename)37- return int((info.LastAccessTimeUtc - epoch).TotalSeconds)38-39-40-path = _PathModule()modified:jinja2/bccache.py+3 added-3 removed
106 unmodified lines107 108 def load_bytecode(self, bucket):109 filename = path.join(self.directory, bucket.key)110 if path.exists(filename):111- with file(filename, 'rb') as f:111+ with open(filename, 'rb') as f:112 bucket.load_bytecode(f)113 114 def dump_bytecode(self, bucket):115 filename = path.join(self.directory, bucket.key)116- with file(filename, 'wb') as f:116+ with open(filename, 'wb') as f:117 bucket.write_bytecode(f)118 119 A more advanced version of a filesystem based bytecode cache is part of120 Jinja2.80 unmodified lines201 finally:202 f.close()203 204 def dump_bytecode(self, bucket):205- f = file(self._get_cache_filename(bucket), 'wb')205+ f = open(self._get_cache_filename(bucket), 'wb')206 try:207 bucket.write_bytecode(f)208 finally:209 f.close()71 unmodified linesmodified:jinja2/environment.py+5 added-2 removed
806 unmodified lines807 self._body_stream = list(template.root_render_func(context))808 self.__dict__.update(context.get_exported())809 self.__name__ = template.name810 811- __unicode__ = lambda x: concat(x._body_stream)812- __html__ = lambda x: Markup(concat(x._body_stream))811+ def __unicode__(self):812+ return concat(self._body_stream)813 814+ def __html__(self):815+ return Markup(concat(self._body_stream))816+817 def __str__(self):818 return unicode(self).encode('utf-8')819 820 def __repr__(self):110 unmodified linesmodified:jinja2/runtime.py+2 added-2 removed
515 unmodified lines516 ...517 UndefinedError: 'foo' is undefined518 """519 __slots__ = ()520- __iter__ = __unicode__ = __len__ = __nonzero__ = __eq__ = __ne__ = \521- Undefined._fail_with_undefined_error520+ __iter__ = __unicode__ = __str__ = __len__ = __nonzero__ = __eq__ = \521+ __ne__ = Undefined._fail_with_undefined_error522 523 524 # remove remaining slots attributes, after the metaclass did the magic they525 # are unneeded and irritating as they contain wrong data for the subclasses.1 unmodified linemodified:jinja2/utils.py+1 added-1 removed
196 unmodified lines197 if not silent:198 raise199 200 201-def open_if_exists(filename, mode='r'):201+def open_if_exists(filename, mode='rb'):202 """Returns a file descriptor for the filename if that file exists,203 otherwise `None`.204 """205 try:579 unmodified linesmodified:.hgignore-1 removed
5 unmodified lines6 \.py[cod]$7 \$py\.class$8 \.DS_Store$9 ^j?env/10-^py3k/modified:Makefile+2 added-6 removed
1 test:2 nosetests --with-doctest jinja2 tests3 4 2to3:5- rm -rf py3k6- mkdir py3k7- cp -R jinja2 py3k8- cp -R tests py3k9- 2to3 jinja2 tests > py3k/convert.patch10- cd py3k; patch -p0 < convert.patch5+ rm -rf build/lib6+ python3 setup.py build7 8 .PHONY: testmodified:setup.py+8 added-7 removed
41 unmodified lines42 import os43 import sys44 45 from setuptools import setup, Extension, Feature46-from distutils.command.build_ext import build_ext47-from distutils.errors import CCompilerError, DistutilsPlatformError46 49-try:50- from distutils.command.build_py import build_py_2to3 as build_py51-except ImportError:52- from distutils.command.build_py import build_py47+# tell distribute to use 2to3 with our own fixers.48+extra = {}49+if sys.version_info >= (3, 0):50+ extra.update(51+ use_2to3=True,52+ use_2to3_fixers=['custom_fixers']53+ )54 55 56 setup(57 name='Jinja2',31 unmodified lines89 entry_points="""90 [babel.extractors]91 jinja2 = jinja2.ext:babel_extract[i18n]92 """,92- cmdclass=dict(build_py=build_py)93+ **extra94 )