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

Make the conversion script exit early if include statements are found in the XML inputs #148

Merged
merged 2 commits into from
Nov 2, 2023
Merged
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
15 changes: 11 additions & 4 deletions k4MarlinWrapper/scripts/convertMarlinSteeringToGaudi.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ def convertConstants(lines, tree):
""" Find constant tags, write them to python and replace constants within themselves """
constants = dict()

constElements = tree.findall('constants/include')
if constElements:
print('WARNING: include statements found inside constants tag')

constElements = tree.findall('constants/constant')
for const in constElements:
constants[const.attrib.get('name')] = getValue(const)
Expand Down Expand Up @@ -249,7 +245,18 @@ def convertProcessors(lines, tree, globParams, constants):
return lines


def findWarnIncludes(tree):
"""Check the parsed XML structure for include statments and issue a warning"""
if any(True for _ in tree.iter("include")):
print("ERROR: Found at least one <include ref=\"...\"/> statement in the Marlin steering file")
print(" These cannot be handled by the conversion script.")
print(" Use Marlin -n <input-file> to resolve these includes and convert the output of that")

sys.exit(1)


def generateGaudiSteering(tree):
findWarnIncludes(tree)
globParams = getGlobalParameters(tree)
lines = []
createHeader(lines)
Expand Down
Loading