summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/cache.cc68
-rw-r--r--python/configuration.cc19
-rw-r--r--python/generic.h6
-rw-r--r--python/pkgrecords.cc51
-rw-r--r--python/tag.cc55
5 files changed, 100 insertions, 99 deletions
diff --git a/python/cache.cc b/python/cache.cc
index 3bf6cba9..c17226b8 100644
--- a/python/cache.cc
+++ b/python/cache.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: cache.cc,v 1.2 2002/01/08 06:53:04 jgg Exp $
+// $Id: cache.cc,v 1.3 2002/02/26 01:36:15 mdz Exp $
/* ######################################################################
Cache - Wrapper for the cache related functions
@@ -533,39 +533,6 @@ PyTypeObject PackageFileType =
0, // tp_hash
};
- /*}}}*/
-// Dependency Class /*{{{*/
-// ---------------------------------------------------------------------
-static PyMethodDef DependencyMethods[];
-
-static PyObject *DependencyAttr(PyObject *Self,char *Name)
-{
- pkgCache::DepIterator &Dep = GetCpp<pkgCache::DepIterator>(Self);
- PyObject *Owner = GetOwner<pkgCache::DepIterator>(Self);
-
- if (strcmp("TargetVer",Name) == 0)
- {
- if (Dep->Version == 0)
- return PyString_FromString("");
- return PyString_FromString(Dep.TargetVer());
- }
- else if (strcmp("TargetPkg",Name) == 0)
- return CppOwnedPyObject_NEW<pkgCache::PkgIterator>(Owner,&PackageType,
- Dep.TargetPkg());
- else if (strcmp("ParentVer",Name) == 0)
- return CppOwnedPyObject_NEW<pkgCache::VerIterator>(Owner,&VersionType,
- Dep.ParentVer());
- else if (strcmp("ParentPkg",Name) == 0)
- return CppOwnedPyObject_NEW<pkgCache::PkgIterator>(Owner,&PackageType, Dep.ParentPkg());
- else if (strcmp("CompType",Name) == 0)
- return PyString_FromString(Dep.CompType());
- else if (strcmp("DepType",Name) == 0)
- return PyString_FromString(Dep.DepType());
- else if (strcmp("ID",Name) == 0)
- return Py_BuildValue("i",Dep->ID);
-
- return Py_FindMethod(DependencyMethods,Self,Name);
-}
static PyObject *DependencyRepr(PyObject *Self)
{
@@ -626,6 +593,38 @@ static PyMethodDef DependencyMethods[] =
{}
};
+// Dependency Class /*{{{*/
+// ---------------------------------------------------------------------
+
+static PyObject *DependencyAttr(PyObject *Self,char *Name)
+{
+ pkgCache::DepIterator &Dep = GetCpp<pkgCache::DepIterator>(Self);
+ PyObject *Owner = GetOwner<pkgCache::DepIterator>(Self);
+
+ if (strcmp("TargetVer",Name) == 0)
+ {
+ if (Dep->Version == 0)
+ return PyString_FromString("");
+ return PyString_FromString(Dep.TargetVer());
+ }
+ else if (strcmp("TargetPkg",Name) == 0)
+ return CppOwnedPyObject_NEW<pkgCache::PkgIterator>(Owner,&PackageType,
+ Dep.TargetPkg());
+ else if (strcmp("ParentVer",Name) == 0)
+ return CppOwnedPyObject_NEW<pkgCache::VerIterator>(Owner,&VersionType,
+ Dep.ParentVer());
+ else if (strcmp("ParentPkg",Name) == 0)
+ return CppOwnedPyObject_NEW<pkgCache::PkgIterator>(Owner,&PackageType, Dep.ParentPkg());
+ else if (strcmp("CompType",Name) == 0)
+ return PyString_FromString(Dep.CompType());
+ else if (strcmp("DepType",Name) == 0)
+ return PyString_FromString(Dep.DepType());
+ else if (strcmp("ID",Name) == 0)
+ return Py_BuildValue("i",Dep->ID);
+
+ return Py_FindMethod(DependencyMethods,Self,Name);
+}
+
PyTypeObject DependencyType =
{
PyObject_HEAD_INIT(&PyType_Type)
@@ -647,6 +646,7 @@ PyTypeObject DependencyType =
};
/*}}}*/
+ /*}}}*/
// Reverse Dependency List Class /*{{{*/
// ---------------------------------------------------------------------
static int RDepListLen(PyObject *Self)
diff --git a/python/configuration.cc b/python/configuration.cc
index a66f8b12..a15c4694 100644
--- a/python/configuration.cc
+++ b/python/configuration.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: configuration.cc,v 1.2 2002/01/08 06:53:04 jgg Exp $
+// $Id: configuration.cc,v 1.3 2002/02/26 01:36:15 mdz Exp $
/* ######################################################################
Configuration - Binding for the configuration object.
@@ -25,8 +25,6 @@
#include <Python.h>
/*}}}*/
-static PyMethodDef CnfMethods[];
-
/* If we create a sub tree then it is of this type, the Owner is used
to manage reference counting. */
struct SubConfiguration : public CppPyObject<Configuration>
@@ -34,13 +32,6 @@ struct SubConfiguration : public CppPyObject<Configuration>
PyObject *Owner;
};
-// CnfGetAttr - Get an attribute - variable/method /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-static PyObject *CnfGetAttr(PyObject *Self,char *Name)
-{
- return Py_FindMethod(CnfMethods,Self,Name);
-}
/*}}}*/
// CnfSubFree - Free a sub configuration /*{{{*/
// ---------------------------------------------------------------------
@@ -459,6 +450,14 @@ static PyMethodDef CnfMethods[] =
{}
};
+// CnfGetAttr - Get an attribute - variable/method /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+static PyObject *CnfGetAttr(PyObject *Self,char *Name)
+{
+ return Py_FindMethod(CnfMethods,Self,Name);
+}
+
// Type for a Normal Configuration object
static PyMappingMethods ConfigurationMap = {0,CnfMap,CnfMapSet};
PyTypeObject ConfigurationType =
diff --git a/python/generic.h b/python/generic.h
index 4e51fd9e..54a88f81 100644
--- a/python/generic.h
+++ b/python/generic.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: generic.h,v 1.2 2002/01/08 06:53:04 jgg Exp $
+// $Id: generic.h,v 1.3 2002/02/26 01:36:15 mdz Exp $
/* ######################################################################
generic - Some handy functions to make integration a tad simpler
@@ -110,9 +110,9 @@ void CppOwnedDealloc(PyObject *iObj)
PyMem_DEL(Obj);
}
-inline PyObject *CppPyString(string Str)
+inline PyObject *CppPyString(std::string Str)
{
- return PyString_FromStringAndSize(Str.begin(),Str.length());
+ return PyString_FromStringAndSize(Str.c_str(),Str.length());
}
inline PyObject *Safe_FromString(const char *Str)
diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc
index 4bc05278..d446388b 100644
--- a/python/pkgrecords.cc
+++ b/python/pkgrecords.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: pkgrecords.cc,v 1.2 2002/01/08 06:53:04 jgg Exp $
+// $Id: pkgrecords.cc,v 1.3 2002/02/26 01:36:15 mdz Exp $
/* ######################################################################
Package Records - Wrapper for the package records functions
@@ -27,32 +27,7 @@ struct PkgRecordsStruct
// PkgRecords Class /*{{{*/
// ---------------------------------------------------------------------
-static PyMethodDef PkgRecordsMethods[];
-static PyObject *PkgRecordsAttr(PyObject *Self,char *Name)
-{
- PkgRecordsStruct &Struct = GetCpp<PkgRecordsStruct>(Self);
-
- if (Struct.Last != 0)
- {
- if (strcmp("FileName",Name) == 0)
- return CppPyString(Struct.Last->FileName());
- else if (strcmp("MD5Hash",Name) == 0)
- return CppPyString(Struct.Last->MD5Hash());
- else if (strcmp("SourcePkg",Name) == 0)
- return CppPyString(Struct.Last->SourcePkg());
- else if (strcmp("Maintainer",Name) == 0)
- return CppPyString(Struct.Last->Maintainer());
- else if (strcmp("ShortDesc",Name) == 0)
- return CppPyString(Struct.Last->ShortDesc());
- else if (strcmp("LongDesc",Name) == 0)
- return CppPyString(Struct.Last->LongDesc());
- else if (strcmp("Name",Name) == 0)
- return CppPyString(Struct.Last->Name());
- }
-
- return Py_FindMethod(PkgRecordsMethods,Self,Name);
-}
static PyObject *PkgRecordsLookup(PyObject *Self,PyObject *Args)
{
@@ -85,6 +60,30 @@ static PyMethodDef PkgRecordsMethods[] =
{}
};
+static PyObject *PkgRecordsAttr(PyObject *Self,char *Name)
+{
+ PkgRecordsStruct &Struct = GetCpp<PkgRecordsStruct>(Self);
+
+ if (Struct.Last != 0)
+ {
+ if (strcmp("FileName",Name) == 0)
+ return CppPyString(Struct.Last->FileName());
+ else if (strcmp("MD5Hash",Name) == 0)
+ return CppPyString(Struct.Last->MD5Hash());
+ else if (strcmp("SourcePkg",Name) == 0)
+ return CppPyString(Struct.Last->SourcePkg());
+ else if (strcmp("Maintainer",Name) == 0)
+ return CppPyString(Struct.Last->Maintainer());
+ else if (strcmp("ShortDesc",Name) == 0)
+ return CppPyString(Struct.Last->ShortDesc());
+ else if (strcmp("LongDesc",Name) == 0)
+ return CppPyString(Struct.Last->LongDesc());
+ else if (strcmp("Name",Name) == 0)
+ return CppPyString(Struct.Last->Name());
+ }
+
+ return Py_FindMethod(PkgRecordsMethods,Self,Name);
+}
PyTypeObject PkgRecordsType =
{
PyObject_HEAD_INIT(&PyType_Type)
diff --git a/python/tag.cc b/python/tag.cc
index 682aa0a1..41db059c 100644
--- a/python/tag.cc
+++ b/python/tag.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: tag.cc,v 1.2 2002/01/08 06:53:04 jgg Exp $
+// $Id: tag.cc,v 1.3 2002/02/26 01:36:15 mdz Exp $
/* ######################################################################
Tag - Binding for the RFC 822 tag file parser
@@ -19,18 +19,20 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#ifndef _GNU_SOURCE
#define _GNU_SOURCE
+#endif
#include "generic.h"
#include "apt_pkgmodule.h"
#include <apt-pkg/tagfile.h>
#include <stdio.h>
+#include <iostream>
#include <Python.h>
- /*}}}*/
-static PyMethodDef TagSecMethods[];
-static PyMethodDef TagFileMethods[];
+using namespace std;
+ /*}}}*/
/* We need to keep a private copy of the data.. */
struct TagSecData : public CppPyObject<pkgTagSection>
{
@@ -45,28 +47,6 @@ struct TagFileData : public PyObject
FileFd Fd;
};
-// TagSecGetAttr - Get an attribute - variable/method /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-static PyObject *TagSecGetAttr(PyObject *Self,char *Name)
-{
- return Py_FindMethod(TagSecMethods,Self,Name);
-}
- /*}}}*/
-// TagFileGetAttr - Get an attribute - variable/method /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-static PyObject *TagFileGetAttr(PyObject *Self,char *Name)
-{
- if (strcmp("Section",Name) == 0)
- {
- PyObject *Obj = ((TagFileData *)Self)->Section;
- Py_INCREF(Obj);
- return Obj;
- }
-
- return Py_FindMethod(TagFileMethods,Self,Name);
-}
/*}}}*/
// TagSecFree - Free a Tag Section /*{{{*/
// ---------------------------------------------------------------------
@@ -388,6 +368,14 @@ static PyMethodDef TagSecMethods[] =
{}
};
+// TagSecGetAttr - Get an attribute - variable/method /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+static PyObject *TagSecGetAttr(PyObject *Self,char *Name)
+{
+ return Py_FindMethod(TagSecMethods,Self,Name);
+}
+ /*}}}*/
// Type for a Tag Section
PyMappingMethods TagSecMapMeth = {TagSecLength,TagSecMap,0};
PyTypeObject TagSecType =
@@ -423,6 +411,21 @@ static PyMethodDef TagFileMethods[] =
{}
};
+// TagFileGetAttr - Get an attribute - variable/method /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+static PyObject *TagFileGetAttr(PyObject *Self,char *Name)
+{
+ if (strcmp("Section",Name) == 0)
+ {
+ PyObject *Obj = ((TagFileData *)Self)->Section;
+ Py_INCREF(Obj);
+ return Obj;
+ }
+
+ return Py_FindMethod(TagFileMethods,Self,Name);
+}
+
// Type for a Tag File
PyTypeObject TagFileType =
{