From 24e6f8633e766bb8205a2ac55ad735a97b945f8c Mon Sep 17 00:00:00 2001 From: pauln Date: Wed, 17 Nov 2004 17:05:39 +0000 Subject: [PATCH] Add kwargs everywhere - courtesy of pjones@redhat.com CVS patchset: 7582 CVS date: 2004/11/17 17:05:39 --- python/_rpmdb.c | 604 +++++++++++++++++++++++++++++++--------------------- python/header-py.c | 93 ++++---- python/header-py.h | 16 +- python/poptmodule.c | 139 ++++++------ python/rpmal-py.c | 42 ++-- python/rpmdb-py.c | 23 +- python/rpmdb-py.h | 4 +- python/rpmds-py.c | 142 ++++++------ python/rpmds-py.h | 6 +- python/rpmfd-py.c | 21 +- python/rpmfi-py.c | 140 ++++++------ python/rpmfi-py.h | 2 +- python/rpmfts-py.c | 52 +++-- python/rpmmi-py.c | 29 +-- python/rpmmodule.c | 66 +++--- python/rpmps-py.c | 13 +- python/rpmrc-py.c | 18 +- python/rpmrc-py.h | 4 +- python/rpmte-py.c | 121 +++++------ python/rpmts-py.c | 238 ++++++++++++--------- python/rpmts-py.h | 2 +- 21 files changed, 1001 insertions(+), 774 deletions(-) diff --git a/python/_rpmdb.c b/python/_rpmdb.c index 48ccaba..91b87ef 100644 --- a/python/_rpmdb.c +++ b/python/_rpmdb.c @@ -102,7 +102,7 @@ #endif #define PY_BSDDB_VERSION "4.2.4" -static char *rcs_id = "$Id: _rpmdb.c,v 1.13 2004/10/16 12:50:52 jbj Exp $"; +static char *rcs_id = "$Id: _rpmdb.c,v 1.14 2004/11/17 17:05:39 pauln Exp $"; #ifdef WITH_THREAD @@ -965,15 +965,17 @@ DBLock_dealloc(DBLockObject* self) /* DB methods */ static PyObject* -DB_append(DBObject* self, PyObject* args) +DB_append(DBObject* self, PyObject* args, PyObject * kwargs) { PyObject* txnobj = NULL; PyObject* dataobj; db_recno_t recno; DBT key, data; DB_TXN *txn = NULL; + char* kwnames[] = {"data", "transaction", NULL}; - if (!PyArg_ParseTuple(args, "O|O:append", &dataobj, &txnobj)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:append", kwnames, + &dataobj, &txnobj)) return NULL; CHECK_DB_NOT_CLOSED(self); @@ -1173,11 +1175,14 @@ DB_associate(DBObject* self, PyObject* args, PyObject* kwargs) static PyObject* -DB_close(DBObject* self, PyObject* args) +DB_close(DBObject* self, PyObject* args, PyObject * kwargs) { int err, flags=0; - if (!PyArg_ParseTuple(args,"|i:close", &flags)) + char *kwnames[] = {"flags", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:close", kwnames, &flags)) return NULL; + if (self->db != NULL) { if (self->myenvobj) CHECK_ENV_NOT_CLOSED(self->myenvobj); @@ -1244,12 +1249,14 @@ _DB_consume(DBObject* self, PyObject* args, PyObject* kwargs, int consume_flag) return retval; } +/* XXX wtf? This cannot possibly be the right prototype. --pj */ static PyObject* DB_consume(DBObject* self, PyObject* args, PyObject* kwargs, int consume_flag) { return _DB_consume(self, args, kwargs, DB_CONSUME); } +/* XXX wtf? This cannot possibly be the right prototype. --pj */ static PyObject* DB_consume_wait(DBObject* self, PyObject* args, PyObject* kwargs, int consume_flag) @@ -1312,12 +1319,10 @@ DB_delete(DBObject* self, PyObject* args, PyObject* kwargs) static PyObject* -DB_fd(DBObject* self, PyObject* args) +DB_fd(DBObject* self) { int err, the_fd; - if (!PyArg_ParseTuple(args,":fd")) - return NULL; CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -1487,15 +1492,13 @@ DB_get_both(DBObject* self, PyObject* args, PyObject* kwargs) static PyObject* -DB_get_byteswapped(DBObject* self, PyObject* args) +DB_get_byteswapped(DBObject* self) { #if (DBVER >= 33) int err = 0; #endif int retval = -1; - if (!PyArg_ParseTuple(args,":get_byteswapped")) - return NULL; CHECK_DB_NOT_CLOSED(self); #if (DBVER >= 33) @@ -1513,12 +1516,10 @@ DB_get_byteswapped(DBObject* self, PyObject* args) static PyObject* -DB_get_type(DBObject* self, PyObject* args) +DB_get_type(DBObject* self) { int type; - if (!PyArg_ParseTuple(args,":get_type")) - return NULL; CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -1531,16 +1532,17 @@ DB_get_type(DBObject* self, PyObject* args) static PyObject* -DB_join(DBObject* self, PyObject* args) +DB_join(DBObject* self, PyObject* args, PyObject* kwargs) { int err, flags=0; int length, x; PyObject* cursorsObj; DBC** cursors; DBC* dbc; + char* kwnames[] = {"cursors", "flags", NULL}; - - if (!PyArg_ParseTuple(args,"O|i:join", &cursorsObj, &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|i:join", kwnames, + &cursorsObj, &flags)) return NULL; CHECK_DB_NOT_CLOSED(self); @@ -1749,7 +1751,7 @@ DB_remove(DBObject* self, PyObject* args, PyObject* kwargs) char* filename; char* database = NULL; int err, flags=0; - char* kwnames[] = { "filename", "dbname", "flags", NULL}; + char* kwnames[] = { "filename", "dbname", "flags", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|zi:remove", kwnames, &filename, &database, &flags)) @@ -1765,16 +1767,18 @@ DB_remove(DBObject* self, PyObject* args, PyObject* kwargs) static PyObject* -DB_rename(DBObject* self, PyObject* args) +DB_rename(DBObject* self, PyObject* args, PyObject * kwargs) { char* filename; char* database; char* newname; int err, flags=0; + char* kwnames[] = {"filename", "database", "newname", "flags", NULL}; - if (!PyArg_ParseTuple(args, "sss|i:rename", &filename, &database, &newname, - &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sss|i:rename", kwnames, + &filename, &database, &newname, &flags)) return NULL; + CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -1786,12 +1790,15 @@ DB_rename(DBObject* self, PyObject* args) static PyObject* -DB_set_bt_minkey(DBObject* self, PyObject* args) +DB_set_bt_minkey(DBObject* self, PyObject* args, PyObject* kwargs) { int err, minkey; + char* kwnames[] = {"minkey", NULL}; - if (!PyArg_ParseTuple(args,"i:set_bt_minkey", &minkey )) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:set_bt_minkey", kwnames, + &minkey)) return NULL; + CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -1803,14 +1810,16 @@ DB_set_bt_minkey(DBObject* self, PyObject* args) static PyObject* -DB_set_cachesize(DBObject* self, PyObject* args) +DB_set_cachesize(DBObject* self, PyObject* args, PyObject* kwargs) { int err; int gbytes = 0, bytes = 0, ncache = 0; + char* kwnames[] = {"gbytes", "bytes", "ncache", NULL}; - if (!PyArg_ParseTuple(args,"ii|i:set_cachesize", - &gbytes,&bytes,&ncache)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii|i:set_cachesize", + kwnames, &gbytes, &bytes, &ncache)) return NULL; + CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -1822,12 +1831,15 @@ DB_set_cachesize(DBObject* self, PyObject* args) static PyObject* -DB_set_flags(DBObject* self, PyObject* args) +DB_set_flags(DBObject* self, PyObject* args, PyObject* kwargs) { int err, flags; + char* kwnames[] = {"flags", NULL}; - if (!PyArg_ParseTuple(args,"i:set_flags", &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:set_flags", kwnames, + &flags)) return NULL; + CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -1841,12 +1853,15 @@ DB_set_flags(DBObject* self, PyObject* args) static PyObject* -DB_set_h_ffactor(DBObject* self, PyObject* args) +DB_set_h_ffactor(DBObject* self, PyObject* args, PyObject* kwargs) { int err, ffactor; + char* kwnames[] = {"ffactor", NULL}; - if (!PyArg_ParseTuple(args,"i:set_h_ffactor", &ffactor)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:set_h_ffactor", kwnames, + &ffactor)) return NULL; + CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -1858,12 +1873,15 @@ DB_set_h_ffactor(DBObject* self, PyObject* args) static PyObject* -DB_set_h_nelem(DBObject* self, PyObject* args) +DB_set_h_nelem(DBObject* self, PyObject* args, PyObject* kwargs) { int err, nelem; + char* kwnames[] = {"nelem", NULL}; - if (!PyArg_ParseTuple(args,"i:set_h_nelem", &nelem)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:set_h_nelem", kwnames, + &nelem)) return NULL; + CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -1875,12 +1893,15 @@ DB_set_h_nelem(DBObject* self, PyObject* args) static PyObject* -DB_set_lorder(DBObject* self, PyObject* args) +DB_set_lorder(DBObject* self, PyObject* args, PyObject* kwargs) { int err, lorder; + char* kwnames[] = {"lorder", NULL}; - if (!PyArg_ParseTuple(args,"i:set_lorder", &lorder)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:set_lorder", kwnames, + &lorder)) return NULL; + CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -1892,12 +1913,15 @@ DB_set_lorder(DBObject* self, PyObject* args) static PyObject* -DB_set_pagesize(DBObject* self, PyObject* args) +DB_set_pagesize(DBObject* self, PyObject* args, PyObject* kwargs) { int err, pagesize; + char* kwnames[] = {"pagesize", NULL}; - if (!PyArg_ParseTuple(args,"i:set_pagesize", &pagesize)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:set_pagesize", kwnames, + &pagesize)) return NULL; + CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -1909,14 +1933,17 @@ DB_set_pagesize(DBObject* self, PyObject* args) static PyObject* -DB_set_re_delim(DBObject* self, PyObject* args) +DB_set_re_delim(DBObject* self, PyObject* args, PyObject* kwargs) { int err; char delim; + char* kwnames[] = {"delim", NULL}; - if (!PyArg_ParseTuple(args,"b:set_re_delim", &delim)) { + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "b:set_re_delim", kwnames, + &delim)) { PyErr_Clear(); - if (!PyArg_ParseTuple(args,"c:set_re_delim", &delim)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "c:set_re_delim", + kwnames, &delim)) return NULL; } @@ -1930,12 +1957,15 @@ DB_set_re_delim(DBObject* self, PyObject* args) } static PyObject* -DB_set_re_len(DBObject* self, PyObject* args) +DB_set_re_len(DBObject* self, PyObject* args, PyObject* kwargs) { int err, len; + char* kwnames[] = {"len", NULL}; - if (!PyArg_ParseTuple(args,"i:set_re_len", &len)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:set_re_len", kwnames, + &len)) return NULL; + CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -1947,16 +1977,20 @@ DB_set_re_len(DBObject* self, PyObject* args) static PyObject* -DB_set_re_pad(DBObject* self, PyObject* args) +DB_set_re_pad(DBObject* self, PyObject* args, PyObject* kwargs) { int err; char pad; + char* kwnames[] = {"pad", NULL}; - if (!PyArg_ParseTuple(args,"b:set_re_pad", &pad)) { + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "b:set_re_pad", kwnames, + &pad)) { PyErr_Clear(); - if (!PyArg_ParseTuple(args,"c:set_re_pad", &pad)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "c:set_re_pad", kwnames, + &pad)) return NULL; } + CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -1968,13 +2002,16 @@ DB_set_re_pad(DBObject* self, PyObject* args) static PyObject* -DB_set_re_source(DBObject* self, PyObject* args) +DB_set_re_source(DBObject* self, PyObject* args, PyObject *kwargs) { int err; char *re_source; + char* kwnames[] = {"source", NULL}; - if (!PyArg_ParseTuple(args,"s:set_re_source", &re_source)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:set_re_source", kwnames, + &re_source)) return NULL; + CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -1987,13 +2024,16 @@ DB_set_re_source(DBObject* self, PyObject* args) #if (DBVER >= 32) static PyObject* -DB_set_q_extentsize(DBObject* self, PyObject* args) +DB_set_q_extentsize(DBObject* self, PyObject* args, PyObject* kwargs) { int err; int extentsize; + char* kwnames[] = {"extentsize", NULL}; - if (!PyArg_ParseTuple(args,"i:set_q_extentsize", &extentsize)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:set_q_extentsize", + kwnames, &extentsize)) return NULL; + CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -2005,15 +2045,16 @@ DB_set_q_extentsize(DBObject* self, PyObject* args) #endif static PyObject* -DB_stat(DBObject* self, PyObject* args) +DB_stat(DBObject* self, PyObject* args, PyObject *kwargs) { int err, flags = 0, type; void* sp; PyObject* d; + char* kwnames[] = {"flags", NULL}; - - if (!PyArg_ParseTuple(args, "|i:stat", &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:stat", kwnames, &flags)) return NULL; + CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -2118,13 +2159,15 @@ DB_stat(DBObject* self, PyObject* args) } static PyObject* -DB_sync(DBObject* self, PyObject* args) +DB_sync(DBObject* self, PyObject* args, PyObject* kwargs) { int err; int flags = 0; + char* kwnames[] = {"flags", NULL}; - if (!PyArg_ParseTuple(args,"|i:sync", &flags )) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:sync", kwnames, &flags)) return NULL; + CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -2162,13 +2205,16 @@ DB_truncate(DBObject* self, PyObject* args, PyObject* kwargs) static PyObject* -DB_upgrade(DBObject* self, PyObject* args) +DB_upgrade(DBObject* self, PyObject* args, PyObject *kwargs) { int err, flags=0; char *filename; + char* kwnames[] = {"filename", "flags", NULL}; - if (!PyArg_ParseTuple(args,"s|i:upgrade", &filename, &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|i:upgrade", kwnames, + &filename, &flags)) return NULL; + CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -2219,13 +2265,16 @@ DB_verify(DBObject* self, PyObject* args, PyObject* kwargs) static PyObject* -DB_set_get_returns_none(DBObject* self, PyObject* args) +DB_set_get_returns_none(DBObject* self, PyObject* args, PyObject* kwargs) { int flags=0; int oldValue=0; + char* kwnames[] = {"returns_none", NULL}; - if (!PyArg_ParseTuple(args,"i:set_get_returns_none", &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:set_get_returns_none", + kwnames, &flags)) return NULL; + CHECK_DB_NOT_CLOSED(self); if (self->moduleFlags.getReturnsNone) @@ -2387,16 +2436,19 @@ DB_ass_sub(DBObject* self, PyObject* keyobj, PyObject* dataobj) static PyObject* -DB_has_key(DBObject* self, PyObject* args) +DB_has_key(DBObject* self, PyObject* args, PyObject* kwargs) { int err; PyObject* keyobj; DBT key, data; PyObject* txnobj = NULL; DB_TXN *txn = NULL; + char* kwnames[] = {"key", "txn", NULL}; - if (!PyArg_ParseTuple(args,"O|O:has_key", &keyobj, &txnobj)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:has_key", kwnames, + &keyobj, &txnobj)) return NULL; + CHECK_DB_NOT_CLOSED(self); if (!make_key_dbt(self, keyobj, &key, NULL)) return NULL; @@ -2529,13 +2581,15 @@ _DB_make_list(DBObject* self, DB_TXN* txn, int type) static PyObject* -DB_keys(DBObject* self, PyObject* args) +DB_keys(DBObject* self, PyObject* args, PyObject* kwargs) { PyObject* txnobj = NULL; DB_TXN *txn = NULL; + char* kwnames[] = {"txn", NULL}; - if (!PyArg_ParseTuple(args,"|O:keys", &txnobj)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:keys", kwnames, &txnobj)) return NULL; + if (!checkTxnObj(txnobj, &txn)) return NULL; return _DB_make_list(self, txn, _KEYS_LIST); @@ -2543,13 +2597,16 @@ DB_keys(DBObject* self, PyObject* args) static PyObject* -DB_items(DBObject* self, PyObject* args) +DB_items(DBObject* self, PyObject* args, PyObject* kwargs) { PyObject* txnobj = NULL; DB_TXN *txn = NULL; + char* kwnames[] = {"txn", NULL}; - if (!PyArg_ParseTuple(args,"|O:items", &txnobj)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:items", kwnames, + &txnobj)) return NULL; + if (!checkTxnObj(txnobj, &txn)) return NULL; return _DB_make_list(self, txn, _ITEMS_LIST); @@ -2557,12 +2614,14 @@ DB_items(DBObject* self, PyObject* args) static PyObject* -DB_values(DBObject* self, PyObject* args) +DB_values(DBObject* self, PyObject* args, PyObject* kwargs) { PyObject* txnobj = NULL; DB_TXN *txn = NULL; + char* kwnames[] = {"txn", NULL}; - if (!PyArg_ParseTuple(args,"|O:values", &txnobj)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:values", kwnames, + &txnobj)) return NULL; if (!checkTxnObj(txnobj, &txn)) return NULL; @@ -2574,13 +2633,10 @@ DB_values(DBObject* self, PyObject* args) static PyObject* -DBC_close(DBCursorObject* self, PyObject* args) +DBC_close(DBCursorObject* self) { int err = 0; - if (!PyArg_ParseTuple(args, ":close")) - return NULL; - if (self->dbc != NULL) { MYDB_BEGIN_ALLOW_THREADS; err = self->dbc->c_close(self->dbc); @@ -2593,13 +2649,14 @@ DBC_close(DBCursorObject* self, PyObject* args) static PyObject* -DBC_count(DBCursorObject* self, PyObject* args) +DBC_count(DBCursorObject* self, PyObject* args, PyObject* kwargs) { int err = 0; db_recno_t count; int flags = 0; + char* kwnames[] = {"flags", NULL}; - if (!PyArg_ParseTuple(args, "|i:count", &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:count", kwnames, &flags)) return NULL; CHECK_CURSOR_NOT_CLOSED(self); @@ -2621,11 +2678,13 @@ DBC_current(DBCursorObject* self, PyObject* args, PyObject *kwargs) static PyObject* -DBC_delete(DBCursorObject* self, PyObject* args) +DBC_delete(DBCursorObject* self, PyObject* args, PyObject* kwargs) { int err, flags=0; + char* kwnames[] = {"flags", NULL}; - if (!PyArg_ParseTuple(args, "|i:delete", &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:delete", kwnames, + &flags)) return NULL; CHECK_CURSOR_NOT_CLOSED(self); @@ -2641,12 +2700,13 @@ DBC_delete(DBCursorObject* self, PyObject* args) static PyObject* -DBC_dup(DBCursorObject* self, PyObject* args) +DBC_dup(DBCursorObject* self, PyObject* args, PyObject* kwargs) { int err, flags =0; DBC* dbc = NULL; + char* kwnames[] = {"flags", NULL}; - if (!PyArg_ParseTuple(args, "|i:dup", &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:dup", kwnames, &flags)) return NULL; CHECK_CURSOR_NOT_CLOSED(self); @@ -2749,16 +2809,13 @@ DBC_get(DBCursorObject* self, PyObject* args, PyObject *kwargs) static PyObject* -DBC_get_recno(DBCursorObject* self, PyObject* args) +DBC_get_recno(DBCursorObject* self) { int err; db_recno_t recno; DBT key; DBT data; - if (!PyArg_ParseTuple(args, ":get_recno")) - return NULL; - CHECK_CURSOR_NOT_CLOSED(self); CLEAR_DBT(key); @@ -3005,12 +3062,14 @@ _DBC_get_set_both(DBCursorObject* self, PyObject* keyobj, PyObject* dataobj, } static PyObject* -DBC_get_both(DBCursorObject* self, PyObject* args) +DBC_get_both(DBCursorObject* self, PyObject* args, PyObject* kwargs) { int flags=0; PyObject *keyobj, *dataobj; + char* kwnames[] = {"key", "data", "flags", NULL}; - if (!PyArg_ParseTuple(args, "OO|i:get_both", &keyobj, &dataobj, &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|i:get_both", kwnames, + &keyobj, &dataobj, &flags)) return NULL; /* if the cursor is closed, self->mydb may be invalid */ @@ -3022,14 +3081,12 @@ DBC_get_both(DBCursorObject* self, PyObject* args) /* Return size of entry */ static PyObject* -DBC_get_current_size(DBCursorObject* self, PyObject* args) +DBC_get_current_size(DBCursorObject* self) { int err, flags=DB_CURRENT; PyObject* retval = NULL; DBT key, data; - if (!PyArg_ParseTuple(args, ":get_current_size")) - return NULL; CHECK_CURSOR_NOT_CLOSED(self); CLEAR_DBT(key); CLEAR_DBT(data); @@ -3054,12 +3111,14 @@ DBC_get_current_size(DBCursorObject* self, PyObject* args) } static PyObject* -DBC_set_both(DBCursorObject* self, PyObject* args) +DBC_set_both(DBCursorObject* self, PyObject* args, PyObject* kwargs) { int flags=0; PyObject *keyobj, *dataobj; + char* kwnames[] = {"key", "data", "flags", NULL}; - if (!PyArg_ParseTuple(args, "OO|i:set_both", &keyobj, &dataobj, &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|i:set_both", kwnames, + &keyobj, &dataobj, &flags)) return NULL; /* if the cursor is closed, self->mydb may be invalid */ @@ -3159,13 +3218,15 @@ DBC_prev_nodup(DBCursorObject* self, PyObject* args, PyObject *kwargs) static PyObject* -DBC_join_item(DBCursorObject* self, PyObject* args) +DBC_join_item(DBCursorObject* self, PyObject* args, PyObject* kwargs) { int err, flags=0; DBT key, data; PyObject* retval; + char* kwnames[] = {"flags", NULL}; - if (!PyArg_ParseTuple(args, "|i:join_item", &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:join_item", kwnames, + &flags)) return NULL; CHECK_CURSOR_NOT_CLOSED(self); @@ -3202,11 +3263,12 @@ DBC_join_item(DBCursorObject* self, PyObject* args) static PyObject* -DBEnv_close(DBEnvObject* self, PyObject* args) +DBEnv_close(DBEnvObject* self, PyObject* args, PyObject* kwargs) { int err, flags = 0; + char* kwnames[] = {"flags", NULL}; - if (!PyArg_ParseTuple(args, "|i:close", &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:close", kwnames, &flags)) return NULL; if (!self->closed) { /* Don't close more than once */ MYDB_BEGIN_ALLOW_THREADS; @@ -3223,12 +3285,14 @@ DBEnv_close(DBEnvObject* self, PyObject* args) static PyObject* -DBEnv_open(DBEnvObject* self, PyObject* args) +DBEnv_open(DBEnvObject* self, PyObject* args, PyObject* kwargs) { int err, flags=0, mode=0660; char *db_home; + char* kwnames[] = {"db_home", "flags", "mode", NULL}; - if (!PyArg_ParseTuple(args, "z|ii:open", &db_home, &flags, &mode)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "z|ii:open", kwnames, + &db_home, &flags, &mode)) return NULL; CHECK_ENV_NOT_CLOSED(self); @@ -3244,13 +3308,16 @@ DBEnv_open(DBEnvObject* self, PyObject* args) static PyObject* -DBEnv_remove(DBEnvObject* self, PyObject* args) +DBEnv_remove(DBEnvObject* self, PyObject* args, PyObject *kwargs) { int err, flags=0; char *db_home; + char* kwnames[] = {"db_home", "flags", NULL}; - if (!PyArg_ParseTuple(args, "s|i:remove", &db_home, &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|i:remove", kwnames, + &db_home, &flags)) return NULL; + CHECK_ENV_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; err = self->db_env->remove(self->db_env, db_home, flags); @@ -3360,13 +3427,16 @@ DBEnv_set_timeout(DBEnvObject* self, PyObject* args, PyObject* kwargs) #endif /* DBVER >= 40 */ static PyObject* -DBEnv_set_shm_key(DBEnvObject* self, PyObject* args) +DBEnv_set_shm_key(DBEnvObject* self, PyObject* args, PyObject *kwargs) { int err; long shm_key = 0; + char* kwnames[] = {"shm_key", NULL}; - if (!PyArg_ParseTuple(args, "l:set_shm_key", &shm_key)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "l:set_shm_key", kwnames, + &shm_key)) return NULL; + CHECK_ENV_NOT_CLOSED(self); err = self->db_env->set_shm_key(self->db_env, shm_key); @@ -3375,13 +3445,15 @@ DBEnv_set_shm_key(DBEnvObject* self, PyObject* args) } static PyObject* -DBEnv_set_cachesize(DBEnvObject* self, PyObject* args) +DBEnv_set_cachesize(DBEnvObject* self, PyObject* args, PyObject* kwargs) { int err, gbytes=0, bytes=0, ncache=0; + char* kwnames[] = {"gbytes", "bytes", "ncache", NULL}; - if (!PyArg_ParseTuple(args, "ii|i:set_cachesize", - &gbytes, &bytes, &ncache)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii|i:set_cachesize", + kwnames, &gbytes, &bytes, &ncache)) return NULL; + CHECK_ENV_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -3394,13 +3466,15 @@ DBEnv_set_cachesize(DBEnvObject* self, PyObject* args) #if (DBVER >= 32) static PyObject* -DBEnv_set_flags(DBEnvObject* self, PyObject* args) +DBEnv_set_flags(DBEnvObject* self, PyObject* args, PyObject* kwargs) { int err, flags=0, onoff=0; + char* kwnames[] = {"flags", "onoff", NULL}; - if (!PyArg_ParseTuple(args, "ii:set_flags", - &flags, &onoff)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:set_flags", kwnames, + &flags, &onoff)) return NULL; + CHECK_ENV_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -3413,13 +3487,16 @@ DBEnv_set_flags(DBEnvObject* self, PyObject* args) static PyObject* -DBEnv_set_data_dir(DBEnvObject* self, PyObject* args) +DBEnv_set_data_dir(DBEnvObject* self, PyObject* args, PyObject* kwargs) { int err; char *dir; + char* kwnames[] = {"dir", NULL}; - if (!PyArg_ParseTuple(args, "s:set_data_dir", &dir)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:set_data_dir", kwnames, + &dir)) return NULL; + CHECK_ENV_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -3431,12 +3508,15 @@ DBEnv_set_data_dir(DBEnvObject* self, PyObject* args) static PyObject* -DBEnv_set_lg_bsize(DBEnvObject* self, PyObject* args) +DBEnv_set_lg_bsize(DBEnvObject* self, PyObject* args, PyObject* kwargs) { int err, lg_bsize; + char* kwnames[] = {"lg_bsize", NULL}; - if (!PyArg_ParseTuple(args, "i:set_lg_bsize", &lg_bsize)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:set_lg_bsize", kwnames, + &lg_bsize)) return NULL; + CHECK_ENV_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -3448,13 +3528,16 @@ DBEnv_set_lg_bsize(DBEnvObject* self, PyObject* args) static PyObject* -DBEnv_set_lg_dir(DBEnvObject* self, PyObject* args) +DBEnv_set_lg_dir(DBEnvObject* self, PyObject* args, PyObject* kwargs) { int err; char *dir; + char* kwnames[] = {"dir", NULL}; - if (!PyArg_ParseTuple(args, "s:set_lg_dir", &dir)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:set_lg_dir", kwnames, + &dir)) return NULL; + CHECK_ENV_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -3465,12 +3548,15 @@ DBEnv_set_lg_dir(DBEnvObject* self, PyObject* args) } static PyObject* -DBEnv_set_lg_max(DBEnvObject* self, PyObject* args) +DBEnv_set_lg_max(DBEnvObject* self, PyObject* args, PyObject* kwargs) { int err, lg_max; + char* kwnames[] = {"lg_max", NULL}; - if (!PyArg_ParseTuple(args, "i:set_lg_max", &lg_max)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:set_lg_max", kwnames, + &lg_max)) return NULL; + CHECK_ENV_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -3482,12 +3568,15 @@ DBEnv_set_lg_max(DBEnvObject* self, PyObject* args) static PyObject* -DBEnv_set_lk_detect(DBEnvObject* self, PyObject* args) +DBEnv_set_lk_detect(DBEnvObject* self, PyObject* args, PyObject *kwargs) { int err, lk_detect; + char* kwnames[] = {"lk_detect", NULL}; - if (!PyArg_ParseTuple(args, "i:set_lk_detect", &lk_detect)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:set_lk_detect", kwnames, + &lk_detect)) return NULL; + CHECK_ENV_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -3499,12 +3588,15 @@ DBEnv_set_lk_detect(DBEnvObject* self, PyObject* args) static PyObject* -DBEnv_set_lk_max(DBEnvObject* self, PyObject* args) +DBEnv_set_lk_max(DBEnvObject* self, PyObject* args, PyObject* kwargs) { int err, max; + char* kwnames[] = {"max", NULL}; - if (!PyArg_ParseTuple(args, "i:set_lk_max", &max)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:set_lk_max", kwnames, + &max)) return NULL; + CHECK_ENV_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -3518,12 +3610,15 @@ DBEnv_set_lk_max(DBEnvObject* self, PyObject* args) #if (DBVER >= 32) static PyObject* -DBEnv_set_lk_max_locks(DBEnvObject* self, PyObject* args) +DBEnv_set_lk_max_locks(DBEnvObject* self, PyObject* args, PyObject* kwargs) { int err, max; + char* kwnames[] = {"max_locks", NULL}; - if (!PyArg_ParseTuple(args, "i:set_lk_max_locks", &max)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:set_lk_max_locks", + kwnames, &max)) return NULL; + CHECK_ENV_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -3535,12 +3630,15 @@ DBEnv_set_lk_max_locks(DBEnvObject* self, PyObject* args) static PyObject* -DBEnv_set_lk_max_lockers(DBEnvObject* self, PyObject* args) +DBEnv_set_lk_max_lockers(DBEnvObject* self, PyObject* args, PyObject* kwargs) { int err, max; + char* kwnames[] = {"max_lockers", NULL}; - if (!PyArg_ParseTuple(args, "i:set_lk_max_lockers", &max)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:set_lk_max_lockers", + kwnames, &max)) return NULL; + CHECK_ENV_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -3552,12 +3650,15 @@ DBEnv_set_lk_max_lockers(DBEnvObject* self, PyObject* args) static PyObject* -DBEnv_set_lk_max_objects(DBEnvObject* self, PyObject* args) +DBEnv_set_lk_max_objects(DBEnvObject* self, PyObject* args, PyObject* kwargs) { int err, max; + char* kwnames[] = {"max_objects", NULL}; - if (!PyArg_ParseTuple(args, "i:set_lk_max_objects", &max)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:set_lk_max_objects", + kwnames, &max)) return NULL; + CHECK_ENV_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -3571,12 +3672,15 @@ DBEnv_set_lk_max_objects(DBEnvObject* self, PyObject* args) static PyObject* -DBEnv_set_mp_mmapsize(DBEnvObject* self, PyObject* args) +DBEnv_set_mp_mmapsize(DBEnvObject* self, PyObject* args, PyObject* kwargs) { int err, mp_mmapsize; + char* kwnames[] = {"mp_mmapsize", NULL}; - if (!PyArg_ParseTuple(args, "i:set_mp_mmapsize", &mp_mmapsize)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:set_mp_mmapsize", kwnames, + &mp_mmapsize)) return NULL; + CHECK_ENV_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -3588,13 +3692,16 @@ DBEnv_set_mp_mmapsize(DBEnvObject* self, PyObject* args) static PyObject* -DBEnv_set_tmp_dir(DBEnvObject* self, PyObject* args) +DBEnv_set_tmp_dir(DBEnvObject* self, PyObject* args, PyObject* kwargs) { int err; char *dir; + char* kwnames[] = {"dir", NULL}; - if (!PyArg_ParseTuple(args, "s:set_tmp_dir", &dir)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:set_tmp_dir", kwnames, + &dir)) return NULL; + CHECK_ENV_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -3626,12 +3733,15 @@ DBEnv_txn_begin(DBEnvObject* self, PyObject* args, PyObject* kwargs) static PyObject* -DBEnv_txn_checkpoint(DBEnvObject* self, PyObject* args) +DBEnv_txn_checkpoint(DBEnvObject* self, PyObject* args, PyObject* kwargs) { int err, kbyte=0, min=0, flags=0; + char* kwnames[] = {"kbyte", "min", "flags", NULL}; - if (!PyArg_ParseTuple(args, "|iii:txn_checkpoint", &kbyte, &min, &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|iii:txn_checkpoint", + kwnames, &kbyte, &min, &flags)) return NULL; + CHECK_ENV_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -3647,12 +3757,15 @@ DBEnv_txn_checkpoint(DBEnvObject* self, PyObject* args) static PyObject* -DBEnv_set_tx_max(DBEnvObject* self, PyObject* args) +DBEnv_set_tx_max(DBEnvObject* self, PyObject* args, PyObject* kwargs) { int err, max; + char* kwnames[] = {"max", NULL}; - if (!PyArg_ParseTuple(args, "i:set_tx_max", &max)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:set_tx_max", kwnames, + &max)) return NULL; + CHECK_ENV_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -3664,13 +3777,16 @@ DBEnv_set_tx_max(DBEnvObject* self, PyObject* args) static PyObject* -DBEnv_lock_detect(DBEnvObject* self, PyObject* args) +DBEnv_lock_detect(DBEnvObject* self, PyObject* args, PyObject* kwargs) { int err, atype, flags=0; int aborted = 0; + char* kwnames[] = {"atype", "flags", NULL}; - if (!PyArg_ParseTuple(args, "i|i:lock_detect", &atype, &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i|i:lock_detect", kwnames, + &atype, &flags)) return NULL; + CHECK_ENV_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -3686,17 +3802,18 @@ DBEnv_lock_detect(DBEnvObject* self, PyObject* args) static PyObject* -DBEnv_lock_get(DBEnvObject* self, PyObject* args) +DBEnv_lock_get(DBEnvObject* self, PyObject* args, PyObject* kwargs) { int flags=0; int locker, lock_mode; DBT obj; PyObject* objobj; + char* kwnames[] = {"locker", "object", "mode", "flags", NULL}; - if (!PyArg_ParseTuple(args, "iOi|i:lock_get", &locker, &objobj, &lock_mode, &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iOi|i:lock_get", kwnames, + &locker, &objobj, &lock_mode, &flags)) return NULL; - if (!make_dbt(objobj, &obj)) return NULL; @@ -3705,14 +3822,11 @@ DBEnv_lock_get(DBEnvObject* self, PyObject* args) static PyObject* -DBEnv_lock_id(DBEnvObject* self, PyObject* args) +DBEnv_lock_id(DBEnvObject* self) { int err; u_int32_t theID; - if (!PyArg_ParseTuple(args, ":lock_id")) - return NULL; - CHECK_ENV_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; #if (DBVER >= 40) @@ -3728,12 +3842,14 @@ DBEnv_lock_id(DBEnvObject* self, PyObject* args) static PyObject* -DBEnv_lock_put(DBEnvObject* self, PyObject* args) +DBEnv_lock_put(DBEnvObject* self, PyObject* args, PyObject* kwargs) { int err; DBLockObject* dblockobj; + char* kwnames[] = {"lock_type", "object", NULL}; - if (!PyArg_ParseTuple(args, "O!:lock_put", &DBLock_Type, &dblockobj)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:lock_put", kwnames, + &DBLock_Type, &dblockobj)) return NULL; CHECK_ENV_NOT_CLOSED(self); @@ -3750,15 +3866,18 @@ DBEnv_lock_put(DBEnvObject* self, PyObject* args) static PyObject* -DBEnv_lock_stat(DBEnvObject* self, PyObject* args) +DBEnv_lock_stat(DBEnvObject* self, PyObject* args, PyObject* kwargs) { int err; DB_LOCK_STAT* sp; PyObject* d = NULL; u_int32_t flags = 0; + char* kwnames[] = {"flags", NULL}; - if (!PyArg_ParseTuple(args, "|i:lock_stat", &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:lock_stat", kwnames, + &flags)) return NULL; + CHECK_ENV_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -3816,15 +3935,17 @@ DBEnv_lock_stat(DBEnvObject* self, PyObject* args) static PyObject* -DBEnv_log_archive(DBEnvObject* self, PyObject* args) +DBEnv_log_archive(DBEnvObject* self, PyObject* args, PyObject* kwargs) { int flags=0; int err; char **log_list_start, **log_list; PyObject* list; PyObject* item = NULL; + char* kwnames[] = {"flags", NULL}; - if (!PyArg_ParseTuple(args, "|i:log_archive", &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:log_archive", kwnames, + &flags)) return NULL; CHECK_ENV_NOT_CLOSED(self); @@ -3865,15 +3986,18 @@ DBEnv_log_archive(DBEnvObject* self, PyObject* args) static PyObject* -DBEnv_txn_stat(DBEnvObject* self, PyObject* args) +DBEnv_txn_stat(DBEnvObject* self, PyObject* args, PyObject* kwargs) { int err; DB_TXN_STAT* sp; PyObject* d = NULL; u_int32_t flags=0; + char* kwnames[] = {"flags", NULL}; - if (!PyArg_ParseTuple(args, "|i:txn_stat", &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:txn_stat", kwnames, + &flags)) return NULL; + CHECK_ENV_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; @@ -3915,13 +4039,16 @@ DBEnv_txn_stat(DBEnvObject* self, PyObject* args) static PyObject* -DBEnv_set_get_returns_none(DBEnvObject* self, PyObject* args) +DBEnv_set_get_returns_none(DBEnvObject* self, PyObject* args, PyObject* kwargs) { int flags=0; int oldValue=0; + char* kwnames[] = {"flags", NULL}; - if (!PyArg_ParseTuple(args,"i:set_get_returns_none", &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:set_get_returns_none", + kwnames, &flags)) return NULL; + CHECK_ENV_NOT_CLOSED(self); if (self->moduleFlags.getReturnsNone) @@ -3939,12 +4066,14 @@ DBEnv_set_get_returns_none(DBEnvObject* self, PyObject* args) static PyObject* -DBTxn_commit(DBTxnObject* self, PyObject* args) +DBTxn_commit(DBTxnObject* self, PyObject* args, PyObject* kwargs) { int flags=0, err; DB_TXN *txn; + char* kwnames[] = {"flags", NULL}; - if (!PyArg_ParseTuple(args, "|i:commit", &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:commit", kwnames, + &flags)) return NULL; if (!self->txn) { @@ -3966,14 +4095,16 @@ DBTxn_commit(DBTxnObject* self, PyObject* args) } static PyObject* -DBTxn_prepare(DBTxnObject* self, PyObject* args) +DBTxn_prepare(DBTxnObject* self, PyObject* args, PyObject* kwargs) { #if (DBVER >= 33) int err; char* gid=NULL; int gid_size=0; + char* kwnames[] = {"gid", NULL}; - if (!PyArg_ParseTuple(args, "s#:prepare", &gid, &gid_size)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#:prepare", kwnames, &gid, + &gid_size)) return NULL; if (gid_size != DB_XIDDATASIZE) { @@ -3998,8 +4129,9 @@ DBTxn_prepare(DBTxnObject* self, PyObject* args) RETURN_NONE(); #else int err; + char* kwnames[] = {NULL}; - if (!PyArg_ParseTuple(args, ":prepare")) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, ":prepare", kwnames)) return NULL; if (!self->txn) { @@ -4017,14 +4149,11 @@ DBTxn_prepare(DBTxnObject* self, PyObject* args) static PyObject* -DBTxn_abort(DBTxnObject* self, PyObject* args) +DBTxn_abort(DBTxnObject* self) { int err; DB_TXN *txn; - if (!PyArg_ParseTuple(args, ":abort")) - return NULL; - if (!self->txn) { PyErr_SetObject(DBError, Py_BuildValue("(is)", 0, "DBTxn must not be used after txn_commit or txn_abort")); @@ -4045,13 +4174,10 @@ DBTxn_abort(DBTxnObject* self, PyObject* args) static PyObject* -DBTxn_id(DBTxnObject* self, PyObject* args) +DBTxn_id(DBTxnObject* self) { int id; - if (!PyArg_ParseTuple(args, ":id")) - return NULL; - if (!self->txn) { PyErr_SetObject(DBError, Py_BuildValue("(is)", 0, "DBTxn must not be used after txn_commit or txn_abort")); @@ -4071,59 +4197,59 @@ DBTxn_id(DBTxnObject* self, PyObject* args) /* Method definition tables and type objects */ static PyMethodDef DB_methods[] = { - {"append", (PyCFunction)DB_append, METH_VARARGS}, + {"append", (PyCFunction)DB_append, METH_VARARGS|METH_KEYWORDS}, #if (DBVER >= 33) {"associate", (PyCFunction)DB_associate, METH_VARARGS|METH_KEYWORDS}, #endif - {"close", (PyCFunction)DB_close, METH_VARARGS}, + {"close", (PyCFunction)DB_close, METH_VARARGS|METH_KEYWORDS}, #if (DBVER >= 32) {"consume", (PyCFunction)DB_consume, METH_VARARGS|METH_KEYWORDS}, {"consume_wait", (PyCFunction)DB_consume_wait, METH_VARARGS|METH_KEYWORDS}, #endif {"cursor", (PyCFunction)DB_cursor, METH_VARARGS|METH_KEYWORDS}, {"delete", (PyCFunction)DB_delete, METH_VARARGS|METH_KEYWORDS}, - {"fd", (PyCFunction)DB_fd, METH_VARARGS}, + {"fd", (PyCFunction)DB_fd, METH_NOARGS}, {"get", (PyCFunction)DB_get, METH_VARARGS|METH_KEYWORDS}, {"get_both", (PyCFunction)DB_get_both, METH_VARARGS|METH_KEYWORDS}, - {"get_byteswapped", (PyCFunction)DB_get_byteswapped,METH_VARARGS}, + {"get_byteswapped", (PyCFunction)DB_get_byteswapped,METH_NOARGS}, {"get_size", (PyCFunction)DB_get_size, METH_VARARGS|METH_KEYWORDS}, - {"get_type", (PyCFunction)DB_get_type, METH_VARARGS}, - {"join", (PyCFunction)DB_join, METH_VARARGS}, + {"get_type", (PyCFunction)DB_get_type, METH_NOARGS}, + {"join", (PyCFunction)DB_join, METH_VARARGS|METH_KEYWORDS}, {"key_range", (PyCFunction)DB_key_range, METH_VARARGS|METH_KEYWORDS}, - {"has_key", (PyCFunction)DB_has_key, METH_VARARGS}, - {"items", (PyCFunction)DB_items, METH_VARARGS}, - {"keys", (PyCFunction)DB_keys, METH_VARARGS}, + {"has_key", (PyCFunction)DB_has_key, METH_VARARGS|METH_KEYWORDS}, + {"items", (PyCFunction)DB_items, METH_VARARGS|METH_KEYWORDS}, + {"keys", (PyCFunction)DB_keys, METH_VARARGS|METH_KEYWORDS}, {"open", (PyCFunction)DB_open, METH_VARARGS|METH_KEYWORDS}, {"put", (PyCFunction)DB_put, METH_VARARGS|METH_KEYWORDS}, {"remove", (PyCFunction)DB_remove, METH_VARARGS|METH_KEYWORDS}, - {"rename", (PyCFunction)DB_rename, METH_VARARGS}, - {"set_bt_minkey", (PyCFunction)DB_set_bt_minkey, METH_VARARGS}, - {"set_cachesize", (PyCFunction)DB_set_cachesize, METH_VARARGS}, + {"rename", (PyCFunction)DB_rename, METH_VARARGS|METH_KEYWORDS}, + {"set_bt_minkey", (PyCFunction)DB_set_bt_minkey, METH_VARARGS|METH_KEYWORDS}, + {"set_cachesize", (PyCFunction)DB_set_cachesize, METH_VARARGS|METH_KEYWORDS}, #if (DBVER >= 41) {"set_encrypt", (PyCFunction)DB_set_encrypt, METH_VARARGS|METH_KEYWORDS}, #endif - {"set_flags", (PyCFunction)DB_set_flags, METH_VARARGS}, - {"set_h_ffactor", (PyCFunction)DB_set_h_ffactor, METH_VARARGS}, - {"set_h_nelem", (PyCFunction)DB_set_h_nelem, METH_VARARGS}, - {"set_lorder", (PyCFunction)DB_set_lorder, METH_VARARGS}, - {"set_pagesize", (PyCFunction)DB_set_pagesize, METH_VARARGS}, - {"set_re_delim", (PyCFunction)DB_set_re_delim, METH_VARARGS}, - {"set_re_len", (PyCFunction)DB_set_re_len, METH_VARARGS}, - {"set_re_pad", (PyCFunction)DB_set_re_pad, METH_VARARGS}, - {"set_re_source", (PyCFunction)DB_set_re_source, METH_VARARGS}, + {"set_flags", (PyCFunction)DB_set_flags, METH_VARARGS|METH_KEYWORDS}, + {"set_h_ffactor", (PyCFunction)DB_set_h_ffactor, METH_VARARGS|METH_KEYWORDS}, + {"set_h_nelem", (PyCFunction)DB_set_h_nelem, METH_VARARGS|METH_KEYWORDS}, + {"set_lorder", (PyCFunction)DB_set_lorder, METH_VARARGS|METH_KEYWORDS}, + {"set_pagesize", (PyCFunction)DB_set_pagesize, METH_VARARGS|METH_KEYWORDS}, + {"set_re_delim", (PyCFunction)DB_set_re_delim, METH_VARARGS|METH_KEYWORDS}, + {"set_re_len", (PyCFunction)DB_set_re_len, METH_VARARGS|METH_KEYWORDS}, + {"set_re_pad", (PyCFunction)DB_set_re_pad, METH_VARARGS|METH_KEYWORDS}, + {"set_re_source", (PyCFunction)DB_set_re_source, METH_VARARGS|METH_KEYWORDS}, #if (DBVER >= 32) - {"set_q_extentsize",(PyCFunction)DB_set_q_extentsize,METH_VARARGS}, + {"set_q_extentsize",(PyCFunction)DB_set_q_extentsize,METH_VARARGS|METH_KEYWORDS}, #endif - {"stat", (PyCFunction)DB_stat, METH_VARARGS}, - {"sync", (PyCFunction)DB_sync, METH_VARARGS}, + {"stat", (PyCFunction)DB_stat, METH_VARARGS|METH_KEYWORDS}, + {"sync", (PyCFunction)DB_sync, METH_VARARGS|METH_KEYWORDS}, #if (DBVER >= 33) {"truncate", (PyCFunction)DB_truncate, METH_VARARGS|METH_KEYWORDS}, #endif - {"type", (PyCFunction)DB_get_type, METH_VARARGS}, - {"upgrade", (PyCFunction)DB_upgrade, METH_VARARGS}, - {"values", (PyCFunction)DB_values, METH_VARARGS}, + {"type", (PyCFunction)DB_get_type, METH_VARARGS|METH_KEYWORDS}, + {"upgrade", (PyCFunction)DB_upgrade, METH_VARARGS|METH_KEYWORDS}, + {"values", (PyCFunction)DB_values, METH_VARARGS|METH_KEYWORDS}, {"verify", (PyCFunction)DB_verify, METH_VARARGS|METH_KEYWORDS}, - {"set_get_returns_none",(PyCFunction)DB_set_get_returns_none, METH_VARARGS}, + {"set_get_returns_none",(PyCFunction)DB_set_get_returns_none, METH_VARARGS|METH_KEYWORDS}, {NULL, NULL} /* sentinel */ }; @@ -4136,37 +4262,37 @@ static PyMappingMethods DB_mapping = { static PyMethodDef DBCursor_methods[] = { - {"close", (PyCFunction)DBC_close, METH_VARARGS}, - {"count", (PyCFunction)DBC_count, METH_VARARGS}, + {"close", (PyCFunction)DBC_close, METH_NOARGS}, + {"count", (PyCFunction)DBC_count, METH_VARARGS|METH_KEYWORDS}, {"current", (PyCFunction)DBC_current, METH_VARARGS|METH_KEYWORDS}, - {"delete", (PyCFunction)DBC_delete, METH_VARARGS}, - {"dup", (PyCFunction)DBC_dup, METH_VARARGS}, + {"delete", (PyCFunction)DBC_delete, METH_VARARGS|METH_KEYWORDS}, + {"dup", (PyCFunction)DBC_dup, METH_VARARGS|METH_KEYWORDS}, {"first", (PyCFunction)DBC_first, METH_VARARGS|METH_KEYWORDS}, {"get", (PyCFunction)DBC_get, METH_VARARGS|METH_KEYWORDS}, - {"get_recno", (PyCFunction)DBC_get_recno, METH_VARARGS}, + {"get_recno", (PyCFunction)DBC_get_recno, METH_NOARGS}, {"last", (PyCFunction)DBC_last, METH_VARARGS|METH_KEYWORDS}, {"next", (PyCFunction)DBC_next, METH_VARARGS|METH_KEYWORDS}, {"prev", (PyCFunction)DBC_prev, METH_VARARGS|METH_KEYWORDS}, {"put", (PyCFunction)DBC_put, METH_VARARGS|METH_KEYWORDS}, {"set", (PyCFunction)DBC_set, METH_VARARGS|METH_KEYWORDS}, {"set_range", (PyCFunction)DBC_set_range, METH_VARARGS|METH_KEYWORDS}, - {"get_both", (PyCFunction)DBC_get_both, METH_VARARGS}, - {"get_current_size",(PyCFunction)DBC_get_current_size, METH_VARARGS}, - {"set_both", (PyCFunction)DBC_set_both, METH_VARARGS}, + {"get_both", (PyCFunction)DBC_get_both, METH_VARARGS|METH_KEYWORDS}, + {"get_current_size",(PyCFunction)DBC_get_current_size, METH_NOARGS}, + {"set_both", (PyCFunction)DBC_set_both, METH_VARARGS|METH_KEYWORDS}, {"set_recno", (PyCFunction)DBC_set_recno, METH_VARARGS|METH_KEYWORDS}, {"consume", (PyCFunction)DBC_consume, METH_VARARGS|METH_KEYWORDS}, {"next_dup", (PyCFunction)DBC_next_dup, METH_VARARGS|METH_KEYWORDS}, {"next_nodup", (PyCFunction)DBC_next_nodup, METH_VARARGS|METH_KEYWORDS}, {"prev_nodup", (PyCFunction)DBC_prev_nodup, METH_VARARGS|METH_KEYWORDS}, - {"join_item", (PyCFunction)DBC_join_item, METH_VARARGS}, + {"join_item", (PyCFunction)DBC_join_item, METH_VARARGS|METH_KEYWORDS}, {NULL, NULL} /* sentinel */ }; static PyMethodDef DBEnv_methods[] = { - {"close", (PyCFunction)DBEnv_close, METH_VARARGS}, - {"open", (PyCFunction)DBEnv_open, METH_VARARGS}, - {"remove", (PyCFunction)DBEnv_remove, METH_VARARGS}, + {"close", (PyCFunction)DBEnv_close, METH_VARARGS|METH_KEYWORDS}, + {"open", (PyCFunction)DBEnv_open, METH_VARARGS|METH_KEYWORDS}, + {"remove", (PyCFunction)DBEnv_remove, METH_VARARGS|METH_KEYWORDS}, #if (DBVER >= 41) {"dbremove", (PyCFunction)DBEnv_dbremove, METH_VARARGS|METH_KEYWORDS}, {"dbrename", (PyCFunction)DBEnv_dbrename, METH_VARARGS|METH_KEYWORDS}, @@ -4175,44 +4301,44 @@ static PyMethodDef DBEnv_methods[] = { #if (DBVER >= 40) {"set_timeout", (PyCFunction)DBEnv_set_timeout, METH_VARARGS|METH_KEYWORDS}, #endif - {"set_shm_key", (PyCFunction)DBEnv_set_shm_key, METH_VARARGS}, - {"set_cachesize", (PyCFunction)DBEnv_set_cachesize, METH_VARARGS}, - {"set_data_dir", (PyCFunction)DBEnv_set_data_dir, METH_VARARGS}, + {"set_shm_key", (PyCFunction)DBEnv_set_shm_key, METH_VARARGS|METH_KEYWORDS}, + {"set_cachesize", (PyCFunction)DBEnv_set_cachesize, METH_VARARGS|METH_KEYWORDS}, + {"set_data_dir", (PyCFunction)DBEnv_set_data_dir, METH_VARARGS|METH_KEYWORDS}, #if (DBVER >= 32) - {"set_flags", (PyCFunction)DBEnv_set_flags, METH_VARARGS}, + {"set_flags", (PyCFunction)DBEnv_set_flags, METH_VARARGS|METH_KEYWORDS}, #endif - {"set_lg_bsize", (PyCFunction)DBEnv_set_lg_bsize, METH_VARARGS}, - {"set_lg_dir", (PyCFunction)DBEnv_set_lg_dir, METH_VARARGS}, - {"set_lg_max", (PyCFunction)DBEnv_set_lg_max, METH_VARARGS}, - {"set_lk_detect", (PyCFunction)DBEnv_set_lk_detect, METH_VARARGS}, - {"set_lk_max", (PyCFunction)DBEnv_set_lk_max, METH_VARARGS}, + {"set_lg_bsize", (PyCFunction)DBEnv_set_lg_bsize, METH_VARARGS|METH_KEYWORDS}, + {"set_lg_dir", (PyCFunction)DBEnv_set_lg_dir, METH_VARARGS|METH_KEYWORDS}, + {"set_lg_max", (PyCFunction)DBEnv_set_lg_max, METH_VARARGS|METH_KEYWORDS}, + {"set_lk_detect", (PyCFunction)DBEnv_set_lk_detect, METH_VARARGS|METH_KEYWORDS}, + {"set_lk_max", (PyCFunction)DBEnv_set_lk_max, METH_VARARGS|METH_KEYWORDS}, #if (DBVER >= 32) - {"set_lk_max_locks", (PyCFunction)DBEnv_set_lk_max_locks, METH_VARARGS}, - {"set_lk_max_lockers", (PyCFunction)DBEnv_set_lk_max_lockers, METH_VARARGS}, - {"set_lk_max_objects", (PyCFunction)DBEnv_set_lk_max_objects, METH_VARARGS}, + {"set_lk_max_locks", (PyCFunction)DBEnv_set_lk_max_locks, METH_VARARGS|METH_KEYWORDS}, + {"set_lk_max_lockers", (PyCFunction)DBEnv_set_lk_max_lockers, METH_VARARGS|METH_KEYWORDS}, + {"set_lk_max_objects", (PyCFunction)DBEnv_set_lk_max_objects, METH_VARARGS|METH_KEYWORDS}, #endif - {"set_mp_mmapsize", (PyCFunction)DBEnv_set_mp_mmapsize, METH_VARARGS}, - {"set_tmp_dir", (PyCFunction)DBEnv_set_tmp_dir, METH_VARARGS}, + {"set_mp_mmapsize", (PyCFunction)DBEnv_set_mp_mmapsize, METH_VARARGS|METH_KEYWORDS}, + {"set_tmp_dir", (PyCFunction)DBEnv_set_tmp_dir, METH_VARARGS|METH_KEYWORDS}, {"txn_begin", (PyCFunction)DBEnv_txn_begin, METH_VARARGS|METH_KEYWORDS}, - {"txn_checkpoint", (PyCFunction)DBEnv_txn_checkpoint, METH_VARARGS}, - {"txn_stat", (PyCFunction)DBEnv_txn_stat, METH_VARARGS}, - {"set_tx_max", (PyCFunction)DBEnv_set_tx_max, METH_VARARGS}, - {"lock_detect", (PyCFunction)DBEnv_lock_detect, METH_VARARGS}, - {"lock_get", (PyCFunction)DBEnv_lock_get, METH_VARARGS}, - {"lock_id", (PyCFunction)DBEnv_lock_id, METH_VARARGS}, - {"lock_put", (PyCFunction)DBEnv_lock_put, METH_VARARGS}, - {"lock_stat", (PyCFunction)DBEnv_lock_stat, METH_VARARGS}, - {"log_archive", (PyCFunction)DBEnv_log_archive, METH_VARARGS}, - {"set_get_returns_none",(PyCFunction)DBEnv_set_get_returns_none, METH_VARARGS}, + {"txn_checkpoint", (PyCFunction)DBEnv_txn_checkpoint, METH_VARARGS|METH_KEYWORDS}, + {"txn_stat", (PyCFunction)DBEnv_txn_stat, METH_VARARGS|METH_KEYWORDS}, + {"set_tx_max", (PyCFunction)DBEnv_set_tx_max, METH_VARARGS|METH_KEYWORDS}, + {"lock_detect", (PyCFunction)DBEnv_lock_detect, METH_VARARGS|METH_KEYWORDS}, + {"lock_get", (PyCFunction)DBEnv_lock_get, METH_VARARGS|METH_KEYWORDS}, + {"lock_id", (PyCFunction)DBEnv_lock_id, METH_NOARGS}, + {"lock_put", (PyCFunction)DBEnv_lock_put, METH_VARARGS|METH_KEYWORDS}, + {"lock_stat", (PyCFunction)DBEnv_lock_stat, METH_VARARGS|METH_KEYWORDS}, + {"log_archive", (PyCFunction)DBEnv_log_archive, METH_VARARGS|METH_KEYWORDS}, + {"set_get_returns_none",(PyCFunction)DBEnv_set_get_returns_none, METH_VARARGS|METH_KEYWORDS}, {NULL, NULL} /* sentinel */ }; static PyMethodDef DBTxn_methods[] = { - {"commit", (PyCFunction)DBTxn_commit, METH_VARARGS}, - {"prepare", (PyCFunction)DBTxn_prepare, METH_VARARGS}, - {"abort", (PyCFunction)DBTxn_abort, METH_VARARGS}, - {"id", (PyCFunction)DBTxn_id, METH_VARARGS}, + {"commit", (PyCFunction)DBTxn_commit, METH_VARARGS|METH_KEYWORDS}, + {"prepare", (PyCFunction)DBTxn_prepare, METH_VARARGS|METH_KEYWORDS}, + {"abort", (PyCFunction)DBTxn_abort, METH_NOARGS}, + {"id", (PyCFunction)DBTxn_id, METH_NOARGS}, {NULL, NULL} /* sentinel */ }; @@ -4394,10 +4520,14 @@ DB_construct(PyObject* self, PyObject* args, PyObject* kwargs) static PyObject* -DBEnv_construct(PyObject* self, PyObject* args) +DBEnv_construct(PyObject* self, PyObject* args, PyObject* kwargs) { int flags = 0; - if (!PyArg_ParseTuple(args, "|i:DbEnv", &flags)) return NULL; + char* kwnames[] = {"flags", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:DbEnv", kwnames, &flags)) + return NULL; + return (PyObject* )newDBEnvObject(flags); } @@ -4407,23 +4537,21 @@ static char bsddb_version_doc[] = underlying DB library."; static PyObject* -bsddb_version(PyObject* self, PyObject* args) +bsddb_version(PyObject* self) { int major, minor, patch; - if (!PyArg_ParseTuple(args, ":version")) - return NULL; - db_version(&major, &minor, &patch); - return Py_BuildValue("(iii)", major, minor, patch); + db_version(&major, &minor, &patch); + return Py_BuildValue("(iii)", major, minor, patch); } /* List of functions defined in the module */ static PyMethodDef bsddb_methods[] = { - {"DB", (PyCFunction)DB_construct, METH_VARARGS | METH_KEYWORDS }, - {"DBEnv", (PyCFunction)DBEnv_construct, METH_VARARGS}, - {"version", (PyCFunction)bsddb_version, METH_VARARGS, bsddb_version_doc}, + {"DB", (PyCFunction)DB_construct, METH_VARARGS|METH_KEYWORDS}, + {"DBEnv", (PyCFunction)DBEnv_construct, METH_VARARGS|METH_KEYWORDS}, + {"version", (PyCFunction)bsddb_version, METH_NOARGS, bsddb_version_doc}, {NULL, NULL} /* sentinel */ }; diff --git a/python/header-py.c b/python/header-py.c index 4d13e4e..bc86d98 100644 --- a/python/header-py.c +++ b/python/header-py.c @@ -157,15 +157,13 @@ struct hdrObject_s { /** \ingroup py_c */ -static PyObject * hdrKeyList(hdrObject * s, PyObject * args) +static PyObject * hdrKeyList(hdrObject * s) /*@*/ { PyObject * list, *o; HeaderIterator hi; int tag, type; - if (!PyArg_ParseTuple(args, "")) return NULL; - list = PyList_New(0); hi = headerInitIterator(s->h); @@ -226,7 +224,7 @@ static PyObject * hdrUnload(hdrObject * s, PyObject * args, PyObject *keywords) /** \ingroup py_c */ -static PyObject * hdrExpandFilelist(hdrObject * s, PyObject * args) +static PyObject * hdrExpandFilelist(hdrObject * s) /*@*/ { expandFilelist (s->h); @@ -237,7 +235,7 @@ static PyObject * hdrExpandFilelist(hdrObject * s, PyObject * args) /** \ingroup py_c */ -static PyObject * hdrCompressFilelist(hdrObject * s, PyObject * args) +static PyObject * hdrCompressFilelist(hdrObject * s) /*@*/ { compressFilelist (s->h); @@ -274,7 +272,7 @@ static void mungeFilelist(Header h) /** */ -static PyObject * rhnUnload(hdrObject * s, PyObject * args) +static PyObject * rhnUnload(hdrObject * s) /*@*/ { int len; @@ -282,9 +280,6 @@ static PyObject * rhnUnload(hdrObject * s, PyObject * args) PyObject * rc; Header h; - if (!PyArg_ParseTuple(args, "")) - return NULL; - h = headerLink(s->h); /* Retrofit a RHNPlatform: tag. */ @@ -336,12 +331,9 @@ static PyObject * rhnUnload(hdrObject * s, PyObject * args) /** \ingroup py_c */ -static PyObject * hdrFullFilelist(hdrObject * s, PyObject * args) +static PyObject * hdrFullFilelist(hdrObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, "")) - return NULL; - mungeFilelist (s->h); Py_INCREF(Py_None); @@ -350,15 +342,16 @@ static PyObject * hdrFullFilelist(hdrObject * s, PyObject * args) /** \ingroup py_c */ -static PyObject * hdrSprintf(hdrObject * s, PyObject * args) +static PyObject * hdrSprintf(hdrObject * s, PyObject * args, PyObject * kwds) /*@*/ { char * fmt; char * r; errmsg_t err; PyObject * result; + char * kwlist[] = {"format", NULL}; - if (!PyArg_ParseTuple(args, "s", &fmt)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist, &fmt)) return NULL; r = headerSprintf(s->h, fmt, rpmTagTable, rpmHeaderFormats, &err); @@ -390,26 +383,26 @@ static long hdr_hash(PyObject * h) */ /*@unchecked@*/ /*@observer@*/ static struct PyMethodDef hdr_methods[] = { - {"keys", (PyCFunction) hdrKeyList, METH_VARARGS, + {"keys", (PyCFunction) hdrKeyList, METH_NOARGS, NULL }, {"unload", (PyCFunction) hdrUnload, METH_VARARGS|METH_KEYWORDS, NULL }, - {"expandFilelist", (PyCFunction) hdrExpandFilelist,METH_VARARGS, + {"expandFilelist", (PyCFunction) hdrExpandFilelist,METH_NOARGS, NULL }, - {"compressFilelist",(PyCFunction) hdrCompressFilelist,METH_VARARGS, + {"compressFilelist",(PyCFunction) hdrCompressFilelist,METH_NOARGS, NULL }, - {"fullFilelist", (PyCFunction) hdrFullFilelist, METH_VARARGS, + {"fullFilelist", (PyCFunction) hdrFullFilelist, METH_NOARGS, NULL }, - {"rhnUnload", (PyCFunction) rhnUnload, METH_VARARGS, + {"rhnUnload", (PyCFunction) rhnUnload, METH_NOARGS, NULL }, - {"sprintf", (PyCFunction) hdrSprintf, METH_VARARGS, + {"sprintf", (PyCFunction) hdrSprintf, METH_VARARGS|METH_KEYWORDS, NULL }, - {"dsOfHeader", (PyCFunction)hdr_dsOfHeader, METH_VARARGS, + {"dsOfHeader", (PyCFunction)hdr_dsOfHeader, METH_NOARGS, NULL}, - {"dsFromHeader", (PyCFunction)hdr_dsFromHeader, METH_VARARGS, + {"dsFromHeader", (PyCFunction)hdr_dsFromHeader, METH_VARARGS|METH_KEYWORDS, NULL}, - {"fiFromHeader", (PyCFunction)hdr_fiFromHeader, METH_VARARGS, + {"fiFromHeader", (PyCFunction)hdr_fiFromHeader, METH_VARARGS|METH_KEYWORDS, NULL}, {NULL, NULL} /* sentinel */ @@ -722,15 +715,17 @@ Header hdrGetHeader(hdrObject * s) /** */ -PyObject * hdrLoad(PyObject * self, PyObject * args) +PyObject * hdrLoad(PyObject * self, PyObject * args, PyObject * kwds) { hdrObject * hdr; char * copy = NULL; char * obj; Header h; int len; + char * kwlist[] = {"headers", NULL}; - if (!PyArg_ParseTuple(args, "s#", &obj, &len)) return NULL; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#", kwlist, &obj, &len)) + return NULL; /* malloc is needed to avoid surprises from data swab in headerLoad(). */ copy = malloc(len); @@ -757,13 +752,15 @@ PyObject * hdrLoad(PyObject * self, PyObject * args) /** */ -PyObject * rhnLoad(PyObject * self, PyObject * args) +PyObject * rhnLoad(PyObject * self, PyObject * args, PyObject * kwds) { char * obj, * copy=NULL; Header h; int len; + char * kwlist[] = {"headers", NULL}; - if (!PyArg_ParseTuple(args, "s#", &obj, &len)) return NULL; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#", kwlist, &obj, &len)) + return NULL; /* malloc is needed to avoid surprises from data swab in headerLoad(). */ copy = malloc(len); @@ -847,13 +844,16 @@ PyObject * rpmReadHeaders (FD_t fd) /** */ -PyObject * rpmHeaderFromFD(PyObject * self, PyObject * args) +PyObject * rpmHeaderFromFD(PyObject * self, PyObject * args, PyObject * kwds) { FD_t fd; int fileno; PyObject * list; + char * kwlist[] = {"fd", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", kwlist, &fileno)) + return NULL; - if (!PyArg_ParseTuple(args, "i", &fileno)) return NULL; fd = fdDup(fileno); list = rpmReadHeaders (fd); @@ -864,13 +864,16 @@ PyObject * rpmHeaderFromFD(PyObject * self, PyObject * args) /** */ -PyObject * rpmHeaderFromFile(PyObject * self, PyObject * args) +PyObject * rpmHeaderFromFile(PyObject * self, PyObject * args, PyObject *kwds) { char * filespec; FD_t fd; PyObject * list; + char * kwlist[] = {"file", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist, &filespec)) + return NULL; - if (!PyArg_ParseTuple(args, "s", &filespec)) return NULL; fd = Fopen(filespec, "r.fdio"); if (!fd) { @@ -946,15 +949,18 @@ int rpmMergeHeaders(PyObject * list, FD_t fd, int matchTag) return 0; } -PyObject * rpmMergeHeadersFromFD(PyObject * self, PyObject * args) +PyObject * +rpmMergeHeadersFromFD(PyObject * self, PyObject * args, PyObject * kwds) { FD_t fd; int fileno; PyObject * list; int rc; int matchTag; + char * kwlist[] = {"list", "fd", "matchTag", NULL}; - if (!PyArg_ParseTuple(args, "Oii", &list, &fileno, &matchTag)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "Oii", kwlist, &list, + &fileno, &matchTag)) return NULL; if (!PyList_Check(list)) { @@ -977,15 +983,18 @@ PyObject * rpmMergeHeadersFromFD(PyObject * self, PyObject * args) /** */ -PyObject * rpmSingleHeaderFromFD(PyObject * self, PyObject * args) +PyObject * +rpmSingleHeaderFromFD(PyObject * self, PyObject * args, PyObject * kwds) { FD_t fd; int fileno; off_t offset; PyObject * tuple; Header h; + char * kwlist[] = {"fd", NULL}; - if (!PyArg_ParseTuple(args, "i", &fileno)) return NULL; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", kwlist, &fileno)) + return NULL; offset = lseek(fileno, 0, SEEK_CUR); @@ -1020,11 +1029,13 @@ PyObject * rpmSingleHeaderFromFD(PyObject * self, PyObject * args) /** */ -PyObject * versionCompare (PyObject * self, PyObject * args) +PyObject * versionCompare (PyObject * self, PyObject * args, PyObject * kwds) { hdrObject * h1, * h2; + char * kwlist[] = {"version0", "version1", NULL}; - if (!PyArg_ParseTuple(args, "O!O!", &hdr_Type, &h1, &hdr_Type, &h2)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!O!", kwlist, &hdr_Type, + &h1, &hdr_Type, &h2)) return NULL; return Py_BuildValue("i", hdr_compare(h1, h2)); @@ -1043,12 +1054,14 @@ static int compare_values(const char *str1, const char *str2) return rpmvercmp(str1, str2); } -PyObject * labelCompare (PyObject * self, PyObject * args) +PyObject * labelCompare (PyObject * self, PyObject * args, PyObject * kwds) { char *v1, *r1, *e1, *v2, *r2, *e2; int rc; + char * kwlist[] = {"epoch0", "version0", "release0", + "epoch1", "version1", "release1", NULL}; - if (!PyArg_ParseTuple(args, "(zzz)(zzz)", + if (!PyArg_ParseTupleAndKeywords(args, kwds, "(zzz)(zzz)", kwlist, &e1, &v1, &r1, &e2, &v2, &r2)) return NULL; diff --git a/python/header-py.h b/python/header-py.h index 8d4fc22..9e7dc78 100644 --- a/python/header-py.h +++ b/python/header-py.h @@ -25,25 +25,25 @@ Header hdrGetHeader(hdrObject * h) long tagNumFromPyObject (PyObject *item) /*@*/; -PyObject * labelCompare (PyObject * self, PyObject * args) +PyObject * labelCompare (PyObject * self, PyObject * args, PyObject * kwds) /*@*/; -PyObject * versionCompare (PyObject * self, PyObject * args) +PyObject * versionCompare (PyObject * self, PyObject * args, PyObject * kwds) /*@*/; -PyObject * rpmMergeHeadersFromFD(PyObject * self, PyObject * args) +PyObject * rpmMergeHeadersFromFD(PyObject * self, PyObject * args, PyObject * kwds) /*@*/; int rpmMergeHeaders(PyObject * list, FD_t fd, int matchTag) /*@*/; -PyObject * rpmHeaderFromFile(PyObject * self, PyObject * args) +PyObject * rpmHeaderFromFile(PyObject * self, PyObject * args, PyObject * kwds) /*@*/; -PyObject * rpmHeaderFromFD(PyObject * self, PyObject * args) +PyObject * rpmHeaderFromFD(PyObject * self, PyObject * args, PyObject * kwds) /*@*/; -PyObject * rpmSingleHeaderFromFD(PyObject * self, PyObject * args) +PyObject * rpmSingleHeaderFromFD(PyObject * self, PyObject * args, PyObject * kwds) /*@*/; PyObject * rpmReadHeaders (FD_t fd) /*@*/; -PyObject * rhnLoad(PyObject * self, PyObject * args) +PyObject * rhnLoad(PyObject * self, PyObject * args, PyObject * kwds) /*@*/; -PyObject * hdrLoad(PyObject * self, PyObject * args) +PyObject * hdrLoad(PyObject * self, PyObject * args, PyObject * kwds) /*@*/; #endif diff --git a/python/poptmodule.c b/python/poptmodule.c index 06b665d..275518b 100644 --- a/python/poptmodule.c +++ b/python/poptmodule.c @@ -6,7 +6,7 @@ #define PY_POPT_VERSION "0.2" -static const char *rcs_id = "$Id: poptmodule.c,v 1.9 2003/11/23 19:52:38 jbj Exp $"; +static const char *rcs_id = "$Id: poptmodule.c,v 1.10 2004/11/17 17:05:39 pauln Exp $"; static char *module_doc = "Python bindings for the popt library\n\ \n\ @@ -88,29 +88,23 @@ static PyObject * __poptOptionValue2PyObject(const struct poptOption *option) return NULL; } -static PyObject * ctxReset(poptContextObject *self, PyObject *args) +static PyObject * ctxReset(poptContextObject *self) { - if (!PyArg_ParseTuple(args, "")) - return NULL; poptResetContext(self->ctx); self->opt = -1; Py_INCREF(Py_None); return Py_None; } -static PyObject * ctxGetNextOpt(poptContextObject *self, PyObject *args) +static PyObject * ctxGetNextOpt(poptContextObject *self) { - if (!PyArg_ParseTuple(args, "")) - return NULL; self->opt = poptGetNextOpt(self->ctx); return PyInt_FromLong(self->opt); } -static PyObject * ctxGetOptArg(poptContextObject *self, PyObject *args) +static PyObject * ctxGetOptArg(poptContextObject *self) { const char *opt; - if (!PyArg_ParseTuple(args, "")) - return NULL; opt = poptGetOptArg(self->ctx); if (opt == NULL) { Py_INCREF(Py_None); @@ -119,11 +113,9 @@ static PyObject * ctxGetOptArg(poptContextObject *self, PyObject *args) return PyString_FromString(opt); } -static PyObject * ctxGetArg(poptContextObject *self, PyObject *args) +static PyObject * ctxGetArg(poptContextObject *self) { const char *arg; - if (!PyArg_ParseTuple(args, "")) - return NULL; arg = poptGetArg(self->ctx); if (arg == NULL) { Py_INCREF(Py_None); @@ -132,11 +124,9 @@ static PyObject * ctxGetArg(poptContextObject *self, PyObject *args) return PyString_FromString(arg); } -static PyObject * ctxPeekArg(poptContextObject *self, PyObject *args) +static PyObject * ctxPeekArg(poptContextObject *self) { const char *arg; - if (!PyArg_ParseTuple(args, "")) - return NULL; arg = poptPeekArg(self->ctx); if (arg == NULL) { Py_INCREF(Py_None); @@ -145,13 +135,11 @@ static PyObject * ctxPeekArg(poptContextObject *self, PyObject *args) return PyString_FromString(arg); } -static PyObject * ctxGetArgs(poptContextObject *self, PyObject *argsFoo) +static PyObject * ctxGetArgs(poptContextObject *self) { const char **args; PyObject *list; int size, i; - if (!PyArg_ParseTuple(argsFoo, "")) - return NULL; args = poptGetArgs(self->ctx); if (args == NULL) { Py_INCREF(Py_None); @@ -168,12 +156,16 @@ static PyObject * ctxGetArgs(poptContextObject *self, PyObject *argsFoo) return list; } -static PyObject * ctxBadOption(poptContextObject *self, PyObject *args) +static PyObject * +ctxBadOption(poptContextObject *self, PyObject *args, PyObject *kwds) { int flags = 0; const char *badOption; - if (!PyArg_ParseTuple(args, "|i", &flags)) + char * kwlist[] = {"flags", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i", kwlist, &flags)) return NULL; + badOption = poptBadOption(self->ctx, flags); if (badOption == NULL) { Py_INCREF(Py_None); @@ -182,39 +174,56 @@ static PyObject * ctxBadOption(poptContextObject *self, PyObject *args) return PyString_FromString(badOption); } -static PyObject * ctxReadDefaultConfig(poptContextObject *self, PyObject *args) +static PyObject * +ctxReadDefaultConfig(poptContextObject *self, PyObject *args, PyObject *kwds) { int flags = 0; - if (!PyArg_ParseTuple(args, "|i", &flags)) + char * kwlist[] = {"flags", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i", kwlist, &flags)) return NULL; + return PyInt_FromLong(poptReadDefaultConfig(self->ctx, flags)); } -static PyObject * ctxReadConfigFile(poptContextObject *self, PyObject *args) +static PyObject * +ctxReadConfigFile(poptContextObject *self, PyObject *args, PyObject *kwds) { const char *filename; - if (!PyArg_ParseTuple(args, "s", &filename)) + char * kwlist[] = {"filename", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist, &filename)) return NULL; + return PyInt_FromLong(poptReadConfigFile(self->ctx, filename)); } -static PyObject * ctxSetOtherOptionHelp(poptContextObject *self, PyObject *args) +static PyObject * +ctxSetOtherOptionHelp(poptContextObject *self, PyObject *args, PyObject *kwds) { const char *option; - if (!PyArg_ParseTuple(args, "s", &option)) + char * kwlist[] = {"option", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist, &option)) return NULL; + poptSetOtherOptionHelp(self->ctx, option); Py_INCREF(Py_None); return Py_None; } -static PyObject * ctxPrintHelp(poptContextObject *self, PyObject *args) +static PyObject * +ctxPrintHelp(poptContextObject *self, PyObject *args, PyObject *kwds) { FILE *f; int flags = 0; PyObject *file; - if (!PyArg_ParseTuple(args, "|O!i", &PyFile_Type, &file, &flags)) + char * kwlist[] = {"file", "flags", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!i", kwlist, &PyFile_Type, + &file, &flags)) return NULL; + f = PyFile_AsFile(file); if (f == NULL) f = stderr; @@ -223,14 +232,19 @@ static PyObject * ctxPrintHelp(poptContextObject *self, PyObject *args) return Py_None; } -static PyObject * ctxPrintUsage(poptContextObject *self, PyObject *args) +static PyObject * +ctxPrintUsage(poptContextObject *self, PyObject *args, PyObject *kwds) { FILE *f; int flags = 0; PyObject *file; - if (!PyArg_ParseTuple(args, "|O!i", &PyFile_Type, &file, &flags)) + char *kwlist[] = {"file", "flags", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!i", kwlist, &PyFile_Type, + &file, &flags)) return NULL; - f = PyFile_AsFile(file); + + f = PyFile_AsFile(file); if (f == NULL) f = stderr; poptPrintUsage(self->ctx, f, flags); @@ -246,12 +260,11 @@ static PyObject * ctxPrintUsage(poptContextObject *self, PyObject *args) /* Added ctxGetOptValues */ /*******************************/ /* Builds a list of values corresponding to each option */ -static PyObject * ctxGetOptValues(poptContextObject *self, PyObject *args) +static PyObject * ctxGetOptValues(poptContextObject *self) { PyObject *list; int i; - if (!PyArg_ParseTuple(args, "")) - return NULL; + /* Create the list */ list = PyList_New(self->optionsNo); if (list == NULL) @@ -267,11 +280,10 @@ static PyObject * ctxGetOptValues(poptContextObject *self, PyObject *args) return list; } -static PyObject * ctxGetOptValue(poptContextObject *self, PyObject *args) +static PyObject * ctxGetOptValue(poptContextObject *self) { int i; - if (!PyArg_ParseTuple(args, "")) - return NULL; + if (self->opt < 0) { /* No processing */ Py_INCREF(Py_None); @@ -289,25 +301,25 @@ static PyObject * ctxGetOptValue(poptContextObject *self, PyObject *args) } static struct PyMethodDef ctxMethods[] = { - {"reset", (PyCFunction)ctxReset, METH_VARARGS}, - {"getNextOpt", (PyCFunction)ctxGetNextOpt, METH_VARARGS}, - {"getOptArg", (PyCFunction)ctxGetOptArg, METH_VARARGS}, - {"getArg", (PyCFunction)ctxGetArg, METH_VARARGS}, - {"peekArg", (PyCFunction)ctxPeekArg, METH_VARARGS}, - {"getArgs", (PyCFunction)ctxGetArgs, METH_VARARGS}, - {"badOption", (PyCFunction)ctxBadOption, METH_VARARGS}, - {"readDefaultConfig", (PyCFunction)ctxReadDefaultConfig, METH_VARARGS}, - {"readConfigFile", (PyCFunction)ctxReadConfigFile, METH_VARARGS}, - {"setOtherOptionHelp", (PyCFunction)ctxSetOtherOptionHelp, METH_VARARGS}, - {"printHelp", (PyCFunction)ctxPrintHelp, METH_VARARGS}, - {"printUsage", (PyCFunction)ctxPrintUsage, METH_VARARGS}, + {"reset", (PyCFunction)ctxReset, METH_NOARGS}, + {"getNextOpt", (PyCFunction)ctxGetNextOpt, METH_NOARGS}, + {"getOptArg", (PyCFunction)ctxGetOptArg, METH_NOARGS}, + {"getArg", (PyCFunction)ctxGetArg, METH_NOARGS}, + {"peekArg", (PyCFunction)ctxPeekArg, METH_NOARGS}, + {"getArgs", (PyCFunction)ctxGetArgs, METH_NOARGS}, + {"badOption", (PyCFunction)ctxBadOption, METH_VARARGS|METH_KEYWORDS}, + {"readDefaultConfig", (PyCFunction)ctxReadDefaultConfig, METH_VARARGS|METH_KEYWORDS}, + {"readConfigFile", (PyCFunction)ctxReadConfigFile, METH_VARARGS|METH_KEYWORDS}, + {"setOtherOptionHelp", (PyCFunction)ctxSetOtherOptionHelp, METH_VARARGS|METH_KEYWORDS}, + {"printHelp", (PyCFunction)ctxPrintHelp, METH_VARARGS|METH_KEYWORDS}, + {"printUsage", (PyCFunction)ctxPrintUsage, METH_VARARGS|METH_KEYWORDS}, /* {"addAlias", (PyCFunction)ctxAddAlias}, {"stuffArgs", (PyCFunction)ctxStuffArgs}, {"callbackType", (PyCFunction)ctxCallbackType}, */ - {"getOptValues", (PyCFunction)ctxGetOptValues, METH_VARARGS}, - {"getOptValue", (PyCFunction)ctxGetOptValue, METH_VARARGS}, + {"getOptValues", (PyCFunction)ctxGetOptValues, METH_NOARGS}, + {"getOptValue", (PyCFunction)ctxGetOptValue, METH_NOARGS}, {NULL, NULL} }; @@ -316,7 +328,7 @@ static PyObject * ctxGetAttr(poptContextObject *s, char *name) return Py_FindMethod(ctxMethods, (PyObject *)s, name); } -static void ctxDealloc(poptContextObject *self, PyObject *args) +static void ctxDealloc(poptContextObject *self) { if (self->options != NULL) { int i; @@ -575,7 +587,7 @@ char ** __getArgv(PyObject *list, int *argc) } -static PyObject * getContext(PyObject *self, PyObject *args) +static PyObject * getContext(PyObject *self, PyObject *args, PyObject *kwds) { const char *name; PyObject *a, *o; @@ -583,10 +595,13 @@ static PyObject * getContext(PyObject *self, PyObject *args) int argc, count, flags = 0; struct poptOption *opts; poptContextObject *c; + char *kwlist[] = {"name", "argv", "list", NULL}; + /* We should receive name, argv and a list */ - if (!PyArg_ParseTuple(args, "zO!O!|i", &name, &PyList_Type, &a, - &PyList_Type, &o, &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "zO!O!|i", kwlist, + &name, &PyList_Type, &a, &PyList_Type, &o, &flags)) return NULL; + /* Parse argv */ argv = __getArgv(a, &argc); if (argv == NULL) @@ -611,19 +626,21 @@ struct _pyIntConstant { const int value; }; -static PyObject * _strerror(PyObject *self, PyObject *args) +static PyObject * _strerror(PyObject *self, PyObject *args, PyObject *kwds) { int error; - if (!PyArg_ParseTuple(args, "i", &error)) { + char *kwlist[] = {"error", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", kwlist, &error)) return NULL; - } + return PyString_FromString(poptStrerror(error)); } /* Methods for the popt module */ static struct PyMethodDef poptModuleMethods[] = { - {"getContext", (PyCFunction)getContext, METH_VARARGS, NULL}, - {"strerror", (PyCFunction)_strerror, METH_VARARGS, NULL}, + {"getContext", (PyCFunction)getContext, METH_VARARGS|METH_KEYWORDS}, + {"strerror", (PyCFunction)_strerror, METH_VARARGS|METH_KEYWORDS}, {NULL, NULL} }; diff --git a/python/rpmal-py.c b/python/rpmal-py.c index 47b60d1..ddb9d8a 100644 --- a/python/rpmal-py.c +++ b/python/rpmal-py.c @@ -14,26 +14,32 @@ /*@null@*/ static PyObject * -rpmal_Debug(/*@unused@*/ rpmalObject * s, PyObject * args) +rpmal_Debug(/*@unused@*/ rpmalObject * s, PyObject * args, PyObject * kwds) /*@globals _Py_NoneStruct @*/ /*@modifies _Py_NoneStruct @*/ { - if (!PyArg_ParseTuple(args, "i", &_rpmal_debug)) return NULL; + char * kwlist[] = {"debugLevel", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", kwlist, &_rpmal_debug)) + return NULL; + Py_INCREF(Py_None); return Py_None; } /*@null@*/ static PyObject * -rpmal_Add(rpmalObject * s, PyObject * args) +rpmal_Add(rpmalObject * s, PyObject * args, PyObject * kwds) /*@modifies s @*/ { rpmdsObject * dso; rpmfiObject * fio; PyObject * key; alKey pkgKey; + char * kwlist[] = {"packageKey", "key", "dso", "fileInfo", NULL}; - if (!PyArg_ParseTuple(args, "iOO!O!:Add", &pkgKey, &key, &rpmds_Type, &dso, &rpmfi_Type, &fio)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "iOO!O!:Add", kwlist, + &pkgKey, &key, &rpmds_Type, &dso, &rpmfi_Type, &fio)) return NULL; /* XXX errors */ @@ -45,13 +51,14 @@ rpmal_Add(rpmalObject * s, PyObject * args) /*@null@*/ static PyObject * -rpmal_Del(rpmalObject * s, PyObject * args) +rpmal_Del(rpmalObject * s, PyObject * args, PyObject * kwds) /*@globals _Py_NoneStruct @*/ /*@modifies s, _Py_NoneStruct @*/ { alKey pkgKey; + char * kwlist[] = {"key", NULL}; - if (!PyArg_ParseTuple(args, "i:Del", &pkgKey)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:Del", kwlist, &pkgKey)) return NULL; rpmalDel(s->al, pkgKey); @@ -62,14 +69,18 @@ rpmal_Del(rpmalObject * s, PyObject * args) /*@null@*/ static PyObject * -rpmal_AddProvides(rpmalObject * s, PyObject * args) +rpmal_AddProvides(rpmalObject * s, PyObject * args, PyObject * kwds) /*@globals _Py_NoneStruct @*/ /*@modifies s, _Py_NoneStruct @*/ { rpmdsObject * dso; alKey pkgKey; + char * kwlist[] = {"index", "packageIndex", "dso", NULL}; - if (!PyArg_ParseTuple(args, "iOO!O!:AddProvides", &pkgKey, &rpmds_Type, &dso)) + /* XXX: why is there an argument listed in the format string that + * isn't handled? Is that for transaction color? */ + if (!PyArg_ParseTupleAndKeywords(args, kwds, "iOO!O!:AddProvides", kwlist, + &pkgKey, &rpmds_Type, &dso)) return NULL; /* XXX transaction colors */ @@ -81,13 +92,10 @@ rpmal_AddProvides(rpmalObject * s, PyObject * args) /*@null@*/ static PyObject * -rpmal_MakeIndex(rpmalObject * s, PyObject * args) +rpmal_MakeIndex(rpmalObject * s) /*@globals _Py_NoneStruct @*/ /*@modifies s, _Py_NoneStruct @*/ { - if (!PyArg_ParseTuple(args, ":MakeIndex")) - return NULL; - rpmalMakeIndex(s->al); Py_INCREF(Py_None); @@ -97,15 +105,15 @@ rpmal_MakeIndex(rpmalObject * s, PyObject * args) /*@-fullinitblock@*/ /*@unchecked@*/ /*@observer@*/ static struct PyMethodDef rpmal_methods[] = { - {"Debug", (PyCFunction)rpmal_Debug, METH_VARARGS, + {"Debug", (PyCFunction)rpmal_Debug, METH_VARARGS|METH_KEYWORDS, NULL}, - {"add", (PyCFunction)rpmal_Add, METH_VARARGS, + {"add", (PyCFunction)rpmal_Add, METH_VARARGS|METH_KEYWORDS, NULL}, - {"delete", (PyCFunction)rpmal_Del, METH_VARARGS, + {"delete", (PyCFunction)rpmal_Del, METH_VARARGS|METH_KEYWORDS, NULL}, - {"addProvides",(PyCFunction)rpmal_AddProvides, METH_VARARGS, + {"addProvides",(PyCFunction)rpmal_AddProvides, METH_VARARGS|METH_KEYWORDS, NULL}, - {"makeIndex",(PyCFunction)rpmal_MakeIndex, METH_VARARGS, + {"makeIndex",(PyCFunction)rpmal_MakeIndex, METH_NOARGS, NULL}, {NULL, NULL } /* sentinel */ }; diff --git a/python/rpmdb-py.c b/python/rpmdb-py.c index b5251f8..25fdd00 100644 --- a/python/rpmdb-py.c +++ b/python/rpmdb-py.c @@ -107,7 +107,7 @@ */ /*@null@*/ static rpmmiObject * -rpmdb_Match (rpmdbObject * s, PyObject * args) +rpmdb_Match (rpmdbObject * s, PyObject * args, PyObject * kwds) /*@globals rpmGlobalMacroContext @*/ /*@modifies s, rpmGlobalMacroContext @*/ { @@ -115,8 +115,10 @@ rpmdb_Match (rpmdbObject * s, PyObject * args) char *key = NULL; int len = 0; int tag = RPMDBI_PACKAGES; + char * kwlist[] = {"tagNumber", "key", "len", NULL}; - if (!PyArg_ParseTuple(args, "|Ozi", &TagN, &key, &len)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Ozi", kwlist, + &TagN, &key, &len)) return NULL; if (TagN && (tag = tagNumFromPyObject (TagN)) == -1) { @@ -132,7 +134,7 @@ rpmdb_Match (rpmdbObject * s, PyObject * args) /*@-fullinitblock@*/ /*@unchecked@*/ /*@observer@*/ static struct PyMethodDef rpmdb_methods[] = { - {"match", (PyCFunction) rpmdb_Match, METH_VARARGS, + {"match", (PyCFunction) rpmdb_Match, METH_VARARGS|METH_KEYWORDS, "db.match([TagN, [key, [len]]]) -> mi\n\ - Create an rpm db match iterator.\n" }, {NULL, NULL} /* sentinel */ @@ -285,12 +287,16 @@ rpmdb dbFromDb(rpmdbObject * db) /** */ -rpmdbObject * rpmOpenDB(/*@unused@*/ PyObject * self, PyObject * args) { +rpmdbObject * +rpmOpenDB(/*@unused@*/ PyObject * self, PyObject * args, PyObject * kwds) { rpmdbObject * o; char * root = ""; int forWrite = 0; + char * kwlist[] = {"forWrite", "rootdir", NULL}; - if (!PyArg_ParseTuple(args, "|is", &forWrite, &root)) return NULL; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|is", kwlist, + &forWrite, &root)) + return NULL; o = PyObject_New(rpmdbObject, &rpmdb_Type); o->db = NULL; @@ -317,11 +323,14 @@ rpmdbObject * rpmOpenDB(/*@unused@*/ PyObject * self, PyObject * args) { /** * @todo Permit header checks when doing --rebuilddb. */ -PyObject * rebuildDB (/*@unused@*/ PyObject * self, PyObject * args) +PyObject * +rebuildDB (/*@unused@*/ PyObject * self, PyObject * args, PyObject * kwds) { char * rootDir = ""; + char * kwlist[] = {"rootdir", NULL}; - if (!PyArg_ParseTuple(args, "s", &rootDir)) return NULL; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist, &rootDir)) + return NULL; return Py_BuildValue("i", rpmdbRebuild(rootDir, NULL, NULL)); } diff --git a/python/rpmdb-py.h b/python/rpmdb-py.h index 533b545..062ad83 100644 --- a/python/rpmdb-py.h +++ b/python/rpmdb-py.h @@ -29,9 +29,9 @@ extern PyTypeObject rpmdb_Type; rpmdb dbFromDb(rpmdbObject * db) /*@*/; -rpmdbObject * rpmOpenDB(PyObject * self, PyObject * args) +rpmdbObject * rpmOpenDB(PyObject * self, PyObject * args, PyObject * kwds) /*@*/; -PyObject * rebuildDB (PyObject * self, PyObject * args) +PyObject * rebuildDB (PyObject * self, PyObject * args, PyObject * kwds) /*@globals rpmGlobalMacroContext @*/ /*@modifies rpmGlobalMacroContext @*/; #endif diff --git a/python/rpmds-py.c b/python/rpmds-py.c index 472e9c6..269c342 100644 --- a/python/rpmds-py.c +++ b/python/rpmds-py.c @@ -64,102 +64,96 @@ void rpmds_ParseEVR(char * evr, /*@null@*/ static PyObject * -rpmds_Debug(/*@unused@*/ rpmdsObject * s, PyObject * args) +rpmds_Debug(/*@unused@*/ rpmdsObject * s, PyObject * args, PyObject * kwds) /*@globals _Py_NoneStruct @*/ /*@modifies _Py_NoneStruct @*/ { - if (!PyArg_ParseTuple(args, "i", &_rpmds_debug)) return NULL; + char * kwlist[] = {"debugLevel", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", kwlist, &_rpmds_debug)) + return NULL; + Py_INCREF(Py_None); return Py_None; } /*@null@*/ static PyObject * -rpmds_Count(rpmdsObject * s, PyObject * args) +rpmds_Count(rpmdsObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":Count")) return NULL; return Py_BuildValue("i", rpmdsCount(s->ds)); } /*@null@*/ static PyObject * -rpmds_Ix(rpmdsObject * s, PyObject * args) +rpmds_Ix(rpmdsObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":Ix")) return NULL; return Py_BuildValue("i", rpmdsIx(s->ds)); } /*@null@*/ static PyObject * -rpmds_DNEVR(rpmdsObject * s, PyObject * args) +rpmds_DNEVR(rpmdsObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":DNEVR")) return NULL; return Py_BuildValue("s", rpmdsDNEVR(s->ds)); } /*@null@*/ static PyObject * -rpmds_N(rpmdsObject * s, PyObject * args) +rpmds_N(rpmdsObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":N")) return NULL; return Py_BuildValue("s", rpmdsN(s->ds)); } /*@null@*/ static PyObject * -rpmds_EVR(rpmdsObject * s, PyObject * args) +rpmds_EVR(rpmdsObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":EVR")) return NULL; return Py_BuildValue("s", rpmdsEVR(s->ds)); } /*@null@*/ static PyObject * -rpmds_Flags(rpmdsObject * s, PyObject * args) +rpmds_Flags(rpmdsObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":Flags")) return NULL; return Py_BuildValue("i", rpmdsFlags(s->ds)); } /*@null@*/ static PyObject * -rpmds_BT(rpmdsObject * s, PyObject * args) +rpmds_BT(rpmdsObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":BT")) return NULL; return Py_BuildValue("i", (int) rpmdsBT(s->ds)); } /*@null@*/ static PyObject * -rpmds_TagN(rpmdsObject * s, PyObject * args) +rpmds_TagN(rpmdsObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":TagN")) return NULL; return Py_BuildValue("i", rpmdsTagN(s->ds)); } /*@null@*/ static PyObject * -rpmds_Color(rpmdsObject * s, PyObject * args) +rpmds_Color(rpmdsObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":Color")) return NULL; return Py_BuildValue("i", rpmdsColor(s->ds)); } /*@null@*/ static PyObject * -rpmds_Refs(rpmdsObject * s, PyObject * args) +rpmds_Refs(rpmdsObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":Refs")) return NULL; return Py_BuildValue("i", rpmdsRefs(s->ds)); } @@ -269,15 +263,12 @@ rpmds_iternext(rpmdsObject * s) /*@null@*/ static PyObject * -rpmds_Next(rpmdsObject * s, PyObject *args) +rpmds_Next(rpmdsObject * s) /*@globals _Py_NoneStruct @*/ /*@modifies s, _Py_NoneStruct @*/ { PyObject * result; - if (!PyArg_ParseTuple(args, ":Next")) - return NULL; - result = rpmds_iternext(s); if (result == NULL) { @@ -289,27 +280,33 @@ rpmds_Next(rpmdsObject * s, PyObject *args) /*@null@*/ static PyObject * -rpmds_SetNoPromote(rpmdsObject * s, PyObject * args) +rpmds_SetNoPromote(rpmdsObject * s, PyObject * args, PyObject * kwds) /*@modifies s @*/ { int nopromote; + char * kwlist[] = {"noPromote", NULL}; - if (!PyArg_ParseTuple(args, "i:SetNoPromote", &nopromote)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:SetNoPromote", kwlist, + &nopromote)) return NULL; + return Py_BuildValue("i", rpmdsSetNoPromote(s->ds, nopromote)); } /*@null@*/ static PyObject * -rpmds_Notify(rpmdsObject * s, PyObject * args) +rpmds_Notify(rpmdsObject * s, PyObject * args, PyObject * kwds) /*@globals _Py_NoneStruct @*/ /*@modifies _Py_NoneStruct @*/ { const char * where; int rc; + char * kwlist[] = {"location", "returnCode", NULL}; - if (!PyArg_ParseTuple(args, "si:Notify", &where, &rc)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "si:Notify", kwlist, + &where, &rc)) return NULL; + rpmdsNotify(s->ds, where, rc); Py_INCREF(Py_None); return Py_None; @@ -318,12 +315,10 @@ rpmds_Notify(rpmdsObject * s, PyObject * args) /* XXX rpmdsFind uses bsearch on s->ds, so a sort is needed. */ /*@null@*/ static PyObject * -rpmds_Sort(rpmdsObject * s, PyObject * args) +rpmds_Sort(rpmdsObject * s) /*@globals _Py_NoneStruct @*/ /*@modifies _Py_NoneStruct @*/ { - if (!PyArg_ParseTuple(args, ":Sort")) - return NULL; /* XXX sort on (N,EVR,F) here. */ Py_INCREF(Py_None); return Py_None; @@ -331,15 +326,17 @@ rpmds_Sort(rpmdsObject * s, PyObject * args) /*@null@*/ static PyObject * -rpmds_Find(rpmdsObject * s, PyObject * args) +rpmds_Find(rpmdsObject * s, PyObject * args, PyObject * kwds) /*@modifies s @*/ { PyObject * to = NULL; rpmdsObject * o; int rc; + char * kwlist[] = {"element", NULL}; - if (!PyArg_ParseTuple(args, "O:Find", &to)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:Find", kwlist, &to)) return NULL; + /* XXX ds type check needed. */ o = (rpmdsObject *)to; @@ -352,14 +349,16 @@ rpmds_Find(rpmdsObject * s, PyObject * args) /*@null@*/ static PyObject * -rpmds_Merge(rpmdsObject * s, PyObject * args) +rpmds_Merge(rpmdsObject * s, PyObject * args, PyObject * kwds) /*@modifies s @*/ { PyObject * to = NULL; rpmdsObject * o; + char * kwlist[] = {"element", NULL}; - if (!PyArg_ParseTuple(args, "O:Find", &to)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:Merge", kwlist, &to)) return NULL; + /* XXX ds type check needed. */ o = (rpmdsObject *)to; return Py_BuildValue("i", rpmdsMerge(&s->ds, o->ds)); @@ -367,14 +366,16 @@ rpmds_Merge(rpmdsObject * s, PyObject * args) #ifdef NOTYET static PyObject * -rpmds_Compare(rpmdsObject * s, PyObject * args) +rpmds_Compare(rpmdsObject * s, PyObject * args, PyObject * kwds) /*@modifies s @*/ { PyObject * to = NULL; rpmdsObject * o; + char * kwlist[] = {"other", NULL}; - if (!PyArg_ParseTuple(args, "O:Compare", &to)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:Compare", kwlist, &to)) return NULL; + /* XXX ds type check needed. */ o = (rpmdsObject *)to; return Py_BuildValue("i", rpmdsCompare(s->ds, o->ds)); @@ -382,7 +383,7 @@ rpmds_Compare(rpmdsObject * s, PyObject * args) /*@null@*/ static PyObject * -rpmds_Problem(rpmdsObject * s, PyObject * args) +rpmds_Problem(rpmdsObject * s) /*@*/ { if (!PyArg_ParseTuple(args, ":Problem")) @@ -395,45 +396,45 @@ rpmds_Problem(rpmdsObject * s, PyObject * args) /*@-fullinitblock@*/ /*@unchecked@*/ /*@observer@*/ static struct PyMethodDef rpmds_methods[] = { - {"Debug", (PyCFunction)rpmds_Debug, METH_VARARGS, + {"Debug", (PyCFunction)rpmds_Debug, METH_VARARGS|METH_KEYWORDS, NULL}, - {"Count", (PyCFunction)rpmds_Count, METH_VARARGS, + {"Count", (PyCFunction)rpmds_Count, METH_NOARGS, "ds.Count -> Count - Return no. of elements.\n" }, - {"Ix", (PyCFunction)rpmds_Ix, METH_VARARGS, + {"Ix", (PyCFunction)rpmds_Ix, METH_NOARGS, "ds.Ix -> Ix - Return current element index.\n" }, - {"DNEVR", (PyCFunction)rpmds_DNEVR, METH_VARARGS, + {"DNEVR", (PyCFunction)rpmds_DNEVR, METH_NOARGS, "ds.DNEVR -> DNEVR - Return current DNEVR.\n" }, - {"N", (PyCFunction)rpmds_N, METH_VARARGS, + {"N", (PyCFunction)rpmds_N, METH_NOARGS, "ds.N -> N - Return current N.\n" }, - {"EVR", (PyCFunction)rpmds_EVR, METH_VARARGS, + {"EVR", (PyCFunction)rpmds_EVR, METH_NOARGS, "ds.EVR -> EVR - Return current EVR.\n" }, - {"Flags", (PyCFunction)rpmds_Flags, METH_VARARGS, + {"Flags", (PyCFunction)rpmds_Flags, METH_NOARGS, "ds.Flags -> Flags - Return current Flags.\n" }, - {"BT", (PyCFunction)rpmds_BT, METH_VARARGS, + {"BT", (PyCFunction)rpmds_BT, METH_NOARGS, "ds.BT -> BT - Return build time.\n" }, - {"TagN", (PyCFunction)rpmds_TagN, METH_VARARGS, + {"TagN", (PyCFunction)rpmds_TagN, METH_NOARGS, "ds.TagN -> TagN - Return current TagN.\n" }, - {"Color", (PyCFunction)rpmds_Color, METH_VARARGS, + {"Color", (PyCFunction)rpmds_Color, METH_NOARGS, "ds.Color -> Color - Return current Color.\n" }, - {"Refs", (PyCFunction)rpmds_Refs, METH_VARARGS, + {"Refs", (PyCFunction)rpmds_Refs, METH_NOARGS, "ds.Refs -> Refs - Return current Refs.\n" }, - {"next", (PyCFunction)rpmds_Next, METH_VARARGS, + {"next", (PyCFunction)rpmds_Next, METH_NOARGS, "ds.next() -> (N, EVR, Flags)\n\ - Retrieve next dependency triple.\n" }, - {"SetNoPromote",(PyCFunction)rpmds_SetNoPromote, METH_VARARGS, + {"SetNoPromote",(PyCFunction)rpmds_SetNoPromote, METH_VARARGS|METH_KEYWORDS, NULL}, - {"Notify", (PyCFunction)rpmds_Notify, METH_VARARGS, + {"Notify", (PyCFunction)rpmds_Notify, METH_VARARGS|METH_KEYWORDS, NULL}, - {"Sort", (PyCFunction)rpmds_Sort, METH_VARARGS, + {"Sort", (PyCFunction)rpmds_Sort, METH_NOARGS, NULL}, - {"Find", (PyCFunction)rpmds_Find, METH_VARARGS, + {"Find", (PyCFunction)rpmds_Find, METH_VARARGS|METH_KEYWORDS, NULL}, - {"Merge", (PyCFunction)rpmds_Merge, METH_VARARGS, + {"Merge", (PyCFunction)rpmds_Merge, METH_VARARGS|METH_KEYWORDS, NULL}, #ifdef NOTYET - {"Compare", (PyCFunction)rpmds_Compare, METH_VARARGS, + {"Compare", (PyCFunction)rpmds_Compare, METH_VARARGS|METH_KEYWORDS, NULL}, - {"Problem", (PyCFunction)rpmds_Problem, METH_VARARGS, + {"Problem", (PyCFunction)rpmds_Problem, METH_NOARGS, NULL}, #endif {NULL, NULL} /* sentinel */ @@ -520,12 +521,15 @@ static int rpmds_init(rpmdsObject * s, PyObject *args, PyObject *kwds) PyObject * to = NULL; int tagN = RPMTAG_REQUIRENAME; int flags = 0; + char * kwlist[] = {"header", "tag", "flags", NULL}; if (_rpmds_debug < 0) fprintf(stderr, "*** rpmds_init(%p,%p,%p)\n", s, args, kwds); - if (!PyArg_ParseTuple(args, "O!|Oi:rpmds_init", &hdr_Type, &ho, &to, &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!|Oi:rpmds_init", kwlist, + &hdr_Type, &ho, &to, &flags)) return -1; + if (to != NULL) { tagN = tagNumFromPyObject(to); if (tagN == -1) { @@ -660,16 +664,19 @@ rpmds_Wrap(rpmds ds) } rpmdsObject * -rpmds_Single(/*@unused@*/ PyObject * s, PyObject * args) +rpmds_Single(/*@unused@*/ PyObject * s, PyObject * args, PyObject * kwds) { PyObject * to = NULL; int tagN = RPMTAG_PROVIDENAME; const char * N; const char * EVR = NULL; int Flags = 0; + char * kwlist[] = {"to", "name", "evr", "flags", NULL}; - if (!PyArg_ParseTuple(args, "Os|si:Single", &to, &N, &EVR, &Flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "Os|si:Single", kwlist, + &to, &N, &EVR, &Flags)) return NULL; + if (to != NULL) { tagN = tagNumFromPyObject(to); if (tagN == -1) { @@ -683,15 +690,18 @@ rpmds_Single(/*@unused@*/ PyObject * s, PyObject * args) } rpmdsObject * -hdr_dsFromHeader(PyObject * s, PyObject * args) +hdr_dsFromHeader(PyObject * s, PyObject * args, PyObject * kwds) { hdrObject * ho = (hdrObject *)s; PyObject * to = NULL; rpmTag tagN = RPMTAG_REQUIRENAME; int flags = 0; + char * kwlist[] = {"to", "flags", NULL}; - if (!PyArg_ParseTuple(args, "|Oi:dsFromHeader", &to, &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oi:dsFromHeader", kwlist, + &to, &flags)) return NULL; + if (to != NULL) { tagN = tagNumFromPyObject(to); if (tagN == -1) { @@ -703,13 +713,11 @@ hdr_dsFromHeader(PyObject * s, PyObject * args) } rpmdsObject * -hdr_dsOfHeader(PyObject * s, PyObject * args) +hdr_dsOfHeader(PyObject * s) { hdrObject * ho = (hdrObject *)s; int tagN = RPMTAG_PROVIDENAME; int Flags = RPMSENSE_EQUAL; - if (!PyArg_ParseTuple(args, ":dsOfHeader")) - return NULL; return rpmds_Wrap( rpmdsThis(hdrGetHeader(ho), tagN, Flags) ); } diff --git a/python/rpmds-py.h b/python/rpmds-py.h index 0a01fe4..8edbd01 100644 --- a/python/rpmds-py.h +++ b/python/rpmds-py.h @@ -37,19 +37,19 @@ rpmdsObject * rpmds_Wrap(rpmds ds) /** */ /*@null@*/ -rpmdsObject * rpmds_Single(PyObject * s, PyObject * args) +rpmdsObject * rpmds_Single(PyObject * s, PyObject * args, PyObject * kwds) /*@*/; /** */ /*@null@*/ -rpmdsObject * hdr_dsFromHeader(PyObject * s, PyObject * args) +rpmdsObject * hdr_dsFromHeader(PyObject * s, PyObject * args, PyObject * kwds) /*@*/; /** */ /*@null@*/ -rpmdsObject * hdr_dsOfHeader(PyObject * s, PyObject * args) +rpmdsObject * hdr_dsOfHeader(PyObject * s) /*@*/; #endif diff --git a/python/rpmfd-py.c b/python/rpmfd-py.c index 453694b..5681494 100644 --- a/python/rpmfd-py.c +++ b/python/rpmfd-py.c @@ -28,11 +28,15 @@ static int _rpmfd_debug = 1; /*@null@*/ static PyObject * -rpmfd_Debug(/*@unused@*/ rpmfdObject * s, PyObject * args) +rpmfd_Debug(/*@unused@*/ rpmfdObject * s, PyObject * args, PyObject * kwds) /*@globals _Py_NoneStruct @*/ /*@modifies _Py_NoneStruct @*/ { - if (!PyArg_ParseTuple(args, "i", &_rpmfd_debug)) return NULL; + char * kwlist[] = {"debugLevel", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", kwlist, &_rpmfd_debug)) + return NULL; + Py_INCREF(Py_None); return Py_None; } @@ -95,15 +99,16 @@ static int closeCallback(FILE * f) */ /*@null@*/ static PyObject * -rpmfd_Fopen(/*@unused@*/ PyObject * s, PyObject * args) +rpmfd_Fopen(/*@unused@*/ PyObject * s, PyObject * args, PyObject * kwds) /*@globals fdhead, fdtail @*/ /*@modifies fdhead, fdtail @*/ { char * path; char * mode = "r.ufdio"; FDlist *node; + char * kwlist[] = {"path", "mode", NULL}; - if (!PyArg_ParseTuple(args, "s|s", &path, &mode)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|s", kwlist, &path, &mode)) return NULL; node = xmalloc (sizeof(FDlist)); @@ -153,9 +158,9 @@ rpmfd_Fopen(/*@unused@*/ PyObject * s, PyObject * args) /*@-fullinitblock@*/ /*@unchecked@*/ /*@observer@*/ static struct PyMethodDef rpmfd_methods[] = { - {"Debug", (PyCFunction)rpmfd_Debug, METH_VARARGS, + {"Debug", (PyCFunction)rpmfd_Debug, METH_VARARGS|METH_KEYWORDS, NULL}, - {"Fopen", (PyCFunction)rpmfd_Fopen, METH_VARARGS, + {"Fopen", (PyCFunction)rpmfd_Fopen, METH_VARARGS|METH_KEYWORDS, NULL}, {NULL, NULL} /* sentinel */ }; @@ -195,11 +200,13 @@ static int rpmfd_init(rpmfdObject * s, PyObject *args, PyObject *kwds) { char * path; char * mode = "r.ufdio"; + char * kwlist[] = {"path", "mode", NULL}; if (_rpmfd_debug) fprintf(stderr, "*** rpmfd_init(%p,%p,%p)\n", s, args, kwds); - if (!PyArg_ParseTuple(args, "s|s:rpmfd_init", &path, &mode)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|s:rpmfd_init", kwlist, + &path, &mode)) return -1; s->fd = Fopen(path, mode); diff --git a/python/rpmfi-py.c b/python/rpmfi-py.c index 2bc46ce..6055bda 100644 --- a/python/rpmfi-py.c +++ b/python/rpmfi-py.c @@ -15,118 +15,111 @@ /*@null@*/ static PyObject * -rpmfi_Debug(/*@unused@*/ rpmfiObject * s, PyObject * args) +rpmfi_Debug(/*@unused@*/ rpmfiObject * s, PyObject * args, PyObject * kwds) /*@globals _Py_NoneStruct @*/ /*@modifies _Py_NoneStruct @*/ { - if (!PyArg_ParseTuple(args, "i", &_rpmfi_debug)) return NULL; + char * kwlist[] = {"debugLevel", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", kwlist, &_rpmfi_debug)) + return NULL; + Py_INCREF(Py_None); return Py_None; } /*@null@*/ static PyObject * -rpmfi_FC(rpmfiObject * s, PyObject * args) +rpmfi_FC(rpmfiObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":FC")) return NULL; return Py_BuildValue("i", rpmfiFC(s->fi)); } /*@null@*/ static PyObject * -rpmfi_FX(rpmfiObject * s, PyObject * args) +rpmfi_FX(rpmfiObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":FX")) return NULL; return Py_BuildValue("i", rpmfiFX(s->fi)); } /*@null@*/ static PyObject * -rpmfi_DC(rpmfiObject * s, PyObject * args) +rpmfi_DC(rpmfiObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":DC")) return NULL; return Py_BuildValue("i", rpmfiDC(s->fi)); } /*@null@*/ static PyObject * -rpmfi_DX(rpmfiObject * s, PyObject * args) +rpmfi_DX(rpmfiObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":DX")) return NULL; return Py_BuildValue("i", rpmfiDX(s->fi)); } /*@null@*/ static PyObject * -rpmfi_BN(rpmfiObject * s, PyObject * args) +rpmfi_BN(rpmfiObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":BN")) return NULL; return Py_BuildValue("s", xstrdup(rpmfiBN(s->fi))); } /*@null@*/ static PyObject * -rpmfi_DN(rpmfiObject * s, PyObject * args) +rpmfi_DN(rpmfiObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":DN")) return NULL; return Py_BuildValue("s", xstrdup(rpmfiDN(s->fi))); } /*@null@*/ static PyObject * -rpmfi_FN(rpmfiObject * s, PyObject * args) +rpmfi_FN(rpmfiObject * s) /*@modifies s @*/ { - if (!PyArg_ParseTuple(args, ":FN")) return NULL; return Py_BuildValue("s", xstrdup(rpmfiFN(s->fi))); } /*@null@*/ static PyObject * -rpmfi_FFlags(rpmfiObject * s, PyObject * args) +rpmfi_FFlags(rpmfiObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":FFlags")) return NULL; return Py_BuildValue("i", rpmfiFFlags(s->fi)); } /*@null@*/ static PyObject * -rpmfi_VFlags(rpmfiObject * s, PyObject * args) +rpmfi_VFlags(rpmfiObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":VFlags")) return NULL; return Py_BuildValue("i", rpmfiVFlags(s->fi)); } /*@null@*/ static PyObject * -rpmfi_FMode(rpmfiObject * s, PyObject * args) +rpmfi_FMode(rpmfiObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":FMode")) return NULL; return Py_BuildValue("i", rpmfiFMode(s->fi)); } /*@null@*/ static PyObject * -rpmfi_FState(rpmfiObject * s, PyObject * args) +rpmfi_FState(rpmfiObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":FState")) return NULL; return Py_BuildValue("i", rpmfiFState(s->fi)); } /* XXX rpmfiMD5 */ /*@null@*/ static PyObject * -rpmfi_MD5(rpmfiObject * s, PyObject * args) +rpmfi_MD5(rpmfiObject * s) /*@*/ { const unsigned char * MD5; @@ -134,7 +127,6 @@ rpmfi_MD5(rpmfiObject * s, PyObject * args) char * t; int i; - if (!PyArg_ParseTuple(args, ":MD5")) return NULL; MD5 = rpmfiMD5(s->fi); t = fmd5; if (MD5 != NULL) @@ -146,75 +138,67 @@ rpmfi_MD5(rpmfiObject * s, PyObject * args) /*@null@*/ static PyObject * -rpmfi_FLink(rpmfiObject * s, PyObject * args) +rpmfi_FLink(rpmfiObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":FLink")) return NULL; return Py_BuildValue("s", xstrdup(rpmfiFLink(s->fi))); } /*@null@*/ static PyObject * -rpmfi_FSize(rpmfiObject * s, PyObject * args) +rpmfi_FSize(rpmfiObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":FSize")) return NULL; return Py_BuildValue("i", rpmfiFSize(s->fi)); } /*@null@*/ static PyObject * -rpmfi_FRdev(rpmfiObject * s, PyObject * args) +rpmfi_FRdev(rpmfiObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":FRdev")) return NULL; return Py_BuildValue("i", rpmfiFRdev(s->fi)); } /*@null@*/ static PyObject * -rpmfi_FMtime(rpmfiObject * s, PyObject * args) +rpmfi_FMtime(rpmfiObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":FMtime")) return NULL; return Py_BuildValue("i", rpmfiFMtime(s->fi)); } /*@null@*/ static PyObject * -rpmfi_FUser(rpmfiObject * s, PyObject * args) +rpmfi_FUser(rpmfiObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":FUser")) return NULL; return Py_BuildValue("s", xstrdup(rpmfiFUser(s->fi))); } /*@null@*/ static PyObject * -rpmfi_FGroup(rpmfiObject * s, PyObject * args) +rpmfi_FGroup(rpmfiObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":FGroup")) return NULL; return Py_BuildValue("s", xstrdup(rpmfiFGroup(s->fi))); } /*@null@*/ static PyObject * -rpmfi_FColor(rpmfiObject * s, PyObject * args) +rpmfi_FColor(rpmfiObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":FColor")) return NULL; return Py_BuildValue("i", rpmfiFColor(s->fi)); } /*@null@*/ static PyObject * -rpmfi_FClass(rpmfiObject * s, PyObject * args) +rpmfi_FClass(rpmfiObject * s) /*@*/ { const char * FClass; - if (!PyArg_ParseTuple(args, ":FClass")) return NULL; if ((FClass = rpmfiFClass(s->fi)) == NULL) FClass = ""; return Py_BuildValue("s", xstrdup(FClass)); @@ -222,7 +206,7 @@ rpmfi_FClass(rpmfiObject * s, PyObject * args) #if Py_TPFLAGS_HAVE_ITER static PyObject * -rpmfi_iter(rpmfiObject * s, /*@unused@*/ PyObject * args) +rpmfi_iter(rpmfiObject * s) /*@*/ { Py_INCREF(s); @@ -312,7 +296,7 @@ rpmfi_iternext(rpmfiObject * s) } static PyObject * -rpmfi_Next(rpmfiObject * s, /*@unused@*/ PyObject * args) +rpmfi_Next(rpmfiObject * s) /*@globals _Py_NoneStruct @*/ /*@modifies s, _Py_NoneStruct @*/ { @@ -331,22 +315,18 @@ rpmfi_Next(rpmfiObject * s, /*@unused@*/ PyObject * args) #ifdef NOTYET /*@null@*/ static PyObject * -rpmfi_NextD(rpmfiObject * s, PyObject * args) +rpmfi_NextD(rpmfiObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":NextD")) - return NULL; Py_INCREF(Py_None); return Py_None; } /*@null@*/ static PyObject * -rpmfi_InitD(rpmfiObject * s, PyObject * args) +rpmfi_InitD(rpmfiObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":InitD")) - return NULL; Py_INCREF(Py_None); return Py_None; } @@ -355,55 +335,55 @@ rpmfi_InitD(rpmfiObject * s, PyObject * args) /*@-fullinitblock@*/ /*@unchecked@*/ /*@observer@*/ static struct PyMethodDef rpmfi_methods[] = { - {"Debug", (PyCFunction)rpmfi_Debug, METH_VARARGS, + {"Debug", (PyCFunction)rpmfi_Debug, METH_VARARGS|METH_KEYWORDS, NULL}, - {"FC", (PyCFunction)rpmfi_FC, METH_VARARGS, + {"FC", (PyCFunction)rpmfi_FC, METH_NOARGS, NULL}, - {"FX", (PyCFunction)rpmfi_FX, METH_VARARGS, + {"FX", (PyCFunction)rpmfi_FX, METH_NOARGS, NULL}, - {"DC", (PyCFunction)rpmfi_DC, METH_VARARGS, + {"DC", (PyCFunction)rpmfi_DC, METH_NOARGS, NULL}, - {"DX", (PyCFunction)rpmfi_DX, METH_VARARGS, + {"DX", (PyCFunction)rpmfi_DX, METH_NOARGS, NULL}, - {"BN", (PyCFunction)rpmfi_BN, METH_VARARGS, + {"BN", (PyCFunction)rpmfi_BN, METH_NOARGS, NULL}, - {"DN", (PyCFunction)rpmfi_DN, METH_VARARGS, + {"DN", (PyCFunction)rpmfi_DN, METH_NOARGS, NULL}, - {"FN", (PyCFunction)rpmfi_FN, METH_VARARGS, + {"FN", (PyCFunction)rpmfi_FN, METH_NOARGS, NULL}, - {"FFlags", (PyCFunction)rpmfi_FFlags, METH_VARARGS, + {"FFlags", (PyCFunction)rpmfi_FFlags, METH_NOARGS, NULL}, - {"VFlags", (PyCFunction)rpmfi_VFlags, METH_VARARGS, + {"VFlags", (PyCFunction)rpmfi_VFlags, METH_NOARGS, NULL}, - {"FMode", (PyCFunction)rpmfi_FMode, METH_VARARGS, + {"FMode", (PyCFunction)rpmfi_FMode, METH_NOARGS, NULL}, - {"FState", (PyCFunction)rpmfi_FState, METH_VARARGS, + {"FState", (PyCFunction)rpmfi_FState, METH_NOARGS, NULL}, - {"MD5", (PyCFunction)rpmfi_MD5, METH_VARARGS, + {"MD5", (PyCFunction)rpmfi_MD5, METH_NOARGS, NULL}, - {"FLink", (PyCFunction)rpmfi_FLink, METH_VARARGS, + {"FLink", (PyCFunction)rpmfi_FLink, METH_NOARGS, NULL}, - {"FSize", (PyCFunction)rpmfi_FSize, METH_VARARGS, + {"FSize", (PyCFunction)rpmfi_FSize, METH_NOARGS, NULL}, - {"FRdev", (PyCFunction)rpmfi_FRdev, METH_VARARGS, + {"FRdev", (PyCFunction)rpmfi_FRdev, METH_NOARGS, NULL}, - {"FMtime", (PyCFunction)rpmfi_FMtime, METH_VARARGS, + {"FMtime", (PyCFunction)rpmfi_FMtime, METH_NOARGS, NULL}, - {"FUser", (PyCFunction)rpmfi_FUser, METH_VARARGS, + {"FUser", (PyCFunction)rpmfi_FUser, METH_NOARGS, NULL}, - {"FGroup", (PyCFunction)rpmfi_FGroup, METH_VARARGS, + {"FGroup", (PyCFunction)rpmfi_FGroup, METH_NOARGS, NULL}, - {"FColor", (PyCFunction)rpmfi_FColor, METH_VARARGS, + {"FColor", (PyCFunction)rpmfi_FColor, METH_NOARGS, NULL}, - {"FClass", (PyCFunction)rpmfi_FClass, METH_VARARGS, + {"FClass", (PyCFunction)rpmfi_FClass, METH_NOARGS, NULL}, - {"next", (PyCFunction)rpmfi_Next, METH_VARARGS, + {"next", (PyCFunction)rpmfi_Next, METH_NOARGS, "fi.next() -> (FN, FSize, FMode, FMtime, FFlags, FRdev, FInode, FNlink, FState, VFlags, FUser, FGroup, FMD5))\n\ - Retrieve next file info tuple.\n" }, #ifdef NOTYET - {"NextD", (PyCFunction)rpmfi_NextD, METH_VARARGS, + {"NextD", (PyCFunction)rpmfi_NextD, METH_NOARGS, NULL}, - {"InitD", (PyCFunction)rpmfi_InitD, METH_VARARGS, + {"InitD", (PyCFunction)rpmfi_InitD, METH_NOARGS, NULL}, #endif {NULL, NULL} /* sentinel */ @@ -490,12 +470,15 @@ static int rpmfi_init(rpmfiObject * s, PyObject *args, PyObject *kwds) rpmts ts = NULL; /* XXX FIXME: fiFromHeader should be a ts method. */ int tagN = RPMTAG_BASENAMES; int flags = 0; + char * kwlist[] = {"header", "tag", "flags", NULL}; if (_rpmfi_debug < 0) fprintf(stderr, "*** rpmfi_init(%p,%p,%p)\n", s, args, kwds); - if (!PyArg_ParseTuple(args, "O!|Oi:rpmfi_init", &hdr_Type, &ho, &to, &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!|Oi:rpmfi_init", kwlist, + &hdr_Type, &ho, &to, &flags)) return -1; + if (to != NULL) { tagN = tagNumFromPyObject(to); if (tagN == -1) { @@ -629,16 +612,19 @@ rpmfi_Wrap(rpmfi fi) } rpmfiObject * -hdr_fiFromHeader(PyObject * s, PyObject * args) +hdr_fiFromHeader(PyObject * s, PyObject * args, PyObject * kwds) { hdrObject * ho = (hdrObject *)s; PyObject * to = NULL; rpmts ts = NULL; /* XXX FIXME: fiFromHeader should be a ts method. */ rpmTag tagN = RPMTAG_BASENAMES; int flags = 0; + char * kwlist[] = {"tag", "flags", NULL}; - if (!PyArg_ParseTuple(args, "|Oi:fiFromHeader", &to, &flags)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oi:fiFromHeader", kwlist, + &to, &flags)) return NULL; + if (to != NULL) { tagN = tagNumFromPyObject(to); if (tagN == -1) { diff --git a/python/rpmfi-py.h b/python/rpmfi-py.h index addff73..372b675 100644 --- a/python/rpmfi-py.h +++ b/python/rpmfi-py.h @@ -27,7 +27,7 @@ rpmfiObject * rpmfi_Wrap(rpmfi fi) /*@*/; /*@null@*/ -rpmfiObject * hdr_fiFromHeader(PyObject * s, PyObject * args) +rpmfiObject * hdr_fiFromHeader(PyObject * s, PyObject * args, PyObject * kwds) /*@globals rpmGlobalMacroContext @*/ /*@modifies rpmGlobalMacroContext @*/; diff --git a/python/rpmfts-py.c b/python/rpmfts-py.c index cde4d0f..b81bada 100644 --- a/python/rpmfts-py.c +++ b/python/rpmfts-py.c @@ -173,11 +173,14 @@ rpmfts_debug(__FUNCTION__, s); /*@null@*/ static PyObject * -rpmfts_Debug(/*@unused@*/ rpmftsObject * s, PyObject * args) +rpmfts_Debug(/*@unused@*/ rpmftsObject * s, PyObject * args, PyObject * kwds) /*@globals _Py_NoneStruct @*/ /*@modifies _Py_NoneStruct @*/ { - if (!PyArg_ParseTuple(args, "i:Debug", &_rpmfts_debug)) + char * kwlist[] = {"debugLevel", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:Debug", kwlist, + &_rpmfts_debug)) return NULL; Py_INCREF(Py_None); @@ -186,16 +189,19 @@ rpmfts_Debug(/*@unused@*/ rpmftsObject * s, PyObject * args) /*@null@*/ static PyObject * -rpmfts_Open(rpmftsObject * s, PyObject * args) +rpmfts_Open(rpmftsObject * s, PyObject * args, PyObject * kwds) /*@modifies s @*/ { char * root = NULL; int options = -1; int ignore = -1; int xx; + /* XXX: there's bound to be a better name than "ignore" */ + char * kwlist[] = {"root", "options", "ignore", NULL}; rpmfts_debug(__FUNCTION__, s); - if (!PyArg_ParseTuple(args, "|sii:Open", &root, &options, &ignore)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|sii:Open", kwlist, + &root, &options, &ignore)) return NULL; xx = rpmfts_initialize(s, root, options, ignore); @@ -206,14 +212,13 @@ rpmfts_debug(__FUNCTION__, s); /*@null@*/ static PyObject * -rpmfts_Read(rpmftsObject * s, PyObject * args) +rpmfts_Read(rpmftsObject * s) /*@globals _Py_NoneStruct @*/ /*@modifies s, _Py_NoneStruct @*/ { PyObject * result; rpmfts_debug(__FUNCTION__, s); - if (!PyArg_ParseTuple(args, ":Read")) return NULL; result = rpmfts_step(s); @@ -227,14 +232,16 @@ rpmfts_debug(__FUNCTION__, s); /*@null@*/ static PyObject * -rpmfts_Children(rpmftsObject * s, PyObject * args) +rpmfts_Children(rpmftsObject * s, PyObject * args, PyObject * kwds) /*@globals _Py_NoneStruct @*/ /*@modifies s, _Py_NoneStruct @*/ { int instr; + char * kwlist[] = {"instructions", NULL}; rpmfts_debug(__FUNCTION__, s); - if (!PyArg_ParseTuple(args, "i:Children", &instr)) return NULL; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:Children", kwlist, &instr)) + return NULL; if (!(s && s->ftsp)) return NULL; @@ -249,26 +256,27 @@ rpmfts_debug(__FUNCTION__, s); /*@null@*/ static PyObject * -rpmfts_Close(rpmftsObject * s, PyObject * args) +rpmfts_Close(rpmftsObject * s) /*@modifies s @*/ { rpmfts_debug(__FUNCTION__, s); - if (!PyArg_ParseTuple(args, ":Close")) return NULL; return Py_BuildValue("i", rpmfts_state(s, RPMFTS_CLOSE)); } /*@null@*/ static PyObject * -rpmfts_Set(rpmftsObject * s, PyObject * args) +rpmfts_Set(rpmftsObject * s, PyObject * args, PyObject * kwds) /*@modifies s @*/ { int instr = 0; int rc = 0; + char * kwlist[] = {"instructions", NULL}; rpmfts_debug(__FUNCTION__, s); - if (!PyArg_ParseTuple(args, "i:Set", &instr)) return NULL; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:Set", kwlist, &instr)) + return NULL; if (s->ftsp && s->fts) rc = Fts_set(s->ftsp, s->fts, instr); @@ -281,17 +289,17 @@ rpmfts_debug(__FUNCTION__, s); /*@-fullinitblock@*/ /*@unchecked@*/ /*@observer@*/ static struct PyMethodDef rpmfts_methods[] = { - {"Debug", (PyCFunction)rpmfts_Debug, METH_VARARGS, + {"Debug", (PyCFunction)rpmfts_Debug, METH_VARARGS|METH_KEYWORDS, NULL}, - {"open", (PyCFunction)rpmfts_Open, METH_VARARGS, + {"open", (PyCFunction)rpmfts_Open, METH_VARARGS|METH_KEYWORDS, NULL}, - {"read", (PyCFunction)rpmfts_Read, METH_VARARGS, + {"read", (PyCFunction)rpmfts_Read, METH_NOARGS, NULL}, - {"children",(PyCFunction)rpmfts_Children, METH_VARARGS, + {"children",(PyCFunction)rpmfts_Children, METH_VARARGS|METH_KEYWORDS, NULL}, - {"close", (PyCFunction)rpmfts_Close, METH_VARARGS, + {"close", (PyCFunction)rpmfts_Close, METH_NOARGS, NULL}, - {"set", (PyCFunction)rpmfts_Set, METH_VARARGS, + {"set", (PyCFunction)rpmfts_Set, METH_VARARGS|METH_KEYWORDS, NULL}, {NULL, NULL} /* sentinel */ }; @@ -390,9 +398,11 @@ static int rpmfts_init(rpmftsObject * s, PyObject *args, PyObject *kwds) char * root = NULL; int options = -1; int ignore = -1; + char * kwlist[] = {"root", "options", "ignore", NULL}; rpmfts_debug(__FUNCTION__, s); - if (!PyArg_ParseTuple(args, "|sii:rpmfts_init", &root, &options, &ignore)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|sii:rpmfts_init", kwlist, + &root, &options, &ignore)) return -1; return rpmfts_initialize(s, root, options, ignore); @@ -405,7 +415,11 @@ static PyObject * rpmfts_new(PyTypeObject *type, PyObject *args, PyObject *kwds) rpmftsObject *s; PyObject *o; PyObject *n = NULL; + char * kwlist[] = {0}; + /* All the other _new() functions claim to be _init in their errors...*/ + if (!PyArg_ParseTupleAndKeywords(args, kwds, ":rpmfts_new", kwlist)) + return NULL; if ((s = PyObject_GC_New(rpmftsObject, type)) == NULL) return NULL; diff --git a/python/rpmmi-py.c b/python/rpmmi-py.c index 8cb63be..d6ca7ce 100644 --- a/python/rpmmi-py.c +++ b/python/rpmmi-py.c @@ -97,15 +97,12 @@ rpmmi_iternext(rpmmiObject * s) */ /*@null@*/ static PyObject * -rpmmi_Next(rpmmiObject * s, PyObject *args) +rpmmi_Next(rpmmiObject * s) /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/ { PyObject * result; - if (!PyArg_ParseTuple(args, ":Next")) - return NULL; - result = rpmmi_iternext(s); if (result == NULL) { @@ -119,14 +116,11 @@ rpmmi_Next(rpmmiObject * s, PyObject *args) */ /*@null@*/ static PyObject * -rpmmi_Instance(rpmmiObject * s, PyObject * args) +rpmmi_Instance(rpmmiObject * s) /*@*/ { int rc = 0; - if (!PyArg_ParseTuple(args, ":Instance")) - return NULL; - if (s->mi != NULL) rc = rpmdbGetIteratorOffset(s->mi); @@ -137,14 +131,11 @@ rpmmi_Instance(rpmmiObject * s, PyObject * args) */ /*@null@*/ static PyObject * -rpmmi_Count(rpmmiObject * s, PyObject * args) +rpmmi_Count(rpmmiObject * s) /*@*/ { int rc = 0; - if (!PyArg_ParseTuple(args, ":Instance")) - return NULL; - if (s->mi != NULL) rc = rpmdbGetIteratorCount(s->mi); @@ -155,7 +146,7 @@ rpmmi_Count(rpmmiObject * s, PyObject * args) */ /*@null@*/ static PyObject * -rpmmi_Pattern(rpmmiObject * s, PyObject * args) +rpmmi_Pattern(rpmmiObject * s, PyObject * args, PyObject * kwds) /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/ { @@ -163,8 +154,10 @@ rpmmi_Pattern(rpmmiObject * s, PyObject * args) int type; char * pattern; rpmTag tag; + char * kwlist[] = {"tag", "type", "patern", NULL}; - if (!PyArg_ParseTuple(args, "Ois:Pattern", &TagN, &type, &pattern)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "Ois:Pattern", kwlist, + &TagN, &type, &pattern)) return NULL; if ((tag = tagNumFromPyObject (TagN)) == -1) { @@ -184,14 +177,14 @@ rpmmi_Pattern(rpmmiObject * s, PyObject * args) /*@-fullinitblock@*/ /*@unchecked@*/ /*@observer@*/ static struct PyMethodDef rpmmi_methods[] = { - {"next", (PyCFunction) rpmmi_Next, METH_VARARGS, + {"next", (PyCFunction) rpmmi_Next, METH_NOARGS, "mi.next() -> hdr\n\ - Retrieve next header that matches. Iterate directly in python if possible.\n" }, - {"instance", (PyCFunction) rpmmi_Instance, METH_VARARGS, + {"instance", (PyCFunction) rpmmi_Instance, METH_NOARGS, NULL }, - {"count", (PyCFunction) rpmmi_Count, METH_VARARGS, + {"count", (PyCFunction) rpmmi_Count, METH_NOARGS, NULL }, - {"pattern", (PyCFunction) rpmmi_Pattern, METH_VARARGS, + {"pattern", (PyCFunction) rpmmi_Pattern, METH_VARARGS|METH_KEYWORDS, "mi.pattern(TagN, mire_type, pattern)\n\ - Set a secondary match pattern on tags from retrieved header.\n" }, {NULL, NULL} /* sentinel */ diff --git a/python/rpmmodule.c b/python/rpmmodule.c index 7cd6e50..204717e 100644 --- a/python/rpmmodule.c +++ b/python/rpmmodule.c @@ -39,12 +39,13 @@ /** */ -static PyObject * archScore(PyObject * self, PyObject * args) +static PyObject * archScore(PyObject * self, PyObject * args, PyObject * kwds) { char * arch; int score; + char * kwlist[] = {"arch", NULL}; - if (!PyArg_ParseTuple(args, "s", &arch)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist, &arch)) return NULL; score = rpmMachineScore(RPM_MACHTABLE_INSTARCH, arch); @@ -54,12 +55,13 @@ static PyObject * archScore(PyObject * self, PyObject * args) /** */ -static PyObject * setLogFile (PyObject * self, PyObject * args) +static PyObject * setLogFile (PyObject * self, PyObject * args, PyObject *kwds) { PyObject * fop = NULL; FILE * fp = NULL; + char * kwlist[] = {"fileObject", NULL}; - if (!PyArg_ParseTuple(args, "|O:logSetFile", &fop)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:logSetFile", kwlist, &fop)) return NULL; if (fop) { @@ -78,11 +80,13 @@ static PyObject * setLogFile (PyObject * self, PyObject * args) /** */ -static PyObject * setVerbosity (PyObject * self, PyObject * args) +static PyObject * +setVerbosity (PyObject * self, PyObject * args, PyObject *kwds) { int level; + char * kwlist[] = {"level", NULL}; - if (!PyArg_ParseTuple(args, "i", &level)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", kwlist, &level)) return NULL; rpmSetVerbosity(level); @@ -93,20 +97,28 @@ static PyObject * setVerbosity (PyObject * self, PyObject * args) /** */ -static PyObject * setEpochPromote (PyObject * self, PyObject * args) +static PyObject * +setEpochPromote (PyObject * self, PyObject * args, PyObject * kwds) { - if (!PyArg_ParseTuple(args, "i", &_rpmds_nopromote)) + char * kwlist[] = {"promote", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", kwlist, + &_rpmds_nopromote)) return NULL; + Py_INCREF(Py_None); return (PyObject *) Py_None; } /** */ -static PyObject * setStats (PyObject * self, PyObject * args) +static PyObject * setStats (PyObject * self, PyObject * args, PyObject * kwds) { - if (!PyArg_ParseTuple(args, "i", &_rpmts_stats)) + char * kwlist[] = {"stats", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", kwlist, &_rpmts_stats)) return NULL; + Py_INCREF(Py_None); return (PyObject *) Py_None; } @@ -114,7 +126,7 @@ static PyObject * setStats (PyObject * self, PyObject * args) /** */ static PyMethodDef rpmModuleMethods[] = { - { "TransactionSet", (PyCFunction) rpmts_Create, METH_VARARGS, + { "TransactionSet", (PyCFunction) rpmts_Create, METH_VARARGS|METH_KEYWORDS, "rpm.TransactionSet([rootDir, [db]]) -> ts\n\ - Create a transaction set.\n" }, @@ -122,42 +134,42 @@ static PyMethodDef rpmModuleMethods[] = { { "newrc", (PyCFunction) rpmrc_Create, METH_VARARGS|METH_KEYWORDS, NULL }, #endif - { "addMacro", (PyCFunction) rpmrc_AddMacro, METH_VARARGS, + { "addMacro", (PyCFunction) rpmrc_AddMacro, METH_VARARGS|METH_KEYWORDS, NULL }, - { "delMacro", (PyCFunction) rpmrc_DelMacro, METH_VARARGS, + { "delMacro", (PyCFunction) rpmrc_DelMacro, METH_VARARGS|METH_KEYWORDS, NULL }, - { "archscore", (PyCFunction) archScore, METH_VARARGS, + { "archscore", (PyCFunction) archScore, METH_VARARGS|METH_KEYWORDS, NULL }, - { "headerLoad", (PyCFunction) hdrLoad, METH_VARARGS, + { "headerLoad", (PyCFunction) hdrLoad, METH_VARARGS|METH_KEYWORDS, NULL }, - { "rhnLoad", (PyCFunction) rhnLoad, METH_VARARGS, + { "rhnLoad", (PyCFunction) rhnLoad, METH_VARARGS|METH_KEYWORDS, NULL }, - { "mergeHeaderListFromFD", (PyCFunction) rpmMergeHeadersFromFD, METH_VARARGS, + { "mergeHeaderListFromFD", (PyCFunction) rpmMergeHeadersFromFD, METH_VARARGS|METH_KEYWORDS, NULL }, - { "readHeaderListFromFD", (PyCFunction) rpmHeaderFromFD, METH_VARARGS, + { "readHeaderListFromFD", (PyCFunction) rpmHeaderFromFD, METH_VARARGS|METH_KEYWORDS, NULL }, - { "readHeaderListFromFile", (PyCFunction) rpmHeaderFromFile, METH_VARARGS, + { "readHeaderListFromFile", (PyCFunction) rpmHeaderFromFile, METH_VARARGS|METH_KEYWORDS, NULL }, - { "readHeaderFromFD", (PyCFunction) rpmSingleHeaderFromFD, METH_VARARGS, + { "readHeaderFromFD", (PyCFunction) rpmSingleHeaderFromFD, METH_VARARGS|METH_KEYWORDS, NULL }, - { "setLogFile", (PyCFunction) setLogFile, METH_VARARGS, + { "setLogFile", (PyCFunction) setLogFile, METH_VARARGS|METH_KEYWORDS, NULL }, - { "versionCompare", (PyCFunction) versionCompare, METH_VARARGS, + { "versionCompare", (PyCFunction) versionCompare, METH_VARARGS|METH_KEYWORDS, NULL }, - { "labelCompare", (PyCFunction) labelCompare, METH_VARARGS, + { "labelCompare", (PyCFunction) labelCompare, METH_VARARGS|METH_KEYWORDS, NULL }, - { "setVerbosity", (PyCFunction) setVerbosity, METH_VARARGS, + { "setVerbosity", (PyCFunction) setVerbosity, METH_VARARGS|METH_KEYWORDS, NULL }, - { "setEpochPromote", (PyCFunction) setEpochPromote, METH_VARARGS, + { "setEpochPromote", (PyCFunction) setEpochPromote, METH_VARARGS|METH_KEYWORDS, NULL }, - { "setStats", (PyCFunction) setStats, METH_VARARGS, + { "setStats", (PyCFunction) setStats, METH_VARARGS|METH_KEYWORDS, NULL }, - { "dsSingle", (PyCFunction) rpmds_Single, METH_VARARGS, + { "dsSingle", (PyCFunction) rpmds_Single, METH_VARARGS|METH_KEYWORDS, "rpm.dsSingle(TagN, N, [EVR, [Flags]] -> ds\n\ - Create a single element dependency set.\n" }, { NULL } diff --git a/python/rpmps-py.c b/python/rpmps-py.c index 9d7bdef..52fd7d6 100644 --- a/python/rpmps-py.c +++ b/python/rpmps-py.c @@ -19,11 +19,15 @@ /*@null@*/ static PyObject * -rpmps_Debug(/*@unused@*/ rpmpsObject * s, PyObject * args) +rpmps_Debug(/*@unused@*/ rpmpsObject * s, PyObject * args, PyObject * kwds) /*@globals _Py_NoneStruct @*/ /*@modifies _Py_NoneStruct @*/ { - if (!PyArg_ParseTuple(args, "i", &_rpmps_debug)) return NULL; + char * kwlist[] = {"debugLevel", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", kwlist, &_rpmps_debug)) + return NULL; + Py_INCREF(Py_None); return Py_None; } @@ -70,7 +74,7 @@ fprintf(stderr, "*** rpmps_iternext(%p) ps %p ix %d active %d\n", s, s->ps, s->i /*@-fullinitblock@*/ /*@unchecked@*/ /*@observer@*/ static struct PyMethodDef rpmps_methods[] = { - {"Debug", (PyCFunction)rpmps_Debug, METH_VARARGS, + {"Debug", (PyCFunction)rpmps_Debug, METH_VARARGS|METH_KEYWORDS, NULL}, {NULL, NULL} /* sentinel */ }; @@ -238,11 +242,12 @@ static PyMappingMethods rpmps_as_mapping = { static int rpmps_init(rpmpsObject * s, PyObject *args, PyObject *kwds) /*@modifies s @*/ { + char * kwlist[] = {NULL}; if (_rpmps_debug < 0) fprintf(stderr, "*** rpmps_init(%p,%p,%p)\n", s, args, kwds); - if (!PyArg_ParseTuple(args, ":rpmps_init")) + if (!PyArg_ParseTupleAndKeywords(args, kwds, ":rpmps_init", kwlist)) return -1; s->ps = rpmpsCreate(); diff --git a/python/rpmrc-py.c b/python/rpmrc-py.c index 404a328..97b9ac0 100644 --- a/python/rpmrc-py.c +++ b/python/rpmrc-py.c @@ -29,11 +29,14 @@ static int _rc_debug = 0; /** */ -PyObject * rpmrc_AddMacro(/*@unused@*/ PyObject * self, PyObject * args) +PyObject * +rpmrc_AddMacro(/*@unused@*/ PyObject * self, PyObject * args, PyObject * kwds) { char * name, * val; + char * kwlist[] = {"name", "value", NULL}; - if (!PyArg_ParseTuple(args, "ss:AddMacro", &name, &val)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "ss:AddMacro", kwlist, + &name, &val)) return NULL; addMacro(NULL, name, NULL, val, -1); @@ -44,11 +47,13 @@ PyObject * rpmrc_AddMacro(/*@unused@*/ PyObject * self, PyObject * args) /** */ -PyObject * rpmrc_DelMacro(/*@unused@*/ PyObject * self, PyObject * args) +PyObject * +rpmrc_DelMacro(/*@unused@*/ PyObject * self, PyObject * args, PyObject * kwds) { char * name; + char * kwlist[] = {"name", NULL}; - if (!PyArg_ParseTuple(args, "s:DelMacro", &name)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s:DelMacro", kwlist, &name)) return NULL; delMacro(NULL, name); @@ -236,6 +241,7 @@ fprintf(stderr, "*** rpmrc_iternext(%p[%s])\n", s, lbl(s)); /** */ /*@null@*/ +/* XXX: does this _actually_ take any arguments? I don't think it does... */ static PyObject * rpmrc_next(PyObject * s, PyObject *args) /*@*/ { @@ -312,9 +318,9 @@ fprintf(stderr, "*** rpmrc_new(%p[%s],%p,%p) ret %p[%s]\n", subtype, lbl(subtype /*@-fullinitblock@*/ /*@unchecked@*/ /*@observer@*/ static struct PyMethodDef rpmrc_methods[] = { - { "addMacro", (PyCFunction) rpmrc_AddMacro, METH_VARARGS, + { "addMacro", (PyCFunction) rpmrc_AddMacro, METH_VARARGS|METH_KEYWORDS, NULL }, - { "delMacro", (PyCFunction) rpmrc_DelMacro, METH_VARARGS, + { "delMacro", (PyCFunction) rpmrc_DelMacro, METH_VARARGS|METH_KEYWORDS, NULL }, #if Py_TPFLAGS_HAVE_ITER && PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 4 { "next", (PyCFunction) rpmrc_next, METH_VARARGS, diff --git a/python/rpmrc-py.h b/python/rpmrc-py.h index 1ebfa67..619e8f9 100644 --- a/python/rpmrc-py.h +++ b/python/rpmrc-py.h @@ -24,11 +24,11 @@ struct rpmrcObject_s { extern PyTypeObject rpmrc_Type; /*@null@*/ -PyObject * rpmrc_AddMacro(PyObject * self, PyObject * args) +PyObject * rpmrc_AddMacro(PyObject * self, PyObject * args, PyObject * kwds) /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ /*@modifies rpmGlobalMacroContext, _Py_NoneStruct @*/; /*@null@*/ -PyObject * rpmrc_DelMacro(PyObject * self, PyObject * args) +PyObject * rpmrc_DelMacro(PyObject * self, PyObject * args, PyObject * kwds) /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ /*@modifies rpmGlobalMacroContext, _Py_NoneStruct @*/; diff --git a/python/rpmte-py.c b/python/rpmte-py.c index 11f5157..4f40bbd 100644 --- a/python/rpmte-py.c +++ b/python/rpmte-py.c @@ -54,186 +54,171 @@ /*@null@*/ static PyObject * -rpmte_Debug(/*@unused@*/ rpmteObject * s, /*@unused@*/ PyObject * args) +rpmte_Debug(/*@unused@*/ rpmteObject * s, PyObject * args, PyObject * kwds) /*@globals _Py_NoneStruct @*/ /*@modifies _Py_NoneStruct @*/ { - if (!PyArg_ParseTuple(args, "i", &_rpmte_debug)) return NULL; + char * kwlist[] = {"debugLevel", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", kwlist, &_rpmte_debug)) + return NULL; + Py_INCREF(Py_None); return Py_None; } /*@null@*/ static PyObject * -rpmte_TEType(rpmteObject * s, PyObject * args) +rpmte_TEType(rpmteObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":TEType")) return NULL; return Py_BuildValue("i", rpmteType(s->te)); } /*@null@*/ static PyObject * -rpmte_N(rpmteObject * s, PyObject * args) +rpmte_N(rpmteObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":N")) return NULL; return Py_BuildValue("s", rpmteN(s->te)); } /*@null@*/ static PyObject * -rpmte_E(rpmteObject * s, PyObject * args) +rpmte_E(rpmteObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":E")) return NULL; return Py_BuildValue("s", rpmteE(s->te)); } /*@null@*/ static PyObject * -rpmte_V(rpmteObject * s, PyObject * args) +rpmte_V(rpmteObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":V")) return NULL; return Py_BuildValue("s", rpmteV(s->te)); } /*@null@*/ static PyObject * -rpmte_R(rpmteObject * s, PyObject * args) +rpmte_R(rpmteObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":R")) return NULL; return Py_BuildValue("s", rpmteR(s->te)); } /*@null@*/ static PyObject * -rpmte_A(rpmteObject * s, PyObject * args) +rpmte_A(rpmteObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":A")) return NULL; return Py_BuildValue("s", rpmteA(s->te)); } /*@null@*/ static PyObject * -rpmte_O(rpmteObject * s, PyObject * args) +rpmte_O(rpmteObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":O")) return NULL; return Py_BuildValue("s", rpmteO(s->te)); } /*@null@*/ static PyObject * -rpmte_NEVR(rpmteObject * s, PyObject * args) +rpmte_NEVR(rpmteObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":NEVR")) return NULL; return Py_BuildValue("s", rpmteNEVR(s->te)); } /*@null@*/ static PyObject * -rpmte_Color(rpmteObject * s, PyObject * args) +rpmte_Color(rpmteObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":Color")) return NULL; return Py_BuildValue("i", rpmteColor(s->te)); } /*@null@*/ static PyObject * -rpmte_PkgFileSize(rpmteObject * s, PyObject * args) +rpmte_PkgFileSize(rpmteObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":PkgFileSize")) return NULL; return Py_BuildValue("i", rpmtePkgFileSize(s->te)); } /*@null@*/ static PyObject * -rpmte_Depth(rpmteObject * s, PyObject * args) +rpmte_Depth(rpmteObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":Depth")) return NULL; return Py_BuildValue("i", rpmteDepth(s->te)); } /*@null@*/ static PyObject * -rpmte_Npreds(rpmteObject * s, PyObject * args) +rpmte_Npreds(rpmteObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":Npreds")) return NULL; return Py_BuildValue("i", rpmteNpreds(s->te)); } /*@null@*/ static PyObject * -rpmte_Degree(rpmteObject * s, PyObject * args) +rpmte_Degree(rpmteObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":Degree")) return NULL; return Py_BuildValue("i", rpmteDegree(s->te)); } /*@null@*/ static PyObject * -rpmte_Parent(rpmteObject * s, PyObject * args) +rpmte_Parent(rpmteObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":Parent")) return NULL; return Py_BuildValue("i", rpmteParent(s->te)); } /*@null@*/ static PyObject * -rpmte_Tree(rpmteObject * s, PyObject * args) +rpmte_Tree(rpmteObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":Tree")) return NULL; return Py_BuildValue("i", rpmteTree(s->te)); } /*@null@*/ static PyObject * -rpmte_AddedKey(rpmteObject * s, PyObject * args) +rpmte_AddedKey(rpmteObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":AddedKey")) return NULL; return Py_BuildValue("i", rpmteAddedKey(s->te)); } /*@null@*/ static PyObject * -rpmte_DependsOnKey(rpmteObject * s, PyObject * args) +rpmte_DependsOnKey(rpmteObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":DependsOnKey")) return NULL; return Py_BuildValue("i", rpmteDependsOnKey(s->te)); } /*@null@*/ static PyObject * -rpmte_DBOffset(rpmteObject * s, PyObject * args) +rpmte_DBOffset(rpmteObject * s) /*@*/ { - if (!PyArg_ParseTuple(args, ":DBOffset")) return NULL; return Py_BuildValue("i", rpmteDBOffset(s->te)); } /*@null@*/ static PyObject * -rpmte_Key(rpmteObject * s, PyObject * args) +rpmte_Key(rpmteObject * s) /*@globals _Py_NoneStruct @*/ /*@modifies _Py_NoneStruct @*/ { PyObject * Key; - if (!PyArg_ParseTuple(args, ":Key")) return NULL; /* XXX how to insure this is a PyObject??? */ Key = (PyObject *) rpmteKey(s->te); if (Key == NULL) { @@ -245,15 +230,17 @@ rpmte_Key(rpmteObject * s, PyObject * args) /*@null@*/ static PyObject * -rpmte_DS(rpmteObject * s, PyObject * args) +rpmte_DS(rpmteObject * s, PyObject * args, PyObject * kwds) /*@globals _Py_NoneStruct @*/ /*@modifies _Py_NoneStruct @*/ { PyObject * TagN = NULL; rpmds ds; rpmTag tag; + char * kwlist[] = {"tag", NULL}; - if (!PyArg_ParseTuple(args, "O:DS", &TagN)) return NULL; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:DS", kwlist, &TagN)) + return NULL; tag = tagNumFromPyObject(TagN); if (tag == -1) { @@ -276,15 +263,17 @@ rpmte_DS(rpmteObject * s, PyObject * args) /*@null@*/ static PyObject * -rpmte_FI(rpmteObject * s, PyObject * args) +rpmte_FI(rpmteObject * s, PyObject * args, PyObject * kwds) /*@globals _Py_NoneStruct @*/ /*@modifies _Py_NoneStruct @*/ { PyObject * TagN = NULL; rpmfi fi; rpmTag tag; + char * kwlist[] = {"tag", NULL}; - if (!PyArg_ParseTuple(args, "O:FI", &TagN)) return NULL; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:FI", kwlist, &TagN)) + return NULL; tag = tagNumFromPyObject(TagN); if (tag == -1) { @@ -310,59 +299,59 @@ rpmte_FI(rpmteObject * s, PyObject * args) /*@-fullinitblock@*/ /*@unchecked@*/ /*@observer@*/ static struct PyMethodDef rpmte_methods[] = { - {"Debug", (PyCFunction)rpmte_Debug, METH_VARARGS, + {"Debug", (PyCFunction)rpmte_Debug, METH_VARARGS|METH_KEYWORDS, NULL}, - {"Type", (PyCFunction)rpmte_TEType, METH_VARARGS, + {"Type", (PyCFunction)rpmte_TEType, METH_NOARGS, "te.Type() -> Type\n\ - Return element type (rpm.TR_ADDED | rpm.TR_REMOVED).\n" }, - {"N", (PyCFunction)rpmte_N, METH_VARARGS, + {"N", (PyCFunction)rpmte_N, METH_NOARGS, "te.N() -> N\n\ - Return element name.\n" }, - {"E", (PyCFunction)rpmte_E, METH_VARARGS, + {"E", (PyCFunction)rpmte_E, METH_NOARGS, "te.E() -> E\n\ - Return element epoch.\n" }, - {"V", (PyCFunction)rpmte_V, METH_VARARGS, + {"V", (PyCFunction)rpmte_V, METH_NOARGS, "te.V() -> V\n\ - Return element version.\n" }, - {"R", (PyCFunction)rpmte_R, METH_VARARGS, + {"R", (PyCFunction)rpmte_R, METH_NOARGS, "te.R() -> R\n\ - Return element release.\n" }, - {"A", (PyCFunction)rpmte_A, METH_VARARGS, + {"A", (PyCFunction)rpmte_A, METH_NOARGS, "te.A() -> A\n\ - Return element arch.\n" }, - {"O", (PyCFunction)rpmte_O, METH_VARARGS, + {"O", (PyCFunction)rpmte_O, METH_NOARGS, "te.O() -> O\n\ - Return element os.\n" }, - {"NEVR", (PyCFunction)rpmte_NEVR, METH_VARARGS, + {"NEVR", (PyCFunction)rpmte_NEVR, METH_NOARGS, "te.NEVR() -> NEVR\n\ - Return element name-version-release.\n" }, - {"Color",(PyCFunction)rpmte_Color, METH_VARARGS, + {"Color",(PyCFunction)rpmte_Color, METH_NOARGS, NULL}, - {"PkgFileSize",(PyCFunction)rpmte_PkgFileSize, METH_VARARGS, + {"PkgFileSize",(PyCFunction)rpmte_PkgFileSize, METH_NOARGS, NULL}, - {"Depth", (PyCFunction)rpmte_Depth, METH_VARARGS, + {"Depth", (PyCFunction)rpmte_Depth, METH_NOARGS, NULL}, - {"Npreds", (PyCFunction)rpmte_Npreds, METH_VARARGS, + {"Npreds", (PyCFunction)rpmte_Npreds, METH_NOARGS, NULL}, - {"Degree", (PyCFunction)rpmte_Degree, METH_VARARGS, + {"Degree", (PyCFunction)rpmte_Degree, METH_NOARGS, NULL}, - {"Parent", (PyCFunction)rpmte_Parent, METH_VARARGS, + {"Parent", (PyCFunction)rpmte_Parent, METH_NOARGS, NULL}, - {"Tree", (PyCFunction)rpmte_Tree, METH_VARARGS, + {"Tree", (PyCFunction)rpmte_Tree, METH_NOARGS, NULL}, - {"AddedKey",(PyCFunction)rpmte_AddedKey, METH_VARARGS, + {"AddedKey",(PyCFunction)rpmte_AddedKey, METH_NOARGS, NULL}, - {"DependsOnKey",(PyCFunction)rpmte_DependsOnKey, METH_VARARGS, + {"DependsOnKey",(PyCFunction)rpmte_DependsOnKey, METH_NOARGS, NULL}, - {"DBOffset",(PyCFunction)rpmte_DBOffset, METH_VARARGS, + {"DBOffset",(PyCFunction)rpmte_DBOffset, METH_NOARGS, NULL}, - {"Key", (PyCFunction)rpmte_Key, METH_VARARGS, + {"Key", (PyCFunction)rpmte_Key, METH_NOARGS, NULL}, - {"DS", (PyCFunction)rpmte_DS, METH_VARARGS, + {"DS", (PyCFunction)rpmte_DS, METH_VARARGS|METH_KEYWORDS, "te.DS(TagN) -> DS\n\ - Return the TagN dependency set (or None). TagN is one of\n\ 'Providename', 'Requirename', 'Obsoletename', 'Conflictname'\n" }, - {"FI", (PyCFunction)rpmte_FI, METH_VARARGS, + {"FI", (PyCFunction)rpmte_FI, METH_VARARGS|METH_KEYWORDS, "te.FI(TagN) -> FI\n\ - Return the TagN dependency set (or None). TagN must be 'Basenames'.\n" }, {NULL, NULL} /* sentinel */ diff --git a/python/rpmts-py.c b/python/rpmts-py.c index 102a1cb..56d386a 100644 --- a/python/rpmts-py.c +++ b/python/rpmts-py.c @@ -168,11 +168,15 @@ struct rpmtsCallbackType_s { */ /*@null@*/ static PyObject * -rpmts_Debug(/*@unused@*/ rpmtsObject * s, PyObject * args) +rpmts_Debug(/*@unused@*/ rpmtsObject * s, PyObject * args, PyObject * kwds) /*@globals _Py_NoneStruct @*/ /*@modifies _Py_NoneStruct @*/ { - if (!PyArg_ParseTuple(args, "i:Debug", &_rpmts_debug)) return NULL; + char * kwlist[] = {"debugLevel", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:Debug", kwlist, + &_rpmts_debug)) + return NULL; if (_rpmts_debug < 0) fprintf(stderr, "*** rpmts_Debug(%p) ts %p\n", s, s->ts); @@ -211,7 +215,7 @@ fprintf(stderr, "\tAddAvailable(%p) list %p\n", ts, ts->availablePackages); */ /*@null@*/ static PyObject * -rpmts_AddInstall(rpmtsObject * s, PyObject * args) +rpmts_AddInstall(rpmtsObject * s, PyObject * args, PyObject * kwds) /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/ { @@ -219,8 +223,10 @@ rpmts_AddInstall(rpmtsObject * s, PyObject * args) PyObject * key; char * how = "u"; /* XXX default to upgrade element if missing */ int isUpgrade = 0; + char * kwlist[] = {"header", "key", "how", NULL}; - if (!PyArg_ParseTuple(args, "O!O|s:AddInstall", &hdr_Type, &h, &key, &how)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!O|s:AddInstall", kwlist, + &hdr_Type, &h, &key, &how)) return NULL; { PyObject * hObj = (PyObject *) h; @@ -257,18 +263,19 @@ fprintf(stderr, "*** rpmts_AddInstall(%p,%p,%p,%s) ts %p\n", s, h, key, how, s-> */ /*@null@*/ static PyObject * -rpmts_AddErase(rpmtsObject * s, PyObject * args) +rpmts_AddErase(rpmtsObject * s, PyObject * args, PyObject * kwds) /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/ { PyObject * o; int count; rpmdbMatchIterator mi; + char * kwlist[] = {"name", NULL}; if (_rpmts_debug) fprintf(stderr, "*** rpmts_AddErase(%p) ts %p\n", s, s->ts); - if (!PyArg_ParseTuple(args, "O:AddErase", &o)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:AddErase", kwlist, &o)) return NULL; if (PyString_Check(o)) { @@ -355,7 +362,7 @@ fprintf(stderr, "*** rpmts_SolveCallback(%p,%p,%p) \"%s\"\n", ts, ds, data, rpmd */ /*@null@*/ static PyObject * -rpmts_Check(rpmtsObject * s, PyObject * args) +rpmts_Check(rpmtsObject * s, PyObject * args, PyObject * kwds) /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/ { @@ -365,9 +372,11 @@ rpmts_Check(rpmtsObject * s, PyObject * args) struct rpmtsCallbackType_s cbInfo; int i; int xx; + char * kwlist[] = {"callback", NULL}; memset(&cbInfo, 0, sizeof(cbInfo)); - if (!PyArg_ParseTuple(args, "|O:Check", &cbInfo.cb)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:Check", kwlist, + &cbInfo.cb)) return NULL; if (cbInfo.cb != NULL) { @@ -475,7 +484,7 @@ fprintf(stderr, "*** rpmts_Check(%p) ts %p cb %p\n", s, s->ts, cbInfo.cb); */ /*@null@*/ static PyObject * -rpmts_Order(rpmtsObject * s, PyObject * args) +rpmts_Order(rpmtsObject * s) /*@globals rpmGlobalMacroContext @*/ /*@modifies s, rpmGlobalMacroContext @*/ { @@ -484,8 +493,6 @@ rpmts_Order(rpmtsObject * s, PyObject * args) if (_rpmts_debug) fprintf(stderr, "*** rpmts_Order(%p) ts %p\n", s, s->ts); - if (!PyArg_ParseTuple(args, ":Order")) return NULL; - Py_BEGIN_ALLOW_THREADS rc = rpmtsOrder(s->ts); Py_END_ALLOW_THREADS @@ -497,15 +504,13 @@ fprintf(stderr, "*** rpmts_Order(%p) ts %p\n", s, s->ts); */ /*@null@*/ static PyObject * -rpmts_Clean(rpmtsObject * s, PyObject * args) +rpmts_Clean(rpmtsObject * s) /*@globals _Py_NoneStruct @*/ /*@modifies s, _Py_NoneStruct @*/ { if (_rpmts_debug) fprintf(stderr, "*** rpmts_Clean(%p) ts %p\n", s, s->ts); - if (!PyArg_ParseTuple(args, ":Clean")) return NULL; - rpmtsClean(s->ts); Py_INCREF(Py_None); @@ -516,7 +521,7 @@ fprintf(stderr, "*** rpmts_Clean(%p) ts %p\n", s, s->ts); */ /*@null@*/ static PyObject * -rpmts_IDTXload(rpmtsObject * s, PyObject * args) +rpmts_IDTXload(rpmtsObject * s) /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/ { @@ -527,8 +532,6 @@ rpmts_IDTXload(rpmtsObject * s, PyObject * args) if (_rpmts_debug) fprintf(stderr, "*** rpmts_IDTXload(%p) ts %p\n", s, s->ts); - if (!PyArg_ParseTuple(args, ":IDTXload")) return NULL; - Py_BEGIN_ALLOW_THREADS idtx = IDTXload(s->ts, tag); Py_END_ALLOW_THREADS @@ -563,7 +566,7 @@ fprintf(stderr, "*** rpmts_IDTXload(%p) ts %p\n", s, s->ts); */ /*@null@*/ static PyObject * -rpmts_IDTXglob(rpmtsObject * s, PyObject * args) +rpmts_IDTXglob(rpmtsObject * s) /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/ { @@ -575,8 +578,6 @@ rpmts_IDTXglob(rpmtsObject * s, PyObject * args) if (_rpmts_debug) fprintf(stderr, "*** rpmts_IDTXglob(%p) ts %p\n", s, s->ts); - if (!PyArg_ParseTuple(args, ":IDTXglob")) return NULL; - Py_BEGIN_ALLOW_THREADS globstr = rpmExpand("%{_repackage_dir}/*.rpm", NULL); idtx = IDTXglob(s->ts, globstr, tag); @@ -613,7 +614,7 @@ fprintf(stderr, "*** rpmts_IDTXglob(%p) ts %p\n", s, s->ts); */ /*@null@*/ static PyObject * -rpmts_Rollback(rpmtsObject * s, PyObject * args) +rpmts_Rollback(rpmtsObject * s, PyObject * args, PyObject * kwds) /*@globals rpmGlobalMacroContext @*/ /*@modifies s, rpmGlobalMacroContext @*/ { @@ -622,11 +623,13 @@ rpmts_Rollback(rpmtsObject * s, PyObject * args) const char ** av = NULL; uint_32 rbtid; int rc; + char * kwlist[] = {"transactionId", NULL}; if (_rpmts_debug) fprintf(stderr, "*** rpmts_Rollback(%p) ts %p\n", s, s->ts); - if (!PyArg_ParseTuple(args, "i:Rollback", &rbtid)) return NULL; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:Rollback", kwlist, &rbtid)) + return NULL; Py_BEGIN_ALLOW_THREADS memset(ia, 0, sizeof(*ia)); @@ -650,7 +653,7 @@ fprintf(stderr, "*** rpmts_Rollback(%p) ts %p\n", s, s->ts); */ /*@null@*/ static PyObject * -rpmts_OpenDB(rpmtsObject * s, PyObject * args) +rpmts_OpenDB(rpmtsObject * s) /*@globals rpmGlobalMacroContext @*/ /*@modifies s, rpmGlobalMacroContext @*/ { @@ -658,8 +661,6 @@ rpmts_OpenDB(rpmtsObject * s, PyObject * args) if (_rpmts_debug) fprintf(stderr, "*** rpmts_OpenDB(%p) ts %p\n", s, s->ts); - if (!PyArg_ParseTuple(args, ":OpenDB")) return NULL; - if (s->ts->dbmode == -1) s->ts->dbmode = O_RDONLY; @@ -670,7 +671,7 @@ fprintf(stderr, "*** rpmts_OpenDB(%p) ts %p\n", s, s->ts); */ /*@null@*/ static PyObject * -rpmts_CloseDB(rpmtsObject * s, PyObject * args) +rpmts_CloseDB(rpmtsObject * s) /*@modifies s @*/ { int rc; @@ -678,8 +679,6 @@ rpmts_CloseDB(rpmtsObject * s, PyObject * args) if (_rpmts_debug) fprintf(stderr, "*** rpmts_CloseDB(%p) ts %p\n", s, s->ts); - if (!PyArg_ParseTuple(args, ":CloseDB")) return NULL; - rc = rpmtsCloseDB(s->ts); s->ts->dbmode = -1; /* XXX disable lazy opens */ @@ -690,7 +689,7 @@ fprintf(stderr, "*** rpmts_CloseDB(%p) ts %p\n", s, s->ts); */ /*@null@*/ static PyObject * -rpmts_InitDB(rpmtsObject * s, PyObject * args) +rpmts_InitDB(rpmtsObject * s) /*@globals rpmGlobalMacroContext @*/ /*@modifies s, rpmGlobalMacroContext @*/ { @@ -699,8 +698,6 @@ rpmts_InitDB(rpmtsObject * s, PyObject * args) if (_rpmts_debug) fprintf(stderr, "*** rpmts_InitDB(%p) ts %p\n", s, s->ts); - if (!PyArg_ParseTuple(args, ":InitDB")) return NULL; - rc = rpmtsInitDB(s->ts, O_RDONLY); if (rc == 0) rc = rpmtsCloseDB(s->ts); @@ -712,7 +709,7 @@ fprintf(stderr, "*** rpmts_InitDB(%p) ts %p\n", s, s->ts); */ /*@null@*/ static PyObject * -rpmts_RebuildDB(rpmtsObject * s, PyObject * args) +rpmts_RebuildDB(rpmtsObject * s) /*@globals rpmGlobalMacroContext @*/ /*@modifies s, rpmGlobalMacroContext @*/ { @@ -721,8 +718,6 @@ rpmts_RebuildDB(rpmtsObject * s, PyObject * args) if (_rpmts_debug) fprintf(stderr, "*** rpmts_RebuildDB(%p) ts %p\n", s, s->ts); - if (!PyArg_ParseTuple(args, ":RebuildDB")) return NULL; - Py_BEGIN_ALLOW_THREADS rc = rpmtsRebuildDB(s->ts); Py_END_ALLOW_THREADS @@ -734,7 +729,7 @@ fprintf(stderr, "*** rpmts_RebuildDB(%p) ts %p\n", s, s->ts); */ /*@null@*/ static PyObject * -rpmts_VerifyDB(rpmtsObject * s, PyObject * args) +rpmts_VerifyDB(rpmtsObject * s) /*@globals rpmGlobalMacroContext @*/ /*@modifies s, rpmGlobalMacroContext @*/ { @@ -743,8 +738,6 @@ rpmts_VerifyDB(rpmtsObject * s, PyObject * args) if (_rpmts_debug) fprintf(stderr, "*** rpmts_VerifyDB(%p) ts %p\n", s, s->ts); - if (!PyArg_ParseTuple(args, ":VerifyDB")) return NULL; - Py_BEGIN_ALLOW_THREADS rc = rpmtsVerifyDB(s->ts); Py_END_ALLOW_THREADS @@ -756,7 +749,7 @@ fprintf(stderr, "*** rpmts_VerifyDB(%p) ts %p\n", s, s->ts); */ /*@null@*/ static PyObject * -rpmts_HdrFromFdno(rpmtsObject * s, PyObject * args) +rpmts_HdrFromFdno(rpmtsObject * s, PyObject * args, PyObject * kwds) /*@globals rpmGlobalMacroContext, fileSystem @*/ /*@modifies s, rpmGlobalMacroContext, fileSystem @*/ { @@ -765,8 +758,11 @@ rpmts_HdrFromFdno(rpmtsObject * s, PyObject * args) FD_t fd; int fdno; rpmRC rpmrc; + char * kwlist[] = {"fd", NULL}; - if (!PyArg_ParseTuple(args, "i:HdrFromFdno", &fdno)) return NULL; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:HdrFromFdno", kwlist, + &fdno)) + return NULL; fd = fdDup(fdno); rpmrc = rpmReadPackageFile(s->ts, fd, "rpmts_HdrFromFdno", &h); @@ -806,7 +802,7 @@ fprintf(stderr, "*** rpmts_HdrFromFdno(%p) ts %p rc %d\n", s, s->ts, rpmrc); */ /*@null@*/ static PyObject * -rpmts_HdrCheck(rpmtsObject * s, PyObject * args) +rpmts_HdrCheck(rpmtsObject * s, PyObject * args, PyObject * kwds) /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/ { @@ -816,11 +812,14 @@ rpmts_HdrCheck(rpmtsObject * s, PyObject * args) const void * uh; int uc; rpmRC rpmrc; + char * kwlist[] = {"headers", NULL}; if (_rpmts_debug) fprintf(stderr, "*** rpmts_HdrCheck(%p) ts %p\n", s, s->ts); - if (!PyArg_ParseTuple(args, "O:HdrCheck", &blob)) return NULL; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:HdrCheck", kwlist, &blob)) + return NULL; + if (blob == Py_None) { Py_INCREF(Py_None); return Py_None; @@ -862,17 +861,21 @@ fprintf(stderr, "*** rpmts_HdrCheck(%p) ts %p\n", s, s->ts); */ /*@null@*/ static PyObject * -rpmts_SetVSFlags(rpmtsObject * s, PyObject * args) +rpmts_SetVSFlags(rpmtsObject * s, PyObject * args, PyObject * kwds) /*@modifies s @*/ { rpmVSFlags vsflags; + char * kwlist[] = {"flags", NULL}; if (_rpmts_debug) fprintf(stderr, "*** rpmts_SetVSFlags(%p) ts %p\n", s, s->ts); - if (!PyArg_ParseTuple(args, "i:SetVSFlags", &vsflags)) return NULL; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:SetVSFlags", kwlist, + &vsflags)) + return NULL; - /* XXX FIXME: value check on vsflags. */ + /* XXX FIXME: value check on vsflags, or build pure python object + * for it, and require an object of that type */ return Py_BuildValue("i", rpmtsSetVSFlags(s->ts, vsflags)); } @@ -881,17 +884,20 @@ fprintf(stderr, "*** rpmts_SetVSFlags(%p) ts %p\n", s, s->ts); */ /*@null@*/ static PyObject * -rpmts_SetColor(rpmtsObject * s, PyObject * args) +rpmts_SetColor(rpmtsObject * s, PyObject * args, PyObject * kwds) /*@modifies s @*/ { uint_32 tscolor; + char * kwlist[] = {"color", NULL}; if (_rpmts_debug) fprintf(stderr, "*** rpmts_SetColor(%p) ts %p\n", s, s->ts); - if (!PyArg_ParseTuple(args, "i:Color", &tscolor)) return NULL; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:Color", kwlist, &tscolor)) + return NULL; - /* XXX FIXME: value check on tscolor. */ + /* XXX FIXME: value check on tscolor, or build pure python object + * for it, and require an object of that type */ return Py_BuildValue("i", rpmtsSetColor(s->ts, tscolor)); } @@ -900,7 +906,7 @@ fprintf(stderr, "*** rpmts_SetColor(%p) ts %p\n", s, s->ts); */ /*@null@*/ static PyObject * -rpmts_PgpPrtPkts(rpmtsObject * s, PyObject * args) +rpmts_PgpPrtPkts(rpmtsObject * s, PyObject * args, PyObject * kwds) /*@globals _Py_NoneStruct @*/ /*@modifies _Py_NoneStruct @*/ { @@ -908,11 +914,14 @@ rpmts_PgpPrtPkts(rpmtsObject * s, PyObject * args) unsigned char * pkt; unsigned int pktlen; int rc; + char * kwlist[] = {"octets", NULL}; if (_rpmts_debug) fprintf(stderr, "*** rpmts_PgpPrtPkts(%p) ts %p\n", s, s->ts); - if (!PyArg_ParseTuple(args, "O:PgpPrtPkts", &blob)) return NULL; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:PgpPrtPkts", kwlist, &blob)) + return NULL; + if (blob == Py_None) { Py_INCREF(Py_None); return Py_None; @@ -933,7 +942,7 @@ fprintf(stderr, "*** rpmts_PgpPrtPkts(%p) ts %p\n", s, s->ts); */ /*@null@*/ static PyObject * -rpmts_PgpImportPubkey(rpmtsObject * s, PyObject * args) +rpmts_PgpImportPubkey(rpmtsObject * s, PyObject * args, PyObject * kwds) /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/ { @@ -941,11 +950,15 @@ rpmts_PgpImportPubkey(rpmtsObject * s, PyObject * args) unsigned char * pkt; unsigned int pktlen; int rc; + char * kwlist[] = {"pubkey", NULL}; if (_rpmts_debug) fprintf(stderr, "*** rpmts_PgpImportPubkey(%p) ts %p\n", s, s->ts); - if (!PyArg_ParseTuple(args, "O:PgpImportPubkey", &blob)) return NULL; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:PgpImportPubkey", + kwlist, &blob)) + return NULL; + if (blob == Py_None) { Py_INCREF(Py_None); return Py_None; @@ -966,7 +979,7 @@ fprintf(stderr, "*** rpmts_PgpImportPubkey(%p) ts %p\n", s, s->ts); */ /*@null@*/ static PyObject * -rpmts_GetKeys(rpmtsObject * s, PyObject * args) +rpmts_GetKeys(rpmtsObject * s) /*@globals _Py_NoneStruct @*/ /*@modifies s, _Py_NoneStruct @*/ { @@ -977,8 +990,6 @@ rpmts_GetKeys(rpmtsObject * s, PyObject * args) if (_rpmts_debug) fprintf(stderr, "*** rpmts_GetKeys(%p) ts %p\n", s, s->ts); - if (!PyArg_ParseTuple(args, ":GetKeys")) return NULL; - rpmtsGetKeys(s->ts, &data, &num); if (data == NULL || num <= 0) { data = _free(data); @@ -1081,29 +1092,38 @@ fprintf(stderr, "\t%ld:%ld key %p\n", amount, total, pkgKey); /** \ingroup py_c */ -static PyObject * rpmts_SetFlags(rpmtsObject * s, PyObject * args) +static PyObject * +rpmts_SetFlags(rpmtsObject * s, PyObject * args, PyObject * kwds) /*@modifies s @*/ { rpmtransFlags transFlags = 0; + char * kwlist[] = {"flags", NULL}; - if (!PyArg_ParseTuple(args, "i:SetFlags", &transFlags)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:SetFlags", kwlist, + &transFlags)) return NULL; if (_rpmts_debug) fprintf(stderr, "*** rpmts_SetFlags(%p) ts %p transFlags %x\n", s, s->ts, transFlags); + /* XXX FIXME: value check on flags, or build pure python object + * for it, and require an object of that type */ + return Py_BuildValue("i", rpmtsSetFlags(s->ts, transFlags)); } /** \ingroup py_c */ -static PyObject * rpmts_SetProbFilter(rpmtsObject * s, PyObject * args) +static PyObject * +rpmts_SetProbFilter(rpmtsObject * s, PyObject * args, PyObject * kwds) /*@modifies s @*/ { rpmprobFilterFlags ignoreSet = 0; rpmprobFilterFlags oignoreSet; + char * kwlist[] = {"ignoreSet", NULL}; - if (!PyArg_ParseTuple(args, "i:ProbFilter", &ignoreSet)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:ProbFilter", kwlist, + &ignoreSet)) return NULL; if (_rpmts_debug) @@ -1119,22 +1139,20 @@ fprintf(stderr, "*** rpmts_SetProbFilter(%p) ts %p ignoreSet %x\n", s, s->ts, ig */ /*@null@*/ static rpmpsObject * -rpmts_Problems(rpmtsObject * s, PyObject * args) +rpmts_Problems(rpmtsObject * s) /*@modifies s @*/ { if (_rpmts_debug) fprintf(stderr, "*** rpmts_Problems(%p) ts %p\n", s, s->ts); - if (!PyArg_ParseTuple(args, ":Problems")) - return NULL; - return rpmps_Wrap( rpmtsProblems(s->ts) ); } /** \ingroup py_c */ -static PyObject * rpmts_Run(rpmtsObject * s, PyObject * args) +static PyObject * +rpmts_Run(rpmtsObject * s, PyObject * args, PyObject * kwds) /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/ /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/ { @@ -1142,8 +1160,10 @@ static PyObject * rpmts_Run(rpmtsObject * s, PyObject * args) PyObject * list; rpmps ps; struct rpmtsCallbackType_s cbInfo; + char * kwlist[] = {"callback", "data", NULL}; - if (!PyArg_ParseTuple(args, "OO:Run", &cbInfo.cb, &cbInfo.data)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO:Run", kwlist, + &cbInfo.cb, &cbInfo.data)) return NULL; cbInfo.tso = s; @@ -1172,7 +1192,6 @@ static PyObject * rpmts_Run(rpmtsObject * s, PyObject * args) sx = rpmsxFree(sx); } - if (_rpmts_debug) fprintf(stderr, "*** rpmts_Run(%p) ts %p ignore %x\n", s, s->ts, s->ignoreSet); @@ -1288,7 +1307,7 @@ fprintf(stderr, "*** rpmts_Next(%p) ts %p\n", s, s->ts); */ /*@null@*/ static specObject * -spec_Parse(rpmtsObject * s, PyObject * args) +spec_Parse(rpmtsObject * s, PyObject * args, PyObject * kwds) /*@globals rpmGlobalMacroContext @*/ /*@modifies s, rpmGlobalMacroContext @*/ { @@ -1300,11 +1319,11 @@ spec_Parse(rpmtsObject * s, PyObject * args) char *cookie = NULL; int anyarch = 1; int force = 1; + char * kwlist[] = {"specfile", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s:Parse", kwlist, &specfile)) + return NULL; - if (!PyArg_ParseTuple(args, "s:Parse", &specfile)) { - return NULL; - } - if (parseSpec(s->ts, specfile,"/", buildRoot,recursing, passPhrase, cookie, anyarch, force)!=0) { PyErr_SetString(pyrpmError, "can't parse specfile\n"); @@ -1319,7 +1338,7 @@ spec_Parse(rpmtsObject * s, PyObject * args) */ /*@null@*/ static rpmmiObject * -rpmts_Match(rpmtsObject * s, PyObject * args) +rpmts_Match(rpmtsObject * s, PyObject * args, PyObject * kwds) /*@globals rpmGlobalMacroContext @*/ /*@modifies s, rpmGlobalMacroContext @*/ { @@ -1329,11 +1348,13 @@ rpmts_Match(rpmtsObject * s, PyObject * args) long lkey = 0; int len = 0; int tag = RPMDBI_PACKAGES; + char * kwlist[] = {"tagNumber", "key", NULL}; if (_rpmts_debug) fprintf(stderr, "*** rpmts_Match(%p) ts %p\n", s, s->ts); - if (!PyArg_ParseTuple(args, "|OO:Match", &TagN, &Key)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO:Match", kwlist, + &TagN, &Key)) return NULL; if (TagN && (tag = tagNumFromPyObject (TagN)) == -1) { @@ -1375,66 +1396,66 @@ fprintf(stderr, "*** rpmts_Match(%p) ts %p\n", s, s->ts); /*@-fullinitblock@*/ /*@unchecked@*/ /*@observer@*/ static struct PyMethodDef rpmts_methods[] = { - {"Debug", (PyCFunction)rpmts_Debug, METH_VARARGS, + {"Debug", (PyCFunction)rpmts_Debug, METH_VARARGS|METH_KEYWORDS, NULL}, - {"addInstall", (PyCFunction) rpmts_AddInstall, METH_VARARGS, + {"addInstall", (PyCFunction) rpmts_AddInstall, METH_VARARGS|METH_KEYWORDS, NULL }, - {"addErase", (PyCFunction) rpmts_AddErase, METH_VARARGS, + {"addErase", (PyCFunction) rpmts_AddErase, METH_VARARGS|METH_KEYWORDS, NULL }, - {"check", (PyCFunction) rpmts_Check, METH_VARARGS, + {"check", (PyCFunction) rpmts_Check, METH_VARARGS|METH_KEYWORDS, NULL }, - {"order", (PyCFunction) rpmts_Order, METH_VARARGS, + {"order", (PyCFunction) rpmts_Order, METH_NOARGS, NULL }, - {"setFlags", (PyCFunction) rpmts_SetFlags, METH_VARARGS, + {"setFlags", (PyCFunction) rpmts_SetFlags, METH_VARARGS|METH_KEYWORDS, "ts.setFlags(transFlags) -> previous transFlags\n\ - Set control bit(s) for executing ts.run().\n\ Note: This method replaces the 1st argument to the old ts.run()\n" }, - {"setProbFilter", (PyCFunction) rpmts_SetProbFilter, METH_VARARGS, + {"setProbFilter", (PyCFunction) rpmts_SetProbFilter, METH_VARARGS|METH_KEYWORDS, "ts.setProbFilter(ignoreSet) -> previous ignoreSet\n\ - Set control bit(s) for ignoring problems found by ts.run().\n\ Note: This method replaces the 2nd argument to the old ts.run()\n" }, - {"problems", (PyCFunction) rpmts_Problems, METH_VARARGS, + {"problems", (PyCFunction) rpmts_Problems, METH_NOARGS, "ts.problems() -> ps\n\ - Return current problem set.\n" }, - {"run", (PyCFunction) rpmts_Run, METH_VARARGS, + {"run", (PyCFunction) rpmts_Run, METH_VARARGS|METH_KEYWORDS, "ts.run(callback, data) -> (problems)\n\ - Run a transaction set, returning list of problems found.\n\ Note: The callback may not be None.\n" }, - {"clean", (PyCFunction) rpmts_Clean, METH_VARARGS, + {"clean", (PyCFunction) rpmts_Clean, METH_NOARGS, NULL }, - {"IDTXload", (PyCFunction) rpmts_IDTXload, METH_VARARGS, + {"IDTXload", (PyCFunction) rpmts_IDTXload, METH_NOARGS, "ts.IDTXload() -> ((tid,hdr,instance)+)\n\ - Return list of installed packages reverse sorted by transaction id.\n" }, - {"IDTXglob", (PyCFunction) rpmts_IDTXglob, METH_VARARGS, + {"IDTXglob", (PyCFunction) rpmts_IDTXglob, METH_NOARGS, "ts.IDTXglob() -> ((tid,hdr,instance)+)\n\ - Return list of removed packages reverse sorted by transaction id.\n" }, - {"rollback", (PyCFunction) rpmts_Rollback, METH_VARARGS, + {"rollback", (PyCFunction) rpmts_Rollback, METH_VARARGS|METH_KEYWORDS, NULL }, - {"openDB", (PyCFunction) rpmts_OpenDB, METH_VARARGS, + {"openDB", (PyCFunction) rpmts_OpenDB, METH_NOARGS, "ts.openDB() -> None\n\ - Open the default transaction rpmdb.\n\ Note: The transaction rpmdb is lazily opened, so ts.openDB() is seldom needed.\n" }, - {"closeDB", (PyCFunction) rpmts_CloseDB, METH_VARARGS, + {"closeDB", (PyCFunction) rpmts_CloseDB, METH_NOARGS, "ts.closeDB() -> None\n\ - Close the default transaction rpmdb.\n\ Note: ts.closeDB() disables lazy opens, and should hardly ever be used.\n" }, - {"initDB", (PyCFunction) rpmts_InitDB, METH_VARARGS, + {"initDB", (PyCFunction) rpmts_InitDB, METH_NOARGS, "ts.initDB() -> None\n\ - Initialize the default transaction rpmdb.\n\ Note: ts.initDB() is seldom needed anymore.\n" }, - {"rebuildDB", (PyCFunction) rpmts_RebuildDB, METH_VARARGS, + {"rebuildDB", (PyCFunction) rpmts_RebuildDB, METH_NOARGS, "ts.rebuildDB() -> None\n\ - Rebuild the default transaction rpmdb.\n" }, - {"verifyDB", (PyCFunction) rpmts_VerifyDB, METH_VARARGS, + {"verifyDB", (PyCFunction) rpmts_VerifyDB, METH_NOARGS, "ts.verifyDB() -> None\n\ - Verify the default transaction rpmdb.\n" }, - {"hdrFromFdno",(PyCFunction) rpmts_HdrFromFdno,METH_VARARGS, + {"hdrFromFdno",(PyCFunction) rpmts_HdrFromFdno,METH_VARARGS|METH_KEYWORDS, "ts.hdrFromFdno(fdno) -> hdr\n\ - Read a package header from a file descriptor.\n" }, - {"hdrCheck", (PyCFunction) rpmts_HdrCheck, METH_VARARGS, + {"hdrCheck", (PyCFunction) rpmts_HdrCheck, METH_VARARGS|METH_KEYWORDS, NULL }, - {"setVSFlags",(PyCFunction) rpmts_SetVSFlags, METH_VARARGS, + {"setVSFlags",(PyCFunction) rpmts_SetVSFlags, METH_VARARGS|METH_KEYWORDS, "ts.setVSFlags(vsflags) -> ovsflags\n\ - Set signature verification flags. Values for vsflags are:\n\ rpm.RPMVSF_NOHDRCHK if set, don't check rpmdb headers\n\ @@ -1446,21 +1467,21 @@ static struct PyMethodDef rpmts_methods[] = { rpm.RPMVSF_NORSA if set, don't check header+payload RSA signature\n\ rpm._RPMVSF_NODIGESTS if set, don't check digest(s)\n\ rpm._RPMVSF_NOSIGNATURES if set, don't check signature(s)\n" }, - {"setColor",(PyCFunction) rpmts_SetColor, METH_VARARGS, + {"setColor",(PyCFunction) rpmts_SetColor, METH_VARARGS|METH_KEYWORDS, NULL }, - {"pgpPrtPkts", (PyCFunction) rpmts_PgpPrtPkts, METH_VARARGS, + {"pgpPrtPkts", (PyCFunction) rpmts_PgpPrtPkts, METH_VARARGS|METH_KEYWORDS, NULL }, - {"pgpImportPubkey", (PyCFunction) rpmts_PgpImportPubkey, METH_VARARGS, + {"pgpImportPubkey", (PyCFunction) rpmts_PgpImportPubkey, METH_VARARGS|METH_KEYWORDS, NULL }, - {"getKeys", (PyCFunction) rpmts_GetKeys, METH_VARARGS, + {"getKeys", (PyCFunction) rpmts_GetKeys, METH_NOARGS, NULL }, - {"parseSpec", (PyCFunction) spec_Parse, METH_VARARGS, + {"parseSpec", (PyCFunction) spec_Parse, METH_VARARGS|METH_KEYWORDS, "ts.parseSpec(\"/path/to/foo.spec\") -> spec\n\ - Parse a spec file.\n" }, - {"dbMatch", (PyCFunction) rpmts_Match, METH_VARARGS, + {"dbMatch", (PyCFunction) rpmts_Match, METH_VARARGS|METH_KEYWORDS, "ts.dbMatch([TagN, [key, [len]]]) -> mi\n\ - Create a match iterator for the default transaction rpmdb.\n" }, - {"next", (PyCFunction)rpmts_Next, METH_VARARGS, + {"next", (PyCFunction)rpmts_Next, METH_NOARGS, "ts.next() -> te\n\ - Retrieve next transaction set element.\n" }, {NULL, NULL} /* sentinel */ @@ -1524,15 +1545,20 @@ static int rpmts_init(rpmtsObject * s, PyObject *args, PyObject *kwds) { char * rootDir = "/"; int vsflags = rpmExpandNumeric("%{?_vsflags_up2date}"); + char * kwlist[] = {"rootdir", "vsflags", 0}; if (_rpmts_debug < 0) fprintf(stderr, "*** rpmts_init(%p,%p,%p)\n", s, args, kwds); - if (!PyArg_ParseTuple(args, "|si:rpmts_init", &rootDir, &vsflags)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|si:rpmts_init", kwlist, + &rootDir, &vsflags)) return -1; s->ts = rpmtsCreate(); + /* XXX: Why is there no rpmts_SetRootDir() ? */ (void) rpmtsSetRootDir(s->ts, rootDir); + /* XXX: make this use common code with rpmts_SetVSFlags() to check the + * python objects */ (void) rpmtsSetVSFlags(s->ts, vsflags); s->keyList = PyList_New(0); s->scriptFd = NULL; @@ -1651,20 +1677,26 @@ PyTypeObject rpmts_Type = { /** */ +/* XXX: This should use the same code as rpmts_init */ rpmtsObject * -rpmts_Create(/*@unused@*/ PyObject * self, PyObject * args) +rpmts_Create(/*@unused@*/ PyObject * self, PyObject * args, PyObject * kwds) { rpmtsObject * o; char * rootDir = "/"; int vsflags = rpmExpandNumeric("%{?_vsflags_up2date}"); + char * kwlist[] = {"rootdir", "vsflags", NULL}; - if (!PyArg_ParseTuple(args, "|si:Create", &rootDir, &vsflags)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|si:Create", kwlist, + &rootDir, &vsflags)) return NULL; o = (void *) PyObject_New(rpmtsObject, &rpmts_Type); o->ts = rpmtsCreate(); + /* XXX: Why is there no rpmts_SetRootDir() ? */ (void) rpmtsSetRootDir(o->ts, rootDir); + /* XXX: make this use common code with rpmts_SetVSFlags() to check the + * python objects */ (void) rpmtsSetVSFlags(o->ts, vsflags); o->keyList = PyList_New(0); diff --git a/python/rpmts-py.h b/python/rpmts-py.h index 10d05d9..6d5b6b2 100644 --- a/python/rpmts-py.h +++ b/python/rpmts-py.h @@ -28,7 +28,7 @@ enum { RPMDEP_SENSE_CONFLICTS /*!< conflict was found. */ }; -rpmtsObject * rpmts_Create(PyObject * s, PyObject * args) +rpmtsObject * rpmts_Create(PyObject * s, PyObject * args, PyObject * kwds) /*@globals rpmGlobalMacroContext @*/ /*@modifies rpmGlobalMacroContext @*/; -- 2.7.4