From fcbfce39841e9c7e29dfd7a18f4edfbcf8035db5 Mon Sep 17 00:00:00 2001 From: Johnny Robeson Date: Tue, 9 Aug 2016 00:33:38 -0400 Subject: [PATCH] replace deprecated log.warn() with log.warning() --- beets/importer.py | 14 +++++++------- beets/plugins.py | 4 ++-- beets/ui/commands.py | 14 +++++++------- beets/util/__init__.py | 2 +- beets/util/artresizer.py | 8 ++++---- beetsplug/chroma.py | 2 +- beetsplug/edit.py | 6 +++--- beetsplug/fetchart.py | 8 ++++---- beetsplug/lyrics.py | 12 ++++++------ beetsplug/permissions.py | 2 +- beetsplug/smartplaylist.py | 6 +++--- beetsplug/spotify.py | 12 ++++++------ beetsplug/the.py | 6 +++--- beetsplug/zero.py | 12 +++++++----- 14 files changed, 55 insertions(+), 53 deletions(-) diff --git a/beets/importer.py b/beets/importer.py index 6a1be6ddc..2c1d07c5c 100644 --- a/beets/importer.py +++ b/beets/importer.py @@ -362,8 +362,8 @@ class ImportSession(object): # Either accept immediately or prompt for input to decide. if self.want_resume is True or \ self.should_resume(toppath): - log.warn(u'Resuming interrupted import of {0}', - util.displayable_path(toppath)) + log.warning(u'Resuming interrupted import of {0}', + util.displayable_path(toppath)) self._is_resuming[toppath] = True else: # Clear progress; we're starting from the top. @@ -1148,8 +1148,8 @@ class ImportTaskFactory(object): if not (self.session.config['move'] or self.session.config['copy']): - log.warn(u"Archive importing requires either " - u"'copy' or 'move' to be enabled.") + log.warning(u"Archive importing requires either " + u"'copy' or 'move' to be enabled.") return log.debug(u'Extracting archive: {0}', @@ -1179,7 +1179,7 @@ class ImportTaskFactory(object): # Silently ignore non-music files. pass elif isinstance(exc.reason, mediafile.UnreadableFileError): - log.warn(u'unreadable file: {0}', displayable_path(path)) + log.warning(u'unreadable file: {0}', displayable_path(path)) else: log.error(u'error reading {0}: {1}', displayable_path(path), exc) @@ -1204,8 +1204,8 @@ def read_tasks(session): skipped += task_factory.skipped if not task_factory.imported: - log.warn(u'No files imported from {0}', - displayable_path(toppath)) + log.warning(u'No files imported from {0}', + displayable_path(toppath)) # Show skipped directories (due to incremental/resume). if skipped: diff --git a/beets/plugins.py b/beets/plugins.py index 8fe4c6d0c..6c48d47d2 100644 --- a/beets/plugins.py +++ b/beets/plugins.py @@ -255,7 +255,7 @@ def load_plugins(names=()): except ImportError as exc: # Again, this is hacky: if exc.args[0].endswith(' ' + name): - log.warn(u'** plugin {0} not found', name) + log.warning(u'** plugin {0} not found', name) else: raise else: @@ -265,7 +265,7 @@ def load_plugins(names=()): _classes.add(obj) except: - log.warn( + log.warning( u'** error loading plugin {}:\n{}', name, traceback.format_exc(), diff --git a/beets/ui/commands.py b/beets/ui/commands.py index fce977b14..6ea9872d3 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -823,8 +823,8 @@ class TerminalImportSession(importer.ImportSession): """Decide what to do when a new album or item seems similar to one that's already in the library. """ - log.warn(u"This {0} is already in the library!", - (u"album" if task.is_album else u"item")) + log.warning(u"This {0} is already in the library!", + (u"album" if task.is_album else u"item")) if config['import']['quiet']: # In quiet mode, don't prompt -- just skip. @@ -902,9 +902,9 @@ class TerminalImportSession(importer.ImportSession): # Keep the first of the choices, removing the rest. dup_choices = [c for c in all_choices if c.short == short] for c in dup_choices[1:]: - log.warn(u"Prompt choice '{0}' removed due to conflict " - u"with '{1}' (short letter: '{2}')", - c.long, dup_choices[0].long, c.short) + log.warning(u"Prompt choice '{0}' removed due to conflict " + u"with '{1}' (short letter: '{2}')", + c.long, dup_choices[0].long, c.short) extra_choices.remove(c) return extra_choices @@ -1667,8 +1667,8 @@ def print_completion(*args): for line in completion_script(default_commands + plugins.commands()): print_(line, end=u'') if not any(map(os.path.isfile, BASH_COMPLETION_PATHS)): - log.warn(u'Warning: Unable to find the bash-completion package. ' - u'Command line completion might not work.') + log.warning(u'Warning: Unable to find the bash-completion package. ' + u'Command line completion might not work.') BASH_COMPLETION_PATHS = map(syspath, [ u'/etc/bash_completion', diff --git a/beets/util/__init__.py b/beets/util/__init__.py index ba3070e82..5732c81b5 100644 --- a/beets/util/__init__.py +++ b/beets/util/__init__.py @@ -169,7 +169,7 @@ def sorted_walk(path, ignore=(), ignore_hidden=False, logger=None): contents = os.listdir(syspath(path)) except OSError as exc: if logger: - logger.warn(u'could not list directory {0}: {1}'.format( + logger.warning(u'could not list directory {0}: {1}'.format( displayable_path(path), exc.strerror )) return diff --git a/beets/util/artresizer.py b/beets/util/artresizer.py index e15ada3af..c1382b5bf 100644 --- a/beets/util/artresizer.py +++ b/beets/util/artresizer.py @@ -96,8 +96,8 @@ def im_resize(maxwidth, path_in, path_out=None): util.syspath(path_out, prefix=False), ]) except subprocess.CalledProcessError: - log.warn(u'artresizer: IM convert failed for {0}', - util.displayable_path(path_in)) + log.warning(u'artresizer: IM convert failed for {0}', + util.displayable_path(path_in)) return path_in return path_out @@ -124,7 +124,7 @@ def im_getsize(path_in): try: out = util.command_output(cmd) except subprocess.CalledProcessError as exc: - log.warn(u'ImageMagick size query failed') + log.warning(u'ImageMagick size query failed') log.debug( u'`convert` exited with (status {}) when ' u'getting size with command {}:\n{}', @@ -134,7 +134,7 @@ def im_getsize(path_in): try: return tuple(map(int, out.split(b' '))) except IndexError: - log.warn(u'Could not understand IM output: {0!r}', out) + log.warning(u'Could not understand IM output: {0!r}', out) BACKEND_GET_SIZE = { diff --git a/beetsplug/chroma.py b/beetsplug/chroma.py index b45bcfe3e..cd0a77593 100644 --- a/beetsplug/chroma.py +++ b/beetsplug/chroma.py @@ -236,7 +236,7 @@ def submit_items(log, userkey, items, chunksize=64): try: acoustid.submit(API_KEY, userkey, data) except acoustid.AcoustidError as exc: - log.warn(u'acoustid submission error: {0}', exc) + log.warning(u'acoustid submission error: {0}', exc) del data[:] for item in items: diff --git a/beetsplug/edit.py b/beetsplug/edit.py index 7f35e49bc..1411c0401 100644 --- a/beetsplug/edit.py +++ b/beetsplug/edit.py @@ -319,8 +319,8 @@ class EditPlugin(plugins.BeetsPlugin): are temporary. """ if len(old_data) != len(new_data): - self._log.warn(u'number of objects changed from {} to {}', - len(old_data), len(new_data)) + self._log.warning(u'number of objects changed from {} to {}', + len(old_data), len(new_data)) obj_by_id = {o.id: o for o in objs} ignore_fields = self.config['ignore_fields'].as_str_seq() @@ -330,7 +330,7 @@ class EditPlugin(plugins.BeetsPlugin): forbidden = False for key in ignore_fields: if old_dict.get(key) != new_dict.get(key): - self._log.warn(u'ignoring object whose {} changed', key) + self._log.warning(u'ignoring object whose {} changed', key) forbidden = True break if forbidden: diff --git a/beetsplug/fetchart.py b/beetsplug/fetchart.py index aaa18dd02..4db22397e 100644 --- a/beetsplug/fetchart.py +++ b/beetsplug/fetchart.py @@ -265,10 +265,10 @@ class RemoteArtSource(ArtSource): ext = b'.' + CONTENT_TYPES[real_ct][0] if real_ct != ct: - self._log.warn(u'Server specified {}, but returned a ' - u'{} image. Correcting the extension ' - u'to {}', - ct, real_ct, ext) + self._log.warning(u'Server specified {}, but returned a ' + u'{} image. Correcting the extension ' + u'to {}', + ct, real_ct, ext) suffix = py3_path(ext) with NamedTemporaryFile(suffix=suffix, delete=False) as fh: diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index 4cc8cb441..32473dd10 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -624,9 +624,9 @@ class LyricsPlugin(plugins.BeetsPlugin): u'no API key configured.') sources.remove('google') elif not HAS_BEAUTIFUL_SOUP: - self._log.warn(u'To use the google lyrics source, you must ' - u'install the beautifulsoup4 module. See the ' - u'documentation for further details.') + self._log.warning(u'To use the google lyrics source, you must ' + u'install the beautifulsoup4 module. See ' + u'the documentation for further details.') sources.remove('google') self.config['bing_lang_from'] = [ @@ -634,9 +634,9 @@ class LyricsPlugin(plugins.BeetsPlugin): self.bing_auth_token = None if not HAS_LANGDETECT and self.config['bing_client_secret'].get(): - self._log.warn(u'To use bing translations, you need to ' - u'install the langdetect module. See the ' - u'documentation for further details.') + self._log.warning(u'To use bing translations, you need to ' + u'install the langdetect module. See the ' + u'documentation for further details.') self.backends = [self.SOURCE_BACKENDS[source](self.config, self._log) for source in sources] diff --git a/beetsplug/permissions.py b/beetsplug/permissions.py index 9bced8396..dd9e09843 100644 --- a/beetsplug/permissions.py +++ b/beetsplug/permissions.py @@ -39,7 +39,7 @@ def assert_permissions(path, permission, log): `check_permissions`. """ if not check_permissions(util.syspath(path), permission): - log.warn( + log.warning( u'could not set permissions on {}', util.displayable_path(path), ) diff --git a/beetsplug/smartplaylist.py b/beetsplug/smartplaylist.py index 11c5530b2..416dc37f5 100644 --- a/beetsplug/smartplaylist.py +++ b/beetsplug/smartplaylist.py @@ -98,7 +98,7 @@ class SmartPlaylistPlugin(BeetsPlugin): for playlist in self.config['playlists'].get(list): if 'name' not in playlist: - self._log.warn(u"playlist configuration is missing name") + self._log.warning(u"playlist configuration is missing name") continue playlist_data = (playlist['name'],) @@ -134,8 +134,8 @@ class SmartPlaylistPlugin(BeetsPlugin): playlist_data += (query_and_sort,) except ParsingError as exc: - self._log.warn(u"invalid query in playlist {}: {}", - playlist['name'], exc) + self._log.warning(u"invalid query in playlist {}: {}", + playlist['name'], exc) continue self._unmatched_playlists.add(playlist_data) diff --git a/beetsplug/spotify.py b/beetsplug/spotify.py index 619faebbc..36231f297 100644 --- a/beetsplug/spotify.py +++ b/beetsplug/spotify.py @@ -63,8 +63,8 @@ class SpotifyPlugin(BeetsPlugin): self.config['show_failures'].set(True) if self.config['mode'].get() not in ['list', 'open']: - self._log.warn(u'{0} is not a valid mode', - self.config['mode'].get()) + self._log.warning(u'{0} is not a valid mode', + self.config['mode'].get()) return False self.opts = opts @@ -154,9 +154,9 @@ class SpotifyPlugin(BeetsPlugin): self._log.info(u'track: {0}', track) self._log.info(u'') else: - self._log.warn(u'{0} track(s) did not match a Spotify ID;\n' - u'use --show-failures to display', - failure_count) + self._log.warning(u'{0} track(s) did not match a Spotify ID;\n' + u'use --show-failures to display', + failure_count) return results @@ -172,4 +172,4 @@ class SpotifyPlugin(BeetsPlugin): for item in ids: print(self.open_url + item) else: - self._log.warn(u'No Spotify tracks found from beets query') + self._log.warning(u'No Spotify tracks found from beets query') diff --git a/beetsplug/the.py b/beetsplug/the.py index c746f88b0..cfb583ced 100644 --- a/beetsplug/the.py +++ b/beetsplug/the.py @@ -54,14 +54,14 @@ class ThePlugin(BeetsPlugin): self._log.error(u'invalid pattern: {0}', p) else: if not (p.startswith('^') or p.endswith('$')): - self._log.warn(u'warning: \"{0}\" will not ' - u'match string start/end', p) + self._log.warning(u'warning: \"{0}\" will not ' + u'match string start/end', p) if self.config['a']: self.patterns = [PATTERN_A] + self.patterns if self.config['the']: self.patterns = [PATTERN_THE] + self.patterns if not self.patterns: - self._log.warn(u'no patterns defined!') + self._log.warning(u'no patterns defined!') def unthe(self, text, pattern): """Moves pattern in the path format string or strips it diff --git a/beetsplug/zero.py b/beetsplug/zero.py index 80925741b..1401b11de 100644 --- a/beetsplug/zero.py +++ b/beetsplug/zero.py @@ -51,7 +51,9 @@ class ZeroPlugin(BeetsPlugin): # We'll only handle `fields` or `keep_fields`, but not both. if self.config['fields'] and self.config['keep_fields']: - self._log.warn(u'cannot blacklist and whitelist at the same time') + self._log.warning( + u'cannot blacklist and whitelist at the same time' + ) # Blacklist mode. if self.config['fields']: @@ -84,8 +86,8 @@ class ZeroPlugin(BeetsPlugin): self._log.error(u'invalid field: {0}', field) continue if mode == 'fields' and field in ('id', 'path', 'album_id'): - self._log.warn(u'field \'{0}\' ignored, zeroing ' - u'it would be dangerous', field) + self._log.warning(u'field \'{0}\' ignored, zeroing ' + u'it would be dangerous', field) continue def set_pattern(self, field): @@ -102,7 +104,7 @@ class ZeroPlugin(BeetsPlugin): def import_task_choice_event(self, session, task): """Listen for import_task_choice event.""" if task.choice_flag == action.ASIS and not self.warned: - self._log.warn(u'cannot zero in \"as-is\" mode') + self._log.warning(u'cannot zero in \"as-is\" mode') self.warned = True # TODO request write in as-is mode @@ -123,7 +125,7 @@ class ZeroPlugin(BeetsPlugin): by `self.patterns`. """ if not self.patterns: - self._log.warn(u'no fields, nothing to do') + self._log.warning(u'no fields, nothing to do') return for field, patterns in self.patterns.items():