Add support for showing binary package file sizes in emerge
authorZac Medico <zmedico@gentoo.org>
Sat, 29 Dec 2007 10:41:14 +0000 (10:41 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 29 Dec 2007 10:41:14 +0000 (10:41 -0000)
--search output.

svn path=/main/trunk/; revision=9094

pym/_emerge/__init__.py

index 2d34ed553d08119700fd6cfd53266d2607b62cc7..ebb1fcecf6471f837e834c953827b93a0ee3e04f 100644 (file)
@@ -663,12 +663,6 @@ class search(object):
                                                        mysettings=self.settings, all=True)[1]
                                                try:
                                                        mysum[0] = mf.getDistfilesSize(fetchlist)
-                                                       mystr = str(mysum[0] / 1024)
-                                                       mycount = len(mystr)
-                                                       while (mycount > 3):
-                                                               mycount -= 3
-                                                               mystr = mystr[:mycount] + "," + mystr[mycount:]
-                                                       mysum[0] = mystr + " kB"
                                                except KeyError, e:
                                                        mysum[0] = "Unknown (missing digest for %s)" % \
                                                                str(e)
@@ -678,8 +672,22 @@ class search(object):
                                                if db is not vardb and \
                                                        db.cpv_exists(mycpv):
                                                        available = True
+                                                       if not myebuild and hasattr(db, "bintree"):
+                                                               myebuild = db.bintree.getname(mycpv)
+                                                               try:
+                                                                       mysum[0] = os.stat(myebuild).st_size
+                                                               except OSError:
+                                                                       myebuild = None
                                                        break
 
+                                       if myebuild:
+                                               mystr = str(mysum[0] / 1024)
+                                               mycount = len(mystr)
+                                               while (mycount > 3):
+                                                       mycount -= 3
+                                                       mystr = mystr[:mycount] + "," + mystr[mycount:]
+                                               mysum[0] = mystr + " kB"
+
                                        if self.verbose:
                                                if available:
                                                        print "     ", darkgreen("Latest version available:"),myversion