From b0996bc3bdb5abf1907fced641bcb439d025476b Mon Sep 17 00:00:00 2001 From: Clair Mould <86794332+clmould@users.noreply.github.com> Date: Mon, 17 Nov 2025 16:55:20 +0000 Subject: [PATCH 1/2] remove unnecessary logging and comments --- process/io/configuration.py | 1 - process/io/mfile.py | 15 +-------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/process/io/configuration.py b/process/io/configuration.py index 934a901e27..13e9cfc3d0 100644 --- a/process/io/configuration.py +++ b/process/io/configuration.py @@ -36,7 +36,6 @@ def data(self): def data_validate(self, value): """Check that value corresponds to a specific data format.""" - logger.info(f"type of value: {type(value)}") if not isinstance(value, dict) and value is not None: raise ValueError("Configuration data must be specified as a dictionary") diff --git a/process/io/mfile.py b/process/io/mfile.py index 872366b751..c343c20553 100644 --- a/process/io/mfile.py +++ b/process/io/mfile.py @@ -59,11 +59,9 @@ def __init__( self.var_flag = var_flag self.latest_scan = 0 super().__init__(*args, **kwargs) - logger.debug(f"Initialising variable '{self.var_name}': {self.var_description}") def __getattr__(self, name): result = self.get(name) - # print(f"Trying to get({name}) on {self}, {id(self)}" if result: return result raise AttributeError(f"{self.__class__} object has no attribute {name}") @@ -79,9 +77,6 @@ def set_scan(self, scan_number, scan_value): self[f"scan{scan_number:02}"] = scan_value if scan_number > self.latest_scan: self.latest_scan = scan_number - logger.debug( - f"Scan {scan_number} for variable '{self.var_name}' == {scan_value}" - ) def get_scan(self, scan_number): """Returns the value of a specific scan. For scan = -1 or None the last @@ -99,7 +94,7 @@ def get_scan(self, scan_number): return self[f"scan{self.latest_scan:02}"] return self[f"scan{scan_number:02}"] except KeyError: - raise # or substitute with any other exception type you want + raise def get_scans(self): """Returns a list of scan values in order of scan number @@ -112,8 +107,6 @@ def get_scans(self): def get_number_of_scans(self): """Function to return the number of scans in the variable class""" - # likely we can just use self.latest_scan, but not guaranteed, so - # keeping this as it is for now... return len([key for key in self.keys() if "scan" in key]) @property @@ -207,10 +200,7 @@ def __repr__(self): class MFile: def __init__(self, filename="MFILE.DAT"): """Class object to store the MFile Objects""" - logger.info(f"Creating MFile class for file '{filename}'") self.filename = filename - # self.data = MFileDataDictionary() - # self.data = OrderedDict() self.data = DefaultOrderedDict() self.mfile_lines = [] self.mfile_modules = {} @@ -218,9 +208,7 @@ def __init__(self, filename="MFILE.DAT"): self.mfile_modules["Misc"] = [] self.current_module = "Misc" if filename is not None: - logger.info(f"Opening file '{self.filename}'") self.open_mfile() - logger.info(f"Parsing file '{self.filename}'") self.parse_mfile() def open_mfile(self): @@ -236,7 +224,6 @@ def open_mfile(self): def parse_mfile(self): """Function to parse MFILE.DAT""" - # for line in (c for c in (clean_line(l) for l in self.mfile_lines if '#' not in l[:2]) for line in ( c for c in (clean_line(lines) for lines in self.mfile_lines) if c != [""] ): From 9ff05d06b22acc6f990dc2bb960bd842dc5d83b6 Mon Sep 17 00:00:00 2001 From: Clair Mould <86794332+clmould@users.noreply.github.com> Date: Tue, 18 Nov 2025 10:26:23 +0000 Subject: [PATCH 2/2] remove unnecessary try except --- process/io/mfile.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/process/io/mfile.py b/process/io/mfile.py index c343c20553..2133c828dc 100644 --- a/process/io/mfile.py +++ b/process/io/mfile.py @@ -89,12 +89,9 @@ def get_scan(self, scan_number): [single scan requested] """ - try: - if scan_number is None or scan_number == -1: - return self[f"scan{self.latest_scan:02}"] - return self[f"scan{scan_number:02}"] - except KeyError: - raise + if scan_number is None or scan_number == -1: + return self[f"scan{self.latest_scan:02}"] + return self[f"scan{scan_number:02}"] def get_scans(self): """Returns a list of scan values in order of scan number