decode ipfs item paths to satisy python -bb

This commit is contained in:
Johnny Robeson 2016-07-03 23:48:19 -04:00
parent 8c1e9e0dd4
commit b9cd889ef4
2 changed files with 9 additions and 5 deletions

View file

@ -272,9 +272,11 @@ class IPFSPlugin(BeetsPlugin):
break
except AttributeError:
pass
item_path = os.path.basename(item.path).decode(
util._fsencoding(), 'ignore'
)
# Clear current path from item
item.path = '/ipfs/{0}/{1}'.format(album.ipfs,
os.path.basename(item.path))
item.path = '/ipfs/{0}/{1}'.format(album.ipfs, item_path)
item.id = None
items.append(item)

View file

@ -17,7 +17,7 @@ from __future__ import division, absolute_import, print_function
from mock import patch
from beets import library
from beets.util import bytestring_path
from beets.util import bytestring_path, _fsencoding
from beetsplug.ipfs import IPFSPlugin
from test import _common
@ -51,9 +51,11 @@ class IPFSPluginTest(unittest.TestCase, TestHelper):
for check_item in added_album.items():
try:
if check_item.ipfs:
ipfs_item = os.path.basename(want_item.path).decode(
_fsencoding(),
)
want_path = '/ipfs/{0}/{1}'.format(test_album.ipfs,
os.path.basename(
want_item.path))
ipfs_item)
want_path = bytestring_path(want_path)
self.assertEqual(check_item.path, want_path)
self.assertEqual(check_item.ipfs, want_item.ipfs)