[Git][reproducible-builds/diffoscope][master] If we specify a suffix for temporary file or directory, ensure it starts with...

Chris Lamb (@lamby) gitlab at salsa.debian.org
Thu Aug 26 07:51:36 UTC 2021



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
2ec50ebd by Chris Lamb at 2021-08-25T13:55:55+01:00
If we specify a suffix for temporary file or directory, ensure it starts with a "_" to make the generated filenames a bit more human-readable.

- - - - -


1 changed file:

- diffoscope/tempfiles.py


Changes:

=====================================
diffoscope/tempfiles.py
=====================================
@@ -35,6 +35,9 @@ logger = logging.getLogger(__name__)
 def get_named_temporary_file(*args, **kwargs):
     kwargs["dir"] = kwargs.pop("dir", _get_base_temporary_directory())
 
+    if not kwargs.get("suffix", "_").startswith("_"):
+        kwargs["suffix"] = "_{}".format(kwargs["suffix"])
+
     f = tempfile.NamedTemporaryFile(*args, **kwargs)
     _FILES.append(f.name)
 
@@ -61,6 +64,9 @@ def get_temporary_directory(*args, **kwargs):
     """
     kwargs["dir"] = kwargs.pop("dir", _get_base_temporary_directory())
 
+    if not kwargs.get("suffix", "_").startswith("_"):
+        kwargs["suffix"] = "_{}".format(kwargs["suffix"])
+
     d = tempfile.TemporaryDirectory(*args, **kwargs)
 
     return d



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/2ec50ebdcd5d5fc1d5e458d55d46427086e5fb90

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/2ec50ebdcd5d5fc1d5e458d55d46427086e5fb90
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20210826/ac604389/attachment.htm>


More information about the rb-commits mailing list