mirror of
https://github.com/fergalmoran/picard.git
synced 2026-02-14 11:43:59 +00:00
Fixed renaming paths starting with "[a-z]:" being interpreted as drive names on Windows.
Fixes PICARD-663
This commit is contained in:
@@ -134,8 +134,11 @@ def replace_win32_incompat(string, repl=u"_"):
|
||||
"""Replace win32 filename incompatible characters from ``string`` by
|
||||
``repl``."""
|
||||
# Don't replace : with _ for windows drive
|
||||
drive, rest = ntpath.splitdrive(string)
|
||||
return drive + _re_win32_incompat.sub(repl, rest)
|
||||
if os.path.isabs(string):
|
||||
drive, rest = ntpath.splitdrive(string)
|
||||
return drive + _re_win32_incompat.sub(repl, rest)
|
||||
else:
|
||||
return _re_win32_incompat.sub(repl, string)
|
||||
|
||||
|
||||
_re_non_alphanum = re.compile(r'\W+', re.UNICODE)
|
||||
|
||||
@@ -19,6 +19,8 @@ class ReplaceWin32IncompatTest(unittest.TestCase):
|
||||
"c:\\test\\d_/2")
|
||||
self.assertEqual(util.replace_win32_incompat("A\"*:<>?|b"),
|
||||
"A_______b")
|
||||
self.assertEqual(util.replace_win32_incompat("d:test"),
|
||||
"d_test")
|
||||
|
||||
def test_incorrect(self):
|
||||
self.assertNotEqual(util.replace_win32_incompat("c:\\test\\te\"st2"),
|
||||
|
||||
Reference in New Issue
Block a user