Skip to content

Commit 5c4f0b6

Browse files
committed
Use item.filepath instead of displayable_path in logging
1 parent 82bc875 commit 5c4f0b6

File tree

13 files changed

+45
-86
lines changed

13 files changed

+45
-86
lines changed

beets/art.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,7 @@ def get_art(log, item):
3838
try:
3939
mf = mediafile.MediaFile(syspath(item.path))
4040
except mediafile.UnreadableFileError as exc:
41-
log.warning(
42-
"Could not extract art from {}: {}",
43-
displayable_path(item.path),
44-
exc,
45-
)
41+
log.warning("Could not extract art from {}: {}", item.filepath, exc)
4642
return
4743

4844
return mf.art
@@ -189,7 +185,7 @@ def extract(log, outpath, item):
189185
# Add an extension to the filename.
190186
ext = mediafile.image_extension(art)
191187
if not ext:
192-
log.warning("Unknown image type in {}.", displayable_path(item.path))
188+
log.warning("Unknown image type in {}.", item.filepath)
193189
return
194190
outpath += bytestring_path(f".{ext}")
195191

beets/importer/tasks.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,7 @@ def remove_duplicates(self, lib: library.Library):
271271
for item in duplicate_items:
272272
item.remove()
273273
if lib.directory in util.ancestry(item.path):
274-
log.debug(
275-
"deleting duplicate {}", util.displayable_path(item.path)
276-
)
274+
log.debug("deleting duplicate {}", item.filepath)
277275
util.remove(item.path)
278276
util.prune_dirs(os.path.dirname(item.path), lib.directory)
279277

@@ -559,7 +557,7 @@ def _reduce_and_log(new_obj, existing_fields, overwrite_keys):
559557
noun,
560558
new_obj.id,
561559
overwritten_fields,
562-
util.displayable_path(new_obj.path),
560+
new_obj.filepath,
563561
)
564562
for key in overwritten_fields:
565563
del existing_fields[key]
@@ -581,14 +579,14 @@ def _reduce_and_log(new_obj, existing_fields, overwrite_keys):
581579
"Reimported album {}. Preserving attribute ['added']. "
582580
"Path: {}",
583581
self.album.id,
584-
util.displayable_path(self.album.path),
582+
self.album.filepath,
585583
)
586584
log.debug(
587585
"Reimported album {}. Preserving flexible attributes {}. "
588586
"Path: {}",
589587
self.album.id,
590588
list(album_fields.keys()),
591-
util.displayable_path(self.album.path),
589+
self.album.filepath,
592590
)
593591

594592
for item in self.imported_items():
@@ -600,7 +598,7 @@ def _reduce_and_log(new_obj, existing_fields, overwrite_keys):
600598
"Reimported item {}. Preserving attribute ['added']. "
601599
"Path: {}",
602600
item.id,
603-
util.displayable_path(item.path),
601+
item.filepath,
604602
)
605603
item_fields = _reduce_and_log(
606604
item, dup_item._values_flex, REIMPORT_FRESH_FIELDS_ITEM
@@ -611,7 +609,7 @@ def _reduce_and_log(new_obj, existing_fields, overwrite_keys):
611609
"Path: {}",
612610
item.id,
613611
list(item_fields.keys()),
614-
util.displayable_path(item.path),
612+
item.filepath,
615613
)
616614
item.store()
617615

@@ -621,11 +619,7 @@ def remove_replaced(self, lib):
621619
"""
622620
for item in self.imported_items():
623621
for dup_item in self.replaced_items[item]:
624-
log.debug(
625-
"Replacing item {}: {}",
626-
dup_item.id,
627-
util.displayable_path(item.path),
628-
)
622+
log.debug("Replacing item {}: {}", dup_item.id, item.filepath)
629623
dup_item.remove()
630624
log.debug(
631625
"{} of {} items replaced",

beets/library/models.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,10 +1012,7 @@ def try_sync(self, write, move, with_album=True):
10121012
if move:
10131013
# Check whether this file is inside the library directory.
10141014
if self._db and self._db.directory in util.ancestry(self.path):
1015-
log.debug(
1016-
"moving {} to synchronize path",
1017-
util.displayable_path(self.path),
1018-
)
1015+
log.debug("moving {} to synchronize path", self.filepath)
10191016
self.move(with_album=with_album)
10201017
self.store()
10211018

beets/ui/commands.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,7 +1642,7 @@ def update_items(lib, query, album, move, pretend, fields, exclude_fields=None):
16421642
if item.current_mtime() <= item.mtime:
16431643
log.debug(
16441644
"skipping {} because mtime is up to date ({})",
1645-
displayable_path(item.path),
1645+
item.filepath,
16461646
item.mtime,
16471647
)
16481648
continue
@@ -1651,9 +1651,7 @@ def update_items(lib, query, album, move, pretend, fields, exclude_fields=None):
16511651
try:
16521652
item.read()
16531653
except library.ReadError as exc:
1654-
log.error(
1655-
"error reading {}: {}", displayable_path(item.path), exc
1656-
)
1654+
log.error("error reading {}: {}", item.filepath, exc)
16571655
continue
16581656

16591657
# Special-case album artist when it matches track artist. (Hacky
@@ -2177,7 +2175,7 @@ def isalbummoved(album):
21772175
)
21782176

21792177
for obj in objs:
2180-
log.debug("moving: {}", util.displayable_path(obj.path))
2178+
log.debug("moving: {}", obj.filepath)
21812179

21822180
if export:
21832181
# Copy without affecting the database.
@@ -2260,14 +2258,14 @@ def write_items(lib, query, pretend, force):
22602258
for item in items:
22612259
# Item deleted?
22622260
if not os.path.exists(syspath(item.path)):
2263-
log.info("missing file: {}", util.displayable_path(item.path))
2261+
log.info("missing file: {}", item.filepath)
22642262
continue
22652263

22662264
# Get an Item object reflecting the "clean" (on-disk) state.
22672265
try:
22682266
clean_item = library.Item.from_path(item.path)
22692267
except library.ReadError as exc:
2270-
log.error("error reading {}: {}", displayable_path(item.path), exc)
2268+
log.error("error reading {}: {}", item.filepath, exc)
22712269
continue
22722270

22732271
# Check for and display changes.

beetsplug/chroma.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -341,28 +341,20 @@ def fingerprint_item(log, item, write=False):
341341
"""
342342
# Get a fingerprint and length for this track.
343343
if not item.length:
344-
log.info("{}: no duration available", util.displayable_path(item.path))
344+
log.info("{}: no duration available", item.filepath)
345345
elif item.acoustid_fingerprint:
346346
if write:
347-
log.info(
348-
"{}: fingerprint exists, skipping",
349-
util.displayable_path(item.path),
350-
)
347+
log.info("{}: fingerprint exists, skipping", item.filepath)
351348
else:
352-
log.info(
353-
"{}: using existing fingerprint",
354-
util.displayable_path(item.path),
355-
)
349+
log.info("{}: using existing fingerprint", item.filepath)
356350
return item.acoustid_fingerprint
357351
else:
358-
log.info("{}: fingerprinting", util.displayable_path(item.path))
352+
log.info("{}: fingerprinting", item.filepath)
359353
try:
360354
_, fp = acoustid.fingerprint_file(util.syspath(item.path))
361355
item.acoustid_fingerprint = fp.decode()
362356
if write:
363-
log.info(
364-
"{}: writing fingerprint", util.displayable_path(item.path)
365-
)
357+
log.info("{}: writing fingerprint", item.filepath)
366358
item.try_write()
367359
if item._db:
368360
item.store()

beetsplug/convert.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -388,16 +388,15 @@ def convert_item(
388388

389389
if os.path.exists(util.syspath(dest)):
390390
self._log.info(
391-
"Skipping {} (target file exists)",
392-
util.displayable_path(item.path),
391+
"Skipping {} (target file exists)", item.filepath
393392
)
394393
continue
395394

396395
if keep_new:
397396
if pretend:
398397
self._log.info(
399398
"mv {} {}",
400-
util.displayable_path(item.path),
399+
item.filepath,
401400
util.displayable_path(original),
402401
)
403402
else:
@@ -431,9 +430,7 @@ def convert_item(
431430
else ("Linking" if link else "Copying")
432431
)
433432

434-
self._log.info(
435-
"{} {}", msg, util.displayable_path(item.path)
436-
)
433+
self._log.info("{} {}", msg, item.filepath)
437434

438435
if hardlink:
439436
util.hardlink(original, converted)
@@ -464,8 +461,7 @@ def convert_item(
464461
if album and album.artpath:
465462
maxwidth = self._get_art_resize(album.artpath)
466463
self._log.debug(
467-
"embedding album art from {}",
468-
util.displayable_path(album.artpath),
464+
"embedding album art from {}", album.art_filepath
469465
)
470466
art.embed_item(
471467
self._log,
@@ -523,8 +519,7 @@ def copy_album_art(
523519

524520
if os.path.exists(util.syspath(dest)):
525521
self._log.info(
526-
"Skipping {} (target file exists)",
527-
util.displayable_path(album.artpath),
522+
"Skipping {} (target file exists)", album.art_filepath
528523
)
529524
return
530525

@@ -535,7 +530,7 @@ def copy_album_art(
535530
if maxwidth is not None:
536531
self._log.info(
537532
"Resizing cover art from {} to {}",
538-
util.displayable_path(album.artpath),
533+
album.art_filepath,
539534
util.displayable_path(dest),
540535
)
541536
if not pretend:
@@ -547,7 +542,7 @@ def copy_album_art(
547542
self._log.info(
548543
"{} {} {}",
549544
msg,
550-
util.displayable_path(album.artpath),
545+
album.art_filepath,
551546
util.displayable_path(dest),
552547
)
553548
else:
@@ -560,7 +555,7 @@ def copy_album_art(
560555
self._log.info(
561556
"{} cover art from {} to {}",
562557
msg,
563-
util.displayable_path(album.artpath),
558+
album.art_filepath,
564559
util.displayable_path(dest),
565560
)
566561
if hardlink:

beetsplug/duplicates.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def _checksum(self, item, prog):
256256
self._log.debug(
257257
"key {} on item {} not cached:computing checksum",
258258
key,
259-
displayable_path(item.path),
259+
item.filepath,
260260
)
261261
try:
262262
checksum = command_output(args).stdout
@@ -266,16 +266,12 @@ def _checksum(self, item, prog):
266266
"computed checksum for {} using {}", item.title, key
267267
)
268268
except subprocess.CalledProcessError as e:
269-
self._log.debug(
270-
"failed to checksum {}: {}",
271-
displayable_path(item.path),
272-
e,
273-
)
269+
self._log.debug("failed to checksum {}: {}", item.filepath, e)
274270
else:
275271
self._log.debug(
276272
"key {} on item {} cached:not computing checksum",
277273
key,
278-
displayable_path(item.path),
274+
item.filepath,
279275
)
280276
return key, checksum
281277

@@ -295,13 +291,13 @@ def _group_by(self, objs, keys, strict):
295291
self._log.debug(
296292
"some keys {} on item {} are null or empty: skipping",
297293
keys,
298-
displayable_path(obj.path),
294+
obj.filepath,
299295
)
300296
elif not strict and not len(values):
301297
self._log.debug(
302298
"all keys {} on item {} are null or empty: skipping",
303299
keys,
304-
displayable_path(obj.path),
300+
obj.filepath,
305301
)
306302
else:
307303
key = tuple(values)
@@ -363,7 +359,7 @@ def _merge_items(self, objs):
363359
"or empty: setting from item {}",
364360
f,
365361
displayable_path(objs[0].path),
366-
displayable_path(o.path),
362+
o.filepath,
367363
)
368364
setattr(objs[0], f, value)
369365
objs[0].store()
@@ -387,7 +383,7 @@ def _merge_albums(self, objs):
387383
" merging from {} into {}",
388384
missing,
389385
objs[0],
390-
displayable_path(o.path),
386+
o.filepath,
391387
displayable_path(missing.destination()),
392388
)
393389
missing.move(operation=MoveOperation.COPY)

beetsplug/fetchart.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,9 +1541,7 @@ def art_for_album(
15411541
out = candidate
15421542
assert out.path is not None # help mypy
15431543
self._log.debug(
1544-
"using {.LOC} image {}",
1545-
source,
1546-
util.displayable_path(out.path),
1544+
"using {.LOC} image {}", source, out.path
15471545
)
15481546
break
15491547
# Remove temporary files for invalid candidates.

beetsplug/ftintitle.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from typing import TYPE_CHECKING
2121

2222
from beets import plugins, ui
23-
from beets.util import displayable_path
2423

2524
if TYPE_CHECKING:
2625
from beets.importer import ImportSession, ImportTask
@@ -195,7 +194,7 @@ def ft_in_title(
195194
if not featured:
196195
return False
197196

198-
self._log.info("{}", displayable_path(item.path))
197+
self._log.info("{}", item.filepath)
199198

200199
# Attempt to find the featured artist.
201200
feat_part = find_feat_part(artist, albumartist)

beetsplug/importadded.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def update_album_times(self, lib, album):
105105
self._log.debug(
106106
"Album '{}' is reimported, skipping import of "
107107
"added dates for the album and its items.",
108-
util.displayable_path(album.path),
108+
album.filepath,
109109
)
110110
return
111111

@@ -130,7 +130,7 @@ def update_item_times(self, lib, item):
130130
if self.reimported_item(item):
131131
self._log.debug(
132132
"Item '{}' is reimported, skipping import of added date.",
133-
util.displayable_path(item.path),
133+
item.filepath,
134134
)
135135
return
136136
mtime = self.item_mtime.pop(item.path, None)
@@ -140,7 +140,7 @@ def update_item_times(self, lib, item):
140140
self.write_item_mtime(item, mtime)
141141
self._log.debug(
142142
"Import of item '{}', selected item.added={}",
143-
util.displayable_path(item.path),
143+
item.filepath,
144144
item.added,
145145
)
146146
item.store()
@@ -154,6 +154,6 @@ def update_after_write_time(self, item, path):
154154
self.write_item_mtime(item, item.added)
155155
self._log.debug(
156156
"Write of item '{}', selected item.added={}",
157-
util.displayable_path(item.path),
157+
item.filepath,
158158
item.added,
159159
)

0 commit comments

Comments
 (0)