Skip to content

Commit

Permalink
add Path.walk backport
Browse files Browse the repository at this point in the history
  • Loading branch information
fritz-astronomer committed Aug 28, 2024
1 parent d30fefb commit aec0b3d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ test_binary
workflow
*.pyz
orbiter-*
.python-version
12 changes: 11 additions & 1 deletion orbiter/rules/rulesets.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,17 @@ def get_files_with_extension(self, input_dir: Path) -> Generator[Path, dict]:
extensions.append(f".{other_extension}")

logger.debug(f"Finding files with extension={extensions} in {input_dir}")
for directory, _, files in input_dir.walk():

def backport_walk(input_dir: Path):
"""Path.walk() is only available in Python 3.12+, so, backport"""
import os

for result in os.walk(input_dir):
yield Path(result[0]), result[1], result[2]

for directory, _, files in (
input_dir.walk() if hasattr(input_dir, "walk") else backport_walk(input_dir)
):
logger.debug(f"Checking directory={directory}")
for file in files:
file = directory / file
Expand Down

0 comments on commit aec0b3d

Please sign in to comment.