MCPcopy
hub / github.com/beetbox/beets / write_items

Function write_items

beets/ui/commands/write.py:14–40  ·  view source on GitHub ↗

Write tag information from the database to the respective files in the filesystem.

(lib, query, pretend, force)

Source from the content-addressed store, hash-verified

12
13
14def write_items(lib, query, pretend, force):
15 """Write tag information from the database to the respective files
16 in the filesystem.
17 """
18 items, _ = do_query(lib, query, False, False)
19
20 for item in items:
21 # Item deleted?
22 if not os.path.exists(syspath(item.path)):
23 log.info("missing file: {.filepath}", item)
24 continue
25
26 # Get an Item object reflecting the "clean" (on-disk) state.
27 try:
28 clean_item = library.Item.from_path(item.path)
29 except library.ReadError as exc:
30 log.error("error reading {.filepath}: {}", item, exc)
31 continue
32
33 # Check for and display changes.
34 changed = ui.show_model_changes(
35 item, clean_item, library.Item._media_tag_fields, force
36 )
37 if (changed or force) and not pretend:
38 # We use `try_sync` here to keep the mtime up to date in the
39 # database.
40 item.try_sync(True, False)
41
42
43def write_func(lib, opts, args):

Callers 1

write_funcFunction · 0.85

Calls 7

syspathFunction · 0.90
do_queryFunction · 0.85
existsMethod · 0.80
from_pathMethod · 0.80
errorMethod · 0.80
infoMethod · 0.45
try_syncMethod · 0.45

Tested by

no test coverage detected