diff options
| author | Julian Andres Klode <jak@debian.org> | 2009-07-08 20:18:36 +0200 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2009-07-08 20:18:36 +0200 |
| commit | d2423e2c28df63cb0a235f822a9588f8a221600a (patch) | |
| tree | c319735856d77a8f696daddcda19b7b028fac6bf | |
| parent | 3770906714c5e73b844514c431ce07fd9ac416fb (diff) | |
| download | python-apt-d2423e2c28df63cb0a235f822a9588f8a221600a.tar.gz | |
python/pkgsrcrecords.cc: Unify dep handling -- part 2: SourceRecords.build_depends
Change apt_pkg.SourceRecords.build_depends to match exactly the interface of
Version.depends_list_str just with different keys (e.g. Build-Depends).
+ Closes: #468123 - there is no need anymore for binding CompType or
CompTypeDeb, because we don't return integer values for CompType
anymore.
| -rw-r--r-- | debian/changelog | 6 | ||||
| -rw-r--r-- | python/pkgsrcrecords.cc | 51 |
2 files changed, 55 insertions, 2 deletions
diff --git a/debian/changelog b/debian/changelog index 581e1be1..8bc3e320 100644 --- a/debian/changelog +++ b/debian/changelog @@ -25,7 +25,11 @@ python-apt (0.7.92) UNRELEASED; urgency=low * Unification of dependency handling: - apt_pkg.parse_[src_]depends() now use CompType instead of CompTypeDeb (i.e. < instead of <<) to match the interface of Version.depends_list_str - + - apt_pkg.SourceRecords.build_depends matches exactly the interface of + Version.depends_list_str just with different keys (e.g. Build-Depends). + + Closes: #468123 - there is no need anymore for binding CompType or + CompTypeDeb, because we don't return integer values for CompType + anymore. [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index 187050b7..06fd4e3b 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -154,6 +154,54 @@ static PyObject *PkgSrcRecordsGetBuildDepends(PyObject *Self,void*) { PkgSrcRecordsStruct &Struct = GetStruct(Self,"BuildDepends"); if (Struct.Last == 0) return 0; + + PyObject *Dict = PyDict_New(); + PyObject *Dep = 0; + PyObject *LastDep = 0; + PyObject *OrGroup = 0; + + vector<pkgSrcRecords::Parser::BuildDepRec> bd; + if(!Struct.Last->BuildDepends(bd, false /* arch-only*/)) + return NULL; // error + + PyObject *v; + for(unsigned int i=0;i<bd.size();i++) { + + Dep = PyString_FromString(pkgSrcRecords::Parser::BuildDepType(bd[i].Type)); + + LastDep = PyDict_GetItem(Dict,Dep); + if (LastDep == 0) + { + LastDep = PyList_New(0); + PyDict_SetItem(Dict,Dep,LastDep); + Py_DECREF(LastDep); + } + Py_DECREF(Dep); + OrGroup = PyList_New(0); + PyList_Append(LastDep, OrGroup); + Py_DECREF(OrGroup); + + // Add at least one package to the group, add more if Or is set. + while (1) + { + v = Py_BuildValue("(sss)", bd[i].Package.c_str(), + bd[i].Version.c_str(), pkgCache::CompType(bd[i].Op)); + PyList_Append(OrGroup, v); + Py_DECREF(v); + if (pkgCache::Dep::Or != (bd[i].Op & pkgCache::Dep::Or) || i == bd.size()) + break; + i++; + } + + } + return Dict; +} + +#ifdef COMPAT_0_7 +static PyObject *PkgSrcRecordsGetBuildDepends_old(PyObject *Self,void*) { + PkgSrcRecordsStruct &Struct = GetStruct(Self,"BuildDepends"); + if (Struct.Last == 0) + return 0; PyObject *List = PyList_New(0); vector<pkgSrcRecords::Parser::BuildDepRec> bd; @@ -169,6 +217,7 @@ static PyObject *PkgSrcRecordsGetBuildDepends(PyObject *Self,void*) { } return List; } +#endif static PyGetSetDef PkgSrcRecordsGetSet[] = { {"binaries",PkgSrcRecordsGetBinaries}, @@ -182,7 +231,7 @@ static PyGetSetDef PkgSrcRecordsGetSet[] = { {"version",PkgSrcRecordsGetVersion}, #ifdef COMPAT_0_7 {"Binaries",PkgSrcRecordsGetBinaries}, - {"BuildDepends",PkgSrcRecordsGetBuildDepends}, + {"BuildDepends",PkgSrcRecordsGetBuildDepends_old,0,"Deprecated function and deprecated output format."}, {"Files",PkgSrcRecordsGetFiles}, {"Index",PkgSrcRecordsGetIndex}, {"Maintainer",PkgSrcRecordsGetMaintainer}, |
