blob: edc61c3b2ad79c44fd67187a8d2f77079aee468e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
compatibility.py
~~~~~~~~~~~~~~~~
utilities for py2 compatibility
:copyright: (c) 2013 by Jauhien Piatlicki
:license: GPL-2, see LICENSE for more details.
"""
import shutil, sys
py2k = sys.version_info < (3, 0)
if py2k:
from tempfile import mkdtemp
import ConfigParser as configparser
class TemporaryDirectory(object):
def __init__(self):
self.name = mkdtemp()
def __del__(self):
shutil.rmtree(self.name)
else:
from tempfile import TemporaryDirectory
import configparser
#basestring removed in py3k
#fix for it from https://github.com/oxplot/fysom/issues/1
if py2k:
str = str
unicode = unicode
bytes = str
basestring = basestring
else:
str = str
unicode = str
bytes = bytes
basestring = (str, bytes)
|