Skip to content
Closed
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
10 changes: 10 additions & 0 deletions pyPRMS/control/ControlFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ControlFile(Control):

def __init__(self, filename: Union[str, Path],
metadata,
missing_as_default: bool=True,
verbose: Optional[bool] = False):
super(ControlFile, self).__init__(metadata=metadata, verbose=verbose)

Expand All @@ -31,6 +32,7 @@ def __init__(self, filename: Union[str, Path],

self.__verbose = verbose
self.__isloaded = False
self.__missing_as_default = missing_as_default

if isinstance(filename, str):
filename = Path(filename)
Expand Down Expand Up @@ -61,6 +63,7 @@ def _read(self):
Reads the contents of a control file into the class.
"""

vars_in_file = []
if self.__verbose:
chk_vars = []

Expand All @@ -79,6 +82,7 @@ def _read(self):
# We're dealing with a control parameter/variable
# We're in a parameter section
varname = line.split(' ')[0]
vars_in_file += [varname]

if self.__verbose:
if varname in chk_vars:
Expand Down Expand Up @@ -142,6 +146,12 @@ def _read(self):
# Hit the end of the file
continue

if not self.__missing_as_default:
ctl_vars = list(self.control_variables.keys())
for vv in ctl_vars:
if vv not in vars_in_file:
self.remove(vv)

self.header = header_tmp
self.__isloaded = True

Expand Down