示例#1
0
    def iter_parse(self, path: str,
                   factory: PackageFactory) -> Iterable[PackageMaker]:
        for pkgdata in _iter_packages(path):
            with factory.begin(pkgdata['Package']) as pkg:
                fixed_version, flags = parse_debian_version(pkgdata['Version'])

                pkg.set_version(fixed_version)
                pkg.set_rawversion(pkgdata['Version'])
                pkg.set_flags(flags)

                pkg.add_maintainers(
                    extract_maintainers(pkgdata.get('Maintainer', '')))
                pkg.add_maintainers(
                    extract_maintainers(pkgdata.get('Uploaders', '')))
                pkg.add_categories(pkgdata.get('Section'))
                pkg.add_homepages(pkgdata.get('Homepage'))

                self._extra_handling(pkg, pkgdata)

                if (url := _extract_vcs_link(pkgdata)) is not None:
                    if self._allowed_vcs_urls_re is not None and self._allowed_vcs_urls_re.match(
                            url):
                        pkg.add_links(LinkType.PACKAGE_SOURCES, url)

                yield pkg
示例#2
0
def test_inseparable_garbage():
    assert parse_debian_version('1.1.2dfsg3') == ('1.1.2dfsg3', Pf.INCORRECT)
示例#3
0
def test_garbage_suffixes(suffix: str):
    assert parse_debian_version(f'1.1.2{suffix}-2') == ('1.1.2', 0)
示例#4
0
def test_epoch():
    assert parse_debian_version('1:1.2.3-1') == ('1.2.3', 0)
示例#5
0
def test_minus_parts_do_not_produce_extra_flags():
    assert parse_debian_version('1-2-3-4')[1] == 0
示例#6
0
def test_revision_is_not_greedy():
    assert parse_debian_version('1-2-3-4')[0] == '1-2-3'
示例#7
0
def test_revision():
    assert parse_debian_version('1.2.3-1.2.3') == ('1.2.3', 0)
示例#8
0
def test_basic():
    assert parse_debian_version('1.2.3-1') == ('1.2.3', 0)
示例#9
0
def test_real_world_weak(version: str, expected_version: str,
                         expected_flags: int):
    # checks for existence of specified flags, ignores other flags
    fixed_version, flags = parse_debian_version(version)
    assert fixed_version == expected_version
    assert flags & expected_flags == expected_flags
示例#10
0
def test_real_world(version: str, expected_version: str, expected_flags: int):
    fixed_version, flags = parse_debian_version(version)
    assert fixed_version == expected_version
    assert flags == expected_flags
示例#11
0
def test_suffixes(version: str, expected_flags: int):
    assert parse_debian_version(f'{version}-1') == (version, expected_flags)