[Git][reproducible-builds/diffoscope][master] 3 commits: Use a relative import for get_temporary_directory in diffoscope.diff.

Chris Lamb gitlab at salsa.debian.org
Wed Jul 22 15:27:54 UTC 2020



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
e01f3df0 by Chris Lamb at 2020-07-21T10:44:46+01:00
Use a relative import for get_temporary_directory in diffoscope.diff.

- - - - -
d43d580a by Chris Lamb at 2020-07-21T10:53:30+01:00
Rename bail_if_non_existing to exit_if_paths_do_not_exist.

- - - - -
4d89836c by Chris Lamb at 2020-07-21T11:06:51+01:00
Rewrite exit_if_paths_do_not_exist to not check files multiple times.

- - - - -


4 changed files:

- diffoscope/comparators/utils/compare.py
- diffoscope/diff.py
- diffoscope/readers/__init__.py
- diffoscope/utils.py


Changes:

=====================================
diffoscope/comparators/utils/compare.py
=====================================
@@ -26,7 +26,7 @@ import subprocess
 
 from diffoscope.tools import tool_required
 from diffoscope.exc import RequiredToolNotFound
-from diffoscope.utils import bail_if_non_existing
+from diffoscope.utils import exit_if_paths_do_not_exist
 from diffoscope.config import Config
 from diffoscope.excludes import any_excluded
 from diffoscope.profiling import profile
@@ -60,7 +60,7 @@ def compare_root_paths(path1, path2):
     )
 
     if not Config().new_file:
-        bail_if_non_existing(path1, path2)
+        exit_if_paths_do_not_exist(path1, path2)
     if any_excluded(path1, path2):
         return None
 


=====================================
diffoscope/diff.py
=====================================
@@ -31,10 +31,9 @@ import subprocess
 from difflib import Differ
 from multiprocessing.dummy import Queue
 
-from diffoscope.tempfiles import get_temporary_directory
-
 from .tools import get_tool_name, tool_required
 from .config import Config
+from .tempfiles import get_temporary_directory
 
 DIFF_CHUNK = 4096
 


=====================================
diffoscope/readers/__init__.py
=====================================
@@ -20,13 +20,13 @@
 
 import codecs
 
-from diffoscope.utils import bail_if_non_existing
+from diffoscope.utils import exit_if_paths_do_not_exist
 
 from .json import JSONReaderV1
 
 
 def load_diff_from_path(path):
-    bail_if_non_existing(path)
+    exit_if_paths_do_not_exist(path)
     with open(path, "rb") as fp:
         return load_diff(codecs.getreader("utf-8")(fp), path)
 


=====================================
diffoscope/utils.py
=====================================
@@ -55,13 +55,18 @@ def format_bytes(size, decimal_places=2):
     return f"{size:.{decimal_places}f} {unit}"
 
 
-def bail_if_non_existing(*paths):
-    if not all(map(os.path.lexists, paths)):
-        for path in paths:
-            if not os.path.lexists(path):
-                sys.stderr.write(
-                    "%s: %s: No such file or directory\n" % (sys.argv[0], path)
-                )
+def exit_if_paths_do_not_exist(*paths):
+    flag = False
+    for path in paths:
+        if os.path.lexists(path):
+            continue
+        flag = True
+        print(
+            f"{sys.argv[0]}: {path}: No such file or directory",
+            file=sys.stderr,
+        )
+
+    if flag:
         sys.exit(2)
 
 



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/ac66d291582c4a856f2735ff87a755c14a70b882...4d89836cb983845b626c83ff6588ea4bc025c8d8

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/ac66d291582c4a856f2735ff87a755c14a70b882...4d89836cb983845b626c83ff6588ea4bc025c8d8
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/20200722/83e7919e/attachment.htm>


More information about the rb-commits mailing list