= Package Relationship Model = We call "package relationship" the DSC field which describes relation between the package in question and others availble: For sources DSC provides: * builddepends * builddependsindep For binaries we have: * shlibdeps * depends * recommends * suggests * conflicts * replaces * provides Those lines contain a list of comma-separated relationship where each element follows this format: $NAME [($OPERATOR $VERSION)] For example: >>> relationship_line = ( ... 'gcc-3.4-base, libc6 (>= 2.3.2.ds1-4), gcc-3.4 ( = 3.4.1-4sarge1)') Launchpad models package relationship elements via the IPackageRelationShip instance. We use APT to parse the relationship lines: >>> from apt_pkg import ParseDepends ParseDepends returns a 'list of lists of tuples' as: [ [('$NAME', '$VERSION', '$OPERATOR')], [('$NAME', '$VERSION', '$OPERATOR')], ... ] So we need perform a small treatment on its result in order to have *sane* data: >>> parsed_relationships = [relationship for (relationship,) in ... ParseDepends(relationship_line)] Let's see what we call 'sane': >>> parsed_relationships [('gcc-3.4-base', '', ''), ('libc6', '2.3.2.ds1-4', '>='), ('gcc-3.4', '3.4.1-4sarge1', '=')] Now for each parsed element we can build an IPackageRelationship: >>> from lp.soyuz.browser.packagerelationship import PackageRelationship >>> from lp.soyuz.interfaces.packagerelationship import IPackageRelationship >>> from lp.services.webapp.testing import verifyObject >>> name, version, operator = parsed_relationships[1] >>> fake_url = 'http://host/path' >>> pkg_relationship = PackageRelationship( ... name, operator, version, url=fake_url) >>> verifyObject(IPackageRelationship, pkg_relationship) True >>> pkg_relationship.name 'libc6' >>> pkg_relationship.operator '>=' >>> pkg_relationship.version '2.3.2.ds1-4' >>> pkg_relationship.url == fake_url True