Make python Regex Strings raw to avoid py3.12 SyntaxError
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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] + "…"
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user