Skip to content

Commit

Permalink
fix: support multiple plugins in a single require call
Browse files Browse the repository at this point in the history
  • Loading branch information
vberlier committed Nov 15, 2021
1 parent 01f329e commit 4251abc
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions beet/toolchain/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,17 @@ class GenericPipeline(Generic[T]):
plugins: Set[GenericPlugin[T]] = field(default_factory=set)
tasks: List[Task[T]] = field(default_factory=list)

def require(self, spec: GenericPluginSpec[T]):
def require(self, *args: GenericPluginSpec[T]):
"""Execute the specified plugin."""
plugin = self.resolve(spec)
if plugin in self.plugins:
return
for spec in args:
plugin = self.resolve(spec)
if plugin in self.plugins:
return

self.plugins.add(plugin)
self.plugins.add(plugin)

if remaining_work := Task(plugin).advance(self.ctx):
self.tasks.append(remaining_work)
if remaining_work := Task(plugin).advance(self.ctx):
self.tasks.append(remaining_work)

def resolve(self, spec: GenericPluginSpec[T]) -> GenericPlugin[T]:
"""Return the imported plugin if the argument is a dotted path."""
Expand Down

0 comments on commit 4251abc

Please sign in to comment.