[diffoscope] 03/05: Tidy diffoscope.tempfiles

Chris Lamb chris at chris-lamb.co.uk
Wed Dec 28 13:45:09 CET 2016


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository diffoscope.

commit cfb30f580a429bc06e4cbf407a0d37f42be0a43f
Author: Chris Lamb <lamby at debian.org>
Date:   Wed Dec 28 12:39:38 2016 +0000

    Tidy diffoscope.tempfiles
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 diffoscope/__init__.py  |  2 +-
 diffoscope/tempfiles.py | 26 ++++++++++++++------------
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/diffoscope/__init__.py b/diffoscope/__init__.py
index 7347202..a2542ff 100644
--- a/diffoscope/__init__.py
+++ b/diffoscope/__init__.py
@@ -35,7 +35,7 @@ logger.setLevel(logging.WARNING)
 ch = logging.StreamHandler()
 ch.setLevel(logging.DEBUG)
 logger.addHandler(ch)
-formatter = logging.Formatter('%(created)f %(levelname)8s %(message)s')
+formatter = logging.Formatter('%(created)f %(levelname)1s: %(message)s')
 ch.setFormatter(formatter)
 
 OS_NAMES = {
diff --git a/diffoscope/tempfiles.py b/diffoscope/tempfiles.py
index bf6953f..6c38931 100644
--- a/diffoscope/tempfiles.py
+++ b/diffoscope/tempfiles.py
@@ -22,34 +22,36 @@ import tempfile
 
 from diffoscope import logger
 
-temp_dirs = []
-temp_files = []
+_DIRS, _FILES = [], []
 
 
 def get_named_temporary_file(*args, **kwargs):
     kwargs['suffix'] = kwargs.pop('suffix', '_diffoscope')
+
     f = tempfile.NamedTemporaryFile(*args, **kwargs)
-    temp_files.append(f.name)
-    return f
+    _FILES.append(f.name)
 
+    return f
 
 def get_temporary_directory(*args, **kwargs):
     kwargs['suffix'] = kwargs.pop('suffix', '_diffoscope')
+
     d = tempfile.TemporaryDirectory(*args, **kwargs)
-    temp_dirs.append(d)
-    return d
+    _DIRS.append(d)
 
+    return d
 
 def clean_all_temp_files():
-    for temp_file in temp_files:
+    for x in _FILES:
         try:
-            os.unlink(temp_file)
+            os.unlink(x)
         except FileNotFoundError:
             pass
         except:
-            logger.exception('Unable to delete %s', temp_file)
-    for temp_dir in temp_dirs:
+            logger.exception("Unable to delete %s", x)
+
+    for x in _DIRS:
         try:
-            temp_dir.cleanup()
+            x.cleanup()
         except:
-            logger.exception('Unable to delete %s', temp_dir)
+            logger.exception("Unable to delete %s", x)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list