| 1 |
Origin: https://github.com/simoncozens/fontFeatures/pull/73 |
| 2 |
From: Bastian Germann <[email protected]> |
| 3 |
Date: Mon, 21 Jul 2025 08:33:54 +0200 |
| 4 |
Subject: Prevent SyntaxWarnings by using raw strings |
| 5 |
|
| 6 |
Some re.match instances contain invalid escape sequences. |
| 7 |
Rectify that by using raw strings where backslashes do not have to be |
| 8 |
escaped additionally. |
| 9 |
--- |
| 10 |
Lib/fontFeatures/fontDameLib/__init__.py | 14 +++++++------- |
| 11 |
1 file changed, 7 insertions(+), 7 deletions(-) |
| 12 |
|
| 13 |
diff --git a/Lib/fontFeatures/fontDameLib/__init__.py b/Lib/fontFeatures/fontDameLib/__init__.py |
| 14 |
index d978940..63f3e11 100644 |
| 15 |
--- a/Lib/fontFeatures/fontDameLib/__init__.py |
| 16 |
+++ b/Lib/fontFeatures/fontDameLib/__init__.py |
| 17 |
@@ -207,7 +207,7 @@ class FontDameParser: |
| 18 |
self.resetContexts() |
| 19 |
|
| 20 |
def parse_lookup_header(self, line): |
| 21 |
- m = re.match("^lookup\s+([\\w-]+)\s+(.*)$", line) |
| 22 |
+ m = re.match(r"^lookup\s+([\w-]+)\s+(.*)$", line) |
| 23 |
if not m: |
| 24 |
raise ValueError("Unparsable lookup header: |%s|" % line) |
| 25 |
self.current_lookup = Routine(name="lookup_%s" % m[1]) |
| 26 |
@@ -292,12 +292,12 @@ class FontDameParser: |
| 27 |
rule.marks[glyph] = pos |
| 28 |
|
| 29 |
def add_to_lookup(self, line): |
| 30 |
- m = re.match("(\w+)\s+(yes|no)", line) |
| 31 |
+ m = re.match(r"(\w+)\s+(yes|no)", line) |
| 32 |
if m: |
| 33 |
if m[2] == "yes": |
| 34 |
self.append_lookup_flag(m[1]) |
| 35 |
return |
| 36 |
- m = re.match("MarkAttachmentType\s+(\d+)", line, flags=re.IGNORECASE) |
| 37 |
+ m = re.match(r"MarkAttachmentType\s+(\d+)", line, flags=re.IGNORECASE) |
| 38 |
if m: |
| 39 |
self.append_lookup_flag("mat" + m[1]) |
| 40 |
return |
| 41 |
@@ -315,7 +315,7 @@ class FontDameParser: |
| 42 |
if m: |
| 43 |
self.add_single_pos_x_placement(m[1], int(m[2])) |
| 44 |
return |
| 45 |
- m = re.match("([\\w\\.-]+)\s+([\\w\\.-]+)\n", line) |
| 46 |
+ m = re.match(r"([\w.-]+)\s+([\w\\.-]+)\n", line) |
| 47 |
if not m: |
| 48 |
warnings.warn("Odd single lookup: %s" % line) |
| 49 |
# import code |
| 50 |
@@ -331,11 +331,11 @@ class FontDameParser: |
| 51 |
self.add_pair(m[1], m[2], int(m[3])) |
| 52 |
|
| 53 |
elif self.current_lookup_type == "multiple": |
| 54 |
- m = re.match("([\\w\\.-]+)\s+(.*)\n", line) |
| 55 |
+ m = re.match(r"([\w\\.-]+)\s+(.*)\n", line) |
| 56 |
self.add_subst([[m[1]]], [[x] for x in m[2].split("\t")]) |
| 57 |
|
| 58 |
elif self.current_lookup_type == "ligature": |
| 59 |
- m = re.match("([\\w\\.-]+)\s(.*)\n", line) |
| 60 |
+ m = re.match(r"([\w\\.-]+)\s(.*)\n", line) |
| 61 |
if not m: |
| 62 |
raise ValueError("Unparsable line '%s'" % line) |
| 63 |
self.add_subst([[m[2]]], [m[1].split("\t")]) |
| 64 |
@@ -424,7 +424,7 @@ class FontDameParser: |
| 65 |
return context |
| 66 |
|
| 67 |
def add_to_class_definition(self, which, line): |
| 68 |
- m = re.match("([\w\.]+)\s+(\d+)", line) |
| 69 |
+ m = re.match(r"([\w\.]+)\s+(\d+)", line) |
| 70 |
if not m: |
| 71 |
raise ValueError("Unparsable line '%s'" % line) |
| 72 |
if which == "class": |