@@ -352,6 +352,30 @@ def ask_resume(self, toppath):
352
352
class ImportTask (object ):
353
353
"""Represents a single set of items to be imported along with its
354
354
intermediate state. May represent an album or a single item.
355
+
356
+ The import session and stages call the following methods in the
357
+ given order.
358
+
359
+ * `lookup_candidates()` Sets the `common_artist`, `common_album`,
360
+ `candidates`, and `rec` attributes. `candidates` is a list of
361
+ `AlbumMatch` objects.
362
+
363
+ * `choose_match()` Uses the session to set the `match` attribute
364
+ from the `candidates` list.
365
+
366
+ * `find_duplicates()` Returns a list of albums from `lib` with the
367
+ same artist and album name as the task.
368
+
369
+ * `apply_metadata()` Sets the attributes of the items from the
370
+ task's `match` attribute.
371
+
372
+ * `add()` Add the imported items and album to the database.
373
+
374
+ * `manipulate_files()` Copy, move, and write files depending on the
375
+ session configuration.
376
+
377
+ * `finalize()` Update the import progress and cleanup the file
378
+ system.
355
379
"""
356
380
def __init__ (self , toppath = None , paths = None , items = None ):
357
381
self .toppath = toppath
@@ -423,12 +447,15 @@ def chosen_ident(self):
423
447
424
448
def imported_items (self ):
425
449
"""Return a list of Items that should be added to the library.
426
- If this is an album task, return the list of items in the
427
- selected match or everything if the choice is ASIS. If this is a
428
- singleton task, return a list containing the item .
450
+
451
+ If the tasks applies an album match the method only returns the
452
+ matched items .
429
453
"""
430
454
if self .choice_flag == action .ASIS :
431
455
return list (self .items )
456
+ # FIXME this should be a simple attribute. There should be no
457
+ # need to retrieve the keys of `match.mapping`. This requires
458
+ # that we remove unmatched items from the list.
432
459
elif self .choice_flag == action .APPLY :
433
460
return self .match .mapping .keys ()
434
461
else :
@@ -437,6 +464,8 @@ def imported_items(self):
437
464
def apply_metadata (self ):
438
465
"""Copy metadata from match info to the items.
439
466
"""
467
+ # TODO call should be more descriptive like
468
+ # apply_metadata(self.match, self.items)
440
469
autotag .apply_metadata (self .match .info , self .match .mapping )
441
470
442
471
def duplicate_items (self , lib ):
0 commit comments