commit: 50481a69f6e8ed45b870132a255b3db38b6350b6 Author: Michał Górny <mgorny <AT> gentoo <DOT> org> AuthorDate: Mon Jan 16 18:56:04 2023 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Mon Jan 16 18:57:39 2023 +0000 URL: https://gitweb.gentoo.org/proj/gentoopm.git/commit/?id=50481a69
Add getters for license, properties and restrict Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> gentoopm/basepm/pkg.py | 29 ++++++++++++++++++++++++++++- gentoopm/paludispm/pkg.py | 14 +++++++++++++- gentoopm/pkgcorepm/depend.py | 4 +++- gentoopm/pkgcorepm/pkg.py | 14 +++++++++++++- gentoopm/portagepm/pkg.py | 20 +++++++++++++++++++- 5 files changed, 76 insertions(+), 5 deletions(-) diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py index 5034152..99e2046 100644 --- a/gentoopm/basepm/pkg.py +++ b/gentoopm/basepm/pkg.py @@ -1,6 +1,6 @@ #!/usr/bin/python # vim:fileencoding=utf-8 -# (c) 2011 Michał Górny <[email protected]> +# (c) 2011-2023 Michał Górny <[email protected]> # Released under the terms of the 2-clause BSD license. import os.path @@ -342,6 +342,33 @@ class PMPackage(PMAtom, FillMissingComparisons): """ pass + @abstractproperty + def license(self): + """ + Get the C{LICENSE} specification. + + @type: L{PMPackageDepSet} + """ + pass + + @abstractproperty + def properties(self): + """ + Get the C{PROPERTIES} specification. + + @type: L{PMPackageDepSet} + """ + pass + + @abstractproperty + def restrict(self): + """ + Get the C{RESTRICT} specification. + + @type: L{PMPackageDepSet} + """ + pass + @abstractproperty def slotted_atom(self): """ diff --git a/gentoopm/paludispm/pkg.py b/gentoopm/paludispm/pkg.py index 97f50ab..f8fda41 100644 --- a/gentoopm/paludispm/pkg.py +++ b/gentoopm/paludispm/pkg.py @@ -1,6 +1,6 @@ #!/usr/bin/python # vim:fileencoding=utf-8 -# (c) 2011 Michał Górny <[email protected]> +# (c) 2011-2023 Michał Górny <[email protected]> # Released under the terms of the 2-clause BSD license. import paludis @@ -204,6 +204,18 @@ class PaludisID(PMPackage, PaludisAtom): self._get_meta("REQUIRED_USE"), self, PMRequiredUseAtom ) + @property + def license(self): + raise NotImplementedError(".license is not implemented for Paludis") + + @property + def properties(self): + raise NotImplementedError(".properties is not implemented for Paludis") + + @property + def restrict(self): + raise NotImplementedError(".restrict is not implemented for Paludis") + @property def use(self): return PaludisChoiceSet(self._get_meta(self._pkg.choices_key())) diff --git a/gentoopm/pkgcorepm/depend.py b/gentoopm/pkgcorepm/depend.py index a4f1d73..4240cca 100644 --- a/gentoopm/pkgcorepm/depend.py +++ b/gentoopm/pkgcorepm/depend.py @@ -1,6 +1,6 @@ #!/usr/bin/python # vim:fileencoding=utf-8 -# (c) 2011 Michał Górny <[email protected]> +# (c) 2011-2023 Michał Górny <[email protected]> # Released under the terms of the 2-clause BSD license. from pkgcore.ebuild.atom import atom @@ -49,6 +49,8 @@ class PkgCoreBaseDep(PMBaseDep): yield PkgCoreAtMostOneOfDep(d, self._pkg) elif isinstance(d, Conditional) and d.attr == "use": yield PkgCoreConditionalUseDep(d, self._pkg) + elif isinstance(d, str): # LICENSE, PROPERTIES, RESTRICT + yield d else: raise NotImplementedError("Parsing %s not implemented" % repr(d)) diff --git a/gentoopm/pkgcorepm/pkg.py b/gentoopm/pkgcorepm/pkg.py index a56f4b0..743e46b 100644 --- a/gentoopm/pkgcorepm/pkg.py +++ b/gentoopm/pkgcorepm/pkg.py @@ -1,6 +1,6 @@ #!/usr/bin/python # vim:fileencoding=utf-8 -# (c) 2011 Michał Górny <[email protected]> +# (c) 2011-2023 Michał Górny <[email protected]> # Released under the terms of the 2-clause BSD license. from ..basepm.pkg import ( @@ -214,6 +214,18 @@ class PkgCoreInstallablePackage(PkgCorePackage, PMInstallablePackage): def required_use(self): return PkgCorePackageDepSet(self._pkg._raw_pkg.required_use, self._pkg) + @property + def license(self): + return PkgCorePackageDepSet(self._pkg._raw_pkg.license, self._pkg) + + @property + def properties(self): + return PkgCorePackageDepSet(self._pkg._raw_pkg.properties, self._pkg) + + @property + def restrict(self): + return PkgCorePackageDepSet(self._pkg._raw_pkg.restrict, self._pkg) + @property def maintainers(self): return PkgCoreMaintainerTuple(self._pkg.maintainers) diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py index 5506a97..16022df 100644 --- a/gentoopm/portagepm/pkg.py +++ b/gentoopm/portagepm/pkg.py @@ -1,6 +1,6 @@ #!/usr/bin/python # vim:fileencoding=utf-8 -# (c) 2017 Michał Górny <[email protected]> +# (c) 2017-2023 Michał Górny <[email protected]> # Released under the terms of the 2-clause BSD license. import errno @@ -262,6 +262,24 @@ class PortageDBCPV(PMPackage, CompletePortageAtom): self._aux_get("REQUIRED_USE"), self._applied_use, PMRequiredUseAtom ) + @property + def license(self): + return PortagePackageDepSet( + self._aux_get("LICENSE"), self._applied_use, str + ) + + @property + def properties(self): + return PortagePackageDepSet( + self._aux_get("PROPERTIES"), self._applied_use, str + ) + + @property + def restrict(self): + return PortagePackageDepSet( + self._aux_get("RESTRICT"), self._applied_use, str + ) + def __str__(self): return "=%s" % self._cpv
