~ubuntu-branches/ubuntu/trusty/python-babel/trusty

« back to all changes in this revision

Viewing changes to babel/_compat.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-10-28 10:11:31 UTC
  • mfrom: (4.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20131028101131-zwbmm8sc29iemmlr
Tags: 1.3-2ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - debian/rules: Run the testsuite during builds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import sys
 
2
 
 
3
PY2 = sys.version_info[0] == 2
 
4
 
 
5
_identity = lambda x: x
 
6
 
 
7
 
 
8
if not PY2:
 
9
    text_type = str
 
10
    string_types = (str,)
 
11
    integer_types = (int, )
 
12
    unichr = chr
 
13
 
 
14
    text_to_native = lambda s, enc: s
 
15
 
 
16
    iterkeys = lambda d: iter(d.keys())
 
17
    itervalues = lambda d: iter(d.values())
 
18
    iteritems = lambda d: iter(d.items())
 
19
 
 
20
    from io import StringIO, BytesIO
 
21
    import pickle
 
22
 
 
23
    izip = zip
 
24
    imap = map
 
25
    range_type = range
 
26
 
 
27
    cmp = lambda a, b: (a > b) - (a < b)
 
28
 
 
29
else:
 
30
    text_type = unicode
 
31
    string_types = (str, unicode)
 
32
    integer_types = (int, long)
 
33
 
 
34
    text_to_native = lambda s, enc: s.encode(enc)
 
35
    unichr = unichr
 
36
 
 
37
    iterkeys = lambda d: d.iterkeys()
 
38
    itervalues = lambda d: d.itervalues()
 
39
    iteritems = lambda d: d.iteritems()
 
40
 
 
41
    from cStringIO import StringIO as BytesIO
 
42
    from StringIO import StringIO
 
43
    import cPickle as pickle
 
44
 
 
45
    from itertools import izip, imap
 
46
    range_type = xrange
 
47
 
 
48
    cmp = cmp
 
49
 
 
50
 
 
51
number_types = integer_types + (float,)