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

svn path=/main/branches/2.1.2/; revision=9095

bin/emerge

index f1ae377eb6a87ef4264ea6220e6e5a7f039e6c52..365c69a25f7d54c9d89ac2bbd0eac3deed1d2450 100755 (executable)
@@ -637,12 +637,6 @@ class search:
                                                        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)
@@ -652,8 +646,22 @@ class search:
                                                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