= SourcePackage View Classes = >>> from zope.component import queryMultiAdapter >>> from canonical.launchpad.webapp.servers import LaunchpadTestRequest >>> from lp.registry.interfaces.distribution import IDistributionSet Empty request. >>> mock_form = {} >>> request = LaunchpadTestRequest(form=mock_form) Retrieve an known Sourcepackage object: >>> ubuntu = getUtility(IDistributionSet)['ubuntu'] >>> hoary = ubuntu['hoary'] >>> pmount = hoary.getSourcePackage('pmount') Retrieve its respective View class: >>> pmount_view = queryMultiAdapter((pmount, request), name="+index") Check the consistency of a handy structure containing the organized published history of a sourcepackage. It should contain a list of dictionaries containing all supported pockets as key 'pocketdetails' and a list of packages represented by IDistroSeriesSourcePackageRelease as 'packages', as: [ {'pocketdetails': PackagePublishingPocket, 'packages': [IDistroSeriesSourcePackagerelease, ...]} ... ] Each pocket should only contain packages marked as PUBLISHED. >>> for pub in pmount_view.published_by_pocket(): ... pkg_versions = [p.version for p in pub['packages']] ... print pub['pocketdetails'].title, sorted(pkg_versions) Release [u'0.1-2'] Security [] Updates [] Proposed [] Backports [] Check the consistence of the binaries dictionary, it should contains a binarypackagename and the architecture where it was built. Let's retrieve a new view with useful dependency data: >>> warty = ubuntu['warty'] >>> firefox = warty.getSourcePackage('mozilla-firefox') >>> firefox_view = queryMultiAdapter((firefox, request), name="+index") XXX cprov 20060210: this method is very confusing because the architecturespecific attribute is hidden, i.e, this binary is architecture independent and we don't know at this point, that's why we have only on binary. >>> for bin_name, archs in firefox_view.binaries().items(): ... print bin_name, archs mozilla-firefox [u'hppa', u'i386'] mozilla-firefox-data [u'hppa', u'i386'] Check the formatted dependency lines provided by the view class, they return a IPackageRelationshipSet object (see package-relationship.txt). >>> firefox_parsed_depends = firefox_view.builddepends >>> from lp.soyuz.interfaces.packagerelationship import IPackageRelationshipSet >>> from canonical.launchpad.webapp.testing import verifyObject >>> verifyObject(IPackageRelationshipSet, firefox_parsed_depends) True >>> for dep in firefox_parsed_depends: ... dep.name, dep.operator, dep.version, dep.url ('gcc-3.4', '>=', '3.4.1-4sarge1', None) ('gcc-3.4', '<<', '3.4.2', None) ('gcc-3.4-base', None, '', None) ('libc6', '>=', '2.3.2.ds1-4', None) ('libstdc++6-dev', '>=', '3.4.1-4sarge1', None) ('pmount', None, '', u'http://launchpad.dev/ubuntu/warty/+package/pmount') >>> firefox_parsed_dependsindep = firefox_view.builddependsindep >>> verifyObject(IPackageRelationshipSet, firefox_parsed_dependsindep) True >>> for dep in firefox_parsed_dependsindep: ... dep.name, dep.operator, dep.version, dep.url ('bacula-common', '=', '1.34.6-2', None) ('bacula-director-common', '=', '1.34.6-2', None) ('pmount', None, '', u'http://launchpad.dev/ubuntu/warty/+package/pmount') ('postgresql-client', '>=', '7.4', None) Ensure we have fixed bug 31039, by properly escape the sourcepackagename before passing to regexp. >>> libc = hoary.getSourcePackage('libstdc++')['b8p'] >>> libc_view = queryMultiAdapter((libc, request), name="+changelog") >>> print libc_view.changelog_entry libstdc++ (9.9-1) hoary; urgency=high * Placeholder -- Sample Person <email address hidden> Tue, 10 Feb 2006 10:10:08 +0300