def _osu_files(path, recurse):
"""An iterator of ``.osu`` filepaths in a directory.
Parameters
----------
path : path-like
The directory to search in.
recurse : bool
Recursively search ``path``?
Yields
------
path : str
The path to a ``.osu`` file.
"""
if recurse:
for directory, _, filenames in os.walk(path):
for filename in filenames:
if filename.endswith('.osu'):
yield pathlib.Path(os.path.join(directory, filename))
else:
for entry in os.scandir(directory):
path = entry.path
if path.endswith('.osu'):
yield pathlib.Path(path)
评论列表
文章目录