Show More
@@ -1,4 +1,4 | |||
|
1 | import os, errno, stat | |
|
1 | import os, errno, stat, posixpath | |
|
2 | 2 | |
|
3 | 3 | import encoding |
|
4 | 4 | import util |
@@ -188,7 +188,7 def normasprefix(path): | |||
|
188 | 188 | else: |
|
189 | 189 | return path |
|
190 | 190 | |
|
191 |
def join( |
|
|
191 | def join(*args): | |
|
192 | 192 | '''Join two or more pathname components, inserting '/' as needed. |
|
193 | 193 | |
|
194 | 194 | Based on the posix os.path.join() implementation. |
@@ -214,17 +214,7 def join(path, *paths): | |||
|
214 | 214 | >>> join ('foo', '', '', 'bar') |
|
215 | 215 | 'foo/bar' |
|
216 | 216 | ''' |
|
217 | sep = '/' | |
|
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 | |
|
217 | return posixpath.join(*args) | |
|
228 | 218 | |
|
229 | 219 | def dirname(path): |
|
230 | 220 | '''returns the directory portion of the given path |
@@ -246,9 +236,4 def dirname(path): | |||
|
246 | 236 | >>> dirname('/foo//bar') |
|
247 | 237 | '/foo' |
|
248 | 238 | ''' |
|
249 | sep = '/' | |
|
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 | |
|
239 | return posixpath.dirname(path) |
General Comments 0
You need to be logged in to leave comments.
Login now