mirror of
https://github.com/beetbox/beets.git
synced 2025-12-20 15:43:58 +01:00
Implemented a better solution for the pretend flag
Corrected the documentation (shortcut -e is not available any more)
This commit is contained in:
parent
5f67f3ae51
commit
af36d85ef8
2 changed files with 38 additions and 31 deletions
|
|
@ -277,20 +277,25 @@ class ImportSession(object):
|
|||
else:
|
||||
stages = [query_tasks(self)]
|
||||
|
||||
if self.config['group_albums'] and \
|
||||
not self.config['singletons']:
|
||||
# Split directory tasks into one task for each album
|
||||
stages += [group_albums(self)]
|
||||
if self.config['autotag']:
|
||||
# FIXME We should also resolve duplicates when not
|
||||
# autotagging. This is currently handled in `user_query`
|
||||
stages += [lookup_candidates(self), user_query(self)]
|
||||
if self.config['pretend']:
|
||||
# Only log the imported files and end the pipeline
|
||||
stages += [log_files(self)]
|
||||
else:
|
||||
stages += [import_asis(self)]
|
||||
stages += [apply_choices(self)]
|
||||
for stage_func in plugins.import_stages():
|
||||
stages.append(plugin_stage(self, stage_func))
|
||||
stages += [manipulate_files(self)]
|
||||
if self.config['group_albums'] and \
|
||||
not self.config['singletons']:
|
||||
# Split directory tasks into one task for each album
|
||||
stages += [group_albums(self)]
|
||||
if self.config['autotag']:
|
||||
# FIXME We should also resolve duplicates when not
|
||||
# autotagging. This is currently handled in `user_query`
|
||||
stages += [lookup_candidates(self), user_query(self)]
|
||||
else:
|
||||
stages += [import_asis(self)]
|
||||
stages += [apply_choices(self)]
|
||||
|
||||
for stage_func in plugins.import_stages():
|
||||
stages.append(plugin_stage(self, stage_func))
|
||||
stages += [manipulate_files(self)]
|
||||
pl = pipeline.Pipeline(stages)
|
||||
|
||||
# Run the pipeline.
|
||||
|
|
@ -1096,24 +1101,15 @@ def read_tasks(session):
|
|||
task_factory = ImportTaskFactory(toppath, session)
|
||||
imported = False
|
||||
for t in task_factory.tasks():
|
||||
if session.config['pretend']:
|
||||
imported = True
|
||||
if isinstance(t, SingletonImportTask):
|
||||
log.info(displayable_path(t.item['path']))
|
||||
elif t.items:
|
||||
for item in t.items:
|
||||
log.info(displayable_path(item['path']))
|
||||
else:
|
||||
imported |= not t.skip
|
||||
yield t
|
||||
imported |= not t.skip
|
||||
yield t
|
||||
|
||||
# Indicate the directory is finished.
|
||||
# FIXME hack to delete extracted archives
|
||||
if not session.config['pretend']:
|
||||
if archive_task is None:
|
||||
yield task_factory.sentinel()
|
||||
else:
|
||||
yield archive_task
|
||||
if archive_task is None:
|
||||
yield task_factory.sentinel()
|
||||
else:
|
||||
yield archive_task
|
||||
|
||||
if not imported:
|
||||
log.warn(u'No files imported from {0}'
|
||||
|
|
@ -1299,6 +1295,17 @@ def manipulate_files(session, task):
|
|||
task.finalize(session)
|
||||
|
||||
|
||||
@pipeline.stage
|
||||
def log_files(session, task):
|
||||
"""A coroutine (pipeline stage) to log each file which will be imported
|
||||
"""
|
||||
if isinstance(task, SingletonImportTask):
|
||||
log.info(displayable_path(task.item['path']))
|
||||
elif task.items:
|
||||
for item in task.items:
|
||||
log.info(displayable_path(item['path']))
|
||||
|
||||
|
||||
def group_albums(session):
|
||||
"""Group the items of a task by albumartist and album name and create a new
|
||||
task for each album. Yield the tasks as a multi message.
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ import
|
|||
``````
|
||||
::
|
||||
|
||||
beet import [-CeWAPRqst] [-l LOGPATH] PATH...
|
||||
beet import [-CWAPRqst] [-l LOGPATH] PATH...
|
||||
beet import [options] -L QUERY
|
||||
|
||||
Add music to your library, attempting to get correct tags for it from
|
||||
|
|
@ -128,8 +128,8 @@ Optional command flags:
|
|||
``--group-albums`` option to split the files based on their metadata before
|
||||
matching them as separate albums.
|
||||
|
||||
* If you just want to know which files would be imported, you can use the ``-e``
|
||||
(or ``--pretend``) option. If set, beets will only print a list of file
|
||||
* If you just want to know which files would be imported, you can use the
|
||||
``--pretend`` option. If set, beets will only print a list of file
|
||||
it will import when the option is removed and won't do anything else.
|
||||
|
||||
.. _rarfile: https://pypi.python.org/pypi/rarfile/2.2
|
||||
|
|
|
|||
Loading…
Reference in a new issue