##// END OF EJS Templates
pathutil: restate dirname and join as forwards to posixpath...
Augie Fackler -
r25285:46f2df2f default
parent child Browse files
Show More
@@ -1,4 +1,4 b''
1 import os, errno, stat
1 import os, errno, stat, posixpath
2
2
3 import encoding
3 import encoding
4 import util
4 import util
@@ -188,7 +188,7 b' def normasprefix(path):'
188 else:
188 else:
189 return path
189 return path
190
190
191 def join(path, *paths):
191 def join(*args):
192 '''Join two or more pathname components, inserting '/' as needed.
192 '''Join two or more pathname components, inserting '/' as needed.
193
193
194 Based on the posix os.path.join() implementation.
194 Based on the posix os.path.join() implementation.
@@ -214,17 +214,7 b' def join(path, *paths):'
214 >>> join ('foo', '', '', 'bar')
214 >>> join ('foo', '', '', 'bar')
215 'foo/bar'
215 'foo/bar'
216 '''
216 '''
217 sep = '/'
217 return posixpath.join(*args)
218 if not paths:
219 path[:0] + sep #23780: Ensure compatible data type even if p is null.
220 for piece in paths:
221 if piece.startswith(sep):
222 path = piece
223 elif not path or path.endswith(sep):
224 path += piece
225 else:
226 path += sep + piece
227 return path
228
218
229 def dirname(path):
219 def dirname(path):
230 '''returns the directory portion of the given path
220 '''returns the directory portion of the given path
@@ -246,9 +236,4 b' def dirname(path):'
246 >>> dirname('/foo//bar')
236 >>> dirname('/foo//bar')
247 '/foo'
237 '/foo'
248 '''
238 '''
249 sep = '/'
239 return posixpath.dirname(path)
250 i = path.rfind(sep) + 1
251 dirname = path[:i]
252 if dirname and dirname != sep * len(dirname):
253 dirname = dirname.rstrip(sep)
254 return dirname
General Comments 0
You need to be logged in to leave comments. Login now