Skip to content
Snippets Groups Projects
Commit 1879cba9 authored by Rafal Bielski's avatar Rafal Bielski :wave:
Browse files

TrigValSteering: Fix pattern matching in add_precommand

The pattern matching for adding a precommand was matching too wide string
in case similarly-formatted options followed, e.g. `'--preExec "foo" --postExec "bar"'`
could be matched instead of just `'--preExec "foo"'`. Fix this by refining the match
after the first search.
parent f90a51c6
No related branches found
No related tags found
4 merge requests!58791DataQualityConfigurations: Modify L1Calo config for web display,!46784MuonCondInterface: Enable thread-safety checking.,!46776Updated LArMonitoring config file for WD to match new files produced using MT,!43988TrigValSteering: Fix pattern matching in add_precommand
......@@ -177,9 +177,16 @@ class ExecStep(Step):
if not match:
self.args += ' {:s}"{:s}"'.format(precommand_arg_names[0], precommand)
return
opt_match = match.group(0)
# Refine the match to avoid matching '--preExec "foo" --postExec "bar"'
refine_pattern = re.compile(r'(--\w*\s*"|--\w*\s*\'|--\w*="|--\w*=\')')
refine_matches = re.findall(refine_pattern, opt_match)
if len(refine_matches) > 1:
opt_match = opt_match[0:opt_match.find(refine_matches[1])]
old_cmd_pattern = re.compile(r'(".*"|\'.*\')')
old_cmd_match = re.search(old_cmd_pattern, match.group(0))
old_cmd_match = re.search(old_cmd_pattern, opt_match)
if not old_cmd_match:
self.misconfig_abort('Failed to add precommand ' + precommand + ' to step ' + self.name)
old_cmd = old_cmd_match.group(0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment