mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-13 16:34:34 +12:00
Fix Python 3.6 DeprecationWarning invalid escape sequence messages
Fix by ensuring that regular expressions are constructed using either raw string literals [1] or double backslashes [2]. [1] https://stackoverflow.com/questions/44325948/pandas-invalid-escape-sequence-after-update [2] https://github.com/joblib/joblib/pull/526 Note that python only shows the deprecation warnings on initial run [3]. [3] https://bugs.python.org/issue30091 To work around this issue, remove the cached bytecode with: find . -name "__pycache__" -exec rm -rf {} \; Then to prevent compiling to bytecode add the "-B" option to python: python3 -B -m pytest -vs
This commit is contained in:
parent
af53102e77
commit
7f592bae41
|
@ -137,7 +137,7 @@ def createThemePreview(theme, screenRect, size=QSize(200, 120)):
|
||||||
def findThemePath(themeName):
|
def findThemePath(themeName):
|
||||||
p = findFirstFile(re.escape("{}.theme".format(themeName)), "resources/themes")
|
p = findFirstFile(re.escape("{}.theme".format(themeName)), "resources/themes")
|
||||||
if not p:
|
if not p:
|
||||||
return findFirstFile(".*\.theme", "resources/themes")
|
return findFirstFile(r".*\.theme", "resources/themes")
|
||||||
else:
|
else:
|
||||||
return p
|
return p
|
||||||
|
|
||||||
|
|
|
@ -11,19 +11,19 @@ from manuskript.ui.highlighters import BasicHighlighter
|
||||||
class MMDHighlighter(BasicHighlighter):
|
class MMDHighlighter(BasicHighlighter):
|
||||||
|
|
||||||
MARKDOWN_REGEX = {
|
MARKDOWN_REGEX = {
|
||||||
'Bold': '(\*\*)(.+?)(\*\*)',
|
'Bold': r'(\*\*)(.+?)(\*\*)',
|
||||||
'Bold2': '(__)(.+?)(__)',
|
'Bold2': '(__)(.+?)(__)',
|
||||||
'Italic': '(\*)([^\*].+?[^\*])(\*)',
|
'Italic': r'(\*)([^\*].+?[^\*])(\*)',
|
||||||
'Italic2': '(_)([^_].+?[^_])(_)',
|
'Italic2': '(_)([^_].+?[^_])(_)',
|
||||||
'Title': '^(#+)(\s*)(.*)(#*)',
|
'Title': r'^(#+)(\s*)(.*)(#*)',
|
||||||
'HTML': '<.+?>',
|
'HTML': '<.+?>',
|
||||||
'Blockquotes': '^(> )+.*$',
|
'Blockquotes': '^(> )+.*$',
|
||||||
'OrderedList': '^\d+\.\s+',
|
'OrderedList': r'^\d+\.\s+',
|
||||||
'UnorderedList': '^[\*\+-]\s+',
|
'UnorderedList': r'^[\*\+-]\s+',
|
||||||
'Code': '^\s{4,}.*$',
|
'Code': r'^\s{4,}.*$',
|
||||||
'Links-inline': '(\[)(.*?)(\])(\()(.*?)(\))',
|
'Links-inline': r'(\[)(.*?)(\])(\()(.*?)(\))',
|
||||||
'Links-ref': '(\[)(.*?)(\])\s?(\[)(.*?)(\])',
|
'Links-ref': r'(\[)(.*?)(\])\s?(\[)(.*?)(\])',
|
||||||
'Links-ref2': '^\s{,3}(\[)(.*?)(\]:)\s+([^\s]*)\s*(.*?)*$',
|
'Links-ref2': r'^\s{,3}(\[)(.*?)(\]:)\s+([^\s]*)\s*(.*?)*$',
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, editor, style="Default"):
|
def __init__(self, editor, style="Default"):
|
||||||
|
|
|
@ -91,7 +91,7 @@ class MarkdownTokenizer(HighlightTokenizer):
|
||||||
strongRegex.setMinimal(True)
|
strongRegex.setMinimal(True)
|
||||||
strikethroughRegex = QRegExp("~~[^\\s]+.*[^\\s]+~~")
|
strikethroughRegex = QRegExp("~~[^\\s]+.*[^\\s]+~~")
|
||||||
strikethroughRegex.setMinimal(True)
|
strikethroughRegex.setMinimal(True)
|
||||||
superScriptRegex = QRegExp("\^([^\\s]|(\\\\\\s))+\^") # Spaces must be escaped "\ "
|
superScriptRegex = QRegExp(r"\^([^\s]|(\\\\\s))+\^") # Spaces must be escaped "\ "
|
||||||
superScriptRegex.setMinimal(True)
|
superScriptRegex.setMinimal(True)
|
||||||
subScriptRegex = QRegExp("~([^\\s]|(\\\\\\s))+~") # Spaces must be escaped "\ "
|
subScriptRegex = QRegExp("~([^\\s]|(\\\\\\s))+~") # Spaces must be escaped "\ "
|
||||||
subScriptRegex.setMinimal(True)
|
subScriptRegex.setMinimal(True)
|
||||||
|
@ -887,7 +887,7 @@ class MarkdownTokenizer(HighlightTokenizer):
|
||||||
with the escaped characters replaced with a dummy character.
|
with the escaped characters replaced with a dummy character.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return re.sub("\\\\.", "\$", text)
|
return re.sub("\\\\.", r"\$", text)
|
||||||
|
|
||||||
#escape = False
|
#escape = False
|
||||||
#escapedText = text
|
#escapedText = text
|
||||||
|
|
|
@ -18,7 +18,7 @@ from manuskript import functions as F
|
||||||
class MDEditView(textEditView):
|
class MDEditView(textEditView):
|
||||||
|
|
||||||
blockquoteRegex = QRegExp("^ {0,3}(>\\s*)+")
|
blockquoteRegex = QRegExp("^ {0,3}(>\\s*)+")
|
||||||
listRegex = QRegExp("^(\\s*)([+*-]|([0-9a-z])+([.\)]))(\\s+)")
|
listRegex = QRegExp(r"^(\s*)([+*-]|([0-9a-z])+([.\)]))(\s+)")
|
||||||
inlineLinkRegex = QRegExp("\\[([^\n]+)\\]\\(([^\n]+)\\)")
|
inlineLinkRegex = QRegExp("\\[([^\n]+)\\]\\(([^\n]+)\\)")
|
||||||
imageRegex = QRegExp("!\\[([^\n]*)\\]\\(([^\n]+)\\)")
|
imageRegex = QRegExp("!\\[([^\n]*)\\]\\(([^\n]+)\\)")
|
||||||
automaticLinkRegex = QRegExp("(<([a-zA-Z]+\\:[^\n]+)>)|(<([^\n]+@[^\n]+)>)")
|
automaticLinkRegex = QRegExp("(<([a-zA-Z]+\\:[^\n]+)>)|(<([^\n]+@[^\n]+)>)")
|
||||||
|
@ -342,15 +342,15 @@ class MDEditView(textEditView):
|
||||||
def clearedFormat(self, text):
|
def clearedFormat(self, text):
|
||||||
# FIXME: clear also block formats
|
# FIXME: clear also block formats
|
||||||
for reg, rep, flags in [
|
for reg, rep, flags in [
|
||||||
("\*\*(.*?)\*\*", "\\1", None), # bold
|
(r"\*\*(.*?)\*\*", "\\1", None), # bold
|
||||||
("__(.*?)__", "\\1", None), # bold
|
("__(.*?)__", "\\1", None), # bold
|
||||||
("\*(.*?)\*", "\\1", None), # emphasis
|
(r"\*(.*?)\*", "\\1", None), # emphasis
|
||||||
("_(.*?)_", "\\1", None), # emphasis
|
("_(.*?)_", "\\1", None), # emphasis
|
||||||
("`(.*?)`", "\\1", None), # verbatim
|
("`(.*?)`", "\\1", None), # verbatim
|
||||||
("~~(.*?)~~", "\\1", None), # strike
|
("~~(.*?)~~", "\\1", None), # strike
|
||||||
("\^(.*?)\^", "\\1", None), # superscript
|
(r"\^(.*?)\^", "\\1", None), # superscript
|
||||||
("~(.*?)~", "\\1", None), # subscript
|
("~(.*?)~", "\\1", None), # subscript
|
||||||
("<!--\s*(.*?)\s*-->", "\\1", re.S), # comments
|
(r"<!--\s*(.*?)\s*-->", "\\1", re.S), # comments
|
||||||
|
|
||||||
# LINES OR BLOCKS
|
# LINES OR BLOCKS
|
||||||
(r"^#*\s*(.+?)\s*", "\\1", re.M), # ATX
|
(r"^#*\s*(.+?)\s*", "\\1", re.M), # ATX
|
||||||
|
@ -394,7 +394,7 @@ class MDEditView(textEditView):
|
||||||
c.insertText("")
|
c.insertText("")
|
||||||
|
|
||||||
char = "=" if level == 1 else "-"
|
char = "=" if level == 1 else "-"
|
||||||
text = re.sub("^#*\s*(.*)\s*#*", "\\1", text) # Removes #
|
text = re.sub(r"^#*\s*(.*)\s*#*", "\\1", text) # Removes #
|
||||||
sub = char * len(text)
|
sub = char * len(text)
|
||||||
text = text + "\n" + sub
|
text = text + "\n" + sub
|
||||||
|
|
||||||
|
@ -429,7 +429,7 @@ class MDEditView(textEditView):
|
||||||
self.titleATX(level)
|
self.titleATX(level)
|
||||||
return
|
return
|
||||||
|
|
||||||
m = re.match("^(#+)(\s*)(.+)", text)
|
m = re.match(r"^(#+)(\s*)(.+)", text)
|
||||||
if m:
|
if m:
|
||||||
pre = m.group(1)
|
pre = m.group(1)
|
||||||
space = m.group(2)
|
space = m.group(2)
|
||||||
|
|
Loading…
Reference in a new issue