| 1 |
Description: Fix several SyntaxWarnings |
| 2 |
Use raw strings to avoid invalid escape sequence |
| 3 |
Author: Graham Inggs <[email protected]> |
| 4 |
Last-Update: 2024-01-22 |
| 5 |
|
| 6 |
--- a/lib/dbtexmf/dblatex/grubber/texparser.py |
| 7 |
+++ b/lib/dbtexmf/dblatex/grubber/texparser.py |
| 8 |
@@ -31,7 +31,7 @@ |
| 9 |
# Make a "foo|bar\*stub" list |
| 10 |
hooklist = [x.replace("*", "\\*") for x in self.hooks] |
| 11 |
|
| 12 |
- pattern = "\\\\(?P<name>%s)\*?"\ |
| 13 |
+ pattern = r"\\\\(?P<name>%s)\*?"\ |
| 14 |
" *(\\[(?P<opt>[^\\]]*)\\])?"\ |
| 15 |
" *({(?P<arg>[^{}]*)}|(?=[^A-Za-z]))" |
| 16 |
|
| 17 |
--- a/lib/dbtexmf/dblatex/texcodec.py |
| 18 |
+++ b/lib/dbtexmf/dblatex/texcodec.py |
| 19 |
@@ -26,7 +26,7 @@ |
| 20 |
l.append(unient.unicode_map[ord(c)]) |
| 21 |
except KeyError: |
| 22 |
print("Missing character &#x%x;" % ord(c)) |
| 23 |
- l.append("\&\#x%x;" % ord(c)) |
| 24 |
+ l.append(r"\&\#x%x;" % ord(c)) |
| 25 |
if post: l.append(post) |
| 26 |
n = n + 1 |
| 27 |
tex_handler_counter[name] = n |
| 28 |
--- a/lib/dbtexmf/dblatex/texhyphen.py |
| 29 |
+++ b/lib/dbtexmf/dblatex/texhyphen.py |
| 30 |
@@ -20,7 +20,7 @@ |
| 31 |
""" |
| 32 |
def __init__(self, codec=None): |
| 33 |
self.codec = codec |
| 34 |
- self.hyphenchar = b"\-" |
| 35 |
+ self.hyphenchar = r"\-" |
| 36 |
|
| 37 |
def hyphenate(self, text): |
| 38 |
if self.codec: text = self.codec.decode(text) |
| 39 |
@@ -32,7 +32,7 @@ |
| 40 |
|
| 41 |
|
| 42 |
class UrlHyphenator(Hyphenator): |
| 43 |
- """ |
| 44 |
+ r""" |
| 45 |
Hyphenates <text> so that cutting is easier on URL separators. |
| 46 |
The hyphen chars are expected to be void to prevent from spurious |
| 47 |
characters in displayed filenames or URLs. |
| 48 |
@@ -51,7 +51,7 @@ |
| 49 |
existing latex styles. |
| 50 |
""" |
| 51 |
def __init__(self, codec=None, |
| 52 |
- h_sep=b"\penalty0{}", h_char=b"\penalty5000{}", |
| 53 |
+ h_sep=r"\penalty0{}", h_char=r"\penalty5000{}", |
| 54 |
h_start=3, h_stop=3): |
| 55 |
self.codec = codec |
| 56 |
self.seps = r":/\@=?#;-." |
| 57 |
--- a/lib/dbtexmf/dblatex/xetex/fcmanager.py |
| 58 |
+++ b/lib/dbtexmf/dblatex/xetex/fcmanager.py |
| 59 |
@@ -48,7 +48,7 @@ |
| 60 |
if i: self._buildattr(i) |
| 61 |
|
| 62 |
# Check the consistency |
| 63 |
- if self.family != self.name.replace("\-", "-"): |
| 64 |
+ if self.family != self.name.replace(r"\-", "-"): |
| 65 |
raise ValueError("Unknown font '%s' vs '%s'" % (self.name, |
| 66 |
self.family)) |
| 67 |
|
| 68 |
--- a/lib/dbtexmf/dblatex/xetex/fontspec.py |
| 69 |
+++ b/lib/dbtexmf/dblatex/xetex/fontspec.py |
| 70 |
@@ -195,7 +195,7 @@ |
| 71 |
""" |
| 72 |
s = '' |
| 73 |
for type, font in fonts.items(): |
| 74 |
- s += '\switch%sfont{%s}' % (type, font) |
| 75 |
+ s += r'\switch%sfont{%s}' % (type, font) |
| 76 |
if s: |
| 77 |
s = r"\savefamily" + s + r"\loadfamily{}" |
| 78 |
return s |