Skip to content

Commit

Permalink
Use rglob to find yml files
Browse files Browse the repository at this point in the history
- TODO: Find files with .yaml extension
- Update pytest as dev dependency
  • Loading branch information
tnagorra committed Jul 12, 2022
1 parent 7a10b75 commit 1465dd2
Show file tree
Hide file tree
Showing 3 changed files with 182 additions and 151 deletions.
10 changes: 4 additions & 6 deletions alacritty_colorscheme/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

from tap import Tap
from os import walk
from pathlib import Path
from os.path import expanduser, isfile, isdir, join
from glob import iglob
from typing import List, Optional, cast
try:
from typing import Literal # type: ignore
Expand Down Expand Up @@ -94,13 +96,9 @@ def get_files_in_directory(path: str) -> Optional[List[str]]:
if not isdir(expanded_path):
return None
try:
files = [join(root, file)
for (root, __dirs, files) in walk(expanded_path, followlinks=True)
for file in files]
# NOTE: joining path with empty string to add a trailing slash to dir
onlyfiles = [file.removeprefix(join(expanded_path, ''))
for file in files
if isfile(file) and file.lower().endswith(('.yml', '.yaml'))]
onlyfiles = [str(x).removeprefix(join(expanded_path, ''))
for x in list(Path(expanded_path).rglob("*.yml"))]
sortedfiles = sorted(onlyfiles)
return sortedfiles
except OSError:
Expand Down
Loading

0 comments on commit 1465dd2

Please sign in to comment.