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