fix some regexs to use raw string literals

This commit is contained in:
Sumpfork 2018-04-25 10:19:36 -07:00
parent e66d0ed9a8
commit 152c705cbf
2 changed files with 17 additions and 17 deletions

View File

@ -102,13 +102,13 @@ class Card(object):
# (?!\w) prevents smaller word matches. Prevents matching "Action" in "Actions"
if bonus['exclude']:
bonus['exclude'].sort(reverse=True)
exclude_regex = '(?!\w)(?!\s*(' + '|'.join(bonus['exclude']) + '))'
exclude_regex = r'(?!\w)(?!\s*(' + '|'.join(bonus['exclude']) + '))'
else:
exclude_regex = ''
bonus['include'].sort(reverse=True)
include_regex = "(\+\s*\d+\s*(" + '|'.join(bonus['include']) + "))"
regex = "((?i)(?!\<b\>)" + include_regex + exclude_regex + "(?!\<\/b\>))"
include_regex = r"(\+\s*\d+\s*(" + '|'.join(bonus['include']) + "))"
regex = r"((?i)(?!\<b\>)" + include_regex + exclude_regex + r"(?!\<\/b\>))"
Card.bonus_regex.append(regex)
def __repr__(self):

View File

@ -377,29 +377,29 @@ class DividerDrawer(object):
# <line>
replace = "<center>%s\n" % ("&ndash;" * 22)
text = re.sub("\<line\>", replace, text)
text = re.sub(r"\<line\>", replace, text)
# <tab> and \t
text = re.sub("\<tab\>", '\t', text)
text = re.sub("\<t\>", '\t', text)
text = re.sub("\t", "&nbsp;" * 4, text)
text = re.sub(r"\<tab\>", '\t', text)
text = re.sub(r"\<t\>", '\t', text)
text = re.sub(r"\t", "&nbsp;" * 4, text)
# various breaks
text = re.sub("\<br\>", "<br />", text)
text = re.sub("\<n\>", "\n", text)
text = re.sub(r"\<br\>", "<br />", text)
text = re.sub(r"\<n\>", "\n", text)
# alignments
text = re.sub("\<c\>", "<center>", text)
text = re.sub("\<center\>", "\n<para alignment='center'>", text)
text = re.sub(r"\<c\>", "<center>", text)
text = re.sub(r"\<center\>", "\n<para alignment='center'>", text)
text = re.sub("\<l\>", "<left>", text)
text = re.sub("\<left\>", "\n<para alignment='left'>", text)
text = re.sub(r"\<l\>", "<left>", text)
text = re.sub(r"\<left\>", "\n<para alignment='left'>", text)
text = re.sub("\<r\>", "<right>", text)
text = re.sub("\<right\>", "\n<para alignment='right'>", text)
text = re.sub(r"\<r\>", "<right>", text)
text = re.sub(r"\<right\>", "\n<para alignment='right'>", text)
text = re.sub("\<j\>", "<justify>", text)
text = re.sub("\<justify\>", "\n<para alignment='justify'>", text)
text = re.sub(r"\<j\>", "<justify>", text)
text = re.sub(r"\<justify\>", "\n<para alignment='justify'>", text)
return text.strip().strip('\n')
def drawOutline(self,