mirror of
https://github.com/beetbox/beets.git
synced 2026-03-02 11:21:01 +01:00
use unicode for import log
We pass all the paths involved through displayable_path now.
This commit is contained in:
parent
194cbc2903
commit
67845f3fb5
2 changed files with 12 additions and 10 deletions
|
|
@ -258,12 +258,13 @@ class ImportSession(object):
|
|||
if not iconfig['copy']:
|
||||
iconfig['delete'] = False
|
||||
|
||||
def tag_log(self, status, path):
|
||||
def tag_log(self, status, paths):
|
||||
"""Log a message about a given album to logfile. The status should
|
||||
reflect the reason the album couldn't be tagged.
|
||||
"""
|
||||
if self.logfile:
|
||||
print('{0} {1}'.format(status, path), file=self.logfile)
|
||||
print(u'{0} {1}'.format(status, displayable_path(paths)),
|
||||
file=self.logfile)
|
||||
self.logfile.flush()
|
||||
|
||||
def log_choice(self, task, duplicate=False):
|
||||
|
|
@ -275,17 +276,17 @@ class ImportSession(object):
|
|||
if duplicate:
|
||||
# Duplicate: log all three choices (skip, keep both, and trump).
|
||||
if task.remove_duplicates:
|
||||
self.tag_log('duplicate-replace', displayable_path(paths))
|
||||
self.tag_log('duplicate-replace', paths)
|
||||
elif task.choice_flag in (action.ASIS, action.APPLY):
|
||||
self.tag_log('duplicate-keep', displayable_path(paths))
|
||||
self.tag_log('duplicate-keep', paths)
|
||||
elif task.choice_flag is (action.SKIP):
|
||||
self.tag_log('duplicate-skip', displayable_path(paths))
|
||||
self.tag_log('duplicate-skip', paths)
|
||||
else:
|
||||
# Non-duplicate: log "skip" and "asis" choices.
|
||||
if task.choice_flag is action.ASIS:
|
||||
self.tag_log('asis', displayable_path(paths))
|
||||
self.tag_log('asis', paths)
|
||||
elif task.choice_flag is action.SKIP:
|
||||
self.tag_log('skip', displayable_path(paths))
|
||||
self.tag_log('skip', paths)
|
||||
|
||||
def should_resume(self, path):
|
||||
raise NotImplementedError
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import os
|
|||
import time
|
||||
import itertools
|
||||
import re
|
||||
import codecs
|
||||
|
||||
import beets
|
||||
from beets import ui
|
||||
|
|
@ -654,11 +655,11 @@ def import_files(lib, paths, query):
|
|||
if config['import']['log'].get() is not None:
|
||||
logpath = config['import']['log'].as_filename()
|
||||
try:
|
||||
logfile = open(syspath(logpath), 'a')
|
||||
logfile = codecs.open(syspath(logpath), 'a', 'utf8')
|
||||
except IOError:
|
||||
raise ui.UserError(u"could not open log file for writing: %s" %
|
||||
displayable_path(logpath))
|
||||
print('import started', time.asctime(), file=logfile)
|
||||
print(u'import started', time.asctime(), file=logfile)
|
||||
else:
|
||||
logfile = None
|
||||
|
||||
|
|
@ -673,7 +674,7 @@ def import_files(lib, paths, query):
|
|||
finally:
|
||||
# If we were logging, close the file.
|
||||
if logfile:
|
||||
print('', file=logfile)
|
||||
print(u'', file=logfile)
|
||||
logfile.close()
|
||||
|
||||
# Emit event.
|
||||
|
|
|
|||
Loading…
Reference in a new issue