Drop redundant re.UNICODE flag

This commit is contained in:
Veronica Berglyd Olsen
2025-07-04 20:20:48 +02:00
parent 5ee362dcf4
commit 9af498d69a
4 changed files with 18 additions and 20 deletions
+2 -4
View File
@@ -289,7 +289,7 @@ class DocSearch:
def __init__(self) -> None:
self._regEx = re.compile(r"")
self._opts = re.UNICODE | re.IGNORECASE
self._opts = re.IGNORECASE
self._words = False
self._escape = True
return
@@ -300,9 +300,7 @@ class DocSearch:
def setCaseSensitive(self, state: bool) -> None:
"""Set the case sensitive search flag."""
self._opts = re.UNICODE
if not state:
self._opts |= re.IGNORECASE
self._opts = 0 if state else re.IGNORECASE
return
def setWholeWords(self, state: bool) -> None:
+1 -1
View File
@@ -51,7 +51,7 @@ if TYPE_CHECKING:
logger = logging.getLogger(__name__)
# RegEx
RX_TEXT = re.compile(r"([\n\t])", re.UNICODE)
RX_TEXT = re.compile(r"([\n\t])")
# Types and Relationships
OOXML_SCM = "http://schemas.openxmlformats.org"
+4 -4
View File
@@ -139,7 +139,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
# Multiple or Trailing Spaces
if CONFIG.showMultiSpaces:
rxRule = re.compile(r"[ ]{2,}|[ ]*$", re.UNICODE)
rxRule = re.compile(r"[ ]{2,}|[ ]*$")
hlRule = {
0: self._hStyles["mspaces"],
}
@@ -148,7 +148,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
self._cmnRules.append((rxRule, hlRule))
# Non-Breaking Spaces
rxRule = re.compile(f"[{nwUnicode.U_NBSP}{nwUnicode.U_THNBSP}]+", re.UNICODE)
rxRule = re.compile(f"[{nwUnicode.U_NBSP}{nwUnicode.U_THNBSP}]+")
hlRule = {
0: self._hStyles["nobreak"],
}
@@ -226,7 +226,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
self._cmnRules.append((rxRule, hlRule))
# Alignment Tags
rxRule = re.compile(r"(^>{1,2}|<{1,2}$)", re.UNICODE)
rxRule = re.compile(r"(^>{1,2}|<{1,2}$)")
hlRule = {
1: self._hStyles["markup"],
}
@@ -234,7 +234,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
self._txtRules.append((rxRule, hlRule))
# Auto-Replace Tags
rxRule = re.compile(r"<(\S+?)>", re.UNICODE)
rxRule = re.compile(r"<(\S+?)>")
hlRule = {
0: self._hStyles["replace"],
}
+11 -11
View File
@@ -37,13 +37,13 @@ class RegExPatterns:
# Static RegExes
_rxUrl = re.compile(nwRegEx.URL, re.ASCII)
_rxWords = re.compile(nwRegEx.WORDS, re.UNICODE)
_rxBreak = re.compile(nwRegEx.BREAK, re.UNICODE)
_rxItalic = re.compile(nwRegEx.FMT_EI, re.UNICODE)
_rxBold = re.compile(nwRegEx.FMT_EB, re.UNICODE)
_rxStrike = re.compile(nwRegEx.FMT_ST, re.UNICODE)
_rxSCPlain = re.compile(nwRegEx.FMT_SC, re.UNICODE)
_rxSCValue = re.compile(nwRegEx.FMT_SV, re.UNICODE)
_rxWords = re.compile(nwRegEx.WORDS)
_rxBreak = re.compile(nwRegEx.BREAK)
_rxItalic = re.compile(nwRegEx.FMT_EI)
_rxBold = re.compile(nwRegEx.FMT_EB)
_rxStrike = re.compile(nwRegEx.FMT_ST)
_rxSCPlain = re.compile(nwRegEx.FMT_SC)
_rxSCValue = re.compile(nwRegEx.FMT_SV)
@property
def url(self) -> re.Pattern:
@@ -108,7 +108,7 @@ class RegExPatterns:
rx.append(f"(?:{qO}[^{qO}]+{qC})")
if CONFIG.allowOpenDial:
rx.append(f"(?:{qO}.+?$)")
return re.compile("|".join(rx), re.UNICODE)
return re.compile("|".join(rx))
return None
@property
@@ -118,7 +118,7 @@ class RegExPatterns:
qO = re.escape(compact(CONFIG.altDialogOpen))
qC = re.escape(compact(CONFIG.altDialogClose))
qB = r"\B" if (qO == qC or qC in self.AMBIGUOUS) else ""
return re.compile(f"{qO}.*?{qC}{qB}", re.UNICODE)
return re.compile(f"{qO}.*?{qC}{qB}")
return None
@@ -163,8 +163,8 @@ class DialogParser:
# Build narrator break RegExes
if narrator := CONFIG.narratorBreak.strip()[:1]:
punct = re.escape(".,:;!?")
self._breakD = re.compile(f"{narrator}.*?(?:{narrator}[{punct}]?|$)", re.UNICODE)
self._breakQ = re.compile(f"{narrator}.*?(?:{narrator}[{punct}]?)", re.UNICODE)
self._breakD = re.compile(f"{narrator}.*?(?:{narrator}[{punct}]?|$)")
self._breakQ = re.compile(f"{narrator}.*?(?:{narrator}[{punct}]?)")
self._narrator = narrator
self._mode = f" {narrator}"