]> git.decadent.org.uk Git - dak.git/blobdiff - dak/examine_package.py
Suppress warnings in the most suitable files.
[dak.git] / dak / examine_package.py
index 5a35a99da9f7a28836fa955debec1b8bad37f60e..0e1b34ff23ee9b86802af1668c7d574b868e34a1 100755 (executable)
@@ -42,6 +42,12 @@ to stdout. Those functions can be used in multithreaded parts of dak.
 
 ################################################################################
 
+# suppress some deprecation warnings in squeeze related to md5 module
+import warnings
+warnings.filterwarnings('ignore', \
+    "the md5 module is deprecated; use hashlib instead", \
+    DeprecationWarning)
+
 import errno
 import os
 import re
@@ -64,8 +70,8 @@ from daklib.regexes import html_escaping, re_html_escaping, re_version, re_space
 Cnf = None
 Cnf = utils.get_conf()
 
-changes_lock = threading.Lock()
-printed_copyrights = {}
+printed = threading.local()
+printed.copyrights = {}
 package_relations = {}           #: Store relations of packages for later output
 
 # default is to not output html.
@@ -114,7 +120,8 @@ ansi_colours = {
   'arch': "\033[32m",
   'end': "\033[0m",
   'bold': "\033[1m",
-  'maintainer': "\033[32m"}
+  'maintainer': "\033[32m",
+  'distro': "\033[1m\033[41m"}
 
 html_colours = {
   'main': ('<span style="color: aqua">',"</span>"),
@@ -122,7 +129,8 @@ html_colours = {
   'nonfree': ('<span style="color: red">',"</span>"),
   'arch': ('<span style="color: green">',"</span>"),
   'bold': ('<span style="font-weight: bold">',"</span>"),
-  'maintainer': ('<span style="color: green">',"</span>")}
+  'maintainer': ('<span style="color: green">',"</span>"),
+  'distro': ('<span style="font-weight: bold; background-color: red">',"</span>")}
 
 def colour_output(s, colour):
     if use_html:
@@ -298,6 +306,9 @@ def read_changes_or_dsc (suite, filename, session = None):
         elif k == "architecture":
             if (dsc["architecture"] != "any"):
                 dsc['architecture'] = colour_output(dsc["architecture"], 'arch')
+        elif k == "distribution":
+            if dsc["distribution"] not in ('unstable', 'experimental'):
+                dsc['distribution'] = colour_output(dsc["distribution"], 'distro')
         elif k in ("files","changes","description"):
             if use_html:
                 dsc[k] = formatted_text(dsc[k], strip=True)
@@ -416,7 +427,7 @@ def do_lintian (filename):
         return do_command("lintian --show-overrides --color always", filename, 1)
 
 def get_copyright (deb_filename):
-    global changes_lock, printed_copyrights
+    global printed
 
     package = re_package.sub(r'\1', deb_filename)
     o = os.popen("dpkg-deb -c %s | egrep 'usr(/share)?/doc/[^/]*/copyright' | awk '{print $6}' | head -n 1" % (deb_filename))
@@ -434,13 +445,11 @@ def get_copyright (deb_filename):
     copyrightmd5 = md5.md5(cright).hexdigest()
 
     res = ""
-    changes_lock.acquire()
-    if printed_copyrights.has_key(copyrightmd5) and printed_copyrights[copyrightmd5] != "%s (%s)" % (package, deb_filename):
+    if printed.copyrights.has_key(copyrightmd5) and printed.copyrights[copyrightmd5] != "%s (%s)" % (package, deb_filename):
         res += formatted_text( "NOTE: Copyright is the same as %s.\n\n" % \
-                               (printed_copyrights[copyrightmd5]))
+                               (printed.copyrights[copyrightmd5]))
     else:
-        printed_copyrights[copyrightmd5] = "%s (%s)" % (package, deb_filename)
-    changes_lock.release()
+        printed.copyrights[copyrightmd5] = "%s (%s)" % (package, deb_filename)
     return res+formatted_text(cright)
 
 def get_readme_source (dsc_filename):
@@ -544,11 +553,9 @@ def strip_pgp_signature (filename):
     return contents
 
 def display_changes(suite, changes_filename):
-    global changes_lock, printed_copyrights
+    global printed
     changes = read_changes_or_dsc(suite, changes_filename)
-    changes_lock.acquire()
-    printed_copyrights = {}
-    changes_lock.release()
+    printed.copyrights = {}
     return foldable_output(changes_filename, "changes", changes, norow=True)
 
 def check_changes (changes_filename):