From 0bf130077cb3d35b133ef00e5dec2483bf2c68d3 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Sat, 7 Nov 2020 17:41:09 -0500 Subject: [PATCH] Lint: W605 invalid escape sequence '' The previous attempt to correct these with character classes failed. Instead, use the proper `r'blah'` regex formatting. --- api-daemon/pvcapid/ova.py | 6 +++--- api-daemon/pvcapid/provisioner.py | 16 ++++++++-------- client-cli/pvc.py | 18 +++++++++--------- daemon-common/ceph.py | 14 +++++++------- daemon-common/network.py | 8 ++++---- daemon-common/vm.py | 4 ++-- 6 files changed, 33 insertions(+), 33 deletions(-) diff --git a/api-daemon/pvcapid/ova.py b/api-daemon/pvcapid/ova.py index af48c19f..264b3edc 100755 --- a/api-daemon/pvcapid/ova.py +++ b/api-daemon/pvcapid/ova.py @@ -70,11 +70,11 @@ def list_ova(limit, is_fuzzy=True): if limit: if is_fuzzy: # Handle fuzzy vs. non-fuzzy limits - if not re.match('\^.*', limit): + if not re.match(r'\^.*', limit): limit = '%' + limit else: limit = limit[1:] - if not re.match('.*\$', limit): + if not re.match(r'.*\$', limit): limit = limit + '%' else: limit = limit[:-1] @@ -252,7 +252,7 @@ def upload_ova(pool, name, ova_size): return output, retcode # Parse through the members list and extract the OVF file - for element in set(x for x in members if re.match('.*\.ovf$', x.name)): + for element in set(x for x in members if re.match(r'.*\.ovf$', x.name)): ovf_file = ova_archive.extractfile(element) # Parse the OVF file to get our VM details diff --git a/api-daemon/pvcapid/provisioner.py b/api-daemon/pvcapid/provisioner.py index 095fa989..89028ff1 100755 --- a/api-daemon/pvcapid/provisioner.py +++ b/api-daemon/pvcapid/provisioner.py @@ -106,11 +106,11 @@ def list_template(limit, table, is_fuzzy=True): if limit: if is_fuzzy: # Handle fuzzy vs. non-fuzzy limits - if not re.match('\^.*', limit): + if not re.match(r'\^.*', limit): limit = '%' + limit else: limit = limit[1:] - if not re.match('.*\$', limit): + if not re.match(r'.*\$', limit): limit = limit + '%' else: limit = limit[:-1] @@ -606,11 +606,11 @@ def list_userdata(limit, is_fuzzy=True): if limit: if is_fuzzy: # Handle fuzzy vs. non-fuzzy limits - if not re.match('\^.*', limit): + if not re.match(r'\^.*', limit): limit = '%' + limit else: limit = limit[1:] - if not re.match('.*\$', limit): + if not re.match(r'.*\$', limit): limit = limit + '%' else: limit = limit[:-1] @@ -701,11 +701,11 @@ def list_script(limit, is_fuzzy=True): if limit: if is_fuzzy: # Handle fuzzy vs. non-fuzzy limits - if not re.match('\^.*', limit): + if not re.match(r'\^.*', limit): limit = '%' + limit else: limit = limit[1:] - if not re.match('.*\$', limit): + if not re.match(r'.*\$', limit): limit = limit + '%' else: limit = limit[:-1] @@ -796,11 +796,11 @@ def list_profile(limit, is_fuzzy=True): if limit: if is_fuzzy: # Handle fuzzy vs. non-fuzzy limits - if not re.match('\^.*', limit): + if not re.match(r'\^.*', limit): limit = '%' + limit else: limit = limit[1:] - if not re.match('.*\$', limit): + if not re.match(r'.*\$', limit): limit = limit + '%' else: limit = limit[:-1] diff --git a/client-cli/pvc.py b/client-cli/pvc.py index 22bf492d..d5ba4caf 100755 --- a/client-cli/pvc.py +++ b/client-cli/pvc.py @@ -733,11 +733,11 @@ def vm_modify(domain, cfgfile, editor, restart): click.echo('') diff = list(difflib.unified_diff(current_vm_cfgfile.split('\n'), new_vm_cfgfile.split('\n'), fromfile='current', tofile='modified', fromfiledate='', tofiledate='', n=3, lineterm='')) for line in diff: - if re.match('^\+', line) is not None: + if re.match(r'^\+', line) is not None: click.echo(colorama.Fore.GREEN + line + colorama.Fore.RESET) - elif re.match('^\-', line) is not None: + elif re.match(r'^\-', line) is not None: click.echo(colorama.Fore.RED + line + colorama.Fore.RESET) - elif re.match('^\^', line) is not None: + elif re.match(r'^\^', line) is not None: click.echo(colorama.Fore.BLUE + line + colorama.Fore.RESET) else: click.echo(line) @@ -3039,11 +3039,11 @@ def provisioner_userdata_modify(name, filename, editor): click.echo('') diff = list(difflib.unified_diff(current_userdata.split('\n'), new_userdata.split('\n'), fromfile='current', tofile='modified', fromfiledate='', tofiledate='', n=3, lineterm='')) for line in diff: - if re.match('^\+', line) is not None: + if re.match(r'^\+', line) is not None: click.echo(colorama.Fore.GREEN + line + colorama.Fore.RESET) - elif re.match('^\-', line) is not None: + elif re.match(r'^\-', line) is not None: click.echo(colorama.Fore.RED + line + colorama.Fore.RESET) - elif re.match('^\^', line) is not None: + elif re.match(r'^\^', line) is not None: click.echo(colorama.Fore.BLUE + line + colorama.Fore.RESET) else: click.echo(line) @@ -3224,11 +3224,11 @@ def provisioner_script_modify(name, filename, editor): click.echo('') diff = list(difflib.unified_diff(current_script.split('\n'), new_script.split('\n'), fromfile='current', tofile='modified', fromfiledate='', tofiledate='', n=3, lineterm='')) for line in diff: - if re.match('^\+', line) is not None: + if re.match(r'^\+', line) is not None: click.echo(colorama.Fore.GREEN + line + colorama.Fore.RESET) - elif re.match('^\-', line) is not None: + elif re.match(r'^\-', line) is not None: click.echo(colorama.Fore.RED + line + colorama.Fore.RESET) - elif re.match('^\^', line) is not None: + elif re.match(r'^\^', line) is not None: click.echo(colorama.Fore.BLUE + line + colorama.Fore.RESET) else: click.echo(line) diff --git a/daemon-common/ceph.py b/daemon-common/ceph.py index 73fa32d4..9e991c1b 100644 --- a/daemon-common/ceph.py +++ b/daemon-common/ceph.py @@ -118,7 +118,7 @@ def format_bytes_fromhuman(datahuman): # Trim off human-readable character dataunit = str(datahuman)[-1] datasize = int(str(datahuman)[:-1]) - if not re.match('[A-Z]', dataunit): + if not re.match(r'[A-Z]', dataunit): dataunit = 'B' datasize = int(datahuman) databytes = datasize * byte_unit_matrix[dataunit] @@ -322,9 +322,9 @@ def get_list_osd(zk_conn, limit, is_fuzzy=True): if is_fuzzy and limit: # Implicitly assume fuzzy limits - if not re.match('\^.*', limit): + if not re.match(r'\^.*', limit): limit = '.*' + limit - if not re.match('.*\$', limit): + if not re.match(r'.*\$', limit): limit = limit + '.*' for osd in full_osd_list: @@ -658,9 +658,9 @@ def get_list_volume(zk_conn, pool, limit, is_fuzzy=True): limit = '^' + limit + '$' else: # Implicitly assume fuzzy limits - if not re.match('\^.*', limit): + if not re.match(r'\^.*', limit): limit = '.*' + limit - if not re.match('.*\$', limit): + if not re.match(r'.*\$', limit): limit = limit + '.*' for volume in full_volume_list: @@ -764,9 +764,9 @@ def get_list_snapshot(zk_conn, pool, volume, limit, is_fuzzy=True): if is_fuzzy and limit: # Implicitly assume fuzzy limits - if not re.match('\^.*', limit): + if not re.match(r'\^.*', limit): limit = '.*' + limit - if not re.match('.*\$', limit): + if not re.match(r'.*\$', limit): limit = limit + '.*' for snapshot in full_snapshot_list: diff --git a/daemon-common/network.py b/daemon-common/network.py index a727c53a..bb30ec72 100644 --- a/daemon-common/network.py +++ b/daemon-common/network.py @@ -574,9 +574,9 @@ def get_list_dhcp(zk_conn, network, limit, only_static=False, is_fuzzy=True): limit = '^' + limit + '$' # Implcitly assume fuzzy limits - if not re.match('\^.*', limit): + if not re.match(r'\^.*', limit): limit = '.*' + limit - if not re.match('.*\$', limit): + if not re.match(r'.*\$', limit): limit = limit + '.*' except Exception as e: return False, 'Regex Error: {}'.format(e) @@ -620,9 +620,9 @@ def get_list_acl(zk_conn, network, limit, direction, is_fuzzy=True): limit = '^' + limit + '$' # Implcitly assume fuzzy limits - if not re.match('\^.*', limit): + if not re.match(r'\^.*', limit): limit = '.*' + limit - if not re.match('.*\$', limit): + if not re.match(r'.*\$', limit): limit = limit + '.*' except Exception as e: return False, 'Regex Error: {}'.format(e) diff --git a/daemon-common/vm.py b/daemon-common/vm.py index 6d948a4d..bb9191bf 100644 --- a/daemon-common/vm.py +++ b/daemon-common/vm.py @@ -689,9 +689,9 @@ def get_list(zk_conn, node, state, limit, is_fuzzy=True): if limit and is_fuzzy: try: # Implcitly assume fuzzy limits - if not re.match('\^.*', limit): + if not re.match(r'\^.*', limit): limit = '.*' + limit - if not re.match('.*\$', limit): + if not re.match(r'.*\$', limit): limit = limit + '.*' except Exception as e: return False, 'Regex Error: {}'.format(e)