[yum-commits] Branch 'yum-3_2_X' - yum/packages.py yum/rpmsack.py yum/sqlitesack.py
skvidal at osuosl.org
skvidal at osuosl.org
Wed Mar 25 14:16:13 UTC 2009
yum/packages.py | 3 +++
yum/rpmsack.py | 5 +++++
yum/sqlitesack.py | 4 ++++
3 files changed, 12 insertions(+)
New commits:
commit d03389725e3779928d721370aed9e14afb5304a6
Author: Seth Vidal <skvidal at fedoraproject.org>
Date: Wed Mar 25 10:13:57 2009 -0400
make help() and other protected attributes lookup properly for rpmdb package objects and sqlite package objects
diff --git a/yum/packages.py b/yum/packages.py
index a7e81e6..319b87a 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -1076,6 +1076,9 @@ class YumHeaderPackage(YumAvailablePackage):
def __getattr__(self, thing):
#FIXME - if an error - return AttributeError, not KeyError
# ONLY FIX THIS AFTER THE API BREAK
+ if thing.startswith('__') and thing.endswith('__'):
+ if not hasattr(self, thing):
+ raise AttributeError, "%s has no attribute %s" % (self, thing)
return self.hdr[thing]
def doepoch(self):
diff --git a/yum/rpmsack.py b/yum/rpmsack.py
index 171ae92..30594cf 100644
--- a/yum/rpmsack.py
+++ b/yum/rpmsack.py
@@ -60,9 +60,14 @@ class RPMInstalledPackage(YumInstalledPackage):
def __getattr__(self, varname):
self.hdr = val = self._get_hdr()
self._has_hdr = True
+ if varname.startswith('__') and varname.endswith('__'):
+ if not hasattr(self, varname):
+ raise AttributeError, "%s has no attribute %s" % (self, varname)
+
if varname != 'hdr': # This is unusual, for anything that happens
val = val[varname] # a lot we should preload at __init__.
# Also note that pkg.no_value raises KeyError.
+
return val
diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index 07f402b..0e8985d 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -141,6 +141,10 @@ class YumAvailablePackageSqlite(YumAvailablePackage, PackageObject, RpmBase):
'license' : 'rpm_license',
'checksum_value' : 'pkgId',
}
+
+ if varname.startswith('__') and varname.endswith('__'):
+ if not hasattr(self, varname):
+ raise AttributeError, varname
dbname = varname
if db2simplemap.has_key(varname):
More information about the Yum-commits
mailing list