* lpapiwrapper.py:

- Rename _SourcePackage to SourcePackage and make it a sub-class of BaseWrapper
This commit is contained in:
Michael Bienia 2009-07-19 15:59:43 +02:00
parent 682d7be285
commit 974deb0a9a

View File

@ -157,7 +157,7 @@ class LpApiWrapper(object):
srcpkg = cls.getUbuntuArchive().getPublishedSources( srcpkg = cls.getUbuntuArchive().getPublishedSources(
source_name = name, distro_series = series._lpobject, pocket = pocket, source_name = name, distro_series = series._lpobject, pocket = pocket,
status = 'Published', exact_match = True)[0] status = 'Published', exact_match = True)[0]
cls._src_pkg[(name, series, pocket)] = _SourcePackage(srcpkg) cls._src_pkg[(name, series, pocket)] = SourcePackage(srcpkg)
except IndexError: except IndexError:
if pocket == 'Release': if pocket == 'Release':
msg = "The package '%s' does not exist in the Ubuntu main archive in '%s'" % \ msg = "The package '%s' does not exist in the Ubuntu main archive in '%s'" % \
@ -182,7 +182,7 @@ class LpApiWrapper(object):
exist yet in Ubuntu assume 'universe' for component. exist yet in Ubuntu assume 'universe' for component.
''' '''
if isinstance(package, _SourcePackage): if isinstance(package, SourcePackage):
component = package.getComponent() component = package.getComponent()
package = package.getPackageName() package = package.getPackageName()
else: else:
@ -220,7 +220,7 @@ class LpApiWrapper(object):
''' '''
Check if the user has PerPackageUpload rights for package. Check if the user has PerPackageUpload rights for package.
''' '''
if isinstance(package, _SourcePackage): if isinstance(package, SourcePackage):
pkg = package.getPackageName() pkg = package.getPackageName()
else: else:
pkg = package pkg = package
@ -287,7 +287,7 @@ class BaseWrapper(object):
raise TypeError("'%s' is not a '%s' object" % (str(lpobject), str(cls.resource_type))) raise TypeError("'%s' is not a '%s' object" % (str(lpobject), str(cls.resource_type)))
def __getattr__(self, attr): def __getattr__(self, attr):
return getattr(self._entry, attr) return getattr(self._lpobject, attr)
class DistroSeries(BaseWrapper): class DistroSeries(BaseWrapper):
@ -296,36 +296,31 @@ class DistroSeries(BaseWrapper):
''' '''
resource_type = 'https://api.edge.launchpad.net/beta/#distro_series' resource_type = 'https://api.edge.launchpad.net/beta/#distro_series'
class _SourcePackage(object):
class SourcePackage(BaseWrapper):
''' '''
Wrapper class around a LP source package object. Wrapper class around a LP source package object.
''' '''
def __init__(self, srcpkg): resource_type = 'https://api.edge.launchpad.net/beta/#source_package_publishing_history'
if isinstance(srcpkg, Entry) and srcpkg.resource_type_link == 'https://api.edge.launchpad.net/beta/#source_package_publishing_history':
self._srcpkg = srcpkg
else:
raise TypeError('A LP API source package representation expected.')
def getPackageName(self): def getPackageName(self):
''' '''
Returns the source package name. Returns the source package name.
''' '''
return self._srcpkg.source_package_name return self._lpobject.source_package_name
def getVersion(self): def getVersion(self):
''' '''
Returns the version of the source package. Returns the version of the source package.
''' '''
return self._srcpkg.source_package_version return self._lpobject.source_package_version
def getComponent(self): def getComponent(self):
''' '''
Returns the component of the source package. Returns the component of the source package.
''' '''
return self._srcpkg.component_name return self._lpobject.component_name
def __getattr__(self, attr):
return getattr(self._srcpkg, attr)
class _PersonTeam(object): class _PersonTeam(object):
''' '''