--- /dev/null
+# -*- coding: utf-8 -*-
+"""
+ jinja2._ipysupport
+ ~~~~~~~~~~~~~~~~~~
+
+ IronPython support library. This library exports functionality from
+ the CLR to Python that is normally available in the standard library.
+
+ :copyright: Copyright 2008 by Armin Ronacher.
+ :license: BSD.
+"""
+from System import DateTime
+from System.IO import Path, File, FileInfo
+
+
+epoch = DateTime(1970, 1, 1)
+
+
+class _PathModule(object):
+ """A minimal path module."""
+
+ sep = str(Path.DirectorySeparatorChar)
+ altsep = str(Path.AltDirectorySeparatorChar)
+ pardir = '..'
+
+ def join(self, path, *args):
+ args = list(args[::-1])
+ while args:
+ path = Path.Combine(path, args.pop())
+ return path
+
+ def isfile(self, filename):
+ return File.Exists(filename)
+
+ def getmtime(self, filename):
+ info = FileInfo(filename)
+ return int((info.LastAccessTimeUtc - epoch).TotalSeconds)
+
+
+path = _PathModule()
:copyright: 2008 by Armin Ronacher.
:license: BSD, see LICENSE for more details.
"""
-from os import path
+try:
+ from os import path
+except ImportError:
+ # support for iron python without standard library
+ from _ipysupport import path
try:
from hashlib import sha1
except ImportError:
"""
import sys
from itertools import chain, imap
-from jinja2.utils import Markup, partial, soft_unicode, escape, missing, concat
+from jinja2.utils import Markup, partial, soft_unicode, escape, missing, \
+ concat, MethodType, FunctionType
from jinja2.exceptions import UndefinedError, TemplateRuntimeError
'markup_join', 'unicode_join']
-#: get the types we support for context functions. We do not use types because
-#: IronPython doesn't provide that module out of the box.
-class _C(object):
- meth = lambda: None
-_context_function_types = (type(lambda: None), type(_C.meth))
-del _C
+#: the types we support for context functions
+_context_function_types = (FunctionType, MethodType)
def markup_join(seq):