mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
_regex_to_static refactored to work on lists
This commit is contained in:
parent
464eef6fe1
commit
de668166f9
1 changed files with 3 additions and 2 deletions
|
@ -1718,11 +1718,12 @@ def _regex_to_static(src, regex):
|
|||
return None
|
||||
|
||||
try:
|
||||
src = re.search(regex, src, re.M)
|
||||
compiled = re.compile(regex, re.DOTALL)
|
||||
src = [res.group() for res in map(compiled.search, src) if res]
|
||||
except Exception as ex:
|
||||
raise CommandExecutionError("{0}: '{1}'".format(_get_error_message(ex), regex))
|
||||
|
||||
return src and src.group().rstrip('\r') or regex
|
||||
return src and src[0] or regex
|
||||
|
||||
|
||||
def _assert_occurrence(src, probe, target, amount=1):
|
||||
|
|
Loading…
Add table
Reference in a new issue