mirror of
https://github.com/beetbox/beets.git
synced 2025-12-28 11:32:30 +01:00
better regex for drive letter; hopefully fixed tests for 2.7; added test to show only drive-letter like colons are affected
This commit is contained in:
parent
0a9a801b05
commit
1eda0d39e6
2 changed files with 10 additions and 3 deletions
|
|
@ -86,8 +86,9 @@ class FormattedMapping(Mapping):
|
|||
if self.for_path:
|
||||
sep_repl = beets.config['path_sep_replace'].as_str()
|
||||
sep_drive = beets.config['drive_sep_replace'].as_str()
|
||||
|
||||
if re.match(r'^\w:', value):
|
||||
value = value.replace(':', sep_drive)
|
||||
value = re.sub(r'(?<=^\w):', sep_drive, value)
|
||||
|
||||
for sep in (os.path.sep, os.path.altsep):
|
||||
if sep:
|
||||
|
|
|
|||
|
|
@ -105,14 +105,20 @@ class MoveTest(_common.TestCase):
|
|||
def test_move_file_with_colon(self):
|
||||
self.i.artist = u'C:DOS'
|
||||
self.i.move()
|
||||
self.assertRegex(self.i.path.decode(), r'C_DOS')
|
||||
self.assertIn('C_DOS', self.i.path.decode())
|
||||
|
||||
def test_move_file_with_multiple_colons(self):
|
||||
print(beets.config['replace'])
|
||||
self.i.artist = u'COM:DOS'
|
||||
self.i.move()
|
||||
self.assertIn('COM_DOS', self.i.path.decode())
|
||||
|
||||
def test_move_file_with_colon_alt_separator(self):
|
||||
old = beets.config['drive_sep_replace']
|
||||
beets.config["drive_sep_replace"] = '0'
|
||||
self.i.artist = u'C:DOS'
|
||||
self.i.move()
|
||||
self.assertRegex(self.i.path.decode(), r"C0DOS")
|
||||
self.assertIn('C0DOS', self.i.path.decode())
|
||||
beets.config["drive_sep_replace"] = old
|
||||
|
||||
def test_read_only_file_copied_writable(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue