From 2e2087ace28e936bba4264afbe5dc5f3e6e21d41 Mon Sep 17 00:00:00 2001 From: tmadlener Date: Thu, 5 Oct 2023 11:19:16 +0200 Subject: [PATCH 1/2] Warn if any unresolved include statement is found --- .../scripts/convertMarlinSteeringToGaudi.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/k4MarlinWrapper/scripts/convertMarlinSteeringToGaudi.py b/k4MarlinWrapper/scripts/convertMarlinSteeringToGaudi.py index 5413bce4..d0bfcf8c 100755 --- a/k4MarlinWrapper/scripts/convertMarlinSteeringToGaudi.py +++ b/k4MarlinWrapper/scripts/convertMarlinSteeringToGaudi.py @@ -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) @@ -249,7 +245,16 @@ 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("WARNING: Found at least one statement in the Marlin steering file") + print(" These cannot be handled by the conversion script.") + print(" Use Marlin -n to resolve these includes and convert the output of that") + + def generateGaudiSteering(tree): + findWarnIncludes(tree) globParams = getGlobalParameters(tree) lines = [] createHeader(lines) From c5925432feb34550dd5b86d49c07587215c311bf Mon Sep 17 00:00:00 2001 From: tmadlener Date: Wed, 1 Nov 2023 15:42:20 +0100 Subject: [PATCH 2/2] Make warning an error and exit --- k4MarlinWrapper/scripts/convertMarlinSteeringToGaudi.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/k4MarlinWrapper/scripts/convertMarlinSteeringToGaudi.py b/k4MarlinWrapper/scripts/convertMarlinSteeringToGaudi.py index d0bfcf8c..0923a2be 100755 --- a/k4MarlinWrapper/scripts/convertMarlinSteeringToGaudi.py +++ b/k4MarlinWrapper/scripts/convertMarlinSteeringToGaudi.py @@ -248,9 +248,11 @@ def convertProcessors(lines, tree, globParams, constants): def findWarnIncludes(tree): """Check the parsed XML structure for include statments and issue a warning""" if any(True for _ in tree.iter("include")): - print("WARNING: Found at least one statement in the Marlin steering file") - print(" These cannot be handled by the conversion script.") - print(" Use Marlin -n to resolve these includes and convert the output of that") + print("ERROR: Found at least one statement in the Marlin steering file") + print(" These cannot be handled by the conversion script.") + print(" Use Marlin -n to resolve these includes and convert the output of that") + + sys.exit(1) def generateGaudiSteering(tree):