Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg: Support upstream metadata #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

CyberTailor
Copy link

@CyberTailor CyberTailor commented Jan 17, 2024

Fully supported only for Portage, pkgcore can return only remote-ids.

gentoopm/basepm/upstream.py Outdated Show resolved Hide resolved
gentoopm/basepm/upstream.py Outdated Show resolved Hide resolved
gentoopm/basepm/upstream.py Outdated Show resolved Hide resolved
gentoopm/portagepm/pkg.py Outdated Show resolved Hide resolved
gentoopm/portagepm/pkg.py Outdated Show resolved Hide resolved
test-root/usr/portage/a/single/metadata.xml Show resolved Hide resolved
tox.ini Outdated Show resolved Hide resolved
gentoopm/basepm/upstream.py Outdated Show resolved Hide resolved
@CyberTailor CyberTailor force-pushed the upstream branch 2 times, most recently from 97f1ba9 to 938e5d2 Compare January 17, 2024 10:27
@CyberTailor
Copy link
Author

Some tests make sense only for Portage, how to handle this?

@mgorny
Copy link
Member

mgorny commented Jan 17, 2024

Some tests make sense only for Portage, how to handle this?

When a feature is missing from the PM, raise NotImplementedError. Catch it in tests and pytest.skip().

@CyberTailor
Copy link
Author

Good idea, now PkgCoreUpstream raises if any field except for remote_ids is accessed.

Comment on lines 425 to 427
def upstream(self) -> typing.Optional[PMUpstream]:
"""
Get the package upstream metadata (or ``None`` if unavailable).
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if the distinction for None is really useful here. After all, none of the "upstream" keys are mandatory, so there's no technical difference between "missing" upstream metadata and "empty" upstream metadata, so it feels like asking consumers to separately detect two equivalent cases.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reduced the number of keys with such distinction

gentoopm/pkgcorepm/pkg.py Outdated Show resolved Hide resolved
return tuple(PortagePackageMaintainer(m) for m in meta.maintainers())

@property
def upstream(self) -> typing.Optional[PMUpstream]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, this isn't really consistent with gentoopm design. The idea was to provide thin wrappers over PM data types, not copy everything over. So in this case you'd return a PortageUpstream object that would provide accessors for all the shit.

Or well, technically, you wouldn't make a special "upstream" subclass about it and just put them as top-level properties of package class.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did I get it right this time?

Fully supported only for Portage, pkgcore can return only remote-ids.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants