make clean

December 29, 2007

Yummier yumex

Filed under: Uncategorized — harshadrj @ 9:56 am
Tags: , , ,

After many days of struggling with yumex code I finally managed to add a nifty feature to it. With this fix, yumex shows the version difference for an update in bold font.Yumex snap small

I find this very useful to quickly determine if an update is a major upgrade or not. In the above example, rosegarden is a major upgrade, while qt4-x11 is a minor one.

I am posting the patch here, since the yumex website seems to be rather sparse and ill-maintained. This patch is against the 2.0.3 release.

diff -bBud /usr/share/yumex/views.py ./views.py
--- /usr/share/yumex/views.py 2007-11-19 14:59:55.000000000 +0530
+++ ./views.py 2007-12-29 01:00:17.000000000 +0530
@@ -115,9 +115,27 @@
self.view.append_column( column )
return column

+ def diff (self, old, new):
+ index = 0
+ similar = True
+ while (index < len(new)) and (index < len(old)) and similar :
+ if (old[index] != new[index]):
+ similar = False
+ else:
+ index += 1
+
+ if index == 0:
+ return ("", new)
+ else:
+ return (new[0:index], new[index:])
+
def get_data_text( self, column, cell, model, iter,property ):
obj = model.get_value( iter, 0 )
if obj:
+ if (property == "ver"):
+ (common, new) = self.diff (obj.old_version, getattr(obj, property))
+ cell.set_property( 'markup', "%s%s" % (common, new))
+ else:
cell.set_property( 'text', getattr( obj, property ) )
cell.set_property('foreground',obj.color)

diff -bBud /usr/share/yumex/yumex.py ./yumex.py
--- /usr/share/yumex/yumex.py 2007-11-19 14:59:55.000000000 +0530
+++ ./yumex.py 2007-12-29 09:57:40.000000000 +0530
@@ -534,6 +534,12 @@
self.progressLog(_('Population view with packages'))
self.ui.viewPkg.set_model(None)
for po in allpkgs:
+ old_version = self.yumbase.rpmdb.searchNevra(name = po.name)
+ if (len(old_version) > 0):
+ po.old_version = str(old_version[0])
+ po.old_version = po.old_version[po.old_version.find(" -") + 3:]
+ else:
+ po.old_version = ""
self.pkgView.store.append([po,str(po)])
self.ui.viewPkg.set_model(self.pkgView.store)

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: