pkgextra: allow multiple values for reference mapping
Since we added PURLs instead of key->value we map to key->list[value] since the keys are not longer unique.
This commit is contained in:
parent
7f4f822e9b
commit
a19180130b
@ -579,7 +579,7 @@ class Source:
|
|||||||
for ext_id in state.ext_info_ids:
|
for ext_id in state.ext_info_ids:
|
||||||
variants = []
|
variants = []
|
||||||
if ext_id.id in self.pkgextra.references:
|
if ext_id.id in self.pkgextra.references:
|
||||||
mapped = self.pkgextra.references[ext_id.id]
|
mapped = self.pkgextra.references[ext_id.id][0]
|
||||||
if mapped is None:
|
if mapped is None:
|
||||||
continue
|
continue
|
||||||
variants = [mapped]
|
variants = [mapped]
|
||||||
@ -600,7 +600,7 @@ class Source:
|
|||||||
f"https://repology.org/tools/project-by?repo={quote(repology_repo)}&name_type=srcname&target_page=project_versions&name={quote(self.name)}", {})))
|
f"https://repology.org/tools/project-by?repo={quote(repology_repo)}&name_type=srcname&target_page=project_versions&name={quote(self.name)}", {})))
|
||||||
|
|
||||||
# XXX: let anitya do the searching for us, unless we have an ID
|
# XXX: let anitya do the searching for us, unless we have an ID
|
||||||
project_id = self.pkgextra.references.get("anitya", self.realname)
|
project_id = self.pkgextra.references.get("anitya", [self.realname])[0]
|
||||||
if project_id is not None:
|
if project_id is not None:
|
||||||
ext.append((
|
ext.append((
|
||||||
ExtId("anitya", "Anitya", True, True),
|
ExtId("anitya", "Anitya", True, True),
|
||||||
|
|||||||
@ -34,7 +34,7 @@ async def update_pypi_versions(pkgextra: PkgExtra) -> None:
|
|||||||
for entry in pkgextra.packages.values():
|
for entry in pkgextra.packages.values():
|
||||||
if "pypi" not in entry.references:
|
if "pypi" not in entry.references:
|
||||||
continue
|
continue
|
||||||
pypi_name = entry.references["pypi"]
|
pypi_name = entry.references["pypi"][0]
|
||||||
assert isinstance(pypi_name, str)
|
assert isinstance(pypi_name, str)
|
||||||
normalized_name = normalize(pypi_name)
|
normalized_name = normalize(pypi_name)
|
||||||
if normalized_name in projects:
|
if normalized_name in projects:
|
||||||
|
|||||||
@ -8,7 +8,7 @@ from collections.abc import Sequence, Collection
|
|||||||
class PkgExtraEntry(BaseModel):
|
class PkgExtraEntry(BaseModel):
|
||||||
"""Extra metadata for a PKGBUILD"""
|
"""Extra metadata for a PKGBUILD"""
|
||||||
|
|
||||||
references: dict[str, str | None] = Field(default_factory=dict)
|
references: dict[str, list[str | None]] = Field(default_factory=dict)
|
||||||
"""References to third party repositories"""
|
"""References to third party repositories"""
|
||||||
|
|
||||||
changelog_url: str | None = Field(default=None)
|
changelog_url: str | None = Field(default=None)
|
||||||
@ -39,8 +39,8 @@ class PkgExtra(BaseModel):
|
|||||||
"""A mapping of pkgbase names to PkgExtraEntry"""
|
"""A mapping of pkgbase names to PkgExtraEntry"""
|
||||||
|
|
||||||
|
|
||||||
def convert_mapping(array: Sequence[str]) -> dict[str, str | None]:
|
def convert_mapping(array: Sequence[str]) -> dict[str, list[str | None]]:
|
||||||
converted: dict[str, str | None] = {}
|
converted: dict[str, list[str | None]] = {}
|
||||||
for item in array:
|
for item in array:
|
||||||
if ":" in item:
|
if ":" in item:
|
||||||
key, value = item.split(":", 1)
|
key, value = item.split(":", 1)
|
||||||
@ -48,7 +48,7 @@ def convert_mapping(array: Sequence[str]) -> dict[str, str | None]:
|
|||||||
else:
|
else:
|
||||||
key = item
|
key = item
|
||||||
value = None
|
value = None
|
||||||
converted[key] = value
|
converted.setdefault(key, []).append(value)
|
||||||
return converted
|
return converted
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -214,7 +214,7 @@ def test_vercmp():
|
|||||||
def test_extra_to_pkgextra_entry():
|
def test_extra_to_pkgextra_entry():
|
||||||
assert extra_to_pkgextra_entry(
|
assert extra_to_pkgextra_entry(
|
||||||
{"references": ['foo: quux', 'bar']}
|
{"references": ['foo: quux', 'bar']}
|
||||||
).references == {'foo': 'quux', 'bar': None}
|
).references == {'foo': ['quux'], 'bar': [None]}
|
||||||
assert extra_to_pkgextra_entry(
|
assert extra_to_pkgextra_entry(
|
||||||
{"changelog_url": "foo"}
|
{"changelog_url": "foo"}
|
||||||
).changelog_url == "foo"
|
).changelog_url == "foo"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user