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

Bug#733489: [PATCH] apt/package.py: Replaced pre_depend with rawtype in BaseDependency.__repr__ as rawtype gives more information including the information from pre_depend.




On 06/30/2015 10:39 PM, Julian Andres Klode wrote:
On Mon, Jun 29, 2015 at 03:34:53PM +0200, Michael Schaller wrote:

Committed. This *should not* break anything. If it does, we'll
see it.

Thanks and agreed.

A longer paragraph would have been nice, I forgot about this
before pushing it.

Sorry for that. I agree that it would have been better to include in the commit message than in the email...


The next patch is what previously was patch 2/5 and the changes in cache.cc have been actually proposed by you in comment #165 of this bug. Once this has been committed the next step is to add __str__ methods to Dependency and BaseDependency....
>From 1805b4763bebdef40b5d53bb569837263e591419 Mon Sep 17 00:00:00 2001
From: Michael Schaller <michael@5challer.de>
Date: Wed, 1 Jul 2015 14:12:52 +0200
Subject: [PATCH 1/1] Add dependency comparison (aka. relation) type in Debian
 notation

So far python-apt only exposed the dependency comparison type (aka. relation
type) in mathematical notation.  The Debian notation is documented here:
https://www.debian.org/doc/debian-policy/ch-relationships.html#s-depsyntax
---
 apt/package.py  | 18 +++++++++++++++---
 python/cache.cc | 23 +++++++++++++++++++----
 2 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/apt/package.py b/apt/package.py
index 57c89b3..cb9cf05 100644
--- a/apt/package.py
+++ b/apt/package.py
@@ -97,14 +97,26 @@ class BaseDependency(object):
 
     @property
     def relation(self):
-        """The relation (<, <=, !=, =, >=, >, ).
+        """The relation (<, <=, =, !=, >=, >, '') in mathematical notation.
 
-        Note that the empty string is a valid string as well, if no version
-        is specified.
+        The empty string will be returned in case of an unversioned dependency.
         """
         return self.__dstr(self._dep.comp_type)
 
     @property
+    def relation_deb(self):
+        """The relation (<<, <=, =, !=, >=, >>, '') in Debian notation.
+
+        The empty string will be returned in case of an unversioned dependency.
+        For more details see the Debian Policy Manual on the syntax of
+        relationship fields:
+        https://www.debian.org/doc/debian-policy/ch-relationships.html#s-depsyntax  # noqa
+
+        .. versionadded:: 1.0.0
+        """
+        return self._dep.comp_type_deb
+
+    @property
     def version(self):
         """The target version or an empty string.
 
diff --git a/python/cache.cc b/python/cache.cc
index e03462a..2870650 100644
--- a/python/cache.cc
+++ b/python/cache.cc
@@ -238,7 +238,7 @@ static PyObject *PkgCacheGetFileList(PyObject *Self, void*) {
 static PyObject *PkgCacheGetIsMultiArch(PyObject *Self, void*) {
     pkgCache *Cache = GetCpp<pkgCache *>(Self);
     return PyBool_FromLong(Cache->MultiArchCache());
-} 
+}
 
 static PyGetSetDef PkgCacheGetSet[] = {
    {"depends_count",PkgCacheGetDependsCount,0,
@@ -634,7 +634,7 @@ static PyObject *PackageGetFullName(PyObject *Self,PyObject *Args,PyObject *kwds
                                    &pretty) == 0)
       return 0;
 
-   
+
    return CppPyString(Pkg.FullName(pretty));
 }
 
@@ -1433,6 +1433,12 @@ static PyObject *DependencyGetCompType(PyObject *Self,void*)
    return PyString_FromString(Dep.CompType());
 }
 
+static PyObject *DependencyGetCompTypeDeb(PyObject *Self,void*)
+{
+   pkgCache::DepIterator &Dep = GetCpp<pkgCache::DepIterator>(Self);
+   return PyString_FromString(pkgCache::CompTypeDeb(Dep->CompareOp));
+}
+
 static PyObject *DependencyGetDepType(PyObject *Self,void*)
 {
    pkgCache::DepIterator &Dep = GetCpp<pkgCache::DepIterator>(Self);
@@ -1459,8 +1465,17 @@ static PyObject *DependencyGetID(PyObject *Self,void*)
 
 static PyGetSetDef DependencyGetSet[] = {
    {"comp_type",DependencyGetCompType,0,
-    "The type of comparison, as a string, namely one of:\n"
-    "'<', '<=', '=', '!=', '>=', '>', ''."},
+    "The type of comparison in mathematical notation, as a string, namely one "
+    "of:\n"
+    "'<', '<=', '=', '!=', '>=', '>', ''.\n"
+    "The empty string will be returned in case of an unversioned dependency."},
+   {"comp_type_deb",DependencyGetCompTypeDeb,0,
+    "The type of comparison in Debian notation, as a string, namely one of:\n"
+    "'<<', '<=', '=', '!=', '>=', '>>', ''.\n"
+    "The empty string will be returned in case of an unversioned dependency.\n"
+    "For details see the Debian Policy Manual on the syntax of relationship "
+    "fields:\n"
+    "https://www.debian.org/doc/debian-policy/ch-relationships.html#s-depsyntax"},
    {"dep_type",DependencyGetDepType,0,
     "The type of the dependency; may be translated"},
    {"dep_type_untranslated",DependencyGetDepTypeUntranslated,0,
-- 
2.1.4


Reply to: