From 152c705cbf7226696c214418a8ad6aa911e7fd86 Mon Sep 17 00:00:00 2001 From: Sumpfork Date: Wed, 25 Apr 2018 10:19:36 -0700 Subject: [PATCH] fix some regexs to use raw string literals --- domdiv/cards.py | 6 +++--- domdiv/draw.py | 28 ++++++++++++++-------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/domdiv/cards.py b/domdiv/cards.py index 4b47482..26ecaf7 100644 --- a/domdiv/cards.py +++ b/domdiv/cards.py @@ -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)(?!\)" + include_regex + exclude_regex + "(?!\<\/b\>))" + include_regex = r"(\+\s*\d+\s*(" + '|'.join(bonus['include']) + "))" + regex = r"((?i)(?!\)" + include_regex + exclude_regex + r"(?!\<\/b\>))" Card.bonus_regex.append(regex) def __repr__(self): diff --git a/domdiv/draw.py b/domdiv/draw.py index 34b8ae3..f752c91 100644 --- a/domdiv/draw.py +++ b/domdiv/draw.py @@ -377,29 +377,29 @@ class DividerDrawer(object): # replace = "
%s\n" % ("–" * 22) - text = re.sub("\", replace, text) + text = re.sub(r"\", replace, text) # and \t - text = re.sub("\", '\t', text) - text = re.sub("\", '\t', text) - text = re.sub("\t", " " * 4, text) + text = re.sub(r"\", '\t', text) + text = re.sub(r"\", '\t', text) + text = re.sub(r"\t", " " * 4, text) # various breaks - text = re.sub("\", "
", text) - text = re.sub("\", "\n", text) + text = re.sub(r"\", "
", text) + text = re.sub(r"\", "\n", text) # alignments - text = re.sub("\", "
", text) - text = re.sub("\", "\n", text) + text = re.sub(r"\", "
", text) + text = re.sub(r"\", "\n", text) - text = re.sub("\", "", text) - text = re.sub("\", "\n", text) + text = re.sub(r"\", "", text) + text = re.sub(r"\", "\n", text) - text = re.sub("\", "", text) - text = re.sub("\", "\n", text) + text = re.sub(r"\", "", text) + text = re.sub(r"\", "\n", text) - text = re.sub("\", "", text) - text = re.sub("\", "\n", text) + text = re.sub(r"\", "", text) + text = re.sub(r"\", "\n", text) return text.strip().strip('\n') def drawOutline(self,