public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/repository/
@ 2022-12-22  7:11 Arthur Zamarin
  0 siblings, 0 replies; 7+ messages in thread
From: Arthur Zamarin @ 2022-12-22  7:11 UTC (permalink / raw
  To: gentoo-commits

commit:     87c08e2219f86fb2fc034a88c7f72712f677834f
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Fri Aug 28 07:27:45 2020 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Thu Dec 22 02:53:18 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=87c08e22

Update code for modern python standards

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>

 src/pkgcore/repository/prototype.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/pkgcore/repository/prototype.py b/src/pkgcore/repository/prototype.py
index 73b4057de..9c615dba8 100644
--- a/src/pkgcore/repository/prototype.py
+++ b/src/pkgcore/repository/prototype.py
@@ -224,9 +224,7 @@ class tree:
         kwds.pop("sorter", None)
         kwds.pop("yield_none", None)
 
-        for pkg in self.itermatch(atom, **kwds):
-            return True
-        return False
+        return any(True for _ in self.itermatch(atom, **kwds))
 
     def match(self, atom, **kwds):
         return list(self.itermatch(atom, **kwds))


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/repository/
@ 2023-11-24 15:17 Arthur Zamarin
  0 siblings, 0 replies; 7+ messages in thread
From: Arthur Zamarin @ 2023-11-24 15:17 UTC (permalink / raw
  To: gentoo-commits

commit:     939c556d4acbe1d451fd7d336a6ed7bb39f9cd33
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Tue Nov 21 03:44:42 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Nov 24 15:17:21 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=939c556d

repository: shift args to docstring

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/repository/util.py | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/pkgcore/repository/util.py b/src/pkgcore/repository/util.py
index 013c16bd3..beeaf00ae 100644
--- a/src/pkgcore/repository/util.py
+++ b/src/pkgcore/repository/util.py
@@ -13,19 +13,19 @@ from . import multiplex, prototype, virtual
 
 
 class SimpleTree(prototype.tree):
-    """Fake, in-memory repository.
-
-    Args:
-        cpv_dict (dict): CPVs to populate the repo with
-        pkg_klass: class of packages in repo
-        livefs (bool): regular repo if False, vdb if True
-        frozen (bool): repo is modifiable if False, otherwise readonly
-        repo_id (str): repo ID
-    """
+    """in-memory repository used for testing or simple shims."""
 
     def __init__(
         self, cpv_dict, pkg_klass=None, livefs=False, frozen=True, repo_id=None
     ):
+        """
+        Args:
+            cpv_dict (dict): CPVs to populate the repo with
+            pkg_klass: class of packages in repo
+            livefs (bool): regular repo if False, vdb if True
+            frozen (bool): repo is modifiable if False, otherwise readonly
+            repo_id (str): repo ID
+        """
         self.cpv_dict = cpv_dict
         if pkg_klass is None:
             pkg_klass = VersionedCPV


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/repository/
@ 2023-12-03  5:23 Arthur Zamarin
  0 siblings, 0 replies; 7+ messages in thread
From: Arthur Zamarin @ 2023-12-03  5:23 UTC (permalink / raw
  To: gentoo-commits

commit:     bb7b8ec465060dfc754e9115c6e8a03e040272fd
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Tue Nov 21 05:41:53 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sun Dec  3 05:18:39 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=bb7b8ec4

repo: Simplify SimpleTree signature

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/repository/util.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/pkgcore/repository/util.py b/src/pkgcore/repository/util.py
index beeaf00ae..8cc485478 100644
--- a/src/pkgcore/repository/util.py
+++ b/src/pkgcore/repository/util.py
@@ -16,7 +16,7 @@ class SimpleTree(prototype.tree):
     """in-memory repository used for testing or simple shims."""
 
     def __init__(
-        self, cpv_dict, pkg_klass=None, livefs=False, frozen=True, repo_id=None
+        self, cpv_dict, pkg_klass=VersionedCPV, livefs=False, frozen=True, repo_id=None
     ):
         """
         Args:
@@ -27,8 +27,6 @@ class SimpleTree(prototype.tree):
             repo_id (str): repo ID
         """
         self.cpv_dict = cpv_dict
-        if pkg_klass is None:
-            pkg_klass = VersionedCPV
         self.livefs = livefs
         self.repo_id = repo_id
         self.package_class = pkg_klass


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/repository/
@ 2024-01-23 19:01 Arthur Zamarin
  0 siblings, 0 replies; 7+ messages in thread
From: Arthur Zamarin @ 2024-01-23 19:01 UTC (permalink / raw
  To: gentoo-commits

commit:     b25406371ff563b7f7f845f2976a8270149a4cff
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Tue Jan 16 04:14:31 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Tue Jan 23 08:52:08 2024 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=b2540637

refactor: loosen prototype.tree._get_* requirements, add typing.

This moves the burden of derivatives having to ensure they return
immutables, instead this is handled by the internals of prototype.tree
since it already partially was.

This change basically makes it easier to write generators for
cat/pkg/ver listing.

For existing implementations returning immutable objects this has
no impact; `t=(1,2);assert t is tuple(t)` for example, and the
same holds for frozenset.

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>

 src/pkgcore/repository/prototype.py | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/pkgcore/repository/prototype.py b/src/pkgcore/repository/prototype.py
index e69af82ff..656f8e556 100644
--- a/src/pkgcore/repository/prototype.py
+++ b/src/pkgcore/repository/prototype.py
@@ -54,7 +54,7 @@ class PackageMapping(DictMixin):
             return o
         if key not in self._parent:
             raise KeyError(key)
-        self._cache[key] = vals = self._pull_vals(key)
+        self._cache[key] = vals = tuple(self._pull_vals(key))
         return vals
 
     def keys(self):
@@ -79,7 +79,7 @@ class VersionMapping(DictMixin):
             return o
         if not key[1] in self._parent.get(key[0], ()):
             raise KeyError(key)
-        val = self._pull_vals(key)
+        val = tuple(self._pull_vals(key))
         self._cache[key] = val
         return val
 
@@ -141,18 +141,20 @@ class tree(abc.ABC):
         raise NotImplementedError(self, "configure")
 
     @abc.abstractmethod
-    def _get_categories(self):
-        """this must return a list, or sequence"""
+    def _get_categories(self) -> frozenset[str] | typing.Iterable[str]:
+        """this must return an iterable or tuple of this repo's categories"""
         raise NotImplementedError(self, "_get_categories")
 
     @abc.abstractmethod
-    def _get_packages(self, category):
-        """this must return a list, or sequence"""
+    def _get_packages(self, category: str) -> tuple[str] | typing.Iterable[str]:
+        """Receives category and must return the packages of that cat.  Converted to tuple"""
         raise NotImplementedError(self, "_get_packages")
 
     @abc.abstractmethod
-    def _get_versions(self, package):
-        """this must return a list, or sequence"""
+    def _get_versions(
+        self, package: tuple[str, str]
+    ) -> tuple[str] | typing.Iterable[str]:
+        """Receives (cat/pkg) and must return the cp versions.  Converted to tuple"""
         raise NotImplementedError(self, "_get_versions")
 
     def __getitem__(self, cpv):


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/repository/
@ 2024-01-23 19:01 Arthur Zamarin
  0 siblings, 0 replies; 7+ messages in thread
From: Arthur Zamarin @ 2024-01-23 19:01 UTC (permalink / raw
  To: gentoo-commits

commit:     308379df1a6a6a96b9943ebb8b384eb4ff044f54
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Tue Jan 16 04:05:05 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Tue Jan 23 08:52:08 2024 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=308379df

refactor: Add missing abstractmethods for ConfiguredTree.

In this case, it's not needed beyond being explicit- the
GetAttrProxy redirects _get_categories and such to .raw_repo.

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>

 src/pkgcore/repository/configured.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/pkgcore/repository/configured.py b/src/pkgcore/repository/configured.py
index 74487d554..2860a59f9 100644
--- a/src/pkgcore/repository/configured.py
+++ b/src/pkgcore/repository/configured.py
@@ -6,6 +6,7 @@ __all__ = ("tree",)
 
 from functools import partial
 
+import snakeoil.klass
 from snakeoil.klass import DirProxy, GetAttrProxy
 
 from ..operations.repo import operations_proxy
@@ -48,6 +49,11 @@ class tree(prototype.tree):
         # required to override empty pkg_masks inherited from prototype.tree
         return self.raw_repo.pkg_masks
 
+    # add explicit alises to 'show' ABCMeta that the methods are addressed.
+    _get_categories = snakeoil.klass.alias_method("raw_repo._get_categories")
+    _get_packages = snakeoil.klass.alias_method("raw_repo._get_packages")
+    _get_versions = snakeoil.klass.alias_method("raw_repo._get_versions")
+
     __getattr__ = GetAttrProxy("raw_repo")
     __dir__ = DirProxy("raw_repo")
 


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/repository/
@ 2024-01-23 19:01 Arthur Zamarin
  0 siblings, 0 replies; 7+ messages in thread
From: Arthur Zamarin @ 2024-01-23 19:01 UTC (permalink / raw
  To: gentoo-commits

commit:     cc6a8d054363561890bb0552f1439a8ace92b367
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Tue Jan 16 01:22:58 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Tue Jan 23 08:52:08 2024 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=cc6a8d05

refactor: leverage ABC protections for prototype.tree

This was always an abstract class, just typing/ABC didn't
exist when it was written.  Leverage modern protections.

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>

 src/pkgcore/repository/prototype.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/pkgcore/repository/prototype.py b/src/pkgcore/repository/prototype.py
index 8830459e9..e69af82ff 100644
--- a/src/pkgcore/repository/prototype.py
+++ b/src/pkgcore/repository/prototype.py
@@ -15,6 +15,7 @@ from ..ebuild.atom import atom
 from ..operations import repo
 from ..restrictions import boolean, packages, restriction, values
 from ..restrictions.util import collect_package_restrictions
+import abc
 
 
 class CategoryLazyFrozenSet:
@@ -94,8 +95,8 @@ class VersionMapping(DictMixin):
             self._cache.pop(key, None)
 
 
-class tree:
-    """Template for all repository variants.
+class tree(abc.ABC):
+    """ABC for all repository variants.
 
     Args:
         frozen (bool): controls whether the repository is mutable or immutable
@@ -139,14 +140,17 @@ class tree:
         """Return a configured form of the repository."""
         raise NotImplementedError(self, "configure")
 
+    @abc.abstractmethod
     def _get_categories(self):
         """this must return a list, or sequence"""
         raise NotImplementedError(self, "_get_categories")
 
+    @abc.abstractmethod
     def _get_packages(self, category):
         """this must return a list, or sequence"""
         raise NotImplementedError(self, "_get_packages")
 
+    @abc.abstractmethod
     def _get_versions(self, package):
         """this must return a list, or sequence"""
         raise NotImplementedError(self, "_get_versions")


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/repository/
@ 2024-03-29 16:36 Arthur Zamarin
  0 siblings, 0 replies; 7+ messages in thread
From: Arthur Zamarin @ 2024-03-29 16:36 UTC (permalink / raw
  To: gentoo-commits

commit:     2888daf8f23453f8fda514761e81cdc4963104e6
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 29 16:34:14 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Mar 29 16:34:14 2024 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=2888daf8

Revert "refactor: leverage ABC protections for prototype.tree"

This change broke ConfiguredTree, since it was implementing the ABC
function through the `__getattr__` magic. While good intentions, reality
hit us.

Reverts: cc6a8d054363561890bb0552f1439a8ace92b367
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/repository/prototype.py | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/pkgcore/repository/prototype.py b/src/pkgcore/repository/prototype.py
index 656f8e556..9424459c0 100644
--- a/src/pkgcore/repository/prototype.py
+++ b/src/pkgcore/repository/prototype.py
@@ -15,7 +15,6 @@ from ..ebuild.atom import atom
 from ..operations import repo
 from ..restrictions import boolean, packages, restriction, values
 from ..restrictions.util import collect_package_restrictions
-import abc
 
 
 class CategoryLazyFrozenSet:
@@ -95,8 +94,8 @@ class VersionMapping(DictMixin):
             self._cache.pop(key, None)
 
 
-class tree(abc.ABC):
-    """ABC for all repository variants.
+class tree:
+    """Template for all repository variants.
 
     Args:
         frozen (bool): controls whether the repository is mutable or immutable
@@ -140,17 +139,14 @@ class tree(abc.ABC):
         """Return a configured form of the repository."""
         raise NotImplementedError(self, "configure")
 
-    @abc.abstractmethod
     def _get_categories(self) -> frozenset[str] | typing.Iterable[str]:
         """this must return an iterable or tuple of this repo's categories"""
         raise NotImplementedError(self, "_get_categories")
 
-    @abc.abstractmethod
     def _get_packages(self, category: str) -> tuple[str] | typing.Iterable[str]:
         """Receives category and must return the packages of that cat.  Converted to tuple"""
         raise NotImplementedError(self, "_get_packages")
 
-    @abc.abstractmethod
     def _get_versions(
         self, package: tuple[str, str]
     ) -> tuple[str] | typing.Iterable[str]:


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-03-29 16:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-03  5:23 [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/repository/ Arthur Zamarin
  -- strict thread matches above, loose matches on Subject: below --
2024-03-29 16:36 Arthur Zamarin
2024-01-23 19:01 Arthur Zamarin
2024-01-23 19:01 Arthur Zamarin
2024-01-23 19:01 Arthur Zamarin
2023-11-24 15:17 Arthur Zamarin
2022-12-22  7:11 Arthur Zamarin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox