Skip to content

Commit

Permalink
Fix Python string escape sequences (#1554)
Browse files Browse the repository at this point in the history
Python 3.12 now warng on invalid escape sequences in strings. This
converts the strings to "raw" strings so the backslashes are treated
literally.
  • Loading branch information
swalkinshaw authored Dec 21, 2024
1 parent 0aeed2a commit 32dd18d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/trellis/plugins/callback/vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def raw_vars(self, play, host, hostvars):
if not isinstance(raw_vars, list):
raise AnsibleError('The `raw_vars` variable must be defined as a list.')

patterns = [re.sub(r'\*', '(.)*', re.sub(r'\.', '\.', var)) for var in raw_vars if var.split('.')[0] in hostvars]
keys = set(pattern.split('\.')[0] for pattern in patterns)
patterns = [re.sub(r'\*', '(.)*', re.sub(r'\.', r'\.', var)) for var in raw_vars if var.split('.')[0] in hostvars]
keys = set(pattern.split(r'\.')[0] for pattern in patterns)
for key in keys:
if key in play.vars:
play.vars[key] = self.raw_triage(key, play.vars[key], patterns)
Expand Down

0 comments on commit 32dd18d

Please sign in to comment.