Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions src/yamlfix/entrypoints/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,12 @@
log = logging.getLogger(__name__)


def _matches_any_glob(
file_to_test: Path, dir_: Path, globs: Optional[List[str]]
) -> bool:
return any(file_to_test in dir_.glob(glob) for glob in (globs or []))


def _find_all_yaml_files(
dir_: Path, include_globs: Optional[List[str]], exclude_globs: Optional[List[str]]
dir_: Path, include_globs: List[str], exclude_globs: Optional[List[str]]
) -> List[Path]:
files = [dir_.rglob(glob) for glob in (include_globs or [])]
return [
file
for list_ in files
for file in list_
if not _matches_any_glob(file, dir_, exclude_globs) and os.path.isfile(file)
]
files = {f for glob in (include_globs) for f in dir_.rglob(glob) if f.is_file()}
files.difference_update(f for exc in (exclude_globs or []) for f in dir_.rglob(exc))
return sorted(files)


@click.command()
Expand Down Expand Up @@ -80,7 +70,7 @@ def cli( # pylint: disable=too-many-arguments
verbose: bool,
check: bool,
config_file: Optional[List[str]],
include: Optional[List[str]],
include: List[str],
exclude: Optional[List[str]],
env_prefix: str,
) -> None:
Expand Down