Sets the fields given at CLI or configuration to the specified values, for both the album and all its items.
(self, lib: library.Library)
| 287 | ) |
| 288 | |
| 289 | def set_fields(self, lib: library.Library) -> None: |
| 290 | """Sets the fields given at CLI or configuration to the specified |
| 291 | values, for both the album and all its items. |
| 292 | """ |
| 293 | items = self.imported_items() |
| 294 | for field, view in config["import"]["set_fields"].items(): |
| 295 | value = str(view.get()) |
| 296 | log.debug( |
| 297 | "Set field {}={} for {}", |
| 298 | field, |
| 299 | value, |
| 300 | util.displayable_path(self.paths), |
| 301 | ) |
| 302 | self.album.set_parse(field, format(self.album, value)) |
| 303 | for item in items: |
| 304 | item.set_parse(field, format(item, value)) |
| 305 | with lib.transaction(): |
| 306 | for item in items: |
| 307 | item.store() |
| 308 | self.album.store() |
| 309 | |
| 310 | def finalize(self, session: ImportSession) -> None: |
| 311 | """Save progress, clean up files, and emit plugin event.""" |
no test coverage detected