Fix anomalous backslashes and enable pylint test.

This commit is contained in:
Matt Clay
2017-11-21 22:22:40 -08:00
parent 9735a70059
commit c6bb6c72cc
30 changed files with 76 additions and 77 deletions

View File

@@ -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'}

View File

@@ -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)

View File

@@ -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)