X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fpackagelist.py;h=04a0ef518777b754405b26b6bfb4c01ef1e366d4;hb=d92f3e09718a6712554d770ced860cd4712bb941;hp=f98a0c47714fc0a8fa776b0c7740f7715c16f2fb;hpb=0a192c3069a2cc332a08649dc1b0e9887fcb2a77;p=dak.git diff --git a/daklib/packagelist.py b/daklib/packagelist.py index f98a0c47..04a0ef51 100644 --- a/daklib/packagelist.py +++ b/daklib/packagelist.py @@ -27,7 +27,7 @@ class InvalidSource(Exception): class PackageListEntry(object): def __init__(self, name, package_type, section, component, priority, **other): self.name = name - self.package_type = package_type + self.type = package_type self.section = section self.component = component self.priority = priority @@ -62,23 +62,25 @@ class PackageListEntry(object): class PackageList(object): def __init__(self, source): - self._source = source - if 'Package-List' in self._source: - self._parse() - elif 'Binary' in self._source: - self._parse_fallback() + if 'Package-List' in source: + self._parse(source) + elif 'Binary' in source: + self._parse_fallback(source) else: raise InvalidSource('Source package has neither Package-List nor Binary field.') self.fallback = any(entry.architectures is None for entry in self.package_list) - def _parse(self): + def _binaries(self, source): + return set(name.strip() for name in source['Binary'].split(",")) + + def _parse(self, source): self.package_list = [] - binaries_binary = set(self._source['Binary'].split()) + binaries_binary = self._binaries(source) binaries_package_list = set() - for line in self._source['Package-List'].split("\n"): + for line in source['Package-List'].split("\n"): if not line: continue fields = line.split() @@ -88,14 +90,14 @@ class PackageList(object): # [arch=[,]...] name = fields[0] package_type = fields[1] - component, section = extract_component_from_section(fields[2]) + section, component = extract_component_from_section(fields[2]) priority = fields[3] other = dict(kv.split('=', 1) for kv in fields[4:]) if name in binaries_package_list: raise InvalidSource("Package-List has two entries for '{0}'.".format(name)) if name not in binaries_binary: - raise InvalidSource("Package-List lists {0} which is not listed in Binaries.".format(name)) + raise InvalidSource("Package-List lists {0} which is not listed in Binary.".format(name)) binaries_package_list.add(name) entry = PackageListEntry(name, package_type, section, component, priority, **other) @@ -104,10 +106,10 @@ class PackageList(object): if len(binaries_binary) != len(binaries_package_list): raise InvalidSource("Package-List and Binaries fields have a different number of entries.") - def _parse_fallback(self): + def _parse_fallback(self, source): self.package_list = [] - for binary in self._source['Binary'].split(): + for binary in self._binaries(source): name = binary package_type = None component = None