##// END OF EJS Templates
store: treat range as a generator instead of a list for py3 compat
timeless -
r29071:2f58975e default
parent child Browse files
Show More
@@ -57,6 +57,23 b' def decodedir(path):'
57 .replace(".i.hg/", ".i/")
57 .replace(".i.hg/", ".i/")
58 .replace(".hg.hg/", ".hg/"))
58 .replace(".hg.hg/", ".hg/"))
59
59
60 def _reserved():
61 ''' characters that are problematic for filesystems
62
63 * ascii escapes (0..31)
64 * ascii hi (126..255)
65 * windows specials
66
67 these characters will be escaped by encodefunctions
68 '''
69 winreserved = [ord(x) for x in '\\:*?"<>|']
70 for x in range(32):
71 yield x
72 for x in range(126, 256):
73 yield x
74 for x in winreserved:
75 yield x
76
60 def _buildencodefun():
77 def _buildencodefun():
61 '''
78 '''
62 >>> enc, dec = _buildencodefun()
79 >>> enc, dec = _buildencodefun()
@@ -82,11 +99,10 b' def _buildencodefun():'
82 'the\\x07quick\\xadshot'
99 'the\\x07quick\\xadshot'
83 '''
100 '''
84 e = '_'
101 e = '_'
85 winreserved = [ord(x) for x in '\\:*?"<>|']
86 cmap = dict([(chr(x), chr(x)) for x in xrange(127)])
102 cmap = dict([(chr(x), chr(x)) for x in xrange(127)])
87 for x in (range(32) + range(126, 256) + winreserved):
103 for x in _reserved():
88 cmap[chr(x)] = "~%02x" % x
104 cmap[chr(x)] = "~%02x" % x
89 for x in range(ord("A"), ord("Z") + 1) + [ord(e)]:
105 for x in list(range(ord("A"), ord("Z") + 1)) + [ord(e)]:
90 cmap[chr(x)] = e + chr(x).lower()
106 cmap[chr(x)] = e + chr(x).lower()
91 dmap = {}
107 dmap = {}
92 for k, v in cmap.iteritems():
108 for k, v in cmap.iteritems():
@@ -134,9 +150,8 b' def _buildlowerencodefun():'
134 >>> f('the\x07quick\xADshot')
150 >>> f('the\x07quick\xADshot')
135 'the~07quick~adshot'
151 'the~07quick~adshot'
136 '''
152 '''
137 winreserved = [ord(x) for x in '\\:*?"<>|']
138 cmap = dict([(chr(x), chr(x)) for x in xrange(127)])
153 cmap = dict([(chr(x), chr(x)) for x in xrange(127)])
139 for x in (range(32) + range(126, 256) + winreserved):
154 for x in _reserved():
140 cmap[chr(x)] = "~%02x" % x
155 cmap[chr(x)] = "~%02x" % x
141 for x in range(ord("A"), ord("Z") + 1):
156 for x in range(ord("A"), ord("Z") + 1):
142 cmap[chr(x)] = chr(x).lower()
157 cmap[chr(x)] = chr(x).lower()
General Comments 0
You need to be logged in to leave comments. Login now