sane-tag-music: handle multiple CLI paths by iterating a layer above
This commit is contained in:
@@ -854,7 +854,11 @@ class Gatherer:
|
||||
self.derive_tags = derive_tags
|
||||
|
||||
def files(self) -> list[tuple[MediaFile, Tags]]:
|
||||
files = self.walk_files(self.roots)
|
||||
for root in self.roots:
|
||||
yield from self.files_from(root)
|
||||
|
||||
def files_from(self, root: str) -> list[tuple[MediaFile, Tags]]:
|
||||
files = self.walk_files(root)
|
||||
|
||||
if self.derive_tags:
|
||||
files = list(files)
|
||||
@@ -872,17 +876,16 @@ class Gatherer:
|
||||
if self.media_type is None or f.is_type(self.media_type):
|
||||
yield f, tags
|
||||
|
||||
def walk_paths(self, *roots: str) -> None:
|
||||
for root in roots:
|
||||
if os.path.isdir(root):
|
||||
for dir_, subdirs, files_ in os.walk(root):
|
||||
for f in files_:
|
||||
yield os.path.join(dir_, f)
|
||||
else:
|
||||
yield root
|
||||
def walk_paths(self, root: str) -> None:
|
||||
if os.path.isdir(root):
|
||||
for dir_, subdirs, files_ in os.walk(root):
|
||||
for f in files_:
|
||||
yield os.path.join(dir_, f)
|
||||
else:
|
||||
yield root
|
||||
|
||||
def walk_files(self, paths: list[str]):
|
||||
for path_ in self.walk_paths(*paths):
|
||||
def walk_files(self, root: str):
|
||||
for path_ in self.walk_paths(root):
|
||||
file_ = MediaFile.new(path_)
|
||||
yield file_, Tags()
|
||||
|
||||
|
Reference in New Issue
Block a user