diff options
| -rw-r--r-- | doc/examples/indexfile.py | 1 | ||||
| -rw-r--r-- | python/indexfile.cc | 20 |
2 files changed, 19 insertions, 2 deletions
diff --git a/doc/examples/indexfile.py b/doc/examples/indexfile.py index 5eaab517..d383fd61 100644 --- a/doc/examples/indexfile.py +++ b/doc/examples/indexfile.py @@ -18,3 +18,4 @@ for (f,i) in cand.FileList: print index.IsTrusted print index.Exists print index.HasPackages + print index.ArchiveURI("some/path") diff --git a/python/indexfile.cc b/python/indexfile.cc index 4e106e25..ef6ffc8a 100644 --- a/python/indexfile.cc +++ b/python/indexfile.cc @@ -15,6 +15,22 @@ #include <Python.h> +static PyObject *PackageIndexFileArchiveURI(PyObject *Self,PyObject *Args) +{ + pkgIndexFile *File = GetCpp<pkgIndexFile*>(Self); + char *path; + + if (PyArg_ParseTuple(Args, "s",&path) == 0) + return 0; + + return HandleErrors(Safe_FromString(File->ArchiveURI(path).c_str())); +} + +static PyMethodDef PackageIndexFileMethods[] = +{ + {"ArchiveURI",PackageIndexFileArchiveURI,METH_VARARGS,"Returns the ArchiveURI"}, + {} +}; static PyObject *PackageIndexFileAttr(PyObject *Self,char *Name) @@ -33,8 +49,7 @@ static PyObject *PackageIndexFileAttr(PyObject *Self,char *Name) else if (strcmp("IsTrusted",Name) == 0) return Py_BuildValue("i",(File->IsTrusted())); - PyErr_SetString(PyExc_AttributeError,Name); - return 0; + return Py_FindMethod(PackageIndexFileMethods,Self,Name); } static PyObject *PackageIndexFileRepr(PyObject *Self) @@ -51,6 +66,7 @@ static PyObject *PackageIndexFileRepr(PyObject *Self) File->IsTrusted(), File->ArchiveURI("").c_str()); return PyString_FromString(S); } + PyTypeObject PackageIndexFileType = { PyObject_HEAD_INIT(&PyType_Type) |
