Show More
@@ -57,6 +57,23 def decodedir(path): | |||
|
57 | 57 | .replace(".i.hg/", ".i/") |
|
58 | 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 | 77 | def _buildencodefun(): |
|
61 | 78 | ''' |
|
62 | 79 | >>> enc, dec = _buildencodefun() |
@@ -82,11 +99,10 def _buildencodefun(): | |||
|
82 | 99 | 'the\\x07quick\\xadshot' |
|
83 | 100 | ''' |
|
84 | 101 | e = '_' |
|
85 | winreserved = [ord(x) for x in '\\:*?"<>|'] | |
|
86 | 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 | 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 | 106 | cmap[chr(x)] = e + chr(x).lower() |
|
91 | 107 | dmap = {} |
|
92 | 108 | for k, v in cmap.iteritems(): |
@@ -134,9 +150,8 def _buildlowerencodefun(): | |||
|
134 | 150 | >>> f('the\x07quick\xADshot') |
|
135 | 151 | 'the~07quick~adshot' |
|
136 | 152 | ''' |
|
137 | winreserved = [ord(x) for x in '\\:*?"<>|'] | |
|
138 | 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 | 155 | cmap[chr(x)] = "~%02x" % x |
|
141 | 156 | for x in range(ord("A"), ord("Z") + 1): |
|
142 | 157 | cmap[chr(x)] = chr(x).lower() |
General Comments 0
You need to be logged in to leave comments.
Login now