OLD | NEW |
(Empty) | |
| 1 import sys |
| 2 |
| 3 py2k = sys.version_info < (3, 0) |
| 4 py3k = sys.version_info >= (3, 0) |
| 5 py32 = sys.version_info >= (3, 2) |
| 6 py27 = sys.version_info >= (2, 7) |
| 7 jython = sys.platform.startswith('java') |
| 8 win32 = sys.platform.startswith('win') |
| 9 |
| 10 try: |
| 11 import threading |
| 12 except ImportError: |
| 13 import dummy_threading as threading # noqa |
| 14 |
| 15 |
| 16 if py3k: # pragma: no cover |
| 17 string_types = str, |
| 18 text_type = str |
| 19 string_type = str |
| 20 |
| 21 if py32: |
| 22 callable = callable |
| 23 else: |
| 24 def callable(fn): |
| 25 return hasattr(fn, '__call__') |
| 26 |
| 27 def u(s): |
| 28 return s |
| 29 |
| 30 def ue(s): |
| 31 return s |
| 32 |
| 33 import configparser |
| 34 import io |
| 35 import _thread as thread |
| 36 else: |
| 37 string_types = basestring, |
| 38 text_type = unicode |
| 39 string_type = str |
| 40 |
| 41 def u(s): |
| 42 return unicode(s, "utf-8") |
| 43 |
| 44 def ue(s): |
| 45 return unicode(s, "unicode_escape") |
| 46 |
| 47 import ConfigParser as configparser # noqa |
| 48 import StringIO as io # noqa |
| 49 |
| 50 callable = callable # noqa |
| 51 import thread # noqa |
| 52 |
| 53 |
| 54 if py3k or jython: |
| 55 import pickle |
| 56 else: |
| 57 import cPickle as pickle # noqa |
| 58 |
| 59 |
| 60 def timedelta_total_seconds(td): |
| 61 if py27: |
| 62 return td.total_seconds() |
| 63 else: |
| 64 return (td.microseconds + ( |
| 65 td.seconds + td.days * 24 * 3600) * 1e6) / 1e6 |
OLD | NEW |