From 5cbf0b5807b4cc67818eae652b59a25d52eb9f7b Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 29 Jan 2009 09:26:03 +0100 Subject: * apt/cache.py: - when setting a alternative rootdir, read the config from it as well * python/configuration.cc, python/apt_pkgmodule.cc: - add apt_pkg.ReadConfigDir() --- python/apt_pkgmodule.cc | 1 + python/apt_pkgmodule.h | 2 ++ python/configuration.cc | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+) (limited to 'python') diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 2e488d58..86732781 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -402,6 +402,7 @@ static PyMethodDef methods[] = // Command line {"ReadConfigFile",LoadConfig,METH_VARARGS,doc_LoadConfig}, + {"ReadConfigDir",LoadConfigDir,METH_VARARGS,doc_LoadConfigDir}, {"ReadConfigFileISC",LoadConfigISC,METH_VARARGS,doc_LoadConfig}, {"ParseCommandLine",ParseCommandLine,METH_VARARGS,doc_ParseCommandLine}, diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h index 38486182..e047bcd8 100644 --- a/python/apt_pkgmodule.h +++ b/python/apt_pkgmodule.h @@ -23,9 +23,11 @@ extern PyTypeObject VersionType; extern char *doc_LoadConfig; extern char *doc_LoadConfigISC; +extern char *doc_LoadConfigDir; extern char *doc_ParseCommandLine; PyObject *LoadConfig(PyObject *Self,PyObject *Args); PyObject *LoadConfigISC(PyObject *Self,PyObject *Args); +PyObject *LoadConfigDir(PyObject *Self,PyObject *Args); PyObject *ParseCommandLine(PyObject *Self,PyObject *Args); // Tag File Stuff diff --git a/python/configuration.cc b/python/configuration.cc index f52c3c97..21f70bc1 100644 --- a/python/configuration.cc +++ b/python/configuration.cc @@ -327,6 +327,24 @@ PyObject *LoadConfigISC(PyObject *Self,PyObject *Args) if (ReadConfigFile(GetSelf(Self),Name,true) == false) return HandleErrors(); + Py_INCREF(Py_None); + return HandleErrors(Py_None); +} +char *doc_LoadConfigDir = "LoadConfigDir(Configuration,DirName) -> None"; +PyObject *LoadConfigDir(PyObject *Self,PyObject *Args) +{ + char *Name = 0; + if (PyArg_ParseTuple(Args,"Os",&Self,&Name) == 0) + return 0; + if (Configuration_Check(Self)== 0) + { + PyErr_SetString(PyExc_TypeError,"argument 1: expected Configuration."); + return 0; + } + + if (ReadConfigDir(GetSelf(Self),Name,false) == false) + return HandleErrors(); + Py_INCREF(Py_None); return HandleErrors(Py_None); } -- cgit v1.2.3