Skip to content

Commit

Permalink
verify function Args in builder2ibek
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Sep 24, 2023
1 parent a43a165 commit b6a6ca4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"type": "python",
"python": "/dls_sw/prod/tools/RHEL7-x86_64/defaults/bin/dls-python",
"request": "launch",
"program": "dls_builder_conversion/builder2ibek.support.py",
"program": "builder2ibek.support.py",
"console": "integratedTerminal",
"args": [
"/dls_sw/prod/R3.14.12.7/support/ADSimDetector/2-9dls1/",
"/dls_sw/prod/R3.14.12.7/support/pmac/2-5-22/",
],
"justMyCode": false
},
Expand Down
9 changes: 8 additions & 1 deletion builder2ibek.support.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def _extract_substitutions(self, name):
missing = set(database["args"].keys()) - set(self.def_args[name])
if len(missing) > 0:
missed = ", ".join(missing)
database["warning"] = "MACROS missing from args: " + missed
database["warning"] = "Database Args missing: " + missed
return databases

def _make_init_script(
Expand All @@ -273,15 +273,22 @@ def _make_init_script(
func_text = inspect.getsource(func)
print_strings = func_text.split("print")[1:]

command_args = []

commands = ""
for print_string in print_strings:
matches = extract_printed_strings_re.findall(print_string)
if matches:
command_args += macros_re.findall(matches[0][1])
line = macros_re.sub(macro_to_jinja_re, matches[0][1])
commands += line + "\n"
if commands:
script_item["value"] = PreservedScalarString(commands)
script.append(script_item)
missing = set(command_args) - set(self.def_args[name])
if len(missing) > 0:
missed = ", ".join(missing)
script_item["warning"] = "function Args missing: " + missed

def _call_initialise(self, builder_object, name):
"""
Expand Down

0 comments on commit b6a6ca4

Please sign in to comment.