Skip to content
Myr

More work on the ironpython support

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

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent 833a3b5 · Browse files · 3 files+49 added−8 removed
This commit

State

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

Diff stats

3 files+49 added−8 removed

  • other:+49 added−8 removed

3 files+49 added−8 removed

added:jinja2/_ipysupport.py+40 added
1# -*- coding: utf-8 -*-2"""3 jinja2._ipysupport4 ~~~~~~~~~~~~~~~~~~56 IronPython support library. This library exports functionality from7 the CLR to Python that is normally available in the standard library.89 :copyright: Copyright 2008 by Armin Ronacher.10 :license: BSD.11"""12from System import DateTime13from System.IO import Path, File, FileInfo141516epoch = DateTime(1970, 1, 1)171819class _PathModule(object):20 """A minimal path module."""2122 sep = str(Path.DirectorySeparatorChar)23 altsep = str(Path.AltDirectorySeparatorChar)24 pardir = '..'2526 def join(self, path, *args):27 args = list(args[::-1])28 while args:29 path = Path.Combine(path, args.pop())30 return path3132 def isfile(self, filename):33 return File.Exists(filename)3435 def getmtime(self, filename):36 info = FileInfo(filename)37 return int((info.LastAccessTimeUtc - epoch).TotalSeconds)383940path = _PathModule()
modified:jinja2/loaders.py+5 added-1 removed
6 unmodified lines
78 :copyright: 2008 by Armin Ronacher.9 :license: BSD, see LICENSE for more details.10"""11from os import path11try:12 from os import path13except ImportError:14 # support for iron python without standard library15 from _ipysupport import path16try:17 from hashlib import sha118except ImportError:19 from sha import new as sha120from jinja2.exceptions import TemplateNotFound
260 unmodified lines
modified:jinja2/runtime.py+4 added-7 removed
8 unmodified lines
9 :license: BSD.10"""11import sys12from itertools import chain, imap13from jinja2.utils import Markup, partial, soft_unicode, escape, missing, concat13from jinja2.utils import Markup, partial, soft_unicode, escape, missing, \14 concat, MethodType, FunctionType15from jinja2.exceptions import UndefinedError, TemplateRuntimeError161718# these variables are exported to the template runtime
1 unmodified line
20 'TemplateRuntimeError', 'missing', 'concat', 'escape',21 'markup_join', 'unicode_join']222323#: get the types we support for context functions. We do not use types because24#: IronPython doesn't provide that module out of the box.25class _C(object):26 meth = lambda: None27_context_function_types = (type(lambda: None), type(_C.meth))28del _C24#: the types we support for context functions25_context_function_types = (FunctionType, MethodType)262728def markup_join(seq):29 """Concatenation that escapes if necessary and converts to unicode."""
432 unmodified lines