Armin Ronacher | ce67710 | 2008-08-17 19:43:22 +0200 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | """ |
| 3 | jinja2._ipysupport |
| 4 | ~~~~~~~~~~~~~~~~~~ |
| 5 | |
| 6 | IronPython support library. This library exports functionality from |
| 7 | the CLR to Python that is normally available in the standard library. |
| 8 | |
| 9 | :copyright: Copyright 2008 by Armin Ronacher. |
| 10 | :license: BSD. |
| 11 | """ |
| 12 | from System import DateTime |
| 13 | from System.IO import Path, File, FileInfo |
| 14 | |
| 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 path |
| 31 | |
| 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() |