Skip to content

Commit 8cb64c4

Browse files
committed
Dedupe logging args
1 parent 8271960 commit 8cb64c4

File tree

14 files changed

+33
-57
lines changed

14 files changed

+33
-57
lines changed

beets/autotag/match.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def _add_candidate(
197197
checking the track count, ordering the items, checking for
198198
duplicates, and calculating the distance.
199199
"""
200-
log.debug("Candidate: {.artist} - {.album} ({.album_id})", info, info, info)
200+
log.debug("Candidate: {0.artist} - {0.album} ({0.album_id})", info)
201201

202202
# Discard albums with zero tracks.
203203
if not info.tracks:

beets/importer/stages.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,7 @@ def query_tasks(session: ImportSession):
8282
# Search for albums.
8383
for album in session.lib.albums(session.query):
8484
log.debug(
85-
"yielding album {.id}: {.albumartist} - {.album}",
86-
album,
87-
album,
88-
album,
85+
"yielding album {0.id}: {0.albumartist} - {0.album}", album
8986
)
9087
items = list(album.items())
9188
_freshen_items(items)

beets/importer/tasks.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -552,12 +552,11 @@ def _reduce_and_log(new_obj, existing_fields, overwrite_keys):
552552
]
553553
if overwritten_fields:
554554
log.debug(
555-
"Reimported {} {.id}. Not preserving flexible attributes {}. "
556-
"Path: {.filepath}",
555+
"Reimported {0} {1.id}. Not preserving flexible attributes {2}. "
556+
"Path: {1.filepath}",
557557
noun,
558558
new_obj,
559559
overwritten_fields,
560-
new_obj,
561560
)
562561
for key in overwritten_fields:
563562
del existing_fields[key]
@@ -576,17 +575,15 @@ def _reduce_and_log(new_obj, existing_fields, overwrite_keys):
576575
self.album.artpath = replaced_album.artpath
577576
self.album.store()
578577
log.debug(
579-
"Reimported album {.album.id}. Preserving attribute ['added']. "
580-
"Path: {.album.filepath}",
581-
self,
578+
"Reimported album {0.album.id}. Preserving attribute ['added']. "
579+
"Path: {0.album.filepath}",
582580
self,
583581
)
584582
log.debug(
585-
"Reimported album {.album.id}. Preserving flexible attributes {}. "
586-
"Path: {.album.filepath}",
583+
"Reimported album {0.album.id}. Preserving flexible"
584+
" attributes {1}. Path: {0.album.filepath}",
587585
self,
588586
list(album_fields.keys()),
589-
self,
590587
)
591588

592589
for item in self.imported_items():
@@ -595,21 +592,19 @@ def _reduce_and_log(new_obj, existing_fields, overwrite_keys):
595592
if dup_item.added and dup_item.added != item.added:
596593
item.added = dup_item.added
597594
log.debug(
598-
"Reimported item {.id}. Preserving attribute ['added']. "
599-
"Path: {.filepath}",
600-
item,
595+
"Reimported item {0.id}. Preserving attribute ['added']. "
596+
"Path: {0.filepath}",
601597
item,
602598
)
603599
item_fields = _reduce_and_log(
604600
item, dup_item._values_flex, REIMPORT_FRESH_FIELDS_ITEM
605601
)
606602
item.update(item_fields)
607603
log.debug(
608-
"Reimported item {.id}. Preserving flexible attributes {}. "
609-
"Path: {.filepath}",
604+
"Reimported item {0.id}. Preserving flexible attributes {1}. "
605+
"Path: {0.filepath}",
610606
item,
611607
list(item_fields.keys()),
612-
item,
613608
)
614609
item.store()
615610

beets/ui/commands.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,11 +1282,10 @@ def _get_choices(self, task):
12821282
dup_choices = [c for c in all_choices if c.short == short]
12831283
for c in dup_choices[1:]:
12841284
log.warning(
1285-
"Prompt choice '{.long}' removed due to conflict "
1286-
"with '{.long}' (short letter: '{.short}')",
1287-
c,
1288-
dup_choices[0],
1285+
"Prompt choice '{0.long}' removed due to conflict "
1286+
"with '{1[0].long}' (short letter: '{0.short}')",
12891287
c,
1288+
dup_choices,
12901289
)
12911290
extra_choices.remove(c)
12921291

@@ -1641,8 +1640,7 @@ def update_items(lib, query, album, move, pretend, fields, exclude_fields=None):
16411640
# Did the item change since last checked?
16421641
if item.current_mtime() <= item.mtime:
16431642
log.debug(
1644-
"skipping {.filepath} because mtime is up to date ({.mtime})",
1645-
item,
1643+
"skipping {0.filepath} because mtime is up to date ({0.mtime})",
16461644
item,
16471645
)
16481646
continue

beetsplug/badfiles.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,11 @@ def check_item(self, item):
127127
except CheckerCommandError as e:
128128
if e.errno == errno.ENOENT:
129129
self._log.error(
130-
"command not found: {.checker} when validating file: {.path}",
131-
e,
130+
"command not found: {0.checker} when validating file: {0.path}",
132131
e,
133132
)
134133
else:
135-
self._log.error("error invoking {.checker}: {.msg}", e, e)
134+
self._log.error("error invoking {0.checker}: {0.msg}", e)
136135
return []
137136

138137
error_lines = []

beetsplug/bpsync.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ def albums(self, lib, query, move, pretend, write):
139139
albuminfo = self.beatport_plugin.album_for_id(album.mb_albumid)
140140
if not albuminfo:
141141
self._log.info(
142-
"Release ID {.mb_albumid} not found for album {}",
143-
album,
144-
album,
142+
"Release ID {0.mb_albumid} not found for album {0}", album
145143
)
146144
continue
147145

beetsplug/convert.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,9 @@ def encode(self, command, source, dest, pretend=False):
319319
util.displayable_path(source),
320320
)
321321
self._log.debug(
322-
"Command {} exited with status {.returncode}: {.output}",
322+
"Command {0} exited with status {1.returncode}: {1.output}",
323323
args,
324324
exc,
325-
exc,
326325
)
327326
util.remove(dest)
328327
util.prune_dirs(os.path.dirname(dest))

beetsplug/ftintitle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def update_metadata(
153153
"artist: {.artist} (Not changing due to keep_in_artist)", item
154154
)
155155
else:
156-
self._log.info("artist: {.artist} -> {.albumartist}", item, item)
156+
self._log.info("artist: {0.artist} -> {0.albumartist}", item)
157157
item.artist = item.albumartist
158158

159159
if item.artist_sort:

beetsplug/importadded.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,9 @@ def update_album_times(self, lib, album):
119119
item.store()
120120
album.added = min(album_mtimes)
121121
self._log.debug(
122-
"Import of album '{.album}', selected album.added={.added} "
122+
"Import of album '{0.album}', selected album.added={0.added} "
123123
"from item file mtimes.",
124124
album,
125-
album,
126125
)
127126
album.store()
128127

@@ -139,8 +138,7 @@ def update_item_times(self, lib, item):
139138
if self.config["preserve_mtimes"].get(bool):
140139
self.write_item_mtime(item, mtime)
141140
self._log.debug(
142-
"Import of item '{.filepath}', selected item.added={.added}",
143-
item,
141+
"Import of item '{0.filepath}', selected item.added={0.added}",
144142
item,
145143
)
146144
item.store()
@@ -153,7 +151,6 @@ def update_after_write_time(self, item, path):
153151
if self.config["preserve_write_mtimes"].get(bool):
154152
self.write_item_mtime(item, item.added)
155153
self._log.debug(
156-
"Write of item '{.filepath}', selected item.added={.added}",
157-
item,
154+
"Write of item '{0.filepath}', selected item.added={0.added}",
158155
item,
159156
)

beetsplug/lastimport.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,8 @@ def process_tracks(lib, tracks, log):
268268
count = int(song.get("play_count", 0))
269269
new_count = int(tracks[num].get("playcount", 1))
270270
log.debug(
271-
"match: {.artist} - {.title} ({.album}) updating: play_count {} => {}",
272-
song,
273-
song,
271+
"match: {0.artist} - {0.title} ({0.album}) updating:"
272+
" play_count {1} => {2}",
274273
song,
275274
count,
276275
new_count,

0 commit comments

Comments
 (0)