mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-05-23 00:11:32 +00:00
Add PackageId and BinaryPackageId objects
This commit is contained in:
parent
3c8b7ba11d
commit
f11d92bf8f
@ -250,11 +250,46 @@ class SourcePackage(object):
|
|||||||
return getattr(self, self.__slots__[item])
|
return getattr(self, self.__slots__[item])
|
||||||
|
|
||||||
|
|
||||||
BinaryPackageId = namedtuple('BinaryPackageId', [
|
class PackageId(namedtuple(
|
||||||
'package_name',
|
'PackageId',
|
||||||
'version',
|
[
|
||||||
'architecture',
|
'package_name',
|
||||||
])
|
'version',
|
||||||
|
'architecture',
|
||||||
|
])):
|
||||||
|
"""Represent a source or binary package"""
|
||||||
|
|
||||||
|
def __init__(self, package_name, version, architecture):
|
||||||
|
assert self.architecture != 'all', "all not allowed for PackageId (%s)" % (self.name)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return ('PID(%s)' % (self.name))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
if self.architecture == "source":
|
||||||
|
return ('%s/%s' % (self.package_name, self.version))
|
||||||
|
else:
|
||||||
|
return ('%s/%s/%s' % (self.package_name, self.version, self.architecture))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def uvname(self):
|
||||||
|
if self.architecture == "source":
|
||||||
|
return ('%s' % (self.package_name))
|
||||||
|
else:
|
||||||
|
return ('%s/%s' % (self.package_name, self.architecture))
|
||||||
|
|
||||||
|
|
||||||
|
class BinaryPackageId(PackageId):
|
||||||
|
"""Represent a binary package"""
|
||||||
|
|
||||||
|
def __init__(self, package_name, version, architecture):
|
||||||
|
assert self.architecture != 'source', "Source not allowed for BinaryPackageId (%s)" % (self.name)
|
||||||
|
super().__init__(package_name, version, architecture)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return ('BPID(%s)' % (self.name))
|
||||||
|
|
||||||
|
|
||||||
BinaryPackage = namedtuple('BinaryPackage', [
|
BinaryPackage = namedtuple('BinaryPackage', [
|
||||||
'version',
|
'version',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user