27 lines
584 B
Python
27 lines
584 B
Python
"""Compatibility with Python 2 (taken from 'django.utils.six')"""
|
|
import sys
|
|
|
|
PY2 = sys.version_info[0] == 2
|
|
PY3 = sys.version_info[0] == 3
|
|
|
|
|
|
if PY3:
|
|
string_types = (str,)
|
|
integer_types = (int,)
|
|
class_types = (type,)
|
|
text_type = str
|
|
binary_type = bytes
|
|
|
|
MAXSIZE = sys.maxsize
|
|
else:
|
|
string_types = (basestring,)
|
|
integer_types = (int, long)
|
|
|
|
|
|
def with_metaclass(meta, *bases):
|
|
class metaclass(type):
|
|
def __new__(cls, name, this_bases, d):
|
|
return meta(name, bases, d)
|
|
|
|
return type.__new__(metaclass, "temporary_class", (), {})
|