mirror of
https://github.com/rommapp/romm.git
synced 2026-11-30 18:42:34 +01:00
Merge pull request #556 from bfenty/master
Filter out files without extension
This commit is contained in:
@@ -231,9 +231,20 @@ def _exclude_files(files, filetype) -> list[str]:
|
||||
filtered_files: list = []
|
||||
|
||||
for file in files:
|
||||
if file.split(".")[-1] in excluded_extensions or file in excluded_names:
|
||||
# Exclude files starting with a period.
|
||||
if file.startswith('.'):
|
||||
filtered_files.append(file)
|
||||
else:
|
||||
# Split the file name to get the extension.
|
||||
parts = file.split(".")
|
||||
# Exclude the file if it has no extension or the extension is in the excluded list.
|
||||
if len(parts) == 1 or parts[-1] in excluded_extensions:
|
||||
filtered_files.append(file)
|
||||
# Additionally, check if the entire file name is in the excluded names list.
|
||||
elif file in excluded_names:
|
||||
filtered_files.append(file)
|
||||
|
||||
# Return files that are not in the filtered list.
|
||||
return [f for f in files if f not in filtered_files]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user