##// END OF EJS Templates
store: parameter path of _auxencode is now a list of strings
Adrian Buehlmann -
r17589:b1102484 default
parent child Browse files
Show More
@@ -130,22 +130,23 b' def _auxencode(path, dotencode):'
130 130 basename (e.g. "aux", "aux.foo"). A directory or file named "foo.aux"
131 131 doesn't need encoding.
132 132
133 >>> _auxencode('.foo/aux.txt/txt.aux/con/prn/nul/foo.', True)
133 >>> s = '.foo/aux.txt/txt.aux/con/prn/nul/foo.'
134 >>> _auxencode(s.split('/'), True)
134 135 ['~2efoo', 'au~78.txt', 'txt.aux', 'co~6e', 'pr~6e', 'nu~6c', 'foo~2e']
135 >>> _auxencode('.com1com2/lpt9.lpt4.lpt1/conprn/com0/lpt0/foo.', False)
136 >>> s = '.com1com2/lpt9.lpt4.lpt1/conprn/com0/lpt0/foo.'
137 >>> _auxencode(s.split('/'), False)
136 138 ['.com1com2', 'lp~749.lpt4.lpt1', 'conprn', 'com0', 'lpt0', 'foo~2e']
137 >>> _auxencode('foo. ', True)
139 >>> _auxencode(['foo. '], True)
138 140 ['foo.~20']
139 >>> _auxencode(' .foo', True)
141 >>> _auxencode([' .foo'], True)
140 142 ['~20.foo']
141 143 '''
142 res = path.split('/')
143 for i, n in enumerate(res):
144 for i, n in enumerate(path):
144 145 if not n:
145 146 continue
146 147 if dotencode and n[0] in '. ':
147 148 n = "~%02x" % ord(n[0]) + n[1:]
148 res[i] = n
149 path[i] = n
149 150 else:
150 151 l = n.find('.')
151 152 if l == -1:
@@ -156,11 +157,11 b' def _auxencode(path, dotencode):'
156 157 # encode third letter ('aux' -> 'au~78')
157 158 ec = "~%02x" % ord(n[2])
158 159 n = n[0:2] + ec + n[3:]
159 res[i] = n
160 path[i] = n
160 161 if n[-1] in '. ':
161 162 # encode last period or space ('foo...' -> 'foo..~2e')
162 res[i] = n[:-1] + "~%02x" % ord(n[-1])
163 return res
163 path[i] = n[:-1] + "~%02x" % ord(n[-1])
164 return path
164 165
165 166 _maxstorepathlen = 120
166 167 _dirprefixlen = 8
@@ -196,11 +197,11 b' def _hybridencode(path, auxencode):'
196 197 The string 'data/' at the beginning is replaced with 'dh/', if the hashed
197 198 encoding was used.
198 199 '''
199 res = '/'.join(auxencode(encodefilename(path)))
200 res = '/'.join(auxencode(encodefilename(path).split('/')))
200 201 if len(res) > _maxstorepathlen:
201 202 path = encodedir(path)
202 203 digest = _sha(path).hexdigest()
203 parts = auxencode(lowerencode(path))[1:]
204 parts = auxencode(lowerencode(path).split('/')[1:])
204 205 basename = parts[-1]
205 206 _root, ext = os.path.splitext(basename)
206 207 sdirs = []
General Comments 0
You need to be logged in to leave comments. Login now