mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Fix anomalous backslashes and enable pylint test.
This commit is contained in:
@@ -123,7 +123,7 @@ def map_config_to_obj(module):
|
||||
'show running-config | begin banner %s'
|
||||
% module.params['banner'])
|
||||
if out:
|
||||
output = re.search('\^C(.*)\^C', out, re.S).group(1).strip()
|
||||
output = re.search(r'\^C(.*)\^C', out, re.S).group(1).strip()
|
||||
else:
|
||||
output = None
|
||||
obj = {'banner': module.params['banner'], 'state': 'absent'}
|
||||
|
||||
@@ -188,8 +188,8 @@ def parse_ping(ping_stats):
|
||||
Example: "Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/8 ms"
|
||||
Returns the percent of packet loss, recieved packets, transmitted packets, and RTT dict.
|
||||
"""
|
||||
rate_re = re.compile("^\w+\s+\w+\s+\w+\s+(?P<pct>\d+)\s+\w+\s+\((?P<rx>\d+)\/(?P<tx>\d+)\)")
|
||||
rtt_re = re.compile(".*,\s+\S+\s+\S+\s+=\s+(?P<min>\d+)\/(?P<avg>\d+)\/(?P<max>\d+)\s+\w+\s*$|.*\s*$")
|
||||
rate_re = re.compile(r"^\w+\s+\w+\s+\w+\s+(?P<pct>\d+)\s+\w+\s+\((?P<rx>\d+)/(?P<tx>\d+)\)")
|
||||
rtt_re = re.compile(r".*,\s+\S+\s+\S+\s+=\s+(?P<min>\d+)/(?P<avg>\d+)/(?P<max>\d+)\s+\w+\s*$|.*\s*$")
|
||||
|
||||
rate = rate_re.match(ping_stats)
|
||||
rtt = rtt_re.match(ping_stats)
|
||||
|
||||
@@ -130,7 +130,7 @@ def has_vrf(module, vrf):
|
||||
if _CONFIGURED_VRFS is not None:
|
||||
return vrf in _CONFIGURED_VRFS
|
||||
config = get_config(module)
|
||||
_CONFIGURED_VRFS = re.findall('vrf definition (\S+)', config)
|
||||
_CONFIGURED_VRFS = re.findall(r'vrf definition (\S+)', config)
|
||||
return vrf in _CONFIGURED_VRFS
|
||||
|
||||
def requires_vrf(module, vrf):
|
||||
@@ -244,11 +244,11 @@ def map_obj_to_commands(want, have, module):
|
||||
return commands
|
||||
|
||||
def parse_hostname(config):
|
||||
match = re.search('^hostname (\S+)', config, re.M)
|
||||
match = re.search(r'^hostname (\S+)', config, re.M)
|
||||
return match.group(1)
|
||||
|
||||
def parse_domain_name(config):
|
||||
match = re.findall('^ip domain name (?:vrf (\S+) )*(\S+)', config, re.M)
|
||||
match = re.findall(r'^ip domain name (?:vrf (\S+) )*(\S+)', config, re.M)
|
||||
matches = list()
|
||||
for vrf, name in match:
|
||||
if not vrf:
|
||||
@@ -257,7 +257,7 @@ def parse_domain_name(config):
|
||||
return matches
|
||||
|
||||
def parse_domain_search(config):
|
||||
match = re.findall('^ip domain list (?:vrf (\S+) )*(\S+)', config, re.M)
|
||||
match = re.findall(r'^ip domain list (?:vrf (\S+) )*(\S+)', config, re.M)
|
||||
matches = list()
|
||||
for vrf, name in match:
|
||||
if not vrf:
|
||||
@@ -266,7 +266,7 @@ def parse_domain_search(config):
|
||||
return matches
|
||||
|
||||
def parse_name_servers(config):
|
||||
match = re.findall('^ip name-server (?:vrf (\S+) )*(.*)', config, re.M)
|
||||
match = re.findall(r'^ip name-server (?:vrf (\S+) )*(.*)', config, re.M)
|
||||
matches = list()
|
||||
for vrf, servers in match:
|
||||
if not vrf:
|
||||
@@ -276,7 +276,7 @@ def parse_name_servers(config):
|
||||
return matches
|
||||
|
||||
def parse_lookup_source(config):
|
||||
match = re.search('ip domain lookup source-interface (\S+)', config, re.M)
|
||||
match = re.search(r'ip domain lookup source-interface (\S+)', config, re.M)
|
||||
if match:
|
||||
return match.group(1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user