# PYTHON.

## Files

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

## Data Structures

struct | hdrObject_s
struct | hdrObject_s
struct | rpmdbObject_s
struct | rpmdbObject_s
struct | rpmdbMIObject_s
struct | rpmtransObject_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 | rpmtrans
| A python rpmtrans object represents an RPM transaction set. 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)
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: rpmdb

static PyObject * | rpmdbFirst (rpmdbObject *s, PyObject *args)
static PyObject * | rpmdbNext (rpmdbObject *s, PyObject *args)
static PyObject * | handleDbResult (rpmdbMatchIterator mi)
static PyObject * | rpmdbByFile (rpmdbObject *s, PyObject *args)
static PyObject * | rpmdbByName (rpmdbObject *s, PyObject *args)
static PyObject * | rpmdbByProvides (rpmdbObject *s, PyObject *args)
static rpmdbMIObject * | py_rpmdbInitIterator (rpmdbObject *s, PyObject *args)
static PyObject * | rpmdbGetAttr (rpmdbObject *s, char *name)
static void | rpmdbDealloc (rpmdbObject *s)
static int | rpmdbLength (rpmdbObject *s)
static hdrObject * | rpmdbSubscript (rpmdbObject *s, PyObject *key)
static struct PyMethodDef | rpmdbMethods []
static PyMappingMethods | rpmdbAsMapping
static PyTypeObject | rpmdbType

## 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

## Module: rpm

static PyObject * | rpmtransCreate (PyObject *self, PyObject *args)

## 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* handleDbResult | ( | rpmdbMatchIterator | mi | ) | `[static]`

| Definition at line 1010 of file rpmmodule.c. References rpmdbFreeIterator(), rpmdbGetIteratorOffset(), and rpmdbNextIterator(). Referenced by rpmdbByFile(), rpmdbByName(), and rpmdbByProvides().

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

| Definition at line 417 of file rpmmodule.c. References compressFilelist().

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

| Definition at line 567 of file rpmmodule.c. References headerFree().

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

| Definition at line 408 of file rpmmodule.c. References expandFilelist().

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

| Definition at line 511 of file rpmmodule.c. References 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 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 headerSprintf(), pyrpmError, rpmHeaderFormats, and rpmTagTable.

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

Definition at line 596 of file rpmmodule.c.

References HEADER_EXT_TAG, headerSprintfExtension_s::name, RPM_BIN_TYPE, RPM_CHAR_TYPE, RPM_INT16_TYPE, RPM_INT32_TYPE, RPM_INT8_TYPE, RPM_STRING_ARRAY_TYPE, RPM_STRING_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, 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 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 headerGetEntry(), mdfile(), 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, and rpmVerifyFile().

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

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

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

| Definition at line 1060 of file rpmmodule.c. References rpmdbMIObject_s::db, rpmdbMIObject_s::mi, pyrpmError, rpmdbInitIterator(), rpmdbMIType, and tagNumFromPyObject().

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

| Definition at line 1437 of file rpmmodule.c. References rpmtransGetKeys().

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

Definition at line 451 of file rpmmodule.c.

References _free(), 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 PyObject* rpmdbByFile | ( | rpmdbObject * | s,
|  | PyObject * | args
| ) | `[static]`

| Definition at line 1029 of file rpmmodule.c. References handleDbResult(), rpmdbInitIterator(), and RPMTAG_BASENAMES.

static PyObject* rpmdbByName | ( | rpmdbObject * | s,
|  | PyObject * | args
| ) | `[static]`

| Definition at line 1039 of file rpmmodule.c. References handleDbResult(), rpmdbInitIterator(), and RPMTAG_NAME.

static PyObject* rpmdbByProvides | ( | rpmdbObject * | s,
|  | PyObject * | args
| ) | `[static]`

| Definition at line 1049 of file rpmmodule.c. References handleDbResult(), rpmdbInitIterator(), and RPMTAG_PROVIDENAME.

static void rpmdbDealloc | ( | rpmdbObject * | s | ) | `[static]`

| Definition at line 1109 of file rpmmodule.c. References rpmdbClose().

static PyObject* rpmdbFirst | ( | rpmdbObject * | s,
|  | PyObject * | args
| ) | `[static]`

| Definition at line 949 of file rpmmodule.c. References pyrpmError, rpmdbFreeIterator(), rpmdbGetIteratorOffset(), RPMDBI_PACKAGES, rpmdbInitIterator(), and rpmdbNextIterator().

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

| Definition at line 1103 of file rpmmodule.c. References rpmdbMethods.

static int rpmdbLength | ( | rpmdbObject * | s | ) | `[static]`

| Definition at line 1123 of file rpmmodule.c. References rpmdbFreeIterator(), RPMDBI_PACKAGES, rpmdbInitIterator(), and rpmdbNextIterator().

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

| Definition at line 851 of file rpmmodule.c. References rpmdbFreeIterator().

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

| Definition at line 845 of file rpmmodule.c. References rpmdbMIMethods.

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, hdrType, headerLink(), hdrObject_s::linkList, hdrObject_s::md5list, hdrObject_s::modes, hdrObject_s::mtimes, hdrObject_s::rdevs, rpmdbNextIterator(), hdrObject_s::sigs, and hdrObject_s::uids.

static PyObject* rpmdbNext | ( | rpmdbObject * | s,
|  | PyObject * | args
| ) | `[static]`

| Definition at line 988 of file rpmmodule.c.

static hdrObject* rpmdbSubscript | ( | rpmdbObject * | s,
|  | PyObject * | key
| ) | `[static]`

Definition at line 1141 of file rpmmodule.c.

References hdrObject_s::fileList, hdrObject_s::fileSizes, hdrObject_s::gids, hdrObject_s::h, hdrType, headerLink(), hdrObject_s::linkList, hdrObject_s::md5list, hdrObject_s::modes, hdrObject_s::mtimes, pyrpmError, hdrObject_s::rdevs, rpmdbFreeIterator(), RPMDBI_PACKAGES, rpmdbInitIterator(), 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, hdrType, rpmtransAddPackage(), and rpmtransAvailablePackage().

static PyObject* rpmtransCreate | ( | PyObject * | self,
|  | PyObject * | args
| ) | `[static]`

| Definition at line 1652 of file rpmmodule.c. References rpmdbObject_s::db, rpmtransObject_s::dbo, rpmtransObject_s::keyList, rpmdbType, rpmtransCreateSet(), rpmtransType, rpmtransObject_s::scriptFd, 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(), and rpmdepFreeConflicts().

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

| Definition at line 1581 of file rpmmodule.c. References rpmtransMethods.

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

| Definition at line 1426 of file rpmmodule.c. References rpmdepOrder().

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

| Definition at line 1356 of file rpmmodule.c. References pyrpmError, rpmdbFreeIterator(), rpmdbGetIteratorCount(), rpmdbGetIteratorOffset(), RPMDBI_LABEL, rpmdbInitIterator(), rpmdbNextIterator(), and rpmtransRemovePackage().

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

| Definition at line 1521 of file rpmmodule.c. References tsCallbackType::cb, tsCallbackType::data, rpmProblemSet_s::probs, tsCallbackType::pythonError, rpmProblemSetFree(), rpmProblemString(), rpmRunTransactions(), rpmProblem_s::str1, tsCallback(), rpmProblem_s::type, and rpmProblem_s::ulong1.

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

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

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

| Definition at line 578 of file rpmmodule.c. References rpmTagTable, rpmTagTableSize, headerTagTableEntry_s::val, 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.

Referenced by findUpgradeSet(), getTsHeader(), hdrLoad(), initrpm(), rhnLoad(), rpmdbMINext(), rpmdbSubscript(), rpmHeaderFromPackage(), rpmReadHeaders(), rpmtransAdd(), and versionCompare().

PyObject* pyrpmError `[static]`

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

PyMappingMethods rpmdbAsMapping `[static]`

Initial value:

     {
            (inquiry) rpmdbLength,
            (binaryfunc) rpmdbSubscript,
            (objobjargproc)0,
    }

Definition at line 1175 of file rpmmodule.c.

struct PyMethodDef rpmdbMethods[]`[static]`

Initial value:

     {
            {"firstkey",        (PyCFunction) rpmdbFirst,   1 },
            {"nextkey",         (PyCFunction) rpmdbNext,    1 },
            {"findbyfile",      (PyCFunction) rpmdbByFile, 1 },
            {"findbyname",      (PyCFunction) rpmdbByName, 1 },
            {"findbyprovides",  (PyCFunction) rpmdbByProvides, 1 },
            {"match",           (PyCFunction) py_rpmdbInitIterator, 1 },
            {NULL,          NULL}
    }

Definition at line 1091 of file rpmmodule.c.

Referenced by rpmdbGetAttr().

struct PyMethodDef rpmdbMIMethods[]`[static]`

Initial value:

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

Definition at line 838 of file rpmmodule.c.

Referenced by rpmdbMIGetAttr().

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.

Referenced by initrpm(), and py_rpmdbInitIterator().

PyTypeObject rpmdbType `[static]`

Initial value:

     {
            PyObject_HEAD_INIT(NULL)
            0,
            "rpmdb",
            sizeof(rpmdbObject),
            0,
            (destructor) rpmdbDealloc,
            0,
            (getattrfunc) rpmdbGetAttr,
            0,
            0,
            0,
            0,
            0,

            &rpmdbAsMapping,

    }

Definition at line 1184 of file rpmmodule.c.

Referenced by initrpm(), rpmOpenDB(), and rpmtransCreate().

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.

Referenced by rpmtransGetAttr().

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.

Referenced by initrpm(), and rpmtransCreate().

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().