eric6/QScintilla/Exporters/ExporterHTML.py

changeset 8205
4a0f1f896341
parent 7960
e8fc383322f7
child 8243
cc717c2ae956
diff -r fd477cded1c1 -r 4a0f1f896341 eric6/QScintilla/Exporters/ExporterHTML.py
--- a/eric6/QScintilla/Exporters/ExporterHTML.py	Thu Apr 08 17:27:12 2021 +0200
+++ b/eric6/QScintilla/Exporters/ExporterHTML.py	Thu Apr 08 18:27:47 2021 +0200
@@ -27,7 +27,7 @@
 import Utilities
 
 
-class HTMLGenerator(object):
+class HTMLGenerator:
     """
     Class implementing an HTML generator for exporting source code.
     """
@@ -188,6 +188,7 @@
                                 html += '    font-size: {0:d}pt;\n'.format(
                                         QFontInfo(font).pointSize())
                             html += '}\n'
+                            # __IGNORE_WARNING_Y113__
                     else:
                         styleIsUsed[istyle] = False
                 istyle += 1
@@ -415,10 +416,7 @@
             return
         
         fn = self.editor.getFileName()
-        if fn:
-            extension = os.path.normcase(os.path.splitext(fn)[1][1:])
-        else:
-            extension = ""
+        extension = os.path.normcase(os.path.splitext(fn)[1][1:]) if fn else ""
         
         if (
             extension in Preferences.getEditor(
@@ -475,18 +473,18 @@
                 )
         
         if html:
-            try:
-                with E5OverrideCursor():
-                    with open(filename, "w", encoding="utf-8") as f:
-                        f.write(html)
-            except OSError as err:
-                E5MessageBox.critical(
-                    self.editor,
-                    self.tr("Export source"),
-                    self.tr(
-                        """<p>The source could not be exported to"""
-                        """ <b>{0}</b>.</p><p>Reason: {1}</p>""")
-                    .format(filename, str(err)))
+            with E5OverrideCursor(), open(filename, "w", encoding="utf-8"
+                                          ) as f:
+                try:
+                    f.write(html)
+                except OSError as err:
+                    E5MessageBox.critical(
+                        self.editor,
+                        self.tr("Export source"),
+                        self.tr(
+                            """<p>The source could not be exported to"""
+                            """ <b>{0}</b>.</p><p>Reason: {1}</p>""")
+                        .format(filename, str(err)))
         else:
             E5MessageBox.critical(
                 self.editor,
@@ -568,10 +566,12 @@
         text = self.editor.text()
         
         mermaidNeeded = False
-        if Preferences.getEditor("PreviewMarkdownMermaid"):
-            if MarkdownExtensions.MermaidRegexFullText.search(text):
-                extensions.append(MarkdownExtensions.MermaidExtension())
-                mermaidNeeded = True
+        if (
+            Preferences.getEditor("PreviewMarkdownMermaid") and
+            MarkdownExtensions.MermaidRegexFullText.search(text)
+        ):
+            extensions.append(MarkdownExtensions.MermaidExtension())
+            mermaidNeeded = True
         
         if Preferences.getEditor("PreviewMarkdownNLtoBR"):
             extensions.append('nl2br')

eric ide

mercurial