]> git.decadent.org.uk Git - dak.git/blobdiff - utils.py
2004-07-01 James Troup <james@nocrew.org> * emilie (main): handle woody's case...
[dak.git] / utils.py
index 1ad6a4e7762dcc6888b5679a732dae8eca2f566c..3d83da0193fd4d2a5fa90753047de376ab32f7d9 100644 (file)
--- a/utils.py
+++ b/utils.py
@@ -2,7 +2,7 @@
 
 # Utility functions
 # Copyright (C) 2000, 2001, 2002, 2003, 2004  James Troup <james@nocrew.org>
-# $Id: utils.py,v 1.66 2004-04-03 02:49:46 troup Exp $
+# $Id: utils.py,v 1.69 2004-06-24 00:41:39 troup Exp $
 
 ################################################################################
 
@@ -327,10 +327,12 @@ switched to 'email (name)' format."""
     if not maintainer:
         return ('', '', '', '');
 
-    if maintainer.find("<") == -1 or (maintainer[0] == "<" and \
-                                      maintainer[-1:] == ">"):
+    if maintainer.find("<") == -1:
         email = maintainer;
         name = "";
+    elif (maintainer[0] == "<" and maintainer[-1:] == ">"):
+        email = maintainer[1:-1];
+        name = "";
     else:
         m = re_parse_maintainer.match(maintainer);
         if not m:
@@ -499,13 +501,13 @@ def whoami ():
 ################################################################################
 
 def size_type (c):
-    t  = " b";
-    if c > 10000:
-        c = c / 1000;
-        t = " Kb";
-    if c > 10000:
-        c = c / 1000;
-        t = " Mb";
+    t  = " B";
+    if c > 10240:
+        c = c / 1024;
+        t = " KB";
+    if c > 10240:
+        c = c / 1024;
+        t = " MB";
     return ("%d%s" % (c, t))
 
 ################################################################################
@@ -635,6 +637,19 @@ def join_with_commas_and(list):
 
 ################################################################################
 
+def pp_dep (deps):
+    pp_deps = [];
+    for atom in deps:
+        (pkg, version, constraint) = atom;
+        if constraint:
+            pp_dep = "%s (%s %s)" % (pkg, constraint, version);
+        else:
+            pp_dep = pkg;
+        pp_deps.append(pp_dep);
+    return " |".join(pp_deps);
+
+################################################################################
+
 def get_conf():
        return Cnf;