Skip to content
Snippets Groups Projects
Commit 0a7dbdc5 authored by Lan Dam's avatar Lan Dam
Browse files

add get_total_riles to controller/util.py

parent 5c47aceb
No related branches found
No related tags found
1 merge request!122allow to select multi folder to load
......@@ -24,7 +24,6 @@ def validate_file(path2file: Union[str, Path], file_name: str):
:param file_name: name of the file
:return: True if pass checking, False if not.
"""
if file_name.startswith('.'):
# skip info file
return False
......@@ -49,6 +48,25 @@ def validate_dir(path: str):
raise Exception(f"Skip info folder: {path}")
def get_total_files(list_of_dir: Path) -> int:
"""
Get total number of valid files in valid directories from the list_of_dir
:param list_of_dir:
:return total: total number of valid files
"""
total = 0
for folder in list_of_dir:
for path, _, files in os.walk(folder):
try:
validate_dir(path)
except Exception:
continue
total += len([f for f in files
if validate_file(Path(path).joinpath(f), f)])
return total
@QtCore.Slot()
def display_tracking_info(tracking_box: QTextBrowser, text: str,
type: LogType = LogType.INFO):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment