Coverage for mt940/_compat.py: 0%
4 statements
« prev ^ index » next coverage.py v7.6.0, created at 2025-02-23 05:07 +0000
« prev ^ index » next coverage.py v7.6.0, created at 2025-02-23 05:07 +0000
1import sys
3PY2 = sys.version_info[0] == 2
6def _identity(x): # pragma: no cover
7 return x
10__all__ = [
11 'BytesIO',
12 'PY2',
13 'StringIO',
14 'ascii_lowercase',
15 'cmp',
16 'configparser',
17 'console_to_str',
18 'imap',
19 'input',
20 'integer_types',
21 'iteritems',
22 'iterkeys',
23 'itervalues',
24 'izip',
25 'number_types',
26 'pickle',
27 'range_type',
28 'reraise',
29 'string_types',
30 'text_to_native',
31 'text_type',
32 'unichr',
33 'urllib',
34 'urlparse',
35 'urlparse',
36 'urlretrieve',
37 '_identity',
38]
40if PY2: # pragma: no cover
41 unichr = unichr
42 text_type = unicode
43 string_types = (str, unicode)
44 integer_types = (int, long)
45 from urllib import urlretrieve
47 def text_to_native(s, enc):
48 return s.encode(enc)
50 def iterkeys(d):
51 return d.iterkeys()
53 def itervalues(d):
54 return d.itervalues()
56 def iteritems(d):
57 return d.iteritems()
59 from cStringIO import StringIO as BytesIO
60 from StringIO import StringIO
61 import cPickle as pickle
62 import ConfigParser as configparser
64 from itertools import izip, imap
65 range_type = xrange
67 cmp = cmp
69 input = raw_input
70 from string import lower as ascii_lowercase
71 import urlparse
73 def console_to_str(s):
74 return s.decode('utf_8')
76 exec('def reraise(tp, value, tb=None):\n raise tp, value, tb')
78else: # pragma: no cover
79 unichr = chr
80 text_type = str
81 string_types = (str, )
82 integer_types = (int, )
84 def text_to_native(s, enc):
85 return s
87 def iterkeys(d):
88 return iter(d.keys())
90 def itervalues(d):
91 return iter(d.values())
93 def iteritems(d):
94 return iter(d.items())
96 from io import StringIO
97 from io import BytesIO
98 import pickle
99 import configparser
101 izip = zip
102 imap = map
103 range_type = range
105 def cmp(a, b):
106 return (a > b) - (a < b)
108 input = input
109 from string import ascii_lowercase
110 import urllib.parse as urllib
111 import urllib.parse as urlparse
112 from urllib.request import urlretrieve
114 if getattr(sys, '__stdout__', None):
115 console_encoding = sys.__stdout__.encoding
116 else:
117 console_encoding = sys.stdout.encoding
119 def console_to_str(s):
120 ''' From pypa/pip project, pip.backwardwardcompat. License MIT. '''
121 try:
122 return s.decode(console_encoding)
123 except UnicodeDecodeError:
124 return s.decode('utf_8')
126 def reraise(tp, value, tb=None):
127 if value.__traceback__ is not tb:
128 raise (value.with_traceback(tb))
129 raise value
132number_types = integer_types + (float, )