##// END OF EJS Templates
windows: introduce a `util.abspath` to replace os.path.abspath...
marmoute -
r48422:bb917eea default
parent child Browse files
Show More
@@ -36,6 +36,8 b" osutil = policy.importmod('osutil')"
36
36
37 normpath = os.path.normpath
37 normpath = os.path.normpath
38 samestat = os.path.samestat
38 samestat = os.path.samestat
39 abspath = os.path.abspath # re-exports
40
39 try:
41 try:
40 oslink = os.link
42 oslink = os.link
41 except AttributeError:
43 except AttributeError:
@@ -99,6 +99,7 b' else:'
99
99
100 _ = i18n._
100 _ = i18n._
101
101
102 abspath = platform.abspath
102 bindunixsocket = platform.bindunixsocket
103 bindunixsocket = platform.bindunixsocket
103 cachestat = platform.cachestat
104 cachestat = platform.cachestat
104 checkexec = platform.checkexec
105 checkexec = platform.checkexec
@@ -2632,7 +2633,7 b' def makedirs(name, mode=None, notindexed'
2632 return
2633 return
2633 if err.errno != errno.ENOENT or not name:
2634 if err.errno != errno.ENOENT or not name:
2634 raise
2635 raise
2635 parent = os.path.dirname(os.path.abspath(name))
2636 parent = os.path.dirname(abspath(name))
2636 if parent == name:
2637 if parent == name:
2637 raise
2638 raise
2638 makedirs(parent, mode, notindexed)
2639 makedirs(parent, mode, notindexed)
@@ -333,6 +333,25 b' def normcase(path):'
333 return encoding.upper(path) # NTFS compares via upper()
333 return encoding.upper(path) # NTFS compares via upper()
334
334
335
335
336 DRIVE_RE_B = re.compile(b'^[a-z]:')
337 DRIVE_RE_S = re.compile('^[a-z]:')
338
339
340 def abspath(path):
341 abs_path = os.path.abspath(path) # re-exports
342 # Python on Windows is inconsistent regarding the capitalization of drive
343 # letter and this cause issue with various path comparison along the way.
344 # So we normalize the drive later to upper case here.
345 #
346 # See https://bugs.python.org/issue40368 for and example of this hell.
347 if isinstance(abs_path, bytes):
348 if DRIVE_RE_B.match(abs_path):
349 abs_path = abs_path[0:1].upper() + abs_path[1:]
350 elif DRIVE_RE_S.match(abs_path):
351 abs_path = abs_path[0:1].upper() + abs_path[1:]
352 return abs_path
353
354
336 # see posix.py for definitions
355 # see posix.py for definitions
337 normcasespec = encoding.normcasespecs.upper
356 normcasespec = encoding.normcasespecs.upper
338 normcasefallback = encoding.upperfallback
357 normcasefallback = encoding.upperfallback
General Comments 0
You need to be logged in to leave comments. Login now