Skip to content

Update moveall for python3 compatibility #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions beetsplug/moveall.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@ def handle_item_moved(source, destination, **_kwargs):


def handle_cli_exit(lib, **_kwargs):
for src_dir, dst_dir in directories_moved.iteritems():
for src_dir, dst_dir in directories_moved.items():
if dst_dir is MULTIPLE_DESTS:
print ("moves out of %s have multiple dests, will not moveall" %
(src_dir,))
print("moves out of %s have multiple dests, will not moveall" % (src_dir,))
continue
remaining_items = lib.items(library.PathQuery('path', src_dir))
if next(iter(remaining_items), None):
print "some Beets items left in %s, will not moveall" % (src_dir,)
print("some Beets items left in %s, will not moveall" % (src_dir,))
elif os.path.exists(src_dir):
print "moving all leftovers in %s to %s" % (src_dir, dst_dir)
print("moving all leftovers in %s to %s" % (src_dir, dst_dir))
for dirent in os.listdir(src_dir):
dirent_path = os.path.join(src_dir, dirent)
try:
shutil.move(dirent_path, dst_dir)
except shutil.Error, ex:
shutil.move(util.py3_path(dirent_path), util.py3_path(dst_dir))
except shutil.Error as ex:
# Log it but move on.
# XXX unicode problem here if path has non-ascii
log.critical("failed to move {0} to {1}: {2}", dirent_path,
dst_dir, ex)
log.critical("failed to move {0} to {1}: {2}",
util.py3_path(dirent_path),
util.py3_path(dst_dir),
ex)
util.prune_dirs(src_dir)