Hello,

As someone mentioned Python 3 here and on fedora-devel... here's a small patch 
that gets metadata entries' has_key() out of the way of further has_key() 
related changes.

So when previously one would do "entry.has_key(foo)", after this one should do 
"foo in entry" instead.
From a34b26f1e67274cbbe00bce17d280517a8bf103b Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ville=20Skytt=C3=A4?= <ville.sky...@iki.fi>
Date: Fri, 2 Oct 2009 00:25:43 +0300
Subject: [PATCH 6/6] Deprecate has_key() in favour of "in" for metadata entries.

As a side effect, entries are now iterable.
---
 yum/mdparser.py |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/yum/mdparser.py b/yum/mdparser.py
index c74608d..26c128b 100644
--- a/yum/mdparser.py
+++ b/yum/mdparser.py
@@ -22,6 +22,9 @@ except ImportError:
 iterparse = cElementTree.iterparse
 
 from cStringIO import StringIO
+import warnings
+
+import Errors
 
 #TODO: document everything here
 
@@ -79,7 +82,12 @@ class BaseEntry:
         return self._p.values()
 
     def has_key(self, k):
-        return self._p.has_key(k)
+        warnings.warn('has_key() will go away in a future version of Yum.\n'
+                      Errors.YumFutureDeprecationWarning, stacklevel=2)
+        return k in self._p
+
+    def __iter__(self):
+        return iter(self._p)
 
     def __str__(self):
         out = StringIO()
-- 
1.6.2.5

_______________________________________________
Yum-devel mailing list
Yum-devel@lists.baseurl.org
http://lists.baseurl.org/mailman/listinfo/yum-devel

Reply via email to