mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-21 19:43:59 -07:00
Fix invalid string escape sequences.
This commit is contained in:
parent
f9cd50411f
commit
e45c763b64
48 changed files with 77 additions and 77 deletions
|
@ -327,7 +327,7 @@ class LibcloudInventory(object):
|
|||
used as Ansible groups
|
||||
'''
|
||||
|
||||
return re.sub("[^A-Za-z0-9\-]", "_", word)
|
||||
return re.sub(r"[^A-Za-z0-9\-]", "_", word)
|
||||
|
||||
def json_format_dict(self, data, pretty=False):
|
||||
'''
|
||||
|
|
|
@ -572,7 +572,7 @@ class AosInventory(object):
|
|||
- Converting to lowercase
|
||||
"""
|
||||
|
||||
rx = re.compile('\W+')
|
||||
rx = re.compile(r'\W+')
|
||||
clean_group = rx.sub('_', group_name).lower()
|
||||
|
||||
return clean_group
|
||||
|
|
|
@ -842,9 +842,9 @@ class AzureInventory(object):
|
|||
|
||||
def _to_safe(self, word):
|
||||
''' Converts 'bad' characters in a string to underscores so they can be used as Ansible groups '''
|
||||
regex = "[^A-Za-z0-9\_"
|
||||
regex = r"[^A-Za-z0-9\_"
|
||||
if not self.replace_dash_in_groups:
|
||||
regex += "\-"
|
||||
regex += r"\-"
|
||||
return re.sub(regex + "]", "_", word)
|
||||
|
||||
|
||||
|
|
|
@ -444,7 +444,7 @@ class CloudFormsInventory(object):
|
|||
Converts 'bad' characters in a string to underscores so they can be used as Ansible groups
|
||||
"""
|
||||
if self.cloudforms_clean_group_keys:
|
||||
regex = "[^A-Za-z0-9\_]"
|
||||
regex = r"[^A-Za-z0-9\_]"
|
||||
return re.sub(regex, "_", word.replace(" ", ""))
|
||||
else:
|
||||
return word
|
||||
|
|
|
@ -271,7 +271,7 @@ class CobblerInventory(object):
|
|||
def to_safe(self, word):
|
||||
""" Converts 'bad' characters in a string to underscores so they can be used as Ansible groups """
|
||||
|
||||
return re.sub("[^A-Za-z0-9\-]", "_", word)
|
||||
return re.sub(r"[^A-Za-z0-9\-]", "_", word)
|
||||
|
||||
def json_format_dict(self, data, pretty=False):
|
||||
""" Converts a dict to a JSON object and dumps it as a formatted string """
|
||||
|
|
|
@ -423,7 +423,7 @@ class CollinsInventory(object):
|
|||
""" Converts 'bad' characters in a string to underscores so they
|
||||
can be used as Ansible groups """
|
||||
|
||||
return re.sub("[^A-Za-z0-9\-]", "_", word)
|
||||
return re.sub(r"[^A-Za-z0-9\-]", "_", word)
|
||||
|
||||
def json_format_dict(self, data, pretty=False):
|
||||
""" Converts a dict to a JSON object and dumps it as a formatted string """
|
||||
|
|
|
@ -394,7 +394,7 @@ class ConsulInventory(object):
|
|||
def to_safe(self, word):
|
||||
''' Converts 'bad' characters in a string to underscores so they can be used
|
||||
as Ansible groups '''
|
||||
return re.sub('[^A-Za-z0-9\-\.]', '_', word)
|
||||
return re.sub(r'[^A-Za-z0-9\-\.]', '_', word)
|
||||
|
||||
def sanitize_dict(self, d):
|
||||
|
||||
|
|
|
@ -460,7 +460,7 @@ or environment variables (DO_API_TOKEN)\n''')
|
|||
|
||||
def to_safe(self, word):
|
||||
''' Converts 'bad' characters in a string to underscores so they can be used as Ansible groups '''
|
||||
return re.sub("[^A-Za-z0-9\-\.]", "_", word)
|
||||
return re.sub(r"[^A-Za-z0-9\-\.]", "_", word)
|
||||
|
||||
def do_namespace(self, data):
|
||||
''' Returns a copy of the dictionary with all the keys put in a 'do_' namespace '''
|
||||
|
|
|
@ -656,7 +656,7 @@ class DockerInventory(object):
|
|||
self.hostvars[name].update(facts)
|
||||
|
||||
def _slugify(self, value):
|
||||
return 'docker_%s' % (re.sub('[^\w-]', '_', value).lower().lstrip('_'))
|
||||
return 'docker_%s' % (re.sub(r'[^\w-]', '_', value).lower().lstrip('_'))
|
||||
|
||||
def get_hosts(self, config):
|
||||
'''
|
||||
|
|
|
@ -1680,9 +1680,9 @@ class Ec2Inventory(object):
|
|||
|
||||
def to_safe(self, word):
|
||||
''' Converts 'bad' characters in a string to underscores so they can be used as Ansible groups '''
|
||||
regex = "[^A-Za-z0-9\_"
|
||||
regex = r"[^A-Za-z0-9\_"
|
||||
if not self.replace_dash_in_groups:
|
||||
regex += "\-"
|
||||
regex += r"\-"
|
||||
return re.sub(regex + "]", "_", word)
|
||||
|
||||
def json_format_dict(self, data, pretty=False):
|
||||
|
|
|
@ -61,7 +61,7 @@ def get_ssh_config():
|
|||
def list_running_boxes():
|
||||
boxes = []
|
||||
for line in subprocess.check_output(["fleetctl", "list-machines"]).split('\n'):
|
||||
matcher = re.search("[^\s]+[\s]+([^\s]+).+", line)
|
||||
matcher = re.search(r"[^\s]+[\s]+([^\s]+).+", line)
|
||||
if matcher and matcher.group(1) != "IP":
|
||||
boxes.append(matcher.group(1))
|
||||
|
||||
|
|
|
@ -264,7 +264,7 @@ class ForemanInventory(object):
|
|||
>>> ForemanInventory.to_safe("foo-bar baz")
|
||||
'foo_barbaz'
|
||||
'''
|
||||
regex = "[^A-Za-z0-9\_]"
|
||||
regex = r"[^A-Za-z0-9\_]"
|
||||
return re.sub(regex, "_", word.replace(" ", ""))
|
||||
|
||||
def update_cache(self):
|
||||
|
|
|
@ -338,7 +338,7 @@ class LinodeInventory(object):
|
|||
|
||||
def to_safe(self, word):
|
||||
"""Escapes any characters that would be invalid in an ansible group name."""
|
||||
return re.sub("[^A-Za-z0-9\-]", "_", word)
|
||||
return re.sub(r"[^A-Za-z0-9\-]", "_", word)
|
||||
|
||||
def json_format_dict(self, data, pretty=False):
|
||||
"""Converts a dict to a JSON object and dumps it as a formatted string."""
|
||||
|
|
|
@ -480,9 +480,9 @@ class PacketInventory(object):
|
|||
|
||||
def to_safe(self, word):
|
||||
''' Converts 'bad' characters in a string to underscores so they can be used as Ansible groups '''
|
||||
regex = "[^A-Za-z0-9\_"
|
||||
regex = r"[^A-Za-z0-9\_"
|
||||
if not self.replace_dash_in_groups:
|
||||
regex += "\-"
|
||||
regex += r"\-"
|
||||
return re.sub(regex + "]", "_", word)
|
||||
|
||||
def json_format_dict(self, data, pretty=False):
|
||||
|
|
|
@ -189,7 +189,7 @@ p = load_config_file()
|
|||
|
||||
|
||||
def rax_slugify(value):
|
||||
return 'rax_%s' % (re.sub('[^\w-]', '_', value).lower().lstrip('_'))
|
||||
return 'rax_%s' % (re.sub(r'[^\w-]', '_', value).lower().lstrip('_'))
|
||||
|
||||
|
||||
def to_dict(obj):
|
||||
|
|
|
@ -292,7 +292,7 @@ class RudderInventory(object):
|
|||
''' Converts 'bad' characters in a string to underscores so they can be
|
||||
used as Ansible variable names '''
|
||||
|
||||
return re.sub('[^A-Za-z0-9\_]', '_', word)
|
||||
return re.sub(r'[^A-Za-z0-9\_]', '_', word)
|
||||
|
||||
# Run the script
|
||||
RudderInventory()
|
||||
|
|
|
@ -91,7 +91,7 @@ class SoftLayerInventory(object):
|
|||
def to_safe(self, word):
|
||||
'''Converts 'bad' characters in a string to underscores so they can be used as Ansible groups'''
|
||||
|
||||
return re.sub("[^A-Za-z0-9\-\.]", "_", word)
|
||||
return re.sub(r"[^A-Za-z0-9\-\.]", "_", word)
|
||||
|
||||
def push(self, my_dict, key, element):
|
||||
'''Push an element onto an array that may not have been defined in the dict'''
|
||||
|
|
|
@ -79,7 +79,7 @@ def list_running_boxes():
|
|||
boxes = []
|
||||
|
||||
for line in output:
|
||||
matcher = re.search("([^\s]+)[\s]+running \(.+", line)
|
||||
matcher = re.search(r"([^\s]+)[\s]+running \(.+", line)
|
||||
if matcher:
|
||||
boxes.append(matcher.group(1))
|
||||
|
||||
|
|
|
@ -271,7 +271,7 @@ class AzureInventory(object):
|
|||
|
||||
def to_safe(self, word):
|
||||
"""Escapes any characters that would be invalid in an ansible group name."""
|
||||
return re.sub("[^A-Za-z0-9\-]", "_", word)
|
||||
return re.sub(r"[^A-Za-z0-9\-]", "_", word)
|
||||
|
||||
def json_format_dict(self, data, pretty=False):
|
||||
"""Converts a dict to a JSON object and dumps it as a formatted string."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue