Skip to content

Commit

Permalink
Add function to check for specific file extension in a folder case-in…
Browse files Browse the repository at this point in the history
…sensitive

A new function, check_for_file_with_extension, has been added to the file.py module. This function traverses through a specified folder path and checks for the presence of files with a particular extension. It logs specifically to the console if such files are found or not before returning a boolean.
  • Loading branch information
cbusillo committed Jun 20, 2024
1 parent 0a5eb19 commit 43bf219
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions bd_to_avp/modules/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ def move_file_to_output_root_folder(muxed_output_path: Path) -> None:
remove_folder_if_exists(muxed_output_path.parent)


def check_for_file_with_extension(folder_path: Path, extension: str) -> bool:
if not extension.startswith("."):
extension = f".{extension}"
print(f"Checking for {extension} files in: {folder_path}")

for file_path in folder_path.iterdir():
if file_path.suffix.lower() == extension.lower():
print(f"Found {extension} file: {file_path.name}")
return True

print(f"No {extension} files found in {folder_path}")
return False


@contextmanager
def mounted_image(image_path: Path):
mount_point = None
Expand Down

0 comments on commit 43bf219

Please sign in to comment.