From fad2e4882dd1083cdab615ac6ec04e0e4e7af83f Mon Sep 17 00:00:00 2001
From: ldam <ldam@passcal.nmt.edu>
Date: Wed, 30 Aug 2023 13:29:55 -0600
Subject: [PATCH] change get_total_files() to get_valid_file_count(), add total
 of files to the info

---
 sohstationviewer/controller/util.py                 |  4 ++--
 sohstationviewer/model/general_data/general_data.py | 10 ++++++----
 sohstationviewer/model/mseed_data/mseed.py          |  7 +++++--
 sohstationviewer/model/reftek_data/reftek.py        |  6 ++++--
 4 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/sohstationviewer/controller/util.py b/sohstationviewer/controller/util.py
index b3f542680..ae1f35e0e 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 f0d125ab0..101538372 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 d45b9ca73..58acbf31c 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 031deab2a..c60514f9d 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)
-- 
GitLab