# PYTHON.

## Files

file | hash.c
file | hash.h
file | rpmmodule.c
file | upgrade.c
file | upgrade.h

## Data Structures

struct | hdrObject_s
struct | rpmdbObject_s
struct | rpmdbMIObject_s
struct | rpmtransObject_s
struct | tsCallbackType
class | header
| A python header object represents an RPM package header. More...
class | rpmdbMatchIterator
| A python rpmdbMatchIterator object represents the result of an RPM database query. More...
class | rpmdb
| A python rpmdb object represents an RPM database. More...

## Class: header

static PyObject * | hdrKeyList (hdrObject *s, PyObject *args)
static PyObject * | hdrUnload (hdrObject *s, PyObject *args, PyObject *keywords)
static PyObject * | hdrVerifyFile (hdrObject *s, PyObject *args)
| Returns a list of these tuples for each item that failed: (attr_name, correctValue, currentValue) It should be passed the file number to verify.
static PyObject * | hdrExpandFilelist (hdrObject *s, PyObject *args)
static PyObject * | hdrCompressFilelist (hdrObject *s, PyObject *args)
static void | mungeFilelist (Header h)
static PyObject * | hdrFullFilelist (hdrObject *s, PyObject *args)
static PyObject * | hdrSprintf (hdrObject *s, PyObject *args)
static PyObject * | hdrGetAttr (hdrObject *s, char *name)
static void | hdrDealloc (hdrObject *s)
static long | tagNumFromPyObject (PyObject *item)
static PyObject * | hdrSubscript (hdrObject *s, PyObject *item)
static PyObject * | rhnUnload (hdrObject *s, PyObject *args)
static struct PyMethodDef | hdrMethods []
static PyMappingMethods | hdrAsMapping
static PyTypeObject | hdrType

## Class: rpmdbMatchIterator

static PyObject * | rpmdbMINext (rpmdbMIObject *s, PyObject *args)
static PyObject * | rpmdbMIGetAttr (rpmdbObject *s, char *name)
static void | rpmdbMIDealloc (rpmdbMIObject *s)
static struct PyMethodDef | rpmdbMIMethods []
static PyTypeObject | rpmdbMIType

## Class: rpmtrans

static PyObject * | rpmtransAdd (rpmtransObject *s, PyObject *args)
static PyObject * | rpmtransRemove (rpmtransObject *s, PyObject *args)
static PyObject * | rpmtransDepCheck (rpmtransObject *s, PyObject *args)
static PyObject * | rpmtransOrder (rpmtransObject *s, PyObject *args)
static PyObject * | py_rpmtransGetKeys (rpmtransObject *s, PyObject *args)
static void * | tsCallback (const void *hd, const rpmCallbackType what, const unsigned long amount, const unsigned long total, const void *pkgKey, rpmCallbackData data)
static PyObject * | rpmtransRun (rpmtransObject *s, PyObject *args)
static PyObject * | rpmtransGetAttr (rpmtransObject *o, char *name)
static void | rpmtransDealloc (PyObject *o)
static int | rpmtransSetAttr (rpmtransObject *o, char *name, PyObject *val)
static Header | transactionSetHeader = NULL
static struct PyMethodDef | rpmtransMethods []
static PyTypeObject | rpmtransType

## Typedefs

typedef rpmdbObject_s | rpmdbObject
typedef rpmdbMIObject_s | rpmdbMIObject
typedef rpmtransObject_s | rpmtransObject
typedef hdrObject_s | hdrObject

## Variables

static PyObject * | pyrpmError

## Typedef Documentation

typedef struct hdrObject_s hdrObject

| Definition at line 57 of file rpmmodule.c.

typedef struct rpmdbMIObject_s rpmdbMIObject

| Definition at line 49 of file rpmmodule.c.

typedef struct rpmdbObject_s rpmdbObject

| Definition at line 45 of file rpmmodule.c.

typedef struct rpmtransObject_s rpmtransObject

| Definition at line 53 of file rpmmodule.c.

## Function Documentation

static PyObject* hdrCompressFilelist | ( | hdrObject * | s,
|  | PyObject * | args
| ) | `[static]`

| Definition at line 417 of file rpmmodule.c. References compressFilelist(), and hdrObject_s::h.

static void hdrDealloc | ( | hdrObject * | s | ) | `[static]`

| Definition at line 567 of file rpmmodule.c. References hdrObject_s::fileList, hdrObject_s::h, headerFree(), hdrObject_s::linkList, hdrObject_s::md5list, and hdrObject_s::sigs.

static PyObject* hdrExpandFilelist | ( | hdrObject * | s,
|  | PyObject * | args
| ) | `[static]`

| Definition at line 408 of file rpmmodule.c. References expandFilelist(), and hdrObject_s::h.

static PyObject* hdrFullFilelist | ( | hdrObject * | s,
|  | PyObject * | args
| ) | `[static]`

| Definition at line 511 of file rpmmodule.c. References hdrObject_s::h, and mungeFilelist().

static PyObject* hdrGetAttr | ( | hdrObject * | s,
|  | char * | name
| ) | `[static]`

| Definition at line 561 of file rpmmodule.c. References hdrMethods.

static PyObject* hdrKeyList | ( | hdrObject * | s,
|  | PyObject * | args
| ) | `[static]`

| Definition at line 133 of file rpmmodule.c. References hdrObject_s::h, HEADER_I18NTABLE, headerFreeIterator(), headerInitIterator(), headerNextIterator(), RPM_BIN_TYPE, RPM_CHAR_TYPE, RPM_INT16_TYPE, RPM_INT32_TYPE, RPM_INT8_TYPE, RPM_STRING_ARRAY_TYPE, and RPM_STRING_TYPE.

static PyObject* hdrSprintf | ( | hdrObject * | s,
|  | PyObject * | args
| ) | `[static]`

| Definition at line 523 of file rpmmodule.c. References hdrObject_s::h, headerSprintf(), pyrpmError, rpmHeaderFormats, and rpmTagTable.

static PyObject* hdrSubscript | ( | hdrObject * | s,
|  | PyObject * | item
| ) | `[static]`

Definition at line 596 of file rpmmodule.c.

References hdrObject_s::h, HEADER_EXT_TAG, headerSprintfExtension_s::name, RPM_BIN_TYPE, RPM_CHAR_TYPE, RPM_INT32_TYPE, RPM_INT8_TYPE, rpmHeaderFormats, rpmPackageGetEntry(), RPMTAG_DESCRIPTION, RPMTAG_FILEFLAGS, RPMTAG_FILEGIDS, RPMTAG_FILEGROUPNAME, RPMTAG_FILELINKTOS, RPMTAG_FILEMD5S, RPMTAG_FILEMODES, RPMTAG_FILEMTIMES, RPMTAG_FILERDEVS, RPMTAG_FILESIZES, RPMTAG_FILESTATES, RPMTAG_FILEUIDS, RPMTAG_FILEUSERNAME, RPMTAG_GROUP, RPMTAG_OLDFILENAMES, RPMTAG_ROOT, RPMTAG_SUMMARY, hdrObject_s::sigs, headerSprintfExtension_s::tagFunction, tagNumFromPyObject(), headerSprintfExtension_s::type, headerSprintfExtension_s::u, and xstrcasecmp().

static PyObject* hdrUnload | ( | hdrObject * | s,
|  | PyObject * | args,
|  | PyObject * | keywords
| ) | `[static]`

| Definition at line 166 of file rpmmodule.c. References hdrObject_s::h, headerCopy(), headerFree(), headerLink(), headerSizeof(), headerUnload(), and pyrpmError.

static PyObject* hdrVerifyFile | ( | hdrObject * | s,
|  | PyObject * | args
| ) | `[static]`

Returns a list of these tuples for each item that failed: (attr_name, correctValue, currentValue) It should be passed the file number to verify.

Definition at line 202 of file rpmmodule.c.

References hdrObject_s::fileList, hdrObject_s::fileSizes, hdrObject_s::gids, hdrObject_s::h, headerGetEntry(), hdrObject_s::linkList, hdrObject_s::md5list, mdfile(), hdrObject_s::modes, hdrObject_s::mtimes, hdrObject_s::rdevs, RPMTAG_FILEGIDS, RPMTAG_FILELINKTOS, RPMTAG_FILEMD5S, RPMTAG_FILEMODES, RPMTAG_FILEMTIMES, RPMTAG_FILERDEVS, RPMTAG_FILESIZES, RPMTAG_FILEUIDS, RPMTAG_OLDFILENAMES, RPMVERIFY_FILESIZE, RPMVERIFY_GROUP, RPMVERIFY_LINKTO, RPMVERIFY_MD5, RPMVERIFY_MODE, RPMVERIFY_MTIME, RPMVERIFY_NONE, RPMVERIFY_RDEV, RPMVERIFY_USER, rpmVerifyFile(), and hdrObject_s::uids.

static void mungeFilelist | ( | Header | h | ) | `[static]`

| Definition at line 427 of file rpmmodule.c. References compressFilelist(), headerAddEntry(), headerIsEntry(), RPM_STRING_ARRAY_TYPE, rpmBuildFileList(), RPMTAG_BASENAMES, RPMTAG_DIRINDEXES, RPMTAG_DIRNAMES, and RPMTAG_OLDFILENAMES. Referenced by hdrFullFilelist().

static PyObject* py_rpmtransGetKeys | ( | rpmtransObject * | s,
|  | PyObject * | args
| ) | `[static]`

| Definition at line 1437 of file rpmmodule.c. References rpmtransGetKeys(), and rpmtransObject_s::ts.

static PyObject* rhnUnload | ( | hdrObject * | s,
|  | PyObject * | args
| ) | `[static]`

Definition at line 451 of file rpmmodule.c.

References _free(), hdrObject_s::h, headerAddEntry(), headerAllocated(), headerFree(), headerFreeData(), headerGetEntry(), headerIsEntry(), headerLink(), headerLoad(), headerReload(), headerSizeof(), headerUnload(), PGPHASHALGO_SHA1, RPM_STRING_TYPE, RPMDIGEST_NONE, rpmDigestFinal(), rpmDigestInit(), rpmDigestUpdate(), RPMTAG_ARCH, RPMTAG_HEADERIMMUTABLE, RPMTAG_RHNPLATFORM, RPMTAG_SHA1HEADER, and RPMTAG_SHA1RHN.

static void rpmdbMIDealloc | ( | rpmdbMIObject * | s | ) | `[static]`

| Definition at line 851 of file rpmmodule.c. References rpmdbMIObject_s::db, rpmdbMIObject_s::mi, and rpmdbFreeIterator().

static PyObject* rpmdbMIGetAttr | ( | rpmdbObject * | s,
|  | char * | name
| ) | `[static]`

| Definition at line 845 of file rpmmodule.c.

static PyObject* rpmdbMINext | ( | rpmdbMIObject * | s,
|  | PyObject * | args
| ) | `[static]`

| Definition at line 814 of file rpmmodule.c. References hdrObject_s::fileList, hdrObject_s::fileSizes, hdrObject_s::gids, hdrObject_s::h, headerLink(), hdrObject_s::linkList, hdrObject_s::md5list, rpmdbMIObject_s::mi, hdrObject_s::modes, hdrObject_s::mtimes, hdrObject_s::rdevs, rpmdbNextIterator(), hdrObject_s::sigs, and hdrObject_s::uids.

static PyObject* rpmtransAdd | ( | rpmtransObject * | s,
|  | PyObject * | args
| ) | `[static]`

| Definition at line 1322 of file rpmmodule.c. References hdrObject_s::h, rpmtransObject_s::keyList, rpmtransAddPackage(), rpmtransAvailablePackage(), and rpmtransObject_s::ts.

static void rpmtransDealloc | ( | PyObject * | o | ) | `[static]`

| Definition at line 1587 of file rpmmodule.c. References rpmtransObject_s::dbo, Fclose(), rpmtransObject_s::keyList, rpmtransFree(), rpmtransObject_s::scriptFd, and rpmtransObject_s::ts.

static PyObject* rpmtransDepCheck | ( | rpmtransObject * | s,
|  | PyObject * | args
| ) | `[static]`

| Definition at line 1387 of file rpmmodule.c. References rpmdepCheck(), rpmdepFreeConflicts(), and rpmtransObject_s::ts.

static PyObject* rpmtransGetAttr | ( | rpmtransObject * | o,
|  | char * | name
| ) | `[static]`

| Definition at line 1581 of file rpmmodule.c.

static PyObject* rpmtransOrder | ( | rpmtransObject * | s,
|  | PyObject * | args
| ) | `[static]`

| Definition at line 1426 of file rpmmodule.c. References rpmdepOrder(), and rpmtransObject_s::ts.

static PyObject* rpmtransRemove | ( | rpmtransObject * | s,
|  | PyObject * | args
| ) | `[static]`

| Definition at line 1356 of file rpmmodule.c. References rpmdbObject_s::db, rpmtransObject_s::dbo, name, pyrpmError, rpmdbFreeIterator(), rpmdbGetIteratorCount(), rpmdbGetIteratorOffset(), RPMDBI_LABEL, rpmdbInitIterator(), rpmdbNextIterator(), rpmtransRemovePackage(), and rpmtransObject_s::ts.

static PyObject* rpmtransRun | ( | rpmtransObject * | s,
|  | PyObject * | args
| ) | `[static]`

| Definition at line 1521 of file rpmmodule.c. References tsCallbackType::cb, tsCallbackType::data, rpmProblemSet_s::numProblems, rpmProblemSet_s::probs, tsCallbackType::pythonError, rpmProblemSetFree(), rpmProblemString(), rpmRunTransactions(), rpmtransObject_s::ts, and tsCallback().

static int rpmtransSetAttr | ( | rpmtransObject * | o,
|  | char * | name,
|  | PyObject * | val
| ) | `[static]`

| Definition at line 1603 of file rpmmodule.c. References fdDup(), rpmtransSetScriptFd(), rpmtransObject_s::scriptFd, and rpmtransObject_s::ts.

static long tagNumFromPyObject | ( | PyObject * | item | ) | `[static]`

| Definition at line 578 of file rpmmodule.c. References name, rpmTagTable, rpmTagTableSize, and xstrcasecmp(). Referenced by hdrSubscript(), and py_rpmdbInitIterator().

static void* tsCallback | ( | const void * | hd,
|  | const rpmCallbackType | what,
|  | const unsigned long | amount,
|  | const unsigned long | total,
|  | const void * | pkgKey,
|  | rpmCallbackData | data
| ) | `[static]`

| Definition at line 1476 of file rpmmodule.c. References tsCallbackType::cb, tsCallbackType::data, Fclose(), fdDup(), tsCallbackType::pythonError, RPMCALLBACK_INST_CLOSE_FILE, RPMCALLBACK_INST_OPEN_FILE, and transactionSetHeader. Referenced by rpmtransRun().

## Variable Documentation

PyMappingMethods hdrAsMapping`[static]`

Initial value:

     {
            (inquiry) 0,
            (binaryfunc) hdrSubscript,
            (objobjargproc)0,
    }

Definition at line 755 of file rpmmodule.c.

struct PyMethodDef hdrMethods[]`[static]`

Initial value:

     {
            {"keys",        (PyCFunction) hdrKeyList,       1 },
            {"unload",      (PyCFunction) hdrUnload,        METH_VARARGS|METH_KEYWORDS },
            {"verifyFile",  (PyCFunction) hdrVerifyFile,    1 },
            {"expandFilelist",      (PyCFunction) hdrExpandFilelist,        1 },
            {"compressFilelist",    (PyCFunction) hdrCompressFilelist,      1 },
            {"fullFilelist",        (PyCFunction) hdrFullFilelist,  1 },
            {"rhnUnload",   (PyCFunction) rhnUnload, METH_VARARGS },
            {"sprintf",     (PyCFunction) hdrSprintf, METH_VARARGS },
            {NULL,          NULL}
    }

Definition at line 547 of file rpmmodule.c.

Referenced by hdrGetAttr().

PyTypeObject hdrType`[static]`

Initial value:

     {
            PyObject_HEAD_INIT(NULL)
            0,
            "header",
            sizeof(hdrObject),
            0,
            (destructor) hdrDealloc,
            0,
            (getattrfunc) hdrGetAttr,
            0,
            0,
            0,
            0,
            0,
            &hdrAsMapping,
    }

Definition at line 763 of file rpmmodule.c.

PyObject* pyrpmError`[static]`

| Definition at line 61 of file rpmmodule.c. Referenced by doFopen(), hdrLoad(), hdrSprintf(), hdrUnload(), initrpm(), py_rpmdbInitIterator(), rhnLoad(), rpmdbFirst(), rpmdbSubscript(), rpmHeaderFromFile(), rpmHeaderFromPackage(), rpmInitDB(), rpmMergeHeaders(), rpmOpenDB(), rpmReadHeaders(), and rpmtransRemove().

struct PyMethodDef rpmdbMIMethods[]`[static]`

Initial value:

     {
            {"next",            (PyCFunction) rpmdbMINext,  1 },
            {NULL,          NULL}
    }

Definition at line 838 of file rpmmodule.c.

PyTypeObject rpmdbMIType`[static]`

Initial value:

     {
            PyObject_HEAD_INIT(NULL)
            0,
            "rpmdbMatchIterator",
            sizeof(rpmdbMIObject),
            0,
            (destructor) rpmdbMIDealloc,
            0,
            (getattrfunc) rpmdbMIGetAttr,
            0,
            0,
            0,
            0,
            0,
            0,
    }

Definition at line 861 of file rpmmodule.c.

struct PyMethodDef rpmtransMethods[]`[static]`

Initial value:

     {
            {"add",         (PyCFunction) rpmtransAdd,      1 },
            {"remove",      (PyCFunction) rpmtransRemove,   1 },
            {"depcheck",    (PyCFunction) rpmtransDepCheck, 1 },
            {"order",       (PyCFunction) rpmtransOrder,    1 },
            {"getKeys",     (PyCFunction) py_rpmtransGetKeys, 1 },
            {"run",         (PyCFunction) rpmtransRun, 1 },
            {NULL,          NULL}
    }

Definition at line 1569 of file rpmmodule.c.

PyTypeObject rpmtransType`[static]`

Initial value:

     {
            PyObject_HEAD_INIT(NULL)
            0,
            "rpmtrans",
            sizeof(rpmtransObject),
            0,
            (destructor) rpmtransDealloc,
            0,
            (getattrfunc) rpmtransGetAttr,
            (setattrfunc) rpmtransSetAttr,
            0,
            0,
            0,
            0,
            0,
    }

Definition at line 1626 of file rpmmodule.c.

Header transactionSetHeader = NULL`[static]`

Todo:
  Remove, there's no headerLink refcount on the pointer.

Definition at line 1472 of file rpmmodule.c.

Referenced by getTsHeader(), and tsCallback().