[Reproducible-commits] [misc] 01/06: move method into an actually importable module

Chris West faux-guest at moszumanska.debian.org
Mon Dec 14 12:06:58 UTC 2015


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

faux-guest pushed a commit to branch master
in repository misc.

commit 35b54e9c6dd5ece5c6d2c3e83b35bab7e0f912f6
Author: Chris West (Faux) <git at goeswhere.com>
Date:   Mon Dec 14 10:51:59 2015 +0000

    move method into an actually importable module
---
 .gitignore      |  5 +++++
 clean-notes     | 52 +++++++---------------------------------------------
 edit-notes      |  3 ++-
 filter-packages |  4 ++--
 remote.py       | 43 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 59 insertions(+), 48 deletions(-)

diff --git a/.gitignore b/.gitignore
index df2bbf1..c4d5353 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,8 @@ __pycache__/
 rbuilds
 *.lst
 *.err
+.idea
+*.pyc
+*.iml
+reproducible.db
+reproducible.json
diff --git a/clean-notes b/clean-notes
index 49d4270..c25cf95 100755
--- a/clean-notes
+++ b/clean-notes
@@ -8,25 +8,22 @@
 #
 # Depends: python3 python3-apt python3-yaml python3-requests python3-psycopg2
 
-import apt
-import sys
-import json
-import yaml
 import logging
+import sys
+from apt_pkg import version_compare
+
+import apt
 import argparse
 import psycopg2
-import requests
+import yaml
 
-from apt_pkg import version_compare
+
+from remote import load_reproducible_status, RB_SITE
 
 # "apt" is to avoid adding an ugly "apt_pkg.init()" call to fix a "ValueError:
 # _system not initialized" error.
 apt = apt
 
-RB_SITE = 'https://reproducible.debian.net'
-
-REPRODUCIBLE_JSON = '{}/reproducible.json'.format(RB_SITE)
-# [{package: xxx, suite: sid, version: 0.0.0, status: reproducible}, {...}]
 
 NOTES_YAML = 'packages.yml'
 # {package_name: {version: 0.0.0, comments: "blablabla", bugs: [111, 222],
@@ -207,41 +204,6 @@ def query_udd(query):
     return cursor.fetchall()
 
 
-def load_reproducible_status():
-    status = {}
-    try:
-        with open('reproducible.json') as f:
-            rstatus = json.load(f)
-    except FileNotFoundError:
-        rstatus = requests.get(REPRODUCIBLE_JSON).json()
-
-    for item in rstatus:
-        pkg = item['package']
-        version = str(item['version'])
-        # feed status with the unstable value, if available, otherwise prefer
-        # testing and then experimental
-        try:
-            if status[pkg]['suite'] == 'unstable':
-                continue  # that's the best
-            elif status[pkg]['suite'] == 'experimental':  # whatever we've now
-                status[pkg]['version'] = version          # is better
-                status[pkg]['suite'] = item['suite']
-                status[pkg]['status'] = item['status']
-            elif status[pkg]['suite'] == 'testing' and \
-                    item['suite'] != 'experimental':
-                status[pkg]['version'] = version
-                status[pkg]['suite'] = item['suite']
-                status[pkg]['status'] = item['status']
-        except KeyError:
-            status[pkg] = {
-                'version': version,
-                'suite': item['suite'],
-                'status': item['status'],
-            }
-
-    return status
-
-
 def load_notes():
     try:
         with open(NOTES_YAML, encoding='utf-8') as f:
diff --git a/edit-notes b/edit-notes
index b635509..d58a537 100755
--- a/edit-notes
+++ b/edit-notes
@@ -2,6 +2,7 @@
 
 import argparse
 import yaml
+import remote
 
 clean = __import__('clean-notes')
 
@@ -28,7 +29,7 @@ if __name__ == '__main__':
     to_fix.update(to_remove)
 
     notes = clean.load_notes()
-    testedpkgs = clean.load_reproducible_status()
+    testedpkgs = remote.load_reproducible_status()
 
     # Validate issues
     for add in args.add_note:
diff --git a/filter-packages b/filter-packages
index 5cc9c9b..aaa4e85 100755
--- a/filter-packages
+++ b/filter-packages
@@ -77,8 +77,8 @@ def main():
 
         if options.show_ftbfs:
             if not status:
-                clean_notes = __import__('clean-notes')
-                status = clean_notes.load_reproducible_status()
+                import remote
+                status = remote.load_reproducible_status()
 
             if status.get(x, {}).get('status', None) != 'FTBFS':
                 continue
diff --git a/remote.py b/remote.py
new file mode 100644
index 0000000..de4d6f5
--- /dev/null
+++ b/remote.py
@@ -0,0 +1,43 @@
+import json
+
+import requests
+
+RB_SITE = 'https://reproducible.debian.net'
+REPRODUCIBLE_JSON = '{}/reproducible.json'.format(RB_SITE)
+# [{package: xxx, suite: sid, version: 0.0.0, status: reproducible}, {...}]
+
+
+def load_reproducible_status():
+    status = {}
+    try:
+        with open('reproducible.json') as f:
+            rstatus = json.load(f)
+    except FileNotFoundError:
+        rstatus = requests.get(REPRODUCIBLE_JSON).json()
+
+    for item in rstatus:
+        pkg = item['package']
+        version = str(item['version'])
+        # feed status with the unstable value, if available, otherwise prefer
+        # testing and then experimental
+        try:
+            if status[pkg]['suite'] == 'unstable':
+                continue  # that's the best
+            elif status[pkg]['suite'] == 'experimental':  # whatever we've now
+                status[pkg]['version'] = version          # is better
+                status[pkg]['suite'] = item['suite']
+                status[pkg]['status'] = item['status']
+            elif status[pkg]['suite'] == 'testing' and \
+                    item['suite'] != 'experimental':
+                status[pkg]['version'] = version
+                status[pkg]['suite'] = item['suite']
+                status[pkg]['status'] = item['status']
+        except KeyError:
+            status[pkg] = {
+                'version': version,
+                'suite': item['suite'],
+                'status': item['status'],
+            }
+
+    return status
+

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



More information about the Reproducible-commits mailing list