Skip to content

Commit

Permalink
Update _compat to latest.
Browse files Browse the repository at this point in the history
  • Loading branch information
tony committed Feb 5, 2014
1 parent 989a494 commit 0cc917b
Showing 1 changed file with 35 additions and 32 deletions.
67 changes: 35 additions & 32 deletions vcspull/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,43 @@
_identity = lambda x: x


if not PY2:
if PY2:
unichr = unichr
text_type = unicode
string_types = (str, unicode)
integer_types = (int, long)
from urllib import urlretrieve

text_to_native = lambda s, enc: s.encode(enc)

iterkeys = lambda d: d.iterkeys()
itervalues = lambda d: d.itervalues()
iteritems = lambda d: d.iteritems()

from cStringIO import StringIO as BytesIO
from StringIO import StringIO
import cPickle as pickle
import ConfigParser as configparser

from itertools import izip, imap
range_type = xrange

cmp = cmp

input = raw_input
from string import lower as ascii_lowercase
import urlparse

def console_to_str(s):
return s.decode('utf_8')

exec('def reraise(tp, value, tb=None):\n raise tp, value, tb')

else:
unichr = chr
text_type = str
string_types = (str,)
integer_types = (int, )
unichr = chr

text_to_native = lambda s, enc: s

Expand All @@ -31,8 +63,7 @@
from string import ascii_lowercase
import urllib.parse as urllib
import urllib.parse as urlparse

exec('def reraise(tp, value, tb=None):\n raise(tp, value, tb)')
from urllib.request import urlretrieve

console_encoding = sys.__stdout__.encoding

Expand All @@ -42,34 +73,6 @@ def console_to_str(s):
return s.decode(console_encoding)
except UnicodeDecodeError:
return s.decode('utf_8')
else:
text_type = unicode
string_types = (str, unicode)
integer_types = (int, long)

text_to_native = lambda s, enc: s.encode(enc)
unichr = unichr

iterkeys = lambda d: d.iterkeys()
itervalues = lambda d: d.itervalues()
iteritems = lambda d: d.iteritems()

from cStringIO import StringIO as BytesIO
from StringIO import StringIO
import cPickle as pickle
import ConfigParser as configparser

from itertools import izip, imap
range_type = xrange

cmp = cmp

input = raw_input
from string import lower as ascii_lowercase
import urlparse

def console_to_str(s):
return s.decode('utf_8')

def reraise(tp, value, tb=None):
if value.__traceback__ is not tb:
Expand Down

0 comments on commit 0cc917b

Please sign in to comment.