[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#890876: python-apt: Provide API for versioned provides



On 11.04.18 15:54, Julian Andres Klode wrote:
>> python-apt should have an "official" API to access the version
>> information.
> 
> Well, it has in apt_pkg. But the apt package did not keep up. What we need to do apparently
> is create a subtype of str that exposes a name and a version member (we need to be a str too
> for compatibility reasons...).

I, too, would appreciate this feature :-)

I looked at apt/package.py, and it seems that the fix wouldn't be too
hard to implement. Unless I'm mistaken, the 'provides' property [1] of
class 'apt.Version' seems to contain all the necessary information, via
'provides_list'.

So one would only need to create this subtype of str, and add
version-string and Version as attributes. However, is it really
necessary to preserve this interface? In the light of debhelper-compat,
for example, it seems to be broken/useless (which is pointless without
the version).

Another simple solution would be to simply add a new property
'provides_list' that exposes the versioned provides, thereby remaining
backwards-compatible.

diff --git a/apt/package.py b/apt/package.py
index 9033ff84..27628dc9 100644
--- a/apt/package.py
+++ b/apt/package.py
@@ -742,6 +742,12 @@ class Version(object):
         """ Return a list of names that this version provides."""
         return [p[0] for p in self._cand.provides_list]

+    @property
+    def provides_list(self):
+        # type: () -> List[Tuple[str,str,str]]
+        """ Return a list of names that this version provides."""
+        return [p for p in self._cand.provides_list]
+
     @property
     def enhances(self):
         # type: () -> List[Dependency]

In any case, I need this feature for something, and I'd like to help --
if there's anything I can do, please let me know!

[1] https://salsa.debian.org/apt-team/python-apt/blob/master/apt/package.py#L739

Christian


Reply to: