Commit 501cd5af authored by Julian Andres Klode's avatar Julian Andres Klode

Add apt_pkg.Tag and subclasses (one per kind of tag)

parent 1d62eb4c
......@@ -2047,7 +2047,36 @@ section as a string.
Return a list of keys in the section.
.. autofunction:: rewrite_section
A function can be rewritten by using tag classes:
.. autoclass:: Tag
:members:
The following static members can be used to determine the meaning of
:attr:`action`:
.. data:: REWRITE
Change the field value to the value of :attr:`data`
.. data:: RENAME
Rename the tag to a new tag stored in :attr:`data`.
.. data:: REMOVE
Remove the tag.
Apart from this, the class provides access to several attributes.
.. autoclass:: TagRewrite
.. autoclass:: TagRemove
.. autoclass:: TagRename
Pre-defined ordering for tag sections are:
.. data:: REWRITE_PACKAGE_ORDER
......@@ -2059,6 +2088,11 @@ section as a string.
The order in which the information for source packages should be rewritten,
i.e. the order in which the fields should appear.
Before APT 1.1, the function :func:`rewrite_section` was used.
.. autofunction:: rewrite_section
Dependencies
------------
.. function:: check_dep(pkgver: str, op: str, depver: str) -> bool
......
......@@ -820,6 +820,10 @@ extern "C" void initapt_pkg()
/* ============================ tag.cc ============================ */
ADDTYPE(Module,"TagSection",&PyTagSection_Type);
ADDTYPE(Module,"TagFile",&PyTagFile_Type);
ADDTYPE(Module,"Tag",&PyTag_Type);
ADDTYPE(Module,"TagRewrite",&PyTagRewrite_Type);
ADDTYPE(Module,"TagRename",&PyTagRename_Type);
ADDTYPE(Module,"TagRemove",&PyTagRemove_Type);
/* ============================ acquire.cc ============================ */
ADDTYPE(Module,"Acquire",&PyAcquire_Type);
ADDTYPE(Module,"AcquireFile",&PyAcquireFile_Type);
......@@ -950,7 +954,13 @@ extern "C" void initapt_pkg()
MkPyNumber(pkgAcquire::Item::StatError));
PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "STAT_AUTH_ERROR",
MkPyNumber(pkgAcquire::Item::StatAuthError));
// TagSection constants
PyDict_SetItemString(PyTag_Type.tp_dict, "REMOVE",
MkPyNumber(pkgTagSection::Tag::REMOVE));
PyDict_SetItemString(PyTag_Type.tp_dict, "REWRITE",
MkPyNumber(pkgTagSection::Tag::REWRITE));
PyDict_SetItemString(PyTag_Type.tp_dict, "RENAME",
MkPyNumber(pkgTagSection::Tag::RENAME));
#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 1
PyObject *PyCapsule = PyCapsule_New(&API, "apt_pkg._C_API", NULL);
......
......@@ -43,6 +43,10 @@ PyObject *ParseCommandLine(PyObject *Self,PyObject *Args);
// Tag File Stuff
extern PyTypeObject PyTagSection_Type;
extern PyTypeObject PyTagFile_Type;
extern PyTypeObject PyTag_Type;
extern PyTypeObject PyTagRewrite_Type;
extern PyTypeObject PyTagRename_Type;
extern PyTypeObject PyTagRemove_Type;
extern char *doc_ParseSection;
extern char *doc_ParseTagFile;
extern char *doc_RewriteSection;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment