[diffoscope] 01/02: Always suffix temporary files with '_diffoscope'

Mattia Rizzolo mattia at debian.org
Tue May 31 00:58:47 CEST 2016


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

mattia pushed a commit to branch master
in repository diffoscope.

commit 59118e1dbb67490721fe24e1a5de397aed932ecb
Author: Mattia Rizzolo <mattia at debian.org>
Date:   Mon May 30 09:58:24 2016 +0000

    Always suffix temporary files with '_diffoscope'
---
 diffoscope/__init__.py            | 4 ++++
 diffoscope/comparators/device.py  | 2 +-
 diffoscope/comparators/rpm.py     | 2 +-
 diffoscope/comparators/symlink.py | 2 +-
 diffoscope/comparators/utils.py   | 2 +-
 5 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/diffoscope/__init__.py b/diffoscope/__init__.py
index 5be2c6b..438c40c 100644
--- a/diffoscope/__init__.py
+++ b/diffoscope/__init__.py
@@ -169,12 +169,16 @@ temp_dirs = []
 
 
 def get_named_temporary_file(*args, **kwargs):
+    if 'suffix' not in kwargs:
+        kwargs['suffix'] = '_diffoscope'
     f = tempfile.NamedTemporaryFile(*args, **kwargs)
     temp_files.append(f.name)
     return f
 
 
 def get_temporary_directory(*args, **kwargs):
+    if 'suffix' not in kwargs:
+        kwargs['suffix'] = '_diffoscope'
     d = tempfile.TemporaryDirectory(*args, **kwargs)
     temp_dirs.append(d)
     return d
diff --git a/diffoscope/comparators/device.py b/diffoscope/comparators/device.py
index 6416f50..047376f 100644
--- a/diffoscope/comparators/device.py
+++ b/diffoscope/comparators/device.py
@@ -40,7 +40,7 @@ class Device(File):
         return self.get_device() == other.get_device()
 
     def create_placeholder(self):
-        with get_named_temporary_file(mode='w+', suffix='diffoscope', delete=False) as f:
+        with get_named_temporary_file(mode='w+', delete=False) as f:
             f.write(format_device(*self.get_device()))
             f.flush()
             return f.name
diff --git a/diffoscope/comparators/rpm.py b/diffoscope/comparators/rpm.py
index 0bdde1f..4fbb939 100644
--- a/diffoscope/comparators/rpm.py
+++ b/diffoscope/comparators/rpm.py
@@ -67,7 +67,7 @@ def get_rpm_header(path, ts):
 
 def compare_rpm_headers(path1, path2):
     # compare headers
-    with get_temporary_directory(suffix='diffoscope') as rpmdb_dir:
+    with get_temporary_directory() as rpmdb_dir:
         rpm.addMacro("_dbpath", rpmdb_dir)
         ts = rpm.TransactionSet()
         ts.setVSFlags(-1)
diff --git a/diffoscope/comparators/symlink.py b/diffoscope/comparators/symlink.py
index f9b4664..76eaa71 100644
--- a/diffoscope/comparators/symlink.py
+++ b/diffoscope/comparators/symlink.py
@@ -36,7 +36,7 @@ class Symlink(File):
         return os.readlink(self.name)
 
     def create_placeholder(self):
-        with get_named_temporary_file('w+', suffix='diffoscope', delete=False) as f:
+        with get_named_temporary_file('w+', delete=False) as f:
             f.write(format_symlink(self.symlink_destination))
             f.flush()
             return f.name
diff --git a/diffoscope/comparators/utils.py b/diffoscope/comparators/utils.py
index 9df9751..41a1eb7 100644
--- a/diffoscope/comparators/utils.py
+++ b/diffoscope/comparators/utils.py
@@ -238,7 +238,7 @@ class ArchiveMember(File):
         if self._path is None:
             logger.debug('unpacking %s', self._name)
             assert self._temp_dir is None
-            self._temp_dir = get_temporary_directory(suffix='diffoscope')
+            self._temp_dir = get_temporary_directory()
             self._path = self.container.extract(self._name, self._temp_dir.name)
         return self._path
 

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


More information about the diffoscope mailing list