Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capgen cleanup #493

Merged
merged 9 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions scripts/ccpp_database_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, message):
super().__init__(message)

class CCPPDatabaseObj:
"""Ojbect with data and methods to provide information from a run of capgen.
"""Object with data and methods to provide information from a run of capgen.
"""

def __init__(self, run_env, host_model=None, api=None, database_file=None):
Expand Down Expand Up @@ -56,7 +56,7 @@ def db_from_file(self, run_env, database_file):
datatable.xml file created by capgen.
"""
metadata_tables = {}
host_name = "cam"
host_name = "host"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

self.__host_model = HostModel(metadata_tables, host_name, run_env)
self.__api = API(sdfs, host_model, scheme_headers, run_env)
raise CCPPDatabaseObjError("ERROR: <database_file> not supported")
Expand Down
10 changes: 4 additions & 6 deletions scripts/metavar.py
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,7 @@ def __init__(self, name, run_env, variables=None,
self[stdname] = variables[key]
# end for
elif variables is not None:
raise ParseInternalError('Illegal type for variables, {} in {}'.format(type_name(variables), self.name))
raise ParseInternalError(f'Illegal type for variables, {type_name(variables)} in {self.name}')
# end if

@property
Expand Down Expand Up @@ -1623,15 +1623,13 @@ def add_variable_dimensions(self, var, ignore_sources, to_dict=None,
else:
ctx = context_string(var.context)
# end if
err_ret += "{}: ".format(self.name)
err_ret += "Cannot find variable for dimension, {}, of {}{}"
vstdname = var.get_prop_value('standard_name')
err_ret = err_ret.format(dimname, vstdname, ctx)
err_ret += f"{self.name}: "
err_ret += f"Cannot find variable for dimension, {dimname}, of {vstdname}{ctx}"
if dvar:
err_ret += "\nFound {} from excluded source, '{}'{}"
err_ret += f"\nFound {lname} from excluded source, '{dvar.source.ptype}'{dctx}"
lname = dvar.get_prop_value('local_name')
dctx = context_string(dvar.context)
err_ret = err_ret.format(lname, dvar.source.ptype, dctx)
# end if
# end if
# end if
Expand Down
8 changes: 7 additions & 1 deletion scripts/parse_tools/parse_checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@

########################################################################

_UNITS_RE = re.compile(r"^[^/!@#$%^&*=()\|<>\[\]{}?,.]+$")
_UNITLESS_REGEX = "1"
_NON_LEADING_ZERO_NUM = "[1-9]\d*"
_NEGATIVE_NON_LEADING_ZERO_NUM = f"[-]{_NON_LEADING_ZERO_NUM}"
_UNIT_EXPONENT = f"({_NEGATIVE_NON_LEADING_ZERO_NUM}|{_NON_LEADING_ZERO_NUM})"
_UNIT_REGEX = f"[a-zA-Z]+{_UNIT_EXPONENT}?"
_UNITS_REGEX = f"^({_UNIT_REGEX}(\s{_UNIT_REGEX})*|{_UNITLESS_REGEX})$"
_UNITS_RE = re.compile(_UNITS_REGEX)

def check_units(test_val, prop_dict, error):
"""Return <test_val> if a valid unit, otherwise, None
Expand Down