[yum-cvs] yum/yum misc.py,1.11,1.12

Panu Matilainen pmatilai at login.linux.duke.edu
Mon Aug 8 15:45:32 UTC 2005


Update of /home/groups/yum/cvs/yum/yum
In directory login:/tmp/cvs-serv32291/yum

Modified Files:
	misc.py 
Log Message:
Allow misc.GenericHolder class to be accessed like a dictionary.


Index: misc.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/misc.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- misc.py	23 Jun 2005 04:54:50 -0000	1.11
+++ misc.py	8 Aug 2005 15:45:30 -0000	1.12
@@ -146,10 +146,14 @@
 class GenericHolder:
     """Generic Holder class used to hold other objects of known types
        It exists purely to be able to do object.somestuff, object.someotherstuff
-       and pass object to another function that will understand it"""
+       or object[key] and pass object to another function that will 
+       understand it"""
        
-    pass
-
+    def __getitem__(self, item):
+        if hasattr(self, item):
+            return getattr(self, item)
+        else:
+            raise KeyError, item
 
 def procgpgkey(rawkey):
     '''Convert ASCII armoured GPG key to binary




More information about the Yum-cvs-commits mailing list