From 2a2d636ca765e737bdbd36ed6b39b2319a466ce9 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 7 Jul 2009 17:00:38 +0200 Subject: python/policy.cc: Add Policy_ReadPinDir() [APT 0.7.22] --- python/policy.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'python') diff --git a/python/policy.cc b/python/policy.cc index 91ed5454..46d73a1a 100644 --- a/python/policy.cc +++ b/python/policy.cc @@ -96,6 +96,18 @@ static PyObject *Policy_ReadPinFile(PyObject *self, PyObject *arg) { return PyBool_FromLong(ReadPinFile(*policy, PyString_AsString(arg))); } +static char *Policy_ReadPinDir_doc = "read_pindir(dirname: str) -> bool\n\n" + "Read the pin files in the given dir (e.g. '/etc/apt/preferences.d') and\n" + "add them to the policy."; + +static PyObject *Policy_ReadPinDir(PyObject *self, PyObject *arg) { + if (!PyString_Check(arg)) + return 0; + pkgPolicy *policy = GetCpp(self); + + return PyBool_FromLong(ReadPinDir(*policy, PyString_AsString(arg))); +} + static char *Policy_CreatePin_doc = "create_pin(type: str, pkg: str, " "data: str, priority: int)\n\n" "Create a pin for the policy. The parameter 'type' refers to one of the\n" @@ -131,6 +143,8 @@ static PyMethodDef Policy_Methods[] = { Policy_GetCandidateVer_doc}, {"read_pinfile",(PyCFunction)Policy_ReadPinFile,METH_O, Policy_ReadPinFile_doc}, + {"read_pindir",(PyCFunction)Policy_ReadPinDir,METH_O, + Policy_ReadPinFile_doc}, {"create_pin",Policy_CreatePin,METH_VARARGS,Policy_CreatePin_doc}, {"get_match",(PyCFunction)Policy_GetMatch,METH_O, Policy_GetMatch_doc}, {} -- cgit v1.2.3