equal
deleted
inserted
replaced
19 |
19 |
20 umask = os.umask(0) |
20 umask = os.umask(0) |
21 os.umask(umask) |
21 os.umask(umask) |
22 |
22 |
23 def split(p): |
23 def split(p): |
24 '''Same as os.path.split, but faster''' |
24 '''Same as posixpath.split, but faster |
|
25 |
|
26 >>> import posixpath |
|
27 >>> for f in ['/absolute/path/to/file', |
|
28 ... 'relative/path/to/file', |
|
29 ... 'file_alone', |
|
30 ... 'path/to/directory/', |
|
31 ... '/multiple/path//separators', |
|
32 ... '/file_at_root', |
|
33 ... '///multiple_leading_separators_at_root', |
|
34 ... '']: |
|
35 ... assert split(f) == posixpath.split(f), f |
|
36 ''' |
25 ht = p.rsplit('/', 1) |
37 ht = p.rsplit('/', 1) |
26 if len(ht) == 1: |
38 if len(ht) == 1: |
27 return '', p |
39 return '', p |
28 nh = ht[0].rstrip('/') |
40 nh = ht[0].rstrip('/') |
29 if nh: |
41 if nh: |
30 return nh, ht[1] |
42 return nh, ht[1] |
31 return ht |
43 return ht[0] + '/', ht[1] |
32 |
44 |
33 def openhardlinks(): |
45 def openhardlinks(): |
34 '''return true if it is safe to hold open file handles to hardlinks''' |
46 '''return true if it is safe to hold open file handles to hardlinks''' |
35 return True |
47 return True |
36 |
48 |