Merge pull request #1562 from fonttools/depr_warn-invalid_escape

Fix DeprecationWarning: invalid escape sequence
This commit is contained in:
Miguel Sousa 2019-04-01 15:30:36 -07:00 committed by GitHub
commit 30885c50f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 53 additions and 53 deletions

View File

@ -9,52 +9,52 @@ from fontTools.misc.py23 import *
import re
# every single line starts with a "word"
identifierRE = re.compile("^([A-Za-z]+).*")
identifierRE = re.compile(r"^([A-Za-z]+).*")
# regular expression to parse char lines
charRE = re.compile(
"(-?\d+)" # charnum
"\s*;\s*WX\s+" # ; WX
"(-?\d+)" # width
"\s*;\s*N\s+" # ; N
"([.A-Za-z0-9_]+)" # charname
"\s*;\s*B\s+" # ; B
"(-?\d+)" # left
"\s+"
"(-?\d+)" # bottom
"\s+"
"(-?\d+)" # right
"\s+"
"(-?\d+)" # top
"\s*;\s*" # ;
r"(-?\d+)" # charnum
r"\s*;\s*WX\s+" # ; WX
r"(-?\d+)" # width
r"\s*;\s*N\s+" # ; N
r"([.A-Za-z0-9_]+)" # charname
r"\s*;\s*B\s+" # ; B
r"(-?\d+)" # left
r"\s+"
r"(-?\d+)" # bottom
r"\s+"
r"(-?\d+)" # right
r"\s+"
r"(-?\d+)" # top
r"\s*;\s*" # ;
)
# regular expression to parse kerning lines
kernRE = re.compile(
"([.A-Za-z0-9_]+)" # leftchar
"\s+"
"([.A-Za-z0-9_]+)" # rightchar
"\s+"
"(-?\d+)" # value
"\s*"
r"([.A-Za-z0-9_]+)" # leftchar
r"\s+"
r"([.A-Za-z0-9_]+)" # rightchar
r"\s+"
r"(-?\d+)" # value
r"\s*"
)
# regular expressions to parse composite info lines of the form:
# Aacute 2 ; PCC A 0 0 ; PCC acute 182 211 ;
compositeRE = re.compile(
"([.A-Za-z0-9_]+)" # char name
"\s+"
"(\d+)" # number of parts
"\s*;\s*"
r"([.A-Za-z0-9_]+)" # char name
r"\s+"
r"(\d+)" # number of parts
r"\s*;\s*"
)
componentRE = re.compile(
"PCC\s+" # PPC
"([.A-Za-z0-9_]+)" # base char name
"\s+"
"(-?\d+)" # x offset
"\s+"
"(-?\d+)" # y offset
"\s*;\s*"
r"PCC\s+" # PPC
r"([.A-Za-z0-9_]+)" # base char name
r"\s+"
r"(-?\d+)" # x offset
r"\s+"
r"(-?\d+)" # y offset
r"\s*;\s*"
)
preferredAttributeOrder = [

View File

@ -27,7 +27,7 @@ def programToString(program):
def programToCommands(program):
"""Takes a T2CharString program list and returns list of commands.
r"""Takes a T2CharString program list and returns list of commands.
Each command is a two-tuple of commandname,arg-list. The commandname might
be empty string if no commandname shall be emitted (used for glyph width,
hintmask/cntrmask argument, as well as stray arguments at the end of the

View File

@ -5,7 +5,7 @@ import os
import re
numberAddedRE = re.compile("#\d+$")
numberAddedRE = re.compile(r"#\d+$")
def makeOutputFileName(input, outputDir=None, extension=None, overWrite=False):

View File

@ -15,7 +15,7 @@ from __future__ import unicode_literals
from fontTools.misc.py23 import basestring, unicode
illegalCharacters = "\" * + / : < > ? [ \ ] | \0".split(" ")
illegalCharacters = r"\" * + / : < > ? [ \ ] | \0".split(" ")
illegalCharacters += [chr(i) for i in range(1, 32)]
illegalCharacters += [chr(0x7F)]
reservedFileNames = "CON PRN AUX CLOCK$ NUL A:-Z: COM1".lower().split(" ")

View File

@ -110,20 +110,20 @@ def calcsize(fmt):
# matches "name:formatchar" (whitespace is allowed)
_elementRE = re.compile(
"\s*" # whitespace
"([A-Za-z_][A-Za-z_0-9]*)" # name (python identifier)
"\s*:\s*" # whitespace : whitespace
"([cbBhHiIlLqQfd]|[0-9]+[ps]|" # formatchar...
"([0-9]+)\.([0-9]+)(F))" # ...formatchar
"\s*" # whitespace
"(#.*)?$" # [comment] + end of string
r"\s*" # whitespace
r"([A-Za-z_][A-Za-z_0-9]*)" # name (python identifier)
r"\s*:\s*" # whitespace : whitespace
r"([cbBhHiIlLqQfd]|[0-9]+[ps]|" # formatchar...
r"([0-9]+)\.([0-9]+)(F))" # ...formatchar
r"\s*" # whitespace
r"(#.*)?$" # [comment] + end of string
)
# matches the special struct fmt chars and 'x' (pad byte)
_extraRE = re.compile("\s*([x@=<>!])\s*(#.*)?$")
_extraRE = re.compile(r"\s*([x@=<>!])\s*(#.*)?$")
# matches an "empty" string, possibly containing whitespace and/or a comment
_emptyRE = re.compile("\s*(#.*)?$")
_emptyRE = re.compile(r"\s*(#.*)?$")
_fixedpointmappings = {
8: "b",

View File

@ -18,7 +18,7 @@ COMMANDS = set('MmZzLlHhVvCcSsQqTtAa')
UPPERCASE = set('MZLHVCSQTA')
COMMAND_RE = re.compile("([MmZzLlHhVvCcSsQqTtAa])")
FLOAT_RE = re.compile("[-+]?[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?")
FLOAT_RE = re.compile(r"[-+]?[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?")
def _tokenize_path(pathdef):

View File

@ -219,7 +219,7 @@ def disassemble(aCode):
pc += struct.calcsize(fmt)
return res
instre = re.compile("^\s*([^(]+)\s*(?:\(([^)]+)\))?")
instre = re.compile(r"^\s*([^(]+)\s*(?:\(([^)]+)\))?")
def assemble(instrs):
res = b""
for inst in instrs:
@ -231,7 +231,7 @@ def assemble(instrs):
if m.group(2):
if parmfmt == 0:
continue
parms = [int(x) for x in re.split(",\s*", m.group(2))]
parms = [int(x) for x in re.split(r",\s*", m.group(2))]
if parmfmt == -1:
l = len(parms)
res += struct.pack(("%dB" % (l+1)), l, *parms)

View File

@ -1495,7 +1495,7 @@ def _buildClasses():
import re
from .otData import otData
formatPat = re.compile("([A-Za-z0-9]+)Format(\d+)$")
formatPat = re.compile(r"([A-Za-z0-9]+)Format(\d+)$")
namespace = globals()
# populate module with classes

View File

@ -6,7 +6,7 @@ from __future__ import absolute_import, unicode_literals
from fontTools.misc.py23 import basestring, unicode
illegalCharacters = "\" * + / : < > ? [ \ ] | \0".split(" ")
illegalCharacters = r"\" * + / : < > ? [ \ ] | \0".split(" ")
illegalCharacters += [chr(i) for i in range(1, 32)]
illegalCharacters += [chr(0x7F)]
reservedFileNames = "CON PRN AUX CLOCK$ NUL A:-Z: COM1".lower().split(" ")

View File

@ -1185,7 +1185,7 @@ class ParserTest(unittest.TestCase):
self.assertRaisesRegex(
FeatureLibError,
'In reverse chaining single substitutions, the replacement '
'\(after "by"\) must be a single glyph or glyph class',
r'\(after "by"\) must be a single glyph or glyph class',
self.parse, "feature test {rsub f_i by f i;} test;")
def test_script(self):

View File

@ -89,7 +89,7 @@ class TimerTest(object):
time.sleep(0.01)
assert re.match(
"Took [0-9]\.[0-9]{3}s to do something",
r"Took [0-9]\.[0-9]{3}s to do something",
logger.handlers[0].stream.getvalue())
def test_using_logger_calling_instance(self, logger):
@ -98,7 +98,7 @@ class TimerTest(object):
time.sleep(0.01)
assert re.match(
"elapsed time: [0-9]\.[0-9]{3}s",
r"elapsed time: [0-9]\.[0-9]{3}s",
logger.handlers[0].stream.getvalue())
# do it again but with custom level
@ -106,7 +106,7 @@ class TimerTest(object):
time.sleep(0.02)
assert re.search(
"WARNING: Took [0-9]\.[0-9]{3}s to redo it",
r"WARNING: Took [0-9]\.[0-9]{3}s to redo it",
logger.handlers[0].stream.getvalue())
def test_function_decorator(self, logger):