diff --git a/sohstationviewer/controller/util.py b/sohstationviewer/controller/util.py index b3f542680b332492d011e27c33e87cc6cea8df46..ae1f35e0ef24ad47d30f6554038d0fe9a6c1c10a 100644 --- a/sohstationviewer/controller/util.py +++ b/sohstationviewer/controller/util.py @@ -313,10 +313,10 @@ def check_data_sdata(root_dir: str) -> bool: return 'data' in dir_list and 'sdata' in dir_list -def get_total_files(list_of_dir: Path) -> int: +def get_valid_file_count(list_of_dir: Path) -> int: """ Get total number of valid files in valid directories from the list_of_dir - :param list_of_dir: + :param list_of_dir: list of paths to the folders of data :return total: total number of valid files """ total = 0 diff --git a/sohstationviewer/model/general_data/general_data.py b/sohstationviewer/model/general_data/general_data.py index f0d125ab051b28c9496346afe25c53b7b0fa17f6..101538372e8ed1ce18340b12120130f6d7f6038c 100644 --- a/sohstationviewer/model/general_data/general_data.py +++ b/sohstationviewer/model/general_data/general_data.py @@ -11,7 +11,7 @@ from PySide2 import QtCore from PySide2 import QtWidgets from sohstationviewer.controller.util import \ - display_tracking_info, get_total_files, validate_file, validate_dir + display_tracking_info, get_valid_file_count, validate_file, validate_dir from sohstationviewer.view.plotting.gps_plot.gps_point import GPSPoint from sohstationviewer.view.util.enums import LogType from sohstationviewer.database.process_db import execute_db @@ -189,7 +189,7 @@ class GeneralData(): attributes of current class """ count = 0 - total = get_total_files(folders) + total = get_valid_file_count(folders) for folder in folders: count = self.read_folder(folder, total, count) @@ -223,7 +223,7 @@ class GeneralData(): continue count += 1 try: - self.read_file(path2file, file_name, count) + self.read_file(path2file, file_name, count, total) except Exception: fmt = traceback.format_exc() self.track_info(f"Skip file {path2file} can't be read " @@ -231,12 +231,14 @@ class GeneralData(): LogType.WARNING) return count - def read_file(self, path2file: Path, file_name: str, count: int) -> None: + def read_file(self, path2file: Path, file_name: str, + count: int, total: int) -> None: """ Read data or text from file :param path2file: absolute path to file :param file_name: name of file :param count: total number of file read + :param total: total number of all valid files """ pass diff --git a/sohstationviewer/model/mseed_data/mseed.py b/sohstationviewer/model/mseed_data/mseed.py index d45b9ca736dcdfddf7f55ec6cc41a609a312f887..58acbf31c86335f095ec46dd3017a8c0e9ea4456 100644 --- a/sohstationviewer/model/mseed_data/mseed.py +++ b/sohstationviewer/model/mseed_data/mseed.py @@ -3,6 +3,7 @@ MSeed object to hold and process MSeed data """ import os import re +from pathlib import Path from typing import Dict, List from sohstationviewer.view.util.enums import LogType @@ -57,16 +58,18 @@ class MSeed(GeneralData): print("We currently only handle blockettes 500, 1000," " and 1001.") - def read_file(self, path2file, file_name, count): + def read_file(self, path2file: Path, file_name: str, + count: int, total: int) -> None: """ Read data or text from file :param path2file: absolute path to file :param file_name: name of file :param count: total number of file read + :param total: total number of all valid files """ if count % 10 == 0: self.track_info( - f'Read {count} files', LogType.INFO) + f'Read {count}/{total} files', LogType.INFO) log_text = read_text(path2file) if log_text is not None: self.log_texts[path2file] = log_text diff --git a/sohstationviewer/model/reftek_data/reftek.py b/sohstationviewer/model/reftek_data/reftek.py index 031deab2a7b02cb8156ed30b3673c2db1b14854b..c60514f9dd52c7bee284c17dac7b73ade78e6568 100755 --- a/sohstationviewer/model/reftek_data/reftek.py +++ b/sohstationviewer/model/reftek_data/reftek.py @@ -113,16 +113,18 @@ class RT130(GeneralData): folders = self.list_of_dir super().read_folders(folders) - def read_file(self, path2file, file_name, count): + def read_file(self, path2file: Path, file_name: str, + count: int, total: int) -> None: """ Read data or text from file :param path2file: absolute path to file :param file_name: name of file :param count: total number of file read + :param total: total number of all valid files """ if count % 50 == 0: self.track_info( - f"Read {count} files", LogType.INFO) + f"Read {count}/{total} files", LogType.INFO) log_text = read_text(path2file) if log_text is not None: self.log_texts['TEXT'].append(log_text)