Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion process/io/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
22 changes: 3 additions & 19 deletions process/io/mfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -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
Expand All @@ -94,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 # or substitute with any other exception type you want
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
Expand All @@ -112,8 +104,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
Expand Down Expand Up @@ -207,20 +197,15 @@ 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 = {}
self.des_name = []
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):
Expand All @@ -236,7 +221,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 != [""]
):
Expand Down