From: Christian Herdtweck Date: Mon, 30 Sep 2024 08:58:04 +0000 (+0200) Subject: Fix regular expressions for cnfvar X-Git-Tag: v1.7.3~1^2~1 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=ce076b05be7ae9f3ba5ec707904bf8f1d758ca13;p=pyi2ncommon Fix regular expressions for cnfvar New unittest checks noticed missing backslashes. --- diff --git a/src/cnfvar/string.py b/src/cnfvar/string.py index b59058c..7b8f5aa 100644 --- a/src/cnfvar/string.py +++ b/src/cnfvar/string.py @@ -70,7 +70,7 @@ CNF_FIELD_MANDATORY = set ([ "varname", "data", "instance" ]) CNF_FIELD_OPTIONAL = set ([ "parent", "children", "comment", "number" ]) CNF_FIELD_KNOWN = CNF_FIELD_MANDATORY | CNF_FIELD_OPTIONAL -grab_parent_pattern = re.compile(b""" +grab_parent_pattern = re.compile(rb""" ^ # match from start \s* # optional spaces \d+ # line number @@ -79,7 +79,7 @@ grab_parent_pattern = re.compile(b""" """, re.VERBOSE) -base_line_pattern = re.compile(b""" +base_line_pattern = re.compile(rb""" ^ # match from start \s* # optional spaces (\d+) # line number @@ -106,7 +106,7 @@ base_line_pattern = re.compile(b""" """, re.VERBOSE) -child_line_pattern = re.compile(b""" +child_line_pattern = re.compile(rb""" ^ # match from start \s* # optional spaces (\d+) # line number diff --git a/test/cnfvar/test_string.py b/test/cnfvar/test_string.py index 4501196..e61e0f3 100755 --- a/test/cnfvar/test_string.py +++ b/test/cnfvar/test_string.py @@ -133,7 +133,7 @@ demo_cnf_comments = b""" 8 (1) EMAILFILTER_BAN_FILTERLIST_PREDEFINED_ID,0: "1" """ -demo_cnf_escaped_quotes = """ +demo_cnf_escaped_quotes = r""" 1 HERE_BE_QUOTES,0: "\"" 2 HERE_BE_QUOTES,1: "foo\"bar\"\"\"baz" 3 HERE_BE_QUOTES,2: "unquo\\\"table"