mirror of
https://github.com/beetbox/beets.git
synced 2026-01-05 23:43:31 +01:00
fix Windows path manipulation in importfeeds
This commit is contained in:
parent
81d04643bf
commit
5f4a9c6446
3 changed files with 12 additions and 7 deletions
|
|
@ -101,9 +101,13 @@ def _record_items(lib, basename, items):
|
|||
if config['importfeeds']['absolute_path']:
|
||||
paths.append(item.path)
|
||||
else:
|
||||
paths.append(os.path.relpath(
|
||||
item.path, relative_to
|
||||
))
|
||||
try:
|
||||
relpath = os.path.relpath(item.path, relative_to)
|
||||
except ValueError:
|
||||
# On Windows, it is sometimes not possible to construct a
|
||||
# relative path (if the files are on different disks).
|
||||
relpath = item.path
|
||||
paths.append(relpath)
|
||||
|
||||
if 'm3u' in formats:
|
||||
basename = bytestring_path(
|
||||
|
|
|
|||
|
|
@ -9,4 +9,4 @@ ignore=E241,E221
|
|||
|
||||
# List of files that have not been cleand up yet. We will try to reduce
|
||||
# this with each commit
|
||||
exclude=test/test_config_command.py,test/test_files.py,test/test_art.py,test/test_dbcore.py,test/test_web.py,test/test_zero.py,test/rsrc/beetsplug/test.py,test/test_template.py,test/test_importfeeds.py,test/test_echonest.py,test/test_datequery.py,test/test_mb.py,test/test_convert.py,test/testall.py,test/test_player.py,test/test_query.py,test/test_mediafile.py,test/test_keyfinder.py,test/test_the.py,test/test_library.py,test/test_lyrics.py,test/test_ihate.py,test/test_vfs.py,test/test_replaygain.py,test/__init__.py,test/_common.py,test/test_mediafile_edge.py,test/test_ui.py
|
||||
exclude=test/test_config_command.py,test/test_files.py,test/test_art.py,test/test_dbcore.py,test/test_web.py,test/test_zero.py,test/rsrc/beetsplug/test.py,test/test_template.py,test/test_echonest.py,test/test_datequery.py,test/test_mb.py,test/test_convert.py,test/testall.py,test/test_player.py,test/test_query.py,test/test_mediafile.py,test/test_keyfinder.py,test/test_the.py,test/test_library.py,test/test_lyrics.py,test/test_ihate.py,test/test_vfs.py,test/test_replaygain.py,test/__init__.py,test/_common.py,test/test_mediafile_edge.py,test/test_ui.py
|
||||
|
|
|
|||
|
|
@ -16,14 +16,15 @@ class ImportfeedsTestTest(unittest.TestCase):
|
|||
self.lib = Library(':memory:')
|
||||
self.feeds_dir = tempfile.mkdtemp()
|
||||
config['importfeeds']['dir'] = self.feeds_dir
|
||||
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.feeds_dir)
|
||||
|
||||
def test_multi_format_album_playlist(self):
|
||||
config['importfeeds']['formats'] = 'm3u_multi'
|
||||
album = Album(album='album/name', id=1)
|
||||
item = Item(title='song', album_id=1, path='/path/to/item')
|
||||
item_path = os.path.join('path', 'to', 'item')
|
||||
item = Item(title='song', album_id=1, path=item_path)
|
||||
self.lib.add(album)
|
||||
self.lib.add(item)
|
||||
|
||||
|
|
@ -32,7 +33,7 @@ class ImportfeedsTestTest(unittest.TestCase):
|
|||
os.listdir(self.feeds_dir)[0])
|
||||
self.assertTrue(playlist_path.endswith('album_name.m3u'))
|
||||
with open(playlist_path) as playlist:
|
||||
self.assertIn('/path/to/item', playlist.read())
|
||||
self.assertIn(item_path, playlist.read())
|
||||
|
||||
|
||||
def suite():
|
||||
|
|
|
|||
Loading…
Reference in a new issue