Fix regular expressions for cnfvar
authorChristian Herdtweck <christian.herdtweck@intra2net.com>
Mon, 30 Sep 2024 08:58:04 +0000 (10:58 +0200)
committerChristian Herdtweck <christian.herdtweck@intra2net.com>
Mon, 30 Sep 2024 09:08:14 +0000 (11:08 +0200)
New unittest checks noticed missing backslashes.

src/cnfvar/string.py
test/cnfvar/test_string.py

index b59058c..7b8f5aa 100644 (file)
@@ -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
index 4501196..e61e0f3 100755 (executable)
@@ -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"