Exemplo n.º 1
0
    def _parse(self, source):
        self.package_list = []

        binaries_binary = self._binaries(source)
        binaries_package_list = set()

        for line in source['Package-List'].split("\n"):
            if not line:
                continue
            fields = line.split()
            if len(fields) < 4:
                raise InvalidSource("Package-List entry has less than four fields.")

            # <name> <type> <component/section> <priority> [arch=<arch>[,<arch>]...]
            name = fields[0]
            package_type = fields[1]
            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 Binary.".format(name))
            binaries_package_list.add(name)

            entry = PackageListEntry(name, package_type, section, component, priority, **other)
            self.package_list.append(entry)

        if len(binaries_binary) != len(binaries_package_list):
            raise InvalidSource("Package-List and Binaries fields have a different number of entries.")
Exemplo n.º 2
0
 def test_extract_component_from_section(self):
     data = [
         # Argument is passed through as first return value. There
         # is a comment in docs/TODO.old suggesting that it should
         # be changed.
         ('utils', ('utils', 'main')),
         ('main/utils', ('main/utils', 'main')),
         ('non-free/libs', ('non-free/libs', 'non-free')),
         ('contrib/net', ('contrib/net', 'contrib')),
         ('non-free/two/slashes', ('non-free/two/slashes', 'non-free'))
     ]
     for v, r in data:
         self.assertEqual(extract_component_from_section(v), r)
Exemplo n.º 3
0
    def _parse(self, source):
        self.package_list = []

        binaries_binary = self._binaries(source)
        binaries_package_list = set()

        for line in source['Package-List'].split("\n"):
            if not line:
                continue
            fields = line.split()
            if len(fields) < 4:
                raise InvalidSource(
                    "Package-List entry has less than four fields.")

            # <name> <type> <component/section> <priority> [arch=<arch>[,<arch>]...]
            name = fields[0]
            package_type = fields[1]
            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 Binary.".
                    format(name))
            binaries_package_list.add(name)

            entry = PackageListEntry(name, package_type, section, component,
                                     priority, **other)
            self.package_list.append(entry)

        if len(binaries_binary) != len(binaries_package_list):
            raise InvalidSource(
                "Package-List and Binaries fields have a different number of entries."
            )
 def assertExtract(self, input, output):
     self.setup_components()
     self.assertEqual(
         extract_component_from_section(input, self.session)[1],
         output,
     )
 def assertExtract(self, input, output):
     self.setup_components()
     self.assertEqual(
         extract_component_from_section(input, self.session)[1],
         output,
     )