refactoring according to suggestions in pull request
@@ -537,9 +537,8 @@ class ImportTask(BaseImportTask):
"""Sets the fields given at CLI or configuration to the specified
values.
"""
- set_fields_dict = config['import']['set_fields']
- for field in set_fields_dict.keys():
- value = set_fields_dict[field].get()
+ for field, view in config['import']['set_fields'].items():
+ value = view.get()
log.debug(u'Set field {1}={2} for {0}',
displayable_path(self.paths),
field,
@@ -898,9 +897,8 @@ class SingletonImportTask(ImportTask):
"""Sets the fields given at CLI or configuration to the specified
values.
"""
- set_fields_dict = config['import']['set_fields']
- for field in set_fields_dict.keys():
- value = set_fields_dict[field].get()
+ for field, view in config['import']['set_fields'].items():
+ value = view.get()
log.debug(u'Set field {1}={2} for {0}',
displayable_path(self.paths),
field,
@@ -1418,6 +1416,9 @@ def apply_choice(session, task):
# If ``set_fields`` is set, set those fields to the
# configured values.
+ # NOTE: This cannot be done before the ``task.add()`` call above,
+ # because then the ``ImportTask`` won't have an `album` for which
+ # it can set the fields.
if config['import']['set_fields']:
task.set_fields()
