eric7/DebugClients/Python/coverage/html.py

branch
eric7
changeset 8991
2fc945191992
parent 8929
fcca2fa618bf
child 9099
0e511e0e94a3
diff -r ca8e477c590c -r 2fc945191992 eric7/DebugClients/Python/coverage/html.py
--- a/eric7/DebugClients/Python/coverage/html.py	Sun Mar 20 17:26:35 2022 +0100
+++ b/eric7/DebugClients/Python/coverage/html.py	Sun Mar 20 17:49:44 2022 +0100
@@ -164,6 +164,7 @@
         self.incr = IncrementalChecker(self.directory)
         self.datagen = HtmlDataGeneration(self.coverage)
         self.totals = Numbers(precision=self.config.precision)
+        self.directory_was_empty = False
 
         self.template_globals = {
             # Functions available in the templates.
@@ -224,11 +225,11 @@
         for static in self.STATIC_FILES:
             shutil.copyfile(data_filename(static), os.path.join(self.directory, static))
 
+        # Only write the .gitignore file if the directory was originally empty.
         # .gitignore can't be copied from the source tree because it would
         # prevent the static files from being checked in.
-        gitigore_path = os.path.join(self.directory, ".gitignore")
-        if not os.path.exists(gitigore_path):
-            with open(gitigore_path, "w") as fgi:
+        if self.directory_was_empty:
+            with open(os.path.join(self.directory, ".gitignore"), "w") as fgi:
                 fgi.write("# Created by coverage.py\n*\n")
 
         # The user may have extra CSS they want copied.
@@ -240,6 +241,8 @@
         rootname = flat_rootname(fr.relative_filename())
         html_filename = rootname + ".html"
         ensure_dir(self.directory)
+        if not os.listdir(self.directory):
+            self.directory_was_empty = True
         html_path = os.path.join(self.directory, html_filename)
 
         # Get the numbers for this file.

eric ide

mercurial