Merge ~xypron/maas-images:re into maas-images:master

Proposed by Heinrich Schuchardt
Status: Merged
Merged at revision: a10617c7088754e5548ebc4e131ca972d5b0e602
Proposed branch: ~xypron/maas-images:re
Merge into: maas-images:master
Diff against target: 35 lines (+3/-3)
2 files modified
curtin/centos6/curtin-hooks.py (+2/-2)
meph2/commands/dpkg.py (+1/-1)
Reviewer Review Type Date Requested Status
Alexsander de Souza Approve
Review via email: mp+462556@code.launchpad.net

Commit message

Avoid invalid escape sequences in strings

Use raw strings for regular expressions to avoid errors like:

    SyntaxWarning: invalid escape sequence '\s'

To post a comment you must log in.
Revision history for this message
Alexsander de Souza (alexsander-souza) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/curtin/centos6/curtin-hooks.py b/curtin/centos6/curtin-hooks.py
2index 6720839..109e010 100755
3--- a/curtin/centos6/curtin-hooks.py
4+++ b/curtin/centos6/curtin-hooks.py
5@@ -119,7 +119,7 @@ def write_fstab(target, curtin_fstab):
6 def extract_kernel_params(data):
7 """Extracts the kernel parametes from the provided
8 grub config data."""
9- match = re.search('^\s+kernel (.+?)$', data, re.MULTILINE)
10+ match = re.search(r'^\s+kernel (.+?)$', data, re.MULTILINE)
11 return match.group(0)
12
13
14@@ -204,7 +204,7 @@ def get_grub_root(target):
15 ]).encode('utf-8')
16 out, err = in_chroot(['grub', '--batch'],
17 data=data, capture=True)
18- regex = re.search('^\s+(\(.+?\))$', out, re.MULTILINE)
19+ regex = re.search(r'^\s+(\(.+?\))$', out, re.MULTILINE)
20 return regex.groups()[0]
21
22
23diff --git a/meph2/commands/dpkg.py b/meph2/commands/dpkg.py
24index 47ab883..b2e1467 100644
25--- a/meph2/commands/dpkg.py
26+++ b/meph2/commands/dpkg.py
27@@ -84,7 +84,7 @@ def get_packages(base_url, component, architecture, pkg_name):
28 pkg_data = geturl(packages_url)
29 regex_path = re.escape(path)
30 sha256sum = re.search(
31- ("^\s*?([a-fA-F0-9]{64})\s*[0-9]+\s+%s$" % regex_path).encode('utf-8'),
32+ (r"^\s*?([a-fA-F0-9]{64})\s*[0-9]+\s+%s$" % regex_path).encode('utf-8'),
33 release_file,
34 re.MULTILINE).group(1)
35 if get_sha256(pkg_data).encode('utf-8') != sha256sum:

Subscribers

People subscribed via source and target branches