summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/cache.cc7
-rw-r--r--python/policy.cc5
2 files changed, 11 insertions, 1 deletions
diff --git a/python/cache.cc b/python/cache.cc
index b263d320..191e2204 100644
--- a/python/cache.cc
+++ b/python/cache.cc
@@ -229,6 +229,12 @@ static PyObject *PkgCacheGetGroups(PyObject *Self, void*) {
return CppPyObject_NEW<GrpListStruct>(Self,&PyGroupList_Type,Cache->GrpBegin());
}
+static PyObject *PkgCacheGetPolicy(PyObject *Self, void*) {
+ pkgCacheFile *CacheFile = GetCpp<pkgCacheFile *>(Self);
+ std::cerr << "policy: " << CacheFile->Policy << std::endl;
+ return CppPyObject_NEW<pkgPolicy*>(Self,&PyPolicy_Type,CacheFile->Policy);
+}
+
static PyObject *PkgCacheGetPackages(PyObject *Self, void*) {
pkgCache *Cache = GetCpp<pkgCache *>(Self);
return CppPyObject_NEW<PkgListStruct>(Self,&PyPackageList_Type,Cache->PkgBegin());
@@ -289,6 +295,7 @@ static PyGetSetDef PkgCacheGetSet[] = {
{"group_count",PkgCacheGetGroupCount,0,
"The number of apt_pkg.Group objects stored in the cache."},
{"groups", PkgCacheGetGroups, 0, "A list of Group objects in the cache"},
+ {"policy", PkgCacheGetPolicy, 0, "The PkgPolicy for the cache"},
{"is_multi_arch", PkgCacheGetIsMultiArch, 0,
"Whether the cache supports multi-arch."},
{"package_count",PkgCacheGetPackageCount,0,
diff --git a/python/policy.cc b/python/policy.cc
index b11e4dde..96b83abd 100644
--- a/python/policy.cc
+++ b/python/policy.cc
@@ -46,8 +46,11 @@ PyObject *policy_get_priority(PyObject *self, PyObject *arg) {
if (PyObject_TypeCheck(arg, &PyPackage_Type)) {
pkgCache::PkgIterator pkg = GetCpp<pkgCache::PkgIterator>(arg);
return MkPyNumber(policy->GetPriority(pkg));
+ } else if (PyObject_TypeCheck(arg, &PyPackageFile_Type)) {
+ pkgCache::PkgFileIterator pkgfile = GetCpp<pkgCache::PkgFileIterator>(arg);
+ return MkPyNumber(policy->GetPriority(pkgfile));
} else {
- PyErr_SetString(PyExc_TypeError,"Argument must be of Package().");
+ PyErr_SetString(PyExc_TypeError,"Argument must be of Package() or PackageFile().");
return 0;
}
}