[python-debian/master] bugfix: mangle '-' as '_' in method names

Stefano Zacchiroli zack at upsilon.cc
Thu Jun 19 14:04:36 UTC 2008


without this change, the parsed version of Build-Depends will correspond
to a method called "build-depends" which is not callable
---
 debian_bundle/deb822.py |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/debian_bundle/deb822.py b/debian_bundle/deb822.py
index f934581..e1f1277 100644
--- a/debian_bundle/deb822.py
+++ b/debian_bundle/deb822.py
@@ -507,20 +507,21 @@ class _PkgRelMixin(object):
     To use, subclass _PkgRelMixin from a class with a _relationship_fields
     attribute. It should be a list of field names for which structured access
     is desired; for each of them a method wild be added to the inherited class.
-    The method name will be the lowercase version of field name. The method
-    would return relationships in the same format of the PkgRel' rels property.
+    The method name will be the lowercase version of field name; '-' will be
+    mangled as '_'. The method would return relationships in the same format of
+    the PkgRel' rels property.
 
     See Packages and Sources as examples.
     """
 
     def __init__(self, *args, **kwargs):
         for name in self._relationship_fields:
-            name = name.lower()
             if self.has_key(name):
+                methodname = name.lower().replace('-', '_')
                 method = new.instancemethod(
                         lambda self, name=name: PkgRel.parse_rels(self[name]),
                         self, _PkgRelMixin)
-                setattr(_PkgRelMixin, name, method)
+                setattr(_PkgRelMixin, methodname, method)
 
 class _multivalued(Deb822):
     """A class with (R/W) support for multivalued fields.
-- 
1.5.4.2





More information about the pkg-python-debian-commits mailing list