eric6/DocumentationTools/QtHelpGenerator.py

changeset 7785
9978016560ec
parent 7780
41420f82c0ac
child 7852
24d47bf35c2b
child 7924
8a96736d465e
diff -r 3257703e10c5 -r 9978016560ec eric6/DocumentationTools/QtHelpGenerator.py
--- a/eric6/DocumentationTools/QtHelpGenerator.py	Tue Oct 13 19:02:26 2020 +0200
+++ b/eric6/DocumentationTools/QtHelpGenerator.py	Wed Oct 14 17:50:39 2020 +0200
@@ -244,10 +244,9 @@
         }
         
         txt = self.__convertEol(HelpProject.format(**helpAttribs), newline)
-        f = open(os.path.join(self.outputDir, HelpProjectFile), "w",
-                 encoding="utf-8", newline=newline)
-        f.write(txt)
-        f.close()
+        with open(os.path.join(self.outputDir, HelpProjectFile), "w",
+                  encoding="utf-8", newline=newline) as f:
+            f.write(txt)
         
         if (
             self.createCollection and
@@ -260,10 +259,9 @@
             
             txt = self.__convertEol(
                 HelpCollection.format(**collectionAttribs), newline)
-            f = open(os.path.join(self.outputDir, HelpCollectionProjectFile),
-                     "w", encoding="utf-8", newline=newline)
-            f.write(txt)
-            f.close()
+            with open(os.path.join(self.outputDir, HelpCollectionProjectFile),
+                      "w", encoding="utf-8", newline=newline) as f:
+                f.write(txt)
         
         sys.stdout.write("QtHelp files written.\n")
         sys.stdout.write("Generating QtHelp documentation...\n")

eric ide

mercurial