depcheck: elide redundant element from tuple
authorHelmut Grohne <helmut@subdivi.de>
Sat, 2 Mar 2019 09:36:45 +0000 (10:36 +0100)
committerHelmut Grohne <helmut@subdivi.de>
Sat, 2 Mar 2019 09:36:45 +0000 (10:36 +0100)
depcheck.py

index 7f47a58..046b559 100755 (executable)
@@ -394,7 +394,7 @@ def check_bdsat(mirror, arch):
         next(dose_result) # skip header
         for d in dose_result:
             if d["status"] == "ok":
-                yield (d["package"], d["version"], True, None)
+                yield (d["package"], d["version"], None)
             else:
                 r = d["reasons"][0]
                 if "missing" in r:
@@ -405,27 +405,29 @@ def check_bdsat(mirror, arch):
                     reason += r.split()[0].split(':', 1)[0]
                 else:
                     assert False
-                yield (d["package"], d["version"], False, reason)
+                yield (d["package"], d["version"], reason)
 
 def update_depcheck(mirror, db, architecture):
     now = datetime.datetime.utcnow()
     mirror.update_release()
     state = {}
-    for source, version, satisfiable, reason in check_bdsat(mirror, architecture):
-        state[source] = (version, satisfiable, reason)
+    for source, version, reason in check_bdsat(mirror, architecture):
+        state[source] = (version, reason)
     with contextlib.closing(db.cursor()) as cur:
         cur.execute("BEGIN;")
         cur.execute("SELECT source, version, satisfiable, reason FROM depstate WHERE architecture = ?;",
                     (architecture,))
         for source, version, satisfiable, reason in list(cur.fetchall()):
-            if state.get(source) == (version, satisfiable, reason):
+            if satisfiable == (reason is None) and \
+               state.get(source) == (version, reason):
                 del state[source]
             else:
                 cur.execute("DELETE FROM depstate WHERE source = ? AND version = ? AND architecture = ?;",
                             (source, version, architecture))
         cur.executemany("INSERT INTO depstate (source, architecture, version, satisfiable, reason) VALUES (?, ?, ?, ?, ?);",
-                        ((source, architecture, version, satisfiable, reason)
-                         for source, (version, satisfiable, reason) in state.items()))
+                        ((source, architecture, version, reason is None,
+                          reason)
+                         for source, (version, reason) in state.items()))
         cur.execute("UPDATE depcheck SET releasetime = ?, updatetime = ?, giveback = 0 WHERE architecture = ?",
                     (mirror.releasetime, now, architecture))
     db.commit()