_compat.py
Go to the documentation of this file.
00001 """Internal module for Python 2 backwards compatibility."""
00002 import sys
00003 
00004 
00005 if sys.version_info[0] < 3:
00006     from urlparse import urlparse
00007     from itertools import imap, izip
00008     from string import letters as ascii_letters
00009     try:
00010         from cStringIO import StringIO as BytesIO
00011     except ImportError:
00012         from StringIO import StringIO as BytesIO
00013 
00014     iteritems = lambda x: x.iteritems()
00015     dictkeys = lambda x: x.keys()
00016     dictvalues = lambda x: x.values()
00017     nativestr = lambda x: \
00018         x if isinstance(x, str) else x.encode('utf-8', 'replace')
00019     u = lambda x: x.decode()
00020     b = lambda x: x
00021     next = lambda x: x.next()
00022     byte_to_chr = lambda x: x
00023     unichr = unichr
00024     xrange = xrange
00025     basestring = basestring
00026     unicode = unicode
00027     bytes = str
00028     long = long
00029 else:
00030     from urllib.parse import urlparse
00031     from io import BytesIO
00032     from string import ascii_letters
00033 
00034     iteritems = lambda x: x.items()
00035     dictkeys = lambda x: list(x.keys())
00036     dictvalues = lambda x: list(x.values())
00037     byte_to_chr = lambda x: chr(x)
00038     nativestr = lambda x: \
00039         x if isinstance(x, str) else x.decode('utf-8', 'replace')
00040     u = lambda x: x
00041     b = lambda x: x.encode('iso-8859-1')
00042     next = next
00043     unichr = chr
00044     imap = map
00045     izip = zip
00046     xrange = range
00047     basestring = str
00048     unicode = str
00049     bytes = bytes
00050     long = int


rocon_python_redis
Author(s): Andy McCurdy
autogenerated on Fri May 2 2014 10:35:49