fix some regexs to use raw string literals
This commit is contained in:
parent
e66d0ed9a8
commit
152c705cbf
@ -102,13 +102,13 @@ class Card(object):
|
|||||||
# (?!\w) prevents smaller word matches. Prevents matching "Action" in "Actions"
|
# (?!\w) prevents smaller word matches. Prevents matching "Action" in "Actions"
|
||||||
if bonus['exclude']:
|
if bonus['exclude']:
|
||||||
bonus['exclude'].sort(reverse=True)
|
bonus['exclude'].sort(reverse=True)
|
||||||
exclude_regex = '(?!\w)(?!\s*(' + '|'.join(bonus['exclude']) + '))'
|
exclude_regex = r'(?!\w)(?!\s*(' + '|'.join(bonus['exclude']) + '))'
|
||||||
else:
|
else:
|
||||||
exclude_regex = ''
|
exclude_regex = ''
|
||||||
|
|
||||||
bonus['include'].sort(reverse=True)
|
bonus['include'].sort(reverse=True)
|
||||||
include_regex = "(\+\s*\d+\s*(" + '|'.join(bonus['include']) + "))"
|
include_regex = r"(\+\s*\d+\s*(" + '|'.join(bonus['include']) + "))"
|
||||||
regex = "((?i)(?!\<b\>)" + include_regex + exclude_regex + "(?!\<\/b\>))"
|
regex = r"((?i)(?!\<b\>)" + include_regex + exclude_regex + r"(?!\<\/b\>))"
|
||||||
Card.bonus_regex.append(regex)
|
Card.bonus_regex.append(regex)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|||||||
@ -377,29 +377,29 @@ class DividerDrawer(object):
|
|||||||
|
|
||||||
# <line>
|
# <line>
|
||||||
replace = "<center>%s\n" % ("–" * 22)
|
replace = "<center>%s\n" % ("–" * 22)
|
||||||
text = re.sub("\<line\>", replace, text)
|
text = re.sub(r"\<line\>", replace, text)
|
||||||
|
|
||||||
# <tab> and \t
|
# <tab> and \t
|
||||||
text = re.sub("\<tab\>", '\t', text)
|
text = re.sub(r"\<tab\>", '\t', text)
|
||||||
text = re.sub("\<t\>", '\t', text)
|
text = re.sub(r"\<t\>", '\t', text)
|
||||||
text = re.sub("\t", " " * 4, text)
|
text = re.sub(r"\t", " " * 4, text)
|
||||||
|
|
||||||
# various breaks
|
# various breaks
|
||||||
text = re.sub("\<br\>", "<br />", text)
|
text = re.sub(r"\<br\>", "<br />", text)
|
||||||
text = re.sub("\<n\>", "\n", text)
|
text = re.sub(r"\<n\>", "\n", text)
|
||||||
|
|
||||||
# alignments
|
# alignments
|
||||||
text = re.sub("\<c\>", "<center>", text)
|
text = re.sub(r"\<c\>", "<center>", text)
|
||||||
text = re.sub("\<center\>", "\n<para alignment='center'>", text)
|
text = re.sub(r"\<center\>", "\n<para alignment='center'>", text)
|
||||||
|
|
||||||
text = re.sub("\<l\>", "<left>", text)
|
text = re.sub(r"\<l\>", "<left>", text)
|
||||||
text = re.sub("\<left\>", "\n<para alignment='left'>", text)
|
text = re.sub(r"\<left\>", "\n<para alignment='left'>", text)
|
||||||
|
|
||||||
text = re.sub("\<r\>", "<right>", text)
|
text = re.sub(r"\<r\>", "<right>", text)
|
||||||
text = re.sub("\<right\>", "\n<para alignment='right'>", text)
|
text = re.sub(r"\<right\>", "\n<para alignment='right'>", text)
|
||||||
|
|
||||||
text = re.sub("\<j\>", "<justify>", text)
|
text = re.sub(r"\<j\>", "<justify>", text)
|
||||||
text = re.sub("\<justify\>", "\n<para alignment='justify'>", text)
|
text = re.sub(r"\<justify\>", "\n<para alignment='justify'>", text)
|
||||||
return text.strip().strip('\n')
|
return text.strip().strip('\n')
|
||||||
|
|
||||||
def drawOutline(self,
|
def drawOutline(self,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user