mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
Fix invalid string escape sequences.
This commit is contained in:
@@ -137,7 +137,7 @@ from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
def parse_out(string):
|
||||
return re.sub("\s+", " ", string).strip()
|
||||
return re.sub(r"\s+", " ", string).strip()
|
||||
|
||||
|
||||
def has_changed(string):
|
||||
|
||||
@@ -220,7 +220,7 @@ class Npm(object):
|
||||
if dep:
|
||||
# node.js v0.10.22 changed the `npm outdated` module separator
|
||||
# from "@" to " ". Split on both for backwards compatibility.
|
||||
pkg, other = re.split('\s|@', dep, 1)
|
||||
pkg, other = re.split(r'\s|@', dep, 1)
|
||||
outdated.append(pkg)
|
||||
|
||||
return outdated
|
||||
|
||||
@@ -150,7 +150,7 @@ from ansible.module_utils.basic import AnsibleModule
|
||||
def parse_for_packages(stdout):
|
||||
packages = []
|
||||
data = stdout.split('\n')
|
||||
regex = re.compile('^\(\d+/\d+\)\s+\S+\s+(\S+)')
|
||||
regex = re.compile(r'^\(\d+/\d+\)\s+\S+\s+(\S+)')
|
||||
for l in data:
|
||||
p = regex.search(l)
|
||||
if p:
|
||||
|
||||
@@ -208,8 +208,8 @@ class SourcesList(object):
|
||||
return s
|
||||
|
||||
# Drop options and protocols.
|
||||
line = re.sub('\[[^\]]+\]', '', line)
|
||||
line = re.sub('\w+://', '', line)
|
||||
line = re.sub(r'\[[^\]]+\]', '', line)
|
||||
line = re.sub(r'\w+://', '', line)
|
||||
|
||||
# split line into valid keywords
|
||||
parts = [part for part in line.split() if part not in VALID_SOURCE_TYPES]
|
||||
|
||||
@@ -235,7 +235,7 @@ def package_present(names, pkg_spec, module):
|
||||
# "file:/local/package/directory/ is empty" message on stderr
|
||||
# while still installing the package, so we need to look for
|
||||
# for a message like "packagename-1.0: ok" just in case.
|
||||
match = re.search("\W%s-[^:]+: ok\W" % pkg_spec[name]['stem'], pkg_spec[name]['stdout'])
|
||||
match = re.search(r"\W%s-[^:]+: ok\W" % pkg_spec[name]['stem'], pkg_spec[name]['stdout'])
|
||||
|
||||
if match:
|
||||
# It turns out we were able to install the package.
|
||||
@@ -286,7 +286,7 @@ def package_latest(names, pkg_spec, module):
|
||||
pkg_spec[name]['changed'] = False
|
||||
for installed_name in pkg_spec[name]['installed_names']:
|
||||
module.debug("package_latest(): checking for pre-upgrade package name: %s" % installed_name)
|
||||
match = re.search("\W%s->.+: ok\W" % installed_name, pkg_spec[name]['stdout'])
|
||||
match = re.search(r"\W%s->.+: ok\W" % installed_name, pkg_spec[name]['stdout'])
|
||||
if match:
|
||||
module.debug("package_latest(): pre-upgrade package name match: %s" % installed_name)
|
||||
|
||||
@@ -502,7 +502,7 @@ def upgrade_packages(pkg_spec, module):
|
||||
|
||||
# Try to find any occurrence of a package changing version like:
|
||||
# "bzip2-1.0.6->1.0.6p0: ok".
|
||||
match = re.search("\W\w.+->.+: ok\W", pkg_spec['*']['stdout'])
|
||||
match = re.search(r"\W\w.+->.+: ok\W", pkg_spec['*']['stdout'])
|
||||
if match:
|
||||
pkg_spec['*']['changed'] = True
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ def upgrade(module, pacman_path):
|
||||
}
|
||||
|
||||
if rc == 0:
|
||||
regex = re.compile('([\w-]+) ((?:\S+)-(?:\S+)) -> ((?:\S+)-(?:\S+))')
|
||||
regex = re.compile(r'([\w-]+) ((?:\S+)-(?:\S+)) -> ((?:\S+)-(?:\S+))')
|
||||
for p in data:
|
||||
m = regex.search(p)
|
||||
packages.append(m.group(1))
|
||||
@@ -419,11 +419,11 @@ def main():
|
||||
for i, pkg in enumerate(pkgs):
|
||||
if not pkg: # avoid empty strings
|
||||
continue
|
||||
elif re.match(".*\.pkg\.tar(\.(gz|bz2|xz|lrz|lzo|Z))?$", pkg):
|
||||
elif re.match(r".*\.pkg\.tar(\.(gz|bz2|xz|lrz|lzo|Z))?$", pkg):
|
||||
# The package given is a filename, extract the raw pkg name from
|
||||
# it and store the filename
|
||||
pkg_files.append(pkg)
|
||||
pkgs[i] = re.sub('-[0-9].*$', '', pkgs[i].split('/')[-1])
|
||||
pkgs[i] = re.sub(r'-[0-9].*$', '', pkgs[i].split('/')[-1])
|
||||
else:
|
||||
pkg_files.append(None)
|
||||
|
||||
|
||||
@@ -95,8 +95,8 @@ def main():
|
||||
# Try to spot where this has happened and fix it.
|
||||
for fragment in params['name']:
|
||||
if (
|
||||
re.search('^\d+(?:\.\d+)*', fragment)
|
||||
and packages and re.search('@[^,]*$', packages[-1])
|
||||
re.search(r'^\d+(?:\.\d+)*', fragment)
|
||||
and packages and re.search(r'@[^,]*$', packages[-1])
|
||||
):
|
||||
packages[-1] += ',' + fragment
|
||||
else:
|
||||
|
||||
@@ -231,7 +231,7 @@ def codex_list(module):
|
||||
if rc != 0:
|
||||
module.fail_json(msg="unable to list grimoire collection, fix your Codex")
|
||||
|
||||
rex = re.compile("^\s*\[\d+\] : (?P<grim>[\w\-\+\.]+) : [\w\-\+\./]+(?: : (?P<ver>[\w\-\+\.]+))?\s*$")
|
||||
rex = re.compile(r"^\s*\[\d+\] : (?P<grim>[\w\-+.]+) : [\w\-+./]+(?: : (?P<ver>[\w\-+.]+))?\s*$")
|
||||
|
||||
# drop 4-line header and empty trailing line
|
||||
for line in stdout.splitlines()[4:-1]:
|
||||
|
||||
@@ -102,7 +102,7 @@ def query_package(module, name, depot=None):
|
||||
else:
|
||||
rc, stdout, stderr = module.run_command("%s %s | grep %s" % (cmd_list, pipes.quote(name), pipes.quote(name)), use_unsafe_shell=True)
|
||||
if rc == 0:
|
||||
version = re.sub("\s\s+|\t" , " ", stdout).strip().split()[1]
|
||||
version = re.sub(r"\s\s+|\t", " ", stdout).strip().split()[1]
|
||||
else:
|
||||
version = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user