Make python Regex Strings raw to avoid py3.12 SyntaxError

This commit is contained in:
bgbsww
2024-09-26 18:12:20 -04:00
committed by Yorik van Havre
parent e41def8c74
commit 64ecfe7a0e
26 changed files with 75 additions and 75 deletions

View File

@@ -83,12 +83,12 @@ class WidgetReadmeBrowser(QtWidgets.QTextBrowser):
self.setGeometry(geometry)
def _clean_markdown(self, md: str):
# Remove some HTML tags (for now just img and br, which are the most common offenders that break rendering)
# Remove some HTML tags ( for now just img and br, which are the most common offenders that break rendering )
br_re = re.compile(r"<br\s*/?>")
img_re = re.compile(r"<img\s.*?src=(?:'|\")([^'\">]+)(?:'|\").*?\/?>")
cleaned = br_re.sub("\n", md)
cleaned = img_re.sub("[html tag removed]", cleaned)
cleaned = br_re.sub(r"\n", md)
cleaned = img_re.sub(r"[html tag removed]", cleaned)
return cleaned

View File

@@ -183,7 +183,7 @@ class Macro:
desc = "No description available"
self.desc = desc
self.comment, _, _ = desc.partition("<br") # Up to the first line break
self.comment = re.sub("<.*?>", "", self.comment) # Strip any tags
self.comment = re.sub(r"<.*?>", "", self.comment) # Strip any tags
self.url = url
if isinstance(code, list):
code = "".join(code)
@@ -201,7 +201,7 @@ class Macro:
def _fetch_raw_code(self, page_data) -> Optional[str]:
"""Fetch code from the raw code URL specified on the wiki page."""
code = None
self.raw_code_url = re.findall('rawcodeurl.*?href="(http.*?)">', page_data)
self.raw_code_url = re.findall(r'rawcodeurl.*?href="(http.*?)">', page_data)
if self.raw_code_url:
self.raw_code_url = self.raw_code_url[0]
u2 = Macro.blocking_get(self.raw_code_url)

View File

@@ -201,7 +201,7 @@ class MacroParser:
def _cleanup_comment(self):
"""Remove HTML from the comment line, and truncate it at 512 characters."""
self.parse_results["comment"] = re.sub("<.*?>", "", self.parse_results["comment"])
self.parse_results["comment"] = re.sub(r"<.*?>", "", self.parse_results["comment"])
if len(self.parse_results["comment"]) > 512:
self.parse_results["comment"] = self.parse_results["comment"][:511] + ""

View File

@@ -399,7 +399,7 @@ class CreateAddonListWorker(QtCore.QThread):
)
return
p = p.data().decode("utf8")
macros = re.findall('title="(Macro.*?)"', p)
macros = re.findall(r'title="(Macro.*?)"', p)
macros = [mac for mac in macros if "translated" not in mac]
macro_names = []
for _, mac in enumerate(macros):