Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
python-apt
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
APT Developers
python-apt
Commits
45cdd4f2
Commit
45cdd4f2
authored
Apr 19, 2009
by
Julian Andres Klode
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* python/*.cc: Export all types and add a __new__() method to them.
Some names may be changed before the release, but this is a good draft.
parent
6472bb37
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
519 additions
and
174 deletions
+519
-174
python/acquire.cc
python/acquire.cc
+98
-21
python/apt_pkgmodule.cc
python/apt_pkgmodule.cc
+49
-0
python/apt_pkgmodule.h
python/apt_pkgmodule.h
+1
-0
python/cache.cc
python/cache.cc
+73
-52
python/cdrom.cc
python/cdrom.cc
+29
-9
python/configuration.cc
python/configuration.cc
+20
-3
python/depcache.cc
python/depcache.cc
+96
-44
python/indexfile.cc
python/indexfile.cc
+1
-1
python/metaindex.cc
python/metaindex.cc
+1
-1
python/pkgmanager.cc
python/pkgmanager.cc
+33
-19
python/pkgrecords.cc
python/pkgrecords.cc
+24
-7
python/pkgsrcrecords.cc
python/pkgsrcrecords.cc
+17
-1
python/sourcelist.cc
python/sourcelist.cc
+17
-1
python/tag.cc
python/tag.cc
+60
-15
No files found.
python/acquire.cc
View file @
45cdd4f2
...
@@ -194,13 +194,41 @@ static PyGetSetDef PkgAcquireGetSet[] = {
...
@@ -194,13 +194,41 @@ static PyGetSetDef PkgAcquireGetSet[] = {
{}
{}
};
};
static
PyObject
*
PkgAcquireNew
(
PyTypeObject
*
type
,
PyObject
*
Args
,
PyObject
*
kwds
)
{
pkgAcquire
*
fetcher
;
PyObject
*
pyFetchProgressInst
=
NULL
;
static
char
*
kwlist
[]
=
{
"progress"
,
0
};
if
(
PyArg_ParseTupleAndKeywords
(
Args
,
kwds
,
"|O"
,
kwlist
,
&
pyFetchProgressInst
)
==
0
)
return
0
;
if
(
pyFetchProgressInst
!=
NULL
)
{
// FIXME: memleak?
PyFetchProgress
*
progress
=
new
PyFetchProgress
();
progress
->
setCallbackInst
(
pyFetchProgressInst
);
fetcher
=
new
pkgAcquire
(
progress
);
}
else
{
fetcher
=
new
pkgAcquire
();
}
CppPyObject
<
pkgAcquire
*>
*
FetcherObj
=
CppPyObject_NEW
<
pkgAcquire
*>
(
type
,
fetcher
);
return
FetcherObj
;
}
static
const
char
*
doc_PkgAcquire
=
"Acquire(progress) -> Acquire() object.
\n\n
"
"Create a new acquire object. The parameter *progress* can be used to
\n
"
"specify a apt.progress.FetchProgress() object, which will display the
\n
"
"progress of the fetching."
;
PyTypeObject
PkgAcquireType
=
PyTypeObject
PkgAcquireType
=
{
{
PyObject_HEAD_INIT
(
&
PyType_Type
)
PyObject_HEAD_INIT
(
&
PyType_Type
)
#if PY_MAJOR_VERSION < 3
#if PY_MAJOR_VERSION < 3
0
,
// ob_size
0
,
// ob_size
#endif
#endif
"
Acquire"
,
// tp_name
"
apt_pkg.Acquire"
,
// tp_name
sizeof
(
CppPyObject
<
pkgAcquire
*>
),
// tp_basicsize
sizeof
(
CppPyObject
<
pkgAcquire
*>
),
// tp_basicsize
0
,
// tp_itemsize
0
,
// tp_itemsize
// Methods
// Methods
...
@@ -220,7 +248,7 @@ PyTypeObject PkgAcquireType =
...
@@ -220,7 +248,7 @@ PyTypeObject PkgAcquireType =
0
,
// tp_setattro
0
,
// tp_setattro
0
,
// tp_as_buffer
0
,
// tp_as_buffer
Py_TPFLAGS_DEFAULT
,
// tp_flags
Py_TPFLAGS_DEFAULT
,
// tp_flags
"pkgAcquire Object"
,
// tp_doc
doc_PkgAcquire
,
// tp_doc
0
,
// tp_traverse
0
,
// tp_traverse
0
,
// tp_clear
0
,
// tp_clear
0
,
// tp_richcompare
0
,
// tp_richcompare
...
@@ -230,38 +258,66 @@ PyTypeObject PkgAcquireType =
...
@@ -230,38 +258,66 @@ PyTypeObject PkgAcquireType =
PkgAcquireMethods
,
// tp_methods
PkgAcquireMethods
,
// tp_methods
0
,
// tp_members
0
,
// tp_members
PkgAcquireGetSet
,
// tp_getset
PkgAcquireGetSet
,
// tp_getset
0
,
// tp_base
0
,
// tp_dict
0
,
// tp_descr_get
0
,
// tp_descr_set
0
,
// tp_dictoffset
0
,
// tp_init
0
,
// tp_alloc
PkgAcquireNew
,
// tp_new
};
};
PyObject
*
GetAcquire
(
PyObject
*
Self
,
PyObject
*
Args
)
PyObject
*
GetAcquire
(
PyObject
*
Self
,
PyObject
*
Args
)
{
{
pkgAcquire
*
fetcher
;
return
PkgAcquireNew
(
&
PkgAcquireType
,
Args
,
0
);
}
PyObject
*
pyFetchProgressInst
=
NULL
;
static
PyObject
*
PkgAcquireFileNew
(
PyTypeObject
*
type
,
PyObject
*
Args
,
PyObject
*
kwds
)
if
(
PyArg_ParseTuple
(
Args
,
"|O"
,
&
pyFetchProgressInst
)
==
0
)
{
return
0
;
PyObject
*
pyfetcher
;
char
*
uri
,
*
md5
,
*
descr
,
*
shortDescr
,
*
destDir
,
*
destFile
;
int
size
=
0
;
uri
=
md5
=
descr
=
shortDescr
=
destDir
=
destFile
=
""
;
if
(
pyFetchProgressInst
!=
NULL
)
{
char
*
kwlist
[]
=
{
"owner"
,
"uri"
,
"md5"
,
"size"
,
"descr"
,
"shortdescr"
,
// FIXME: memleak?
"destdir"
,
"destfile"
,
NULL
};
PyFetchProgress
*
progress
=
new
PyFetchProgress
();
progress
->
setCallbackInst
(
pyFetchProgressInst
);
fetcher
=
new
pkgAcquire
(
progress
);
}
else
{
fetcher
=
new
pkgAcquire
();
}
CppPyObject
<
pkgAcquire
*>
*
FetcherObj
=
if
(
PyArg_ParseTupleAndKeywords
(
Args
,
kwds
,
"O!s|sissss"
,
kwlist
,
CppPyObject_NEW
<
pkgAcquire
*>
(
&
PkgAcquireType
,
fetcher
);
&
PkgAcquireType
,
&
pyfetcher
,
&
uri
,
&
md5
,
&
size
,
&
descr
,
&
shortDescr
,
&
destDir
,
&
destFile
)
==
0
)
return
0
;
return
FetcherObj
;
pkgAcquire
*
fetcher
=
GetCpp
<
pkgAcquire
*>
(
pyfetcher
);
pkgAcqFile
*
af
=
new
pkgAcqFile
(
fetcher
,
// owner
uri
,
// uri
md5
,
// md5
size
,
// size
descr
,
// descr
shortDescr
,
destDir
,
destFile
);
// short-desc
CppPyObject
<
pkgAcqFile
*>
*
AcqFileObj
=
CppPyObject_NEW
<
pkgAcqFile
*>
(
type
);
AcqFileObj
->
Object
=
af
;
return
AcqFileObj
;
}
}
static
const
char
*
doc_PkgAcquireFile
=
"AcquireFile(owner, uri[, md5, size, descr, short_descr, dest_dir,"
"dest_file]) -> New AcquireFile() object
\n\n
"
"The parameter *owner* refers to an apt_pkg.Acquire() object. You can use
\n
"
"*destdir* OR *destfile* to specify the destination directory/file."
;
PyTypeObject
PkgAcquireFileType
=
PyTypeObject
PkgAcquireFileType
=
{
{
PyObject_HEAD_INIT
(
&
PyType_Type
)
PyObject_HEAD_INIT
(
&
PyType_Type
)
#if PY_MAJOR_VERSION < 3
#if PY_MAJOR_VERSION < 3
0
,
// ob_size
0
,
// ob_size
#endif
#endif
"
pkg
AcquireFile"
,
// tp_name
"
apt_pkg.
AcquireFile"
,
// tp_name
sizeof
(
CppPyObject
<
pkgAcqFile
*>
),
// tp_basicsize
sizeof
(
CppPyObject
<
pkgAcqFile
*>
),
// tp_basicsize
0
,
// tp_itemsize
0
,
// tp_itemsize
// Methods
// Methods
...
@@ -275,6 +331,30 @@ PyTypeObject PkgAcquireFileType =
...
@@ -275,6 +331,30 @@ PyTypeObject PkgAcquireFileType =
0
,
// tp_as_sequence
0
,
// tp_as_sequence
0
,
// tp_as_mapping
0
,
// tp_as_mapping
0
,
// tp_hash
0
,
// tp_hash
0
,
// tp_call
0
,
// tp_str
0
,
// tp_getattro
0
,
// tp_setattro
0
,
// tp_as_buffer
Py_TPFLAGS_DEFAULT
,
// tp_flags
doc_PkgAcquireFile
,
// tp_doc
0
,
// tp_traverse
0
,
// tp_clear
0
,
// tp_richcompare
0
,
// tp_weaklistoffset
0
,
// tp_iter
0
,
// tp_iternext
0
,
// tp_methods
0
,
// tp_members
0
,
// tp_getset
0
,
// tp_base
0
,
// tp_dict
0
,
// tp_descr_get
0
,
// tp_descr_set
0
,
// tp_dictoffset
0
,
// tp_init
0
,
// tp_alloc
PkgAcquireFileNew
,
// tp_new
};
};
char
*
doc_GetPkgAcqFile
=
char
*
doc_GetPkgAcqFile
=
...
@@ -308,6 +388,3 @@ PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject * kwds)
...
@@ -308,6 +388,3 @@ PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject * kwds)
return
AcqFileObj
;
return
AcqFileObj
;
}
}
/*}}}*/
python/apt_pkgmodule.cc
View file @
45cdd4f2
...
@@ -385,14 +385,18 @@ static PyObject *PkgSystemUnLock(PyObject *Self,PyObject *Args)
...
@@ -385,14 +385,18 @@ static PyObject *PkgSystemUnLock(PyObject *Self,PyObject *Args)
static
PyMethodDef
methods
[]
=
static
PyMethodDef
methods
[]
=
{
{
// Constructors
// Constructors
#ifdef COMPAT_0_7
{
"newConfiguration"
,
newConfiguration
,
METH_VARARGS
,
doc_newConfiguration
},
{
"newConfiguration"
,
newConfiguration
,
METH_VARARGS
,
doc_newConfiguration
},
#endif
{
"init"
,
Init
,
METH_VARARGS
,
doc_Init
},
{
"init"
,
Init
,
METH_VARARGS
,
doc_Init
},
{
"InitConfig"
,
InitConfig
,
METH_VARARGS
,
doc_InitConfig
},
{
"InitConfig"
,
InitConfig
,
METH_VARARGS
,
doc_InitConfig
},
{
"InitSystem"
,
InitSystem
,
METH_VARARGS
,
doc_InitSystem
},
{
"InitSystem"
,
InitSystem
,
METH_VARARGS
,
doc_InitSystem
},
// Tag File
// Tag File
#ifdef COMPAT_0_7
{
"ParseSection"
,
ParseSection
,
METH_VARARGS
,
doc_ParseSection
},
{
"ParseSection"
,
ParseSection
,
METH_VARARGS
,
doc_ParseSection
},
{
"ParseTagFile"
,
ParseTagFile
,
METH_VARARGS
,
doc_ParseTagFile
},
{
"ParseTagFile"
,
ParseTagFile
,
METH_VARARGS
,
doc_ParseTagFile
},
#endif
{
"RewriteSection"
,
RewriteSection
,
METH_VARARGS
,
doc_RewriteSection
},
{
"RewriteSection"
,
RewriteSection
,
METH_VARARGS
,
doc_RewriteSection
},
// Locking
// Locking
...
@@ -433,6 +437,7 @@ static PyMethodDef methods[] =
...
@@ -433,6 +437,7 @@ static PyMethodDef methods[] =
{
"StrToTime"
,
StrStrToTime
,
METH_VARARGS
,
"StrToTime(String) -> Int"
},
{
"StrToTime"
,
StrStrToTime
,
METH_VARARGS
,
"StrToTime(String) -> Int"
},
// Cache
// Cache
#ifdef COMPAT_0_7
{
"GetCache"
,
TmpGetCache
,
METH_VARARGS
,
"GetCache() -> PkgCache"
},
{
"GetCache"
,
TmpGetCache
,
METH_VARARGS
,
"GetCache() -> PkgCache"
},
{
"GetDepCache"
,
GetDepCache
,
METH_VARARGS
,
"GetDepCache(Cache) -> DepCache"
},
{
"GetDepCache"
,
GetDepCache
,
METH_VARARGS
,
"GetDepCache(Cache) -> DepCache"
},
{
"GetPkgRecords"
,
GetPkgRecords
,
METH_VARARGS
,
"GetPkgRecords(Cache) -> PkgRecords"
},
{
"GetPkgRecords"
,
GetPkgRecords
,
METH_VARARGS
,
"GetPkgRecords(Cache) -> PkgRecords"
},
...
@@ -452,11 +457,16 @@ static PyMethodDef methods[] =
...
@@ -452,11 +457,16 @@ static PyMethodDef methods[] =
// PkgManager
// PkgManager
{
"GetPackageManager"
,
GetPkgManager
,
METH_VARARGS
,
"GetPackageManager(DepCache) -> PackageManager"
},
{
"GetPackageManager"
,
GetPkgManager
,
METH_VARARGS
,
"GetPackageManager(DepCache) -> PackageManager"
},
#endif
{}
{}
};
};
#define ADDTYPE(mod,name,type) { Py_INCREF(type); \
PyModule_AddObject(mod,name,(PyObject *)type); }
#if PY_MAJOR_VERSION >= 3
#if PY_MAJOR_VERSION >= 3
struct
module_state
{
struct
module_state
{
PyObject
*
error
;
PyObject
*
error
;
...
@@ -527,6 +537,45 @@ extern "C" void initapt_pkg()
...
@@ -527,6 +537,45 @@ extern "C" void initapt_pkg()
Config
->
Object
=
_config
;
Config
->
Object
=
_config
;
PyModule_AddObject
(
Module
,
"Config"
,
Config
);
PyModule_AddObject
(
Module
,
"Config"
,
Config
);
// Add our classes.
/* ============================ tag.cc ============================ */
ADDTYPE
(
Module
,
"TagSection"
,
&
TagSecType
);
ADDTYPE
(
Module
,
"TagFile"
,
&
TagFileType
);
/* ============================ acquire.cc ============================ */
ADDTYPE
(
Module
,
"Acquire"
,
&
PkgAcquireType
);
ADDTYPE
(
Module
,
"AcquireFile"
,
&
PkgAcquireFileType
);
ADDTYPE
(
Module
,
"AcquireItem"
,
&
AcquireItemType
);
// NO __new__()
/* ============================ cache.cc ============================ */
ADDTYPE
(
Module
,
"Cache"
,
&
PkgCacheType
);
ADDTYPE
(
Module
,
"Dependency"
,
&
DependencyType
);
// NO __new__()
ADDTYPE
(
Module
,
"Description"
,
&
DescriptionType
);
// NO __new__()
ADDTYPE
(
Module
,
"PackageFile"
,
&
PackageFileType
);
// NO __new__()
//ADDTYPE(Module,"PackageList",&PkgListType); // NO __new__(), internal
//ADDTYPE(Module,"DependencyList",&RDepListType); // NO __new__(), internal
ADDTYPE
(
Module
,
"Package"
,
&
PackageType
);
// NO __new__()
ADDTYPE
(
Module
,
"Version"
,
&
VersionType
);
// NO __new__()
/* ============================ cdrom.cc ============================ */
ADDTYPE
(
Module
,
"Cdrom"
,
&
PkgCdromType
);
/* ========================= configuration.cc ========================= */
ADDTYPE
(
Module
,
"Configuration"
,
&
ConfigurationType
);
//ADDTYPE(Module,"ConfigurationSub",&ConfigurationSubType); // NO __new__()
//ADDTYPE(Module,"ConfigurationPtr",&ConfigurationPtrType); // NO __new__()
/* ========================= depcache.cc ========================= */
ADDTYPE
(
Module
,
"ActionGroup"
,
&
PkgActionGroupType
);
ADDTYPE
(
Module
,
"DepCache"
,
&
PkgDepCacheType
);
ADDTYPE
(
Module
,
"ProblemResolver"
,
&
PkgProblemResolverType
);
/* ========================= indexfile.cc ========================= */
ADDTYPE
(
Module
,
"PackageIndexFile"
,
&
PackageIndexFileType
);
// NO __new__()
/* ========================= metaindex.cc ========================= */
ADDTYPE
(
Module
,
"MetaIndex"
,
&
MetaIndexType
);
// NO __new__()
/* ========================= pkgmanager.cc ========================= */
ADDTYPE
(
Module
,
"PackageManager"
,
&
PkgManagerType
);
/* ========================= pkgrecords.cc ========================= */
ADDTYPE
(
Module
,
"PackageRecords"
,
&
PkgRecordsType
);
/* ========================= pkgsrcrecords.cc ========================= */
ADDTYPE
(
Module
,
"SourceRecords"
,
&
PkgSrcRecordsType
);
/* ========================= sourcelist.cc ========================= */
ADDTYPE
(
Module
,
"SourceList"
,
&
PkgSourceListType
);
// Tag file constants
// Tag file constants
PyModule_AddObject
(
Module
,
"RewritePackageOrder"
,
PyModule_AddObject
(
Module
,
"RewritePackageOrder"
,
CharCharToList
(
TFRewritePackageOrder
));
CharCharToList
(
TFRewritePackageOrder
));
...
...
python/apt_pkgmodule.h
View file @
45cdd4f2
...
@@ -80,6 +80,7 @@ PyObject *GetCdrom(PyObject *Self,PyObject *Args);
...
@@ -80,6 +80,7 @@ PyObject *GetCdrom(PyObject *Self,PyObject *Args);
// acquire
// acquire
extern
PyTypeObject
AcquireItemType
;
extern
PyTypeObject
AcquireItemType
;
extern
PyTypeObject
PkgAcquireType
;
extern
PyTypeObject
PkgAcquireType
;
extern
PyTypeObject
PkgAcquireFileType
;
extern
char
*
doc_GetPkgAcqFile
;
extern
char
*
doc_GetPkgAcqFile
;
PyObject
*
GetAcquire
(
PyObject
*
Self
,
PyObject
*
Args
);
PyObject
*
GetAcquire
(
PyObject
*
Self
,
PyObject
*
Args
);
PyObject
*
GetPkgAcqFile
(
PyObject
*
Self
,
PyObject
*
Args
,
PyObject
*
kwds
);
PyObject
*
GetPkgAcqFile
(
PyObject
*
Self
,
PyObject
*
Args
,
PyObject
*
kwds
);
...
...
python/cache.cc
View file @
45cdd4f2
...
@@ -235,6 +235,61 @@ void PkgCacheFileDealloc(PyObject *Self)
...
@@ -235,6 +235,61 @@ void PkgCacheFileDealloc(PyObject *Self)
CppOwnedDealloc
<
pkgCache
*>
(
Self
);
CppOwnedDealloc
<
pkgCache
*>
(
Self
);
}
}
static
PyObject
*
PkgCacheNew
(
PyTypeObject
*
type
,
PyObject
*
Args
,
PyObject
*
kwds
)
{
PyObject
*
pyCallbackInst
=
0
;
static
char
*
kwlist
[]
=
{
"progress"
,
0
};
if
(
PyArg_ParseTupleAndKeywords
(
Args
,
kwds
,
"|O"
,
kwlist
,
&
pyCallbackInst
)
==
0
)
return
0
;
if
(
_system
==
0
)
{
PyErr_SetString
(
PyExc_ValueError
,
"_system not initialized"
);
return
0
;
}
pkgCacheFile
*
Cache
=
new
pkgCacheFile
();
if
(
pyCallbackInst
!=
0
)
{
// sanity check for the progress object, see #497049
if
(
PyObject_HasAttrString
(
pyCallbackInst
,
"done"
)
!=
true
)
{
PyErr_SetString
(
PyExc_ValueError
,
"OpProgress object must implement done()"
);
return
0
;
}
if
(
PyObject_HasAttrString
(
pyCallbackInst
,
"update"
)
!=
true
)
{
PyErr_SetString
(
PyExc_ValueError
,
"OpProgress object must implement update()"
);
return
0
;
}
PyOpProgress
progress
;
progress
.
setCallbackInst
(
pyCallbackInst
);
if
(
Cache
->
Open
(
progress
,
false
)
==
false
)
return
HandleErrors
();
}
else
{
OpTextProgress
Prog
;
if
(
Cache
->
Open
(
Prog
,
false
)
==
false
)
return
HandleErrors
();
}
CppOwnedPyObject
<
pkgCacheFile
*>
*
CacheFileObj
=
CppOwnedPyObject_NEW
<
pkgCacheFile
*>
(
0
,
&
PkgCacheFileType
,
Cache
);
CppOwnedPyObject
<
pkgCache
*>
*
CacheObj
=
CppOwnedPyObject_NEW
<
pkgCache
*>
(
CacheFileObj
,
type
,
(
pkgCache
*
)(
*
Cache
));
//Py_DECREF(CacheFileObj);
return
CacheObj
;
}
static
const
char
*
doc_PkgCache
=
"Cache([progress]) -> Cache() object.
\n\n
"
"The cache provides access to the packages and other stuff.
\n\n
"
"The optional parameter *progress* can be used to specify an
\n
"
"apt.progress.OpProgress() object (or similar) which displays
\n
"
"the opening progress.
\n\n
"
"If not specified, the progress is displayed in simple text form."
;
static
PyMappingMethods
CacheMap
=
{
0
,
CacheMapOp
,
0
};
static
PyMappingMethods
CacheMap
=
{
0
,
CacheMapOp
,
0
};
PyTypeObject
PkgCacheType
=
PyTypeObject
PkgCacheType
=
{
{
...
@@ -242,7 +297,7 @@ PyTypeObject PkgCacheType =
...
@@ -242,7 +297,7 @@ PyTypeObject PkgCacheType =
#if PY_MAJOR_VERSION < 3
#if PY_MAJOR_VERSION < 3
0
,
// ob_size
0
,
// ob_size
#endif
#endif
"
pkgCache"
,
// tp_name
"
apt_pkg.Cache"
,
// tp_name
sizeof
(
CppOwnedPyObject
<
pkgCache
*>
),
// tp_basicsize
sizeof
(
CppOwnedPyObject
<
pkgCache
*>
),
// tp_basicsize
0
,
// tp_itemsize
0
,
// tp_itemsize
// Methods
// Methods
...
@@ -262,7 +317,7 @@ PyTypeObject PkgCacheType =
...
@@ -262,7 +317,7 @@ PyTypeObject PkgCacheType =
0
,
// tp_setattro
0
,
// tp_setattro
0
,
// tp_as_buffer
0
,
// tp_as_buffer
Py_TPFLAGS_DEFAULT
,
// tp_flags
Py_TPFLAGS_DEFAULT
,
// tp_flags
"Cache Object"
,
// tp_doc
doc_PkgCache
,
// tp_doc
0
,
// tp_traverse
0
,
// tp_traverse
0
,
// tp_clear
0
,
// tp_clear
0
,
// tp_richcompare
0
,
// tp_richcompare
...
@@ -272,6 +327,14 @@ PyTypeObject PkgCacheType =
...
@@ -272,6 +327,14 @@ PyTypeObject PkgCacheType =
PkgCacheMethods
,
// tp_methods
PkgCacheMethods
,
// tp_methods
0
,
// tp_members
0
,
// tp_members
PkgCacheGetSet
,
// tp_getset
PkgCacheGetSet
,
// tp_getset
0
,
// tp_base
0
,
// tp_dict
0
,
// tp_descr_get
0
,
// tp_descr_set
0
,
// tp_dictoffset
0
,
// tp_init
0
,
// tp_alloc
PkgCacheNew
,
// tp_new
};
};
/*}}}*/
/*}}}*/
// PkgCacheFile Class /*{{{*/
// PkgCacheFile Class /*{{{*/
...
@@ -352,7 +415,7 @@ PyTypeObject PkgListType =
...
@@ -352,7 +415,7 @@ PyTypeObject PkgListType =
#if PY_MAJOR_VERSION < 3
#if PY_MAJOR_VERSION < 3
0
,
// ob_size
0
,
// ob_size
#endif
#endif
"
pkgCache::PkgIterator"
,
// tp_name
"
apt_pkg.PackageList"
,
// tp_name
sizeof
(
CppOwnedPyObject
<
PkgListStruct
>
),
// tp_basicsize
sizeof
(
CppOwnedPyObject
<
PkgListStruct
>
),
// tp_basicsize
0
,
// tp_itemsize
0
,
// tp_itemsize
// Methods
// Methods
...
@@ -452,7 +515,7 @@ PyTypeObject PackageType =
...
@@ -452,7 +515,7 @@ PyTypeObject PackageType =
#if PY_MAJOR_VERSION < 3
#if PY_MAJOR_VERSION < 3
0
,
// ob_size
0
,
// ob_size
#endif
#endif
"
pkgCache::
Package"
,
// tp_name
"
apt_pkg.
Package"
,
// tp_name
sizeof
(
CppOwnedPyObject
<
pkgCache
::
PkgIterator
>
),
// tp_basicsize
sizeof
(
CppOwnedPyObject
<
pkgCache
::
PkgIterator
>
),
// tp_basicsize
0
,
// tp_itemsize
0
,
// tp_itemsize
// Methods
// Methods
...
@@ -539,7 +602,7 @@ PyTypeObject DescriptionType =
...
@@ -539,7 +602,7 @@ PyTypeObject DescriptionType =
#if PY_MAJOR_VERSION < 3
#if PY_MAJOR_VERSION < 3
0
,
// ob_size
0
,
// ob_size
#endif
#endif
"
pkgCache::DescIterator"
,
// tp_name
"
apt_pkg.Description"
,
// tp_name
sizeof
(
CppOwnedPyObject
<
pkgCache
::
DescIterator
>
),
// tp_basicsize
sizeof
(
CppOwnedPyObject
<
pkgCache
::
DescIterator
>
),
// tp_basicsize
0
,
// tp_itemsize
0
,
// tp_itemsize
// Methods
// Methods
...
@@ -743,7 +806,7 @@ PyTypeObject VersionType =
...
@@ -743,7 +806,7 @@ PyTypeObject VersionType =
#if PY_MAJOR_VERSION < 3
#if PY_MAJOR_VERSION < 3
0
,
// ob_size
0
,
// ob_size
#endif
#endif
"
pkgCache::VerIterator"
,
// tp_name
"
apt_pkg.Version"
,
// tp_name
sizeof
(
CppOwnedPyObject
<
pkgCache
::
VerIterator
>
),
// tp_basicsize
sizeof
(
CppOwnedPyObject
<
pkgCache
::
VerIterator
>
),
// tp_basicsize
0
,
// tp_itemsize
0
,
// tp_itemsize
// Methods
// Methods
...
@@ -820,7 +883,7 @@ PyTypeObject PackageFileType =
...
@@ -820,7 +883,7 @@ PyTypeObject PackageFileType =
#if PY_MAJOR_VERSION < 3
#if PY_MAJOR_VERSION < 3
0
,
// ob_size
0
,
// ob_size
#endif
#endif
"
pkgCache::PkgFileIterator
"
,
// tp_name
"
apt_pkg.PackageFile
"
,
// tp_name
sizeof
(
CppOwnedPyObject
<
pkgCache
::
PkgFileIterator
>
),
// tp_basicsize
sizeof
(
CppOwnedPyObject
<
pkgCache
::
PkgFileIterator
>
),
// tp_basicsize
0
,
// tp_itemsize
0
,
// tp_itemsize
// Methods
// Methods
...
@@ -968,7 +1031,7 @@ PyTypeObject DependencyType =
...
@@ -968,7 +1031,7 @@ PyTypeObject DependencyType =
#if PY_MAJOR_VERSION < 3
#if PY_MAJOR_VERSION < 3
0
,
// ob_size
0
,
// ob_size
#endif
#endif
"
pkgCache::DepIterator"
,
// tp_name
"
apt_pkg.Dependency"
,
// tp_name
sizeof
(
CppOwnedPyObject
<
pkgCache
::
DepIterator
>
),
// tp_basicsize
sizeof
(
CppOwnedPyObject
<
pkgCache
::
DepIterator
>
),
// tp_basicsize
0
,
// tp_itemsize
0
,
// tp_itemsize
// Methods
// Methods
...
@@ -1056,7 +1119,7 @@ PyTypeObject RDepListType =
...
@@ -1056,7 +1119,7 @@ PyTypeObject RDepListType =
#if PY_MAJOR_VERSION < 3
#if PY_MAJOR_VERSION < 3
0
,
// ob_size
0
,
// ob_size
#endif
#endif
"
pkgCache::DepIterator
"
,
// tp_name
"
apt_pkg.DependencyList
"
,
// tp_name
sizeof
(
CppOwnedPyObject
<
RDepListStruct
>
),
// tp_basicsize
sizeof
(
CppOwnedPyObject
<
RDepListStruct
>
),
// tp_basicsize
0
,
// tp_itemsize
0
,
// tp_itemsize
// Methods
// Methods
...
@@ -1078,47 +1141,5 @@ PyTypeObject RDepListType =
...
@@ -1078,47 +1141,5 @@ PyTypeObject RDepListType =
PyObject
*
TmpGetCache
(
PyObject
*
Self
,
PyObject
*
Args
)
PyObject
*
TmpGetCache
(
PyObject
*
Self
,
PyObject
*
Args
)
{
{
PyObject
*
pyCallbackInst
=
0
;
return
PkgCacheNew
(
&
PkgCacheType
,
Args
,
0
);
if
(
PyArg_ParseTuple
(
Args
,
"|O"
,
&
pyCallbackInst
)
==
0
)
return
0
;
if
(
_system
==
0
)
{
PyErr_SetString
(
PyExc_ValueError
,
"_system not initialized"
);
return
0
;
}
pkgCacheFile
*
Cache
=
new
pkgCacheFile
();
if
(
pyCallbackInst
!=
0
)
{
// sanity check for the progress object, see #497049
if
(
PyObject_HasAttrString
(
pyCallbackInst
,
"done"
)
!=
true
)
{
PyErr_SetString
(
PyExc_ValueError
,
"OpProgress object must implement done()"
);
return
0
;
}
if
(
PyObject_HasAttrString
(
pyCallbackInst
,
"update"
)
!=
true
)
{
PyErr_SetString
(
PyExc_ValueError
,
"OpProgress object must implement update()"
);
return
0
;
}
PyOpProgress
progress
;
progress
.
setCallbackInst
(
pyCallbackInst
);
if
(
Cache
->
Open
(
progress
,
false
)
==
false
)
return
HandleErrors
();
}
else
{
OpTextProgress
Prog
;
if
(
Cache
->
Open
(
Prog
,
false
)
==
false
)
return
HandleErrors
();
}
CppOwnedPyObject
<
pkgCacheFile
*>
*
CacheFileObj
=
CppOwnedPyObject_NEW
<
pkgCacheFile
*>
(
0
,
&
PkgCacheFileType
,
Cache
);
CppOwnedPyObject
<
pkgCache
*>
*
CacheObj
=
CppOwnedPyObject_NEW
<
pkgCache
*>
(
CacheFileObj
,
&
PkgCacheType
,
(
pkgCache
*
)(
*
Cache
));
//Py_DECREF(CacheFileObj);
return
CacheObj
;
}
}
python/cdrom.cc
View file @
45cdd4f2
...
@@ -58,19 +58,34 @@ static PyObject *PkgCdromIdent(PyObject *Self,PyObject *Args)
...
@@ -58,19 +58,34 @@ static PyObject *PkgCdromIdent(PyObject *Self,PyObject *Args)
static
PyMethodDef
PkgCdromMethods
[]
=
static
PyMethodDef
PkgCdromMethods
[]
=
{
{
{
"Add"
,
PkgCdromAdd
,
METH_VARARGS
,
"Add a cdrom"
},
{
"Add"
,
PkgCdromAdd
,
METH_VARARGS
,
"Add
(progress) -> Add
a cdrom"
},
{
"Ident"
,
PkgCdromIdent
,
METH_VARARGS
,
"Ident a cdrom"
},
{
"Ident"
,
PkgCdromIdent
,
METH_VARARGS
,
"Ident
(progress) -> Ident
a cdrom"
},
{}
{}
};
};
static
PyObject
*
PkgCdromNew
(
PyTypeObject
*
type
,
PyObject
*
Args
,
PyObject
*
kwds
)
{
pkgCdrom
*
cdrom
=
new
pkgCdrom
();
static
char
*
kwlist
[]
=
{};
if
(
PyArg_ParseTupleAndKeywords
(
Args
,
kwds
,
""
,
kwlist
)
==
0
)
return
0
;
CppOwnedPyObject
<
pkgCdrom
>
*
CdromObj
=
CppOwnedPyObject_NEW
<
pkgCdrom
>
(
0
,
type
,
*
cdrom
);
return
CdromObj
;
}
PyTypeObject
PkgCdromType
=
PyTypeObject
PkgCdromType
=
{
{
PyObject_HEAD_INIT
(
&
PyType_Type
)
PyObject_HEAD_INIT
(
&
PyType_Type
)
#if PY_MAJOR_VERSION < 3
#if PY_MAJOR_VERSION < 3
0
,
// ob_size
0
,
// ob_size
#endif
#endif
"
Cdrom"
,
// tp_name
"
apt_pkg.Cdrom"
,
// tp_name
sizeof
(
CppOwnedPyObject
<
PkgCdromStruct
>
),
// tp_basicsize
sizeof
(
CppOwnedPyObject
<
PkgCdromStruct
>
),
// tp_basicsize
0
,
// tp_itemsize
0
,
// tp_itemsize
// Methods
// Methods
...
@@ -98,16 +113,21 @@ PyTypeObject PkgCdromType =
...
@@ -98,16 +113,21 @@ PyTypeObject PkgCdromType =
0
,
// tp_iter
0
,
// tp_iter
0
,
// tp_iternext
0
,
// tp_iternext
PkgCdromMethods
,
// tp_methods
PkgCdromMethods
,
// tp_methods
0
,
// tp_members
0
,
// tp_getset
0
,
// tp_base
0
,
// tp_dict
0
,
// tp_descr_get
0
,
// tp_descr_set
0
,
// tp_dictoffset
0
,
// tp_init
0
,
// tp_alloc
PkgCdromNew
,
// tp_new
};
};
PyObject
*
GetCdrom
(
PyObject
*
Self
,
PyObject
*
Args
)
PyObject
*
GetCdrom
(
PyObject
*
Self
,
PyObject
*
Args
)
{
{
pkgCdrom
*
cdrom
=
new
pkgCdrom
();
return
PkgCdromNew
(
&
PkgCdromType
,
Args
,
0
);
CppOwnedPyObject
<
pkgCdrom
>
*
CdromObj
=
CppOwnedPyObject_NEW
<
pkgCdrom
>
(
0
,
&
PkgCdromType
,
*
cdrom
);
return
CdromObj
;
}
}
...
...
python/configuration.cc
View file @
45cdd4f2
...
@@ -475,6 +475,13 @@ static PyMethodDef CnfMethods[] =
...
@@ -475,6 +475,13 @@ static PyMethodDef CnfMethods[] =
{}
{}
};
};
static
PyObject
*
CnfNew
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
)
{
static
char
*
kwlist
[]
=
{};
if
(
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
""
,
kwlist
)
==
0
)
return
0
;
return
CppPyObject_NEW
<
Configuration
>
(
type
);
}
// Type for a Normal Configuration object
// Type for a Normal Configuration object
static
PySequenceMethods
ConfigurationSeq
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
CnfContains
,
0
,
0
};
static
PySequenceMethods
ConfigurationSeq
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
CnfContains
,
0
,
0
};
static
PyMappingMethods
ConfigurationMap
=
{
0
,
CnfMap
,
CnfMapSet
};
static
PyMappingMethods
ConfigurationMap
=
{
0
,
CnfMap
,
CnfMapSet
};
...
@@ -484,7 +491,7 @@ PyTypeObject ConfigurationType =
...
@@ -484,7 +491,7 @@ PyTypeObject ConfigurationType =
#if PY_MAJOR_VERSION < 3
#if PY_MAJOR_VERSION < 3
0
,
// ob_size
0
,
// ob_size
#endif
#endif
"
Configuration"
,
// tp_name
"
apt_pkg.Configuration"
,
// tp_name
sizeof
(
CppPyObject
<
Configuration
>
),
// tp_basicsize
sizeof
(
CppPyObject
<
Configuration
>
),
// tp_basicsize
0
,
// tp_itemsize
0
,
// tp_itemsize
// Methods
// Methods
...
@@ -512,6 +519,16 @@ PyTypeObject ConfigurationType =
...
@@ -512,6 +519,16 @@ PyTypeObject ConfigurationType =
0
,
// tp_iter
0
,
// tp_iter
0
,
// tp_iternext
0
,
// tp_iternext
CnfMethods
,
// tp_methods
CnfMethods
,
// tp_methods
0
,
// tp_members
0
,
// tp_getset
0
,
// tp_base
0
,
// tp_dict
0
,
// tp_descr_get
0
,
// tp_descr_set
0
,
// tp_dictoffset
0
,
// tp_init
0
,
// tp_alloc
CnfNew
,
// tp_new
};
};
PyTypeObject
ConfigurationPtrType
=
PyTypeObject
ConfigurationPtrType
=
...
@@ -520,7 +537,7 @@ PyTypeObject ConfigurationPtrType =
...
@@ -520,7 +537,7 @@ PyTypeObject ConfigurationPtrType =
#if PY_MAJOR_VERSION < 3
#if PY_MAJOR_VERSION < 3
0
,
// ob_size
0
,
// ob_size
#endif
#endif
"
ConfigurationPtr"
,
// tp_name
"
apt_pkg.ConfigurationPtr"
,
// tp_name
sizeof
(
CppPyObject
<
Configuration
*>
),
// tp_basicsize
sizeof
(
CppPyObject
<
Configuration
*>
),
// tp_basicsize
0
,
// tp_itemsize
0
,
// tp_itemsize
// Methods
// Methods
...
@@ -556,7 +573,7 @@ PyTypeObject ConfigurationSubType =
...
@@ -556,7 +573,7 @@ PyTypeObject ConfigurationSubType =