Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Fix Python invalid escape sequence warnings

Freya Lupen5d44af277b00
diff --git a/plugins/python/comics_project_management_tools/comics_exporter.py b/plugins/python/comics_project_management_tools/comics_exporter.py
index 73fe21bcbe..6cb3f2a095 100644
--- a/plugins/python/comics_project_management_tools/comics_exporter.py
+++ b/plugins/python/comics_project_management_tools/comics_exporter.py
@@ -420,7 +420,7 @@ class comicsExporter():
def handleShapeDescription(self, shape, list, textOnly=False):
return
# Turn off shape retrieval for now until the new text tool is finished.
- """
+ r"""
if (shape.type() != "KoSvgTextShapeID" and textOnly is True):
return
shapeDesc = {}
@@ -429,7 +429,7 @@ class comicsExporter():
listOfPoints = [rect.topLeft(), rect.topRight(), rect.bottomRight(), rect.bottomLeft()]
shapeDoc = minidom.parseString(shape.toSvg())
docElem = shapeDoc.documentElement
- svgRegExp = re.compile('[MLCSQHVATmlzcqshva]\d+\.?\d* \d+\.?\d*')
+ svgRegExp = re.compile(r'[MLCSQHVATmlzcqshva]\d+\.?\d* \d+\.?\d*')
transform = docElem.getAttribute("transform")
coord = []
adjust = QTransform()
@@ -539,7 +539,7 @@ class comicsExporter():
fontsize = int(size)
font = QFont(family, fontsize)
string = el.toxml()
- string = re.sub("\<.*?\>", " ", string)
+ string = re.sub(r"\<.*?\>", " ", string)
string = string.replace(" ", " ")
width = min(QFontMetrics(font).width(string.strip()), rect.width())
height = QFontMetrics(font).height()
diff --git a/plugins/python/comics_project_management_tools/exporters/CPMT_ACBF_XML_Exporter.py b/plugins/python/comics_project_management_tools/exporters/CPMT_ACBF_XML_Exporter.py
index 985b83b640..386f39bd38 100644
--- a/plugins/python/comics_project_management_tools/exporters/CPMT_ACBF_XML_Exporter.py
+++ b/plugins/python/comics_project_management_tools/exporters/CPMT_ACBF_XML_Exporter.py
@@ -507,8 +507,8 @@ def write_xml(configDictionary = {}, pageData = [], pagesLocationList = [], loc
figureOut = figure_out_type(svg.documentElement())
type = figureOut[0]
inverted = figureOut[1]
- string = re.sub("\<\/*?text.*?\>",'', str(v["text"]))
- string = re.sub("\s+?", " ", string)
+ string = re.sub(r"\<\/*?text.*?\>",'', str(v["text"]))
+ string = re.sub(r"\s+?", " ", string)
translationEntry = poParser.get_entry_for_key(string, lang)
string = translationEntry.get("trans", string)
svg.setContent("<text>"+string+"</text>")
diff --git a/plugins/python/comics_project_management_tools/exporters/CPMT_po_parser.py b/plugins/python/comics_project_management_tools/exporters/CPMT_po_parser.py
index 3d35218d27..73a1227443 100644
--- a/plugins/python/comics_project_management_tools/exporters/CPMT_po_parser.py
+++ b/plugins/python/comics_project_management_tools/exporters/CPMT_po_parser.py
@@ -46,8 +46,8 @@ class po_file_parser():
key = ""
if self.key_xml:
text = entry.get("text", "")
- text = re.sub("\<.*?\>", " ", text)
- key += str(re.sub("\s+", " ", text)).strip()
+ text = re.sub(r"\<.*?\>", " ", text)
+ key += str(re.sub(r"\s+", " ", text)).strip()
else:
key += entry.get("text", None)
if key is not None:
@@ -111,8 +111,8 @@ class po_file_parser():
entry = {}
entry["trans"] = " "
if self.key_xml:
- key = re.sub("\<.*?\>", " ", key)
- key = re.sub("\s+", " ", key)
+ key = re.sub(r"\<.*?\>", " ", key)
+ key = re.sub(r"\s+", " ", key)
key = key.strip()
if key in self.translationDict.keys():
translations = {}
diff --git a/plugins/python/scripter/ui_scripter/editor/pythoneditor.py b/plugins/python/scripter/ui_scripter/editor/pythoneditor.py
index 76572ab1e3..da3efbc89c 100644
--- a/plugins/python/scripter/ui_scripter/editor/pythoneditor.py
+++ b/plugins/python/scripter/ui_scripter/editor/pythoneditor.py
@@ -271,7 +271,7 @@ class CodeEditor(QPlainTextEdit):
self.dedentBlock(blockNumber)
def autoindent(self):
- """The return key has just been pressed (and processed by the editor)
+ r"""The return key has just been pressed (and processed by the editor)
now insert leading spaces to reflect an appropriate indent level
against the previous line.
This will depend on the end of the previous line. If it ends:
diff --git a/plugins/python/scripter/ui_scripter/syntax/syntax.py b/plugins/python/scripter/ui_scripter/syntax/syntax.py
index abc7903b3c..b0d3088e03 100644
--- a/plugins/python/scripter/ui_scripter/syntax/syntax.py
+++ b/plugins/python/scripter/ui_scripter/syntax/syntax.py
@@ -30,16 +30,16 @@ class PythonHighlighter (QSyntaxHighlighter):
# Comparison
'==', '!=', '<', '<=', '>', '>=',
# Arithmetic
- '\+', '-', '\*', '/', '//', '\%', '\*\*',
+ r'\+', '-', r'\*', '/', '//', r'\%', r'\*\*',
# In-place
- '\+=', '-=', '\*=', '/=', '\%=',
+ r'\+=', '-=', r'\*=', '/=', r'\%=',
# Bitwise
- '\^', '\|', '\&', '\~', '>>', '<<',
+ r'\^', r'\|', r'\&', r'\~', '>>', '<<',
]
# Python braces
braces = [
- '\{', '\}', '\(', '\)', '\[', '\]',
+ r'\{', r'\}', r'\(', r'\)', r'\[', r'\]',
]
def __init__(self, document, syntaxStyle):