From: Tomas Mlcoch Date: Tue, 10 Sep 2013 13:43:43 +0000 (+0200) Subject: Python: Add docstrings and comments X-Git-Tag: upstream/0.2.1~35 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6b3a06604ed61ec8f8b8d443968670f2dc567e1a;p=services%2Fcreaterepo_c.git Python: Add docstrings and comments --- diff --git a/src/python/__init__.py b/src/python/__init__.py index 96f210d..a3a341a 100644 --- a/src/python/__init__.py +++ b/src/python/__init__.py @@ -2,73 +2,101 @@ """ import _createrepo_c +from _createrepo_c import * -VERSION_MAJOR = _createrepo_c.VERSION_MAJOR -VERSION_MINOR = _createrepo_c.VERSION_MINOR -VERSION_PATCH = _createrepo_c.VERSION_PATCH +VERSION_MAJOR = _createrepo_c.VERSION_MAJOR #: Major version +VERSION_MINOR = _createrepo_c.VERSION_MINOR #: Minor version +VERSION_PATCH = _createrepo_c.VERSION_PATCH #: Patch version + +#: Version string VERSION = u"%d.%d.%d" % (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH) -UNKNOWN_CHECKSUM = _createrepo_c.CHECKSUM_UNKNOWN -CHECKSUM_UNKNOWN = _createrepo_c.CHECKSUM_UNKNOWN -MD5 = _createrepo_c.MD5 -SHA = _createrepo_c.SHA -SHA1 = _createrepo_c.SHA1 -SHA224 = _createrepo_c.SHA224 -SHA256 = _createrepo_c.SHA256 -SHA384 = _createrepo_c.SHA384 -SHA512 = _createrepo_c.SHA512 +UNKNOWN_CHECKSUM = _createrepo_c.CHECKSUM_UNKNOWN #: Checksum unknown +CHECKSUM_UNKNOWN = _createrepo_c.CHECKSUM_UNKNOWN #: Checksum unknown +MD5 = _createrepo_c.MD5 #: MD5 checksum +SHA = _createrepo_c.SHA #: SHA1 checksum alias +SHA1 = _createrepo_c.SHA1 #: SHA1 checksum +SHA224 = _createrepo_c.SHA224 #: SHA224 checksum +SHA256 = _createrepo_c.SHA256 #: SHA256 checksum +SHA384 = _createrepo_c.SHA384 #: SHA384 checksum +SHA512 = _createrepo_c.SHA512 #: SHA512 checksum -MODE_READ = _createrepo_c.MODE_READ -MODE_WRITE = _createrepo_c.MODE_WRITE +MODE_READ = _createrepo_c.MODE_READ #: Read open mode +MODE_WRITE = _createrepo_c.MODE_WRITE #: Write open mode +#: Use compression autodetection AUTO_DETECT_COMPRESSION = _createrepo_c.AUTO_DETECT_COMPRESSION + +#: Unknown compression UNKNOWN_COMPRESSION = _createrepo_c.UNKNOWN_COMPRESSION + +#: No compression NO_COMPRESSION = _createrepo_c.NO_COMPRESSION + +#: Gzip compression GZ_COMPRESSION = _createrepo_c.GZ_COMPRESSION + +#: Bzip2 compression BZ2_COMPRESSION = _createrepo_c.BZ2_COMPRESSION + +#: XZ compression XZ_COMPRESSION = _createrepo_c.XZ_COMPRESSION + +#: Gzip compression alias GZ = _createrepo_c.GZ_COMPRESSION + +#: Bzip2 compression alias BZ2 = _createrepo_c.BZ2_COMPRESSION + +#: XZ compression alias XZ = _createrepo_c.XZ_COMPRESSION -HT_KEY_DEFAULT = _createrepo_c.HT_KEY_DEFAULT -HT_KEY_HASH = _createrepo_c.HT_KEY_HASH -HT_KEY_NAME = _createrepo_c.HT_KEY_NAME -HT_KEY_FILENAME = _createrepo_c.HT_KEY_FILENAME +HT_KEY_DEFAULT = _createrepo_c.HT_KEY_DEFAULT #: Default key (hash) +HT_KEY_HASH = _createrepo_c.HT_KEY_HASH #: Package hash as a key +HT_KEY_NAME = _createrepo_c.HT_KEY_NAME #: Package name as a key +HT_KEY_FILENAME = _createrepo_c.HT_KEY_FILENAME #: Package filename as a key -DB_PRIMARY = _createrepo_c.DB_PRIMARY -DB_FILELISTS = _createrepo_c.DB_FILELISTS -DB_OTHER = _createrepo_c.DB_OTHER +DB_PRIMARY = _createrepo_c.DB_PRIMARY #: Primary database +DB_FILELISTS = _createrepo_c.DB_FILELISTS #: Filelists database +DB_OTHER = _createrepo_c.DB_OTHER #: Other database -XMLFILE_PRIMARY = _createrepo_c.XMLFILE_PRIMARY -XMLFILE_FILELISTS = _createrepo_c.XMLFILE_FILELISTS -XMLFILE_OTHER = _createrepo_c.XMLFILE_OTHER +XMLFILE_PRIMARY = _createrepo_c.XMLFILE_PRIMARY #: Primary xml file +XMLFILE_FILELISTS = _createrepo_c.XMLFILE_FILELISTS #: Filelists xml file +XMLFILE_OTHER = _createrepo_c.XMLFILE_OTHER #: Other xml file +#: XML warning - Unknown tag XML_WARNING_UNKNOWNTAG = _createrepo_c.XML_WARNING_UNKNOWNTAG + +#: XML warning - Missing attribute XML_WARNING_MISSINGATTR = _createrepo_c.XML_WARNING_MISSINGATTR + +#: XML warning - Unknown value XML_WARNING_UNKNOWNVAL = _createrepo_c.XML_WARNING_UNKNOWNVAL + +#: XML warning - Bad attribute value XML_WARNING_BADATTRVAL = _createrepo_c.XML_WARNING_BADATTRVAL # Helper contants # Tuple indexes for provide, conflict, obsolete or require entry -PCOR_ENTRY_NAME = 0 -PCOR_ENTRY_FLAGS = 1 -PCOR_ENTRY_EPOCH = 2 -PCOR_ENTRY_VERSION = 3 -PCOR_ENTRY_RELEASE = 4 -PCOR_ENTRY_PRE = 5 +PCOR_ENTRY_NAME = 0 #: PCOR entry tuple index - name +PCOR_ENTRY_FLAGS = 1 #: PCOR entry tuple index - flags +PCOR_ENTRY_EPOCH = 2 #: PCOR entry tuple index - epoch +PCOR_ENTRY_VERSION = 3 #: PCOR entry tuple index - version +PCOR_ENTRY_RELEASE = 4 #: PCOR entry tuple index - release +PCOR_ENTRY_PRE = 5 #: PCOR entry tuple index - pre + # Tuple indexes for file entry -FILE_ENTRY_TYPE = 0 -FILE_ENTRY_PATH = 1 -FILE_ENTRY_NAME = 2 +FILE_ENTRY_TYPE = 0 #: File entry tuple index - file type +FILE_ENTRY_PATH = 1 #: File entry tuple index - path +FILE_ENTRY_NAME = 2 #: File entry tuple index - file name # Tuple indexes for changelog entry -CHANGELOG_ENTRY_AUTHOR = 0 -CHANGELOG_ENTRY_DATE = 1 -CHANGELOG_ENTRY_CHANGELOG = 2 +CHANGELOG_ENTRY_AUTHOR = 0 #: Changelog entry tuple index - Author +CHANGELOG_ENTRY_DATE = 1 #: Changelog entry tuple index - Date +CHANGELOG_ENTRY_CHANGELOG = 2 #: Changelog entry tuple index - Changelog # Exception @@ -84,6 +112,10 @@ ContentStat = _createrepo_c.ContentStat class CrFile(_createrepo_c.CrFile): def __init__(self, filename, mode=MODE_READ, comtype=NO_COMPRESSION, stat=None): + """:arg filename: Filename + :arg mode: MODE_READ or MODE_WRITE + :arg comtype: Compression type (GZ, BZ, XZ or NO_COMPRESSION) + :arg stat: ContentStat object or None""" _createrepo_c.CrFile.__init__(self, filename, mode, comtype, stat) # Metadata class @@ -127,16 +159,19 @@ class RepomdRecord(_createrepo_c.RepomdRecord): Sqlite = _createrepo_c.Sqlite class PrimarySqlite(Sqlite): - def __init__(self, filename): - Sqlite.__init__(self, filename, DB_PRIMARY) + def __init__(self, path): + """:arg path: path to the primary.sqlite database""" + Sqlite.__init__(self, path, DB_PRIMARY) class FilelistsSqlite(Sqlite): - def __init__(self, filename): - Sqlite.__init__(self, filename, DB_FILELISTS) + def __init__(self, path): + """:arg path: Path to the filelists.sqlite database""" + Sqlite.__init__(self, path, DB_FILELISTS) class OtherSqlite(Sqlite): - def __init__(self, filename): - Sqlite.__init__(self, filename, DB_OTHER) + def __init__(self, path): + """:arg path: Path to the other.sqlite database""" + Sqlite.__init__(self, path, DB_OTHER) # XmlFile class @@ -169,33 +204,39 @@ xml_dump = _createrepo_c.xml_dump def package_from_rpm(filename, checksum_type=SHA256, location_href=None, location_base=None, changelog_limit=10): + """:class:`.Package` object from the rpm package""" return _createrepo_c.package_from_rpm(filename, checksum_type, location_href, location_base, changelog_limit) def xml_from_rpm(filename, checksum_type=SHA256, location_href=None, location_base=None, changelog_limit=10): + """XML for the rpm package""" return _createrepo_c.xml_from_rpm(filename, checksum_type, location_href, location_base, changelog_limit) def xml_parse_primary(path, newpkgcb=None, pkgcb=None, warningcb=None, do_files=1): + """Parse primary.xml""" return _createrepo_c.xml_parse_primary(path, newpkgcb, pkgcb, warningcb, do_files) def xml_parse_filelists(path, newpkgcb=None, pkgcb=None, warningcb=None): + """Parse filelists.xml""" return _createrepo_c.xml_parse_filelists(path, newpkgcb, pkgcb, warningcb) def xml_parse_other(path, newpkgcb=None, pkgcb=None, warningcb=None): + """Parse other.xml""" return _createrepo_c.xml_parse_other(path, newpkgcb, pkgcb, warningcb) def xml_parse_repomd(path, repomdobj, warningcb=None): + """Parse repomd.xml""" return _createrepo_c.xml_parse_repomd(path, repomdobj, warningcb) checksum_name_str = _createrepo_c.checksum_name_str checksum_type = _createrepo_c.checksum_type def compress_file(src, dst, comtype, stat=None): - return _createrepo_c.compress_file(src, dst, comtype, stat) + return _createrepo_c.compress_file_with_stat(src, dst, comtype, stat) compression_suffix = _createrepo_c.compression_suffix detect_compression = _createrepo_c.detect_compression diff --git a/src/python/checksum-py.h b/src/python/checksum-py.h index 933c0e0..3a8932f 100644 --- a/src/python/checksum-py.h +++ b/src/python/checksum-py.h @@ -22,7 +22,16 @@ #include "src/createrepo_c.h" +PyDoc_STRVAR(checksum_name_str__doc__, +"checksum_name_str(checksum_type) -> str\n\n" +"Checksum name from checksum type constant"); + PyObject *py_checksum_name_str(PyObject *self, PyObject *args); + +PyDoc_STRVAR(checksum_type__doc__, +"checksum_type(checksum_name) -> long\n\n" +"Checksum type from checksum name"); + PyObject *py_checksum_type(PyObject *self, PyObject *args); #endif diff --git a/src/python/compression_wrapper-py.c b/src/python/compression_wrapper-py.c index 4971159..1fdad41 100644 --- a/src/python/compression_wrapper-py.c +++ b/src/python/compression_wrapper-py.c @@ -192,6 +192,10 @@ crfile_repr(_CrFileObject *self) /* CrFile methods */ +PyDoc_STRVAR(write__doc__, +"write() -> None\n\n" +"Write a data to the file"); + static PyObject * py_write(_CrFileObject *self, PyObject *args) { @@ -214,6 +218,10 @@ py_write(_CrFileObject *self, PyObject *args) Py_RETURN_NONE; } +PyDoc_STRVAR(close__doc__, +"close() -> None\n\n" +"Close the file"); + static PyObject * py_close(_CrFileObject *self, void *nothing) { @@ -238,8 +246,8 @@ py_close(_CrFileObject *self, void *nothing) } static struct PyMethodDef crfile_methods[] = { - {"write", (PyCFunction)py_write, METH_VARARGS, NULL}, - {"close", (PyCFunction)py_close, METH_NOARGS, NULL}, + {"write", (PyCFunction)py_write, METH_VARARGS, write__doc__}, + {"close", (PyCFunction)py_close, METH_NOARGS, close__doc__}, {NULL} /* sentinel */ }; diff --git a/src/python/compression_wrapper-py.h b/src/python/compression_wrapper-py.h index 7d75cab..6dbc7e5 100644 --- a/src/python/compression_wrapper-py.h +++ b/src/python/compression_wrapper-py.h @@ -26,7 +26,16 @@ extern PyTypeObject CrFile_Type; #define CrFileObject_Check(o) PyObject_TypeCheck(o, &CrFile_Type) +PyDoc_STRVAR(compression_suffix__doc__, +"compression_suffix(compression_type) -> str or None\n\n" +"Compression suffix for the compression type"); + PyObject *py_compression_suffix(PyObject *self, PyObject *args); + +PyDoc_STRVAR(detect_compression__doc__, +"detect_compression(path) -> long\n\n" +"Detect compression type used on the file"); + PyObject *py_detect_compression(PyObject *self, PyObject *args); #endif diff --git a/src/python/contentstat-py.c b/src/python/contentstat-py.c index 2177369..738bf13 100644 --- a/src/python/contentstat-py.c +++ b/src/python/contentstat-py.c @@ -195,9 +195,12 @@ set_str(_ContentStatObject *self, PyObject *value, void *member_offset) } static PyGetSetDef contentstat_getsetters[] = { - {"size", (getter)get_num, (setter)set_num, NULL, OFFSET(size)}, - {"checksum_type", (getter)get_int, (setter)set_int, NULL, OFFSET(checksum_type)}, - {"checksum", (getter)get_str, (setter)set_str, NULL, OFFSET(checksum)}, + {"size", (getter)get_num, (setter)set_num, + "Number of uncompressed bytes written", OFFSET(size)}, + {"checksum_type", (getter)get_int, (setter)set_int, + "Type of used checksum", OFFSET(checksum_type)}, + {"checksum", (getter)get_str, (setter)set_str, + "Calculated checksum", OFFSET(checksum)}, {NULL, NULL, NULL, NULL, NULL} /* sentinel */ }; diff --git a/src/python/createrepo_cmodule.c b/src/python/createrepo_cmodule.c index 6e5e426..0691d3f 100644 --- a/src/python/createrepo_cmodule.c +++ b/src/python/createrepo_cmodule.c @@ -39,35 +39,35 @@ static struct PyMethodDef createrepo_c_methods[] = { {"package_from_rpm", (PyCFunction)py_package_from_rpm, - METH_VARARGS | METH_KEYWORDS, NULL}, + METH_VARARGS | METH_KEYWORDS, package_from_rpm__doc__}, {"xml_from_rpm", (PyCFunction)py_xml_from_rpm, - METH_VARARGS | METH_KEYWORDS, NULL}, + METH_VARARGS | METH_KEYWORDS, package_from_rpm__doc__}, {"xml_dump_primary", (PyCFunction)py_xml_dump_primary, - METH_VARARGS, NULL}, + METH_VARARGS, xml_dump_primary__doc__}, {"xml_dump_filelists", (PyCFunction)py_xml_dump_filelists, - METH_VARARGS, NULL}, + METH_VARARGS, xml_dump_filelists__doc__}, {"xml_dump_other", (PyCFunction)py_xml_dump_other, - METH_VARARGS, NULL}, + METH_VARARGS, xml_dump_other__doc__}, {"xml_dump", (PyCFunction)py_xml_dump, - METH_VARARGS, NULL}, + METH_VARARGS, xml_dump__doc__}, {"xml_parse_primary", (PyCFunction)py_xml_parse_primary, - METH_VARARGS, NULL}, + METH_VARARGS, xml_parse_primary__doc__}, {"xml_parse_filelists", (PyCFunction)py_xml_parse_filelists, - METH_VARARGS, NULL}, + METH_VARARGS, xml_parse_filelists__doc__}, {"xml_parse_other", (PyCFunction)py_xml_parse_other, - METH_VARARGS, NULL}, + METH_VARARGS, xml_parse_other__doc__}, {"xml_parse_repomd", (PyCFunction)py_xml_parse_repomd, - METH_VARARGS, NULL}, + METH_VARARGS, xml_parse_repomd__doc__}, {"checksum_name_str", (PyCFunction)py_checksum_name_str, - METH_VARARGS, NULL}, + METH_VARARGS, checksum_name_str__doc__}, {"checksum_type", (PyCFunction)py_checksum_type, - METH_VARARGS, NULL}, - {"compress_file", (PyCFunction)py_compress_file_with_stat, - METH_VARARGS, NULL}, + METH_VARARGS, checksum_type__doc__}, + {"compress_file_with_stat", (PyCFunction)py_compress_file_with_stat, + METH_VARARGS, compress_file_with_stat__doc__}, {"compression_suffix", (PyCFunction)py_compression_suffix, - METH_VARARGS, NULL}, + METH_VARARGS, compression_suffix__doc__}, {"detect_compression", (PyCFunction)py_detect_compression, - METH_VARARGS, NULL}, + METH_VARARGS, detect_compression__doc__}, { NULL } }; diff --git a/src/python/exception-py.c b/src/python/exception-py.c index 736baab..899e1f8 100644 --- a/src/python/exception-py.c +++ b/src/python/exception-py.c @@ -27,7 +27,8 @@ PyObject *CrErr_Exception = NULL; int init_exceptions() { - CrErr_Exception = PyErr_NewException("createrepo_c.CreaterepoCError", NULL, NULL); + CrErr_Exception = PyErr_NewExceptionWithDoc("createrepo_c.CreaterepoCError", + "Createrepo_c library exception", NULL, NULL); if (!CrErr_Exception) return 0; Py_INCREF(CrErr_Exception); diff --git a/src/python/load_metadata-py.c b/src/python/load_metadata-py.c index e2a5a6b..deddb0e 100644 --- a/src/python/load_metadata-py.c +++ b/src/python/load_metadata-py.c @@ -63,6 +63,16 @@ metadata_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return (PyObject *)self; } +PyDoc_STRVAR(metadata_init__doc__, +".. method:: __init__(key=HT_KEY_DEFAULT, use_single_chunk=False, pkglist=[])\n\n" +" :arg key: Which value shoud be used as a key. One of HT_KEY_* constants.\n" +" :arg use_single_chunk: Specify if all package strings should be stored\n" +" in metadata object instead of package iself. This save some\n" +" space if you need to have a all packages loaded into a memory.\n" +" :arg pkglist: Package list that specify which packages shloud be\n" +" loaded. Use its base filename (e.g.\n" +" \"GConf2-3.2.6-6.fc19.i686.rpm\").\n"); + static int metadata_init(_MetadataObject *self, PyObject *args, PyObject *kwds) { @@ -120,12 +130,16 @@ get_key(_MetadataObject *self, void *nothing) } static PyGetSetDef metadata_getsetters[] = { - {"key", (getter)get_key, NULL, NULL, NULL}, + {"key", (getter)get_key, NULL, "Type of used key", NULL}, {NULL, NULL, NULL, NULL, NULL} /* sentinel */ }; /* Metadata methods */ +PyDoc_STRVAR(load_xml__doc__, +"load_xml(metadata_location_object) -> None\n\n" +"Load XML specified by MetadataLocation Object"); + static PyObject * load_xml(_MetadataObject *self, PyObject *args) { @@ -147,6 +161,10 @@ load_xml(_MetadataObject *self, PyObject *args) Py_RETURN_NONE; } +PyDoc_STRVAR(locate_and_load_xml__doc__, +"locate_and_load_xml(path) -> None" +"Load XML specified by path"); + static PyObject * locate_and_load_xml(_MetadataObject *self, PyObject *args) { @@ -169,6 +187,10 @@ locate_and_load_xml(_MetadataObject *self, PyObject *args) /* Hashtable methods */ +PyDoc_STRVAR(len__doc__, +"len() -> long\n\n" +"Number of packages"); + static PyObject * ht_len(_MetadataObject *self, PyObject *noarg) { @@ -206,6 +228,10 @@ ht_add(_MetadataObject *self, PyObject *args) } */ +PyDoc_STRVAR(has_key__doc__, +"has_key(key) -> bool\n\n" +"Test if metadata contains the key"); + static PyObject * ht_has_key(_MetadataObject *self, PyObject *args) { @@ -221,6 +247,10 @@ ht_has_key(_MetadataObject *self, PyObject *args) Py_RETURN_FALSE; } +PyDoc_STRVAR(keys__doc__, +"keys() -> list\n\n" +"List of all keys"); + static PyObject * ht_keys(_MetadataObject *self, PyObject *args) { @@ -247,6 +277,10 @@ ht_keys(_MetadataObject *self, PyObject *args) return list; } +PyDoc_STRVAR(remove__doc__, +"remove(key) -> bool\n\n" +"Remove package which has a key key from the metadata"); + static PyObject * ht_remove(_MetadataObject *self, PyObject *args) { @@ -262,6 +296,10 @@ ht_remove(_MetadataObject *self, PyObject *args) Py_RETURN_FALSE; } +PyDoc_STRVAR(get__doc__, +"get(key) -> Package\n\n" +"Get Package which has a key key"); + static PyObject * ht_get(_MetadataObject *self, PyObject *args) { @@ -279,14 +317,16 @@ ht_get(_MetadataObject *self, PyObject *args) } static struct PyMethodDef metadata_methods[] = { - {"load_xml", (PyCFunction)load_xml, METH_VARARGS, NULL}, - {"locate_and_load_xml", (PyCFunction)locate_and_load_xml, METH_VARARGS, NULL}, - {"len", (PyCFunction)ht_len, METH_NOARGS, NULL}, + {"load_xml", (PyCFunction)load_xml, METH_VARARGS, + load_xml__doc__}, + {"locate_and_load_xml", (PyCFunction)locate_and_load_xml, METH_VARARGS, + locate_and_load_xml__doc__}, + {"len", (PyCFunction)ht_len, METH_NOARGS, len__doc__}, // {"add", (PyCFunction)ht_add, METH_VARARGS, NULL}, - {"has_key", (PyCFunction)ht_has_key, METH_VARARGS, NULL}, - {"keys", (PyCFunction)ht_keys, METH_NOARGS, NULL}, - {"remove", (PyCFunction)ht_remove, METH_VARARGS, NULL}, - {"get", (PyCFunction)ht_get, METH_VARARGS, NULL}, + {"has_key", (PyCFunction)ht_has_key, METH_VARARGS, has_key__doc__}, + {"keys", (PyCFunction)ht_keys, METH_NOARGS, keys__doc__}, + {"remove", (PyCFunction)ht_remove, METH_VARARGS, remove__doc__}, + {"get", (PyCFunction)ht_get, METH_VARARGS, get__doc__}, {NULL} /* sentinel */ }; @@ -314,7 +354,7 @@ PyTypeObject Metadata_Type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Metadata object", /* tp_doc */ + metadata_init__doc__, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ diff --git a/src/python/locate_metadata-py.c b/src/python/locate_metadata-py.c index 528d4bd..607f6b1 100644 --- a/src/python/locate_metadata-py.c +++ b/src/python/locate_metadata-py.c @@ -66,6 +66,13 @@ metadatalocation_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return (PyObject *)self; } +PyDoc_STRVAR(metadatalocation_init__doc__, +"Class representing location of metadata\n\n" +".. method:: __init__(path, ignore_db)\n\n" +" :arg path: String with url/path to the repository\n" +" :arg ignore_db: Boolean. If False then in case of remote repository\n" +" databases will not be downloaded)\n"); + static int metadatalocation_init(_MetadataLocationObject *self, PyObject *args, PyObject *kwds) { @@ -194,7 +201,7 @@ PyTypeObject MetadataLocation_Type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ - "MetadataLocation object", /* tp_doc */ + metadatalocation_init__doc__, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ diff --git a/src/python/metadata_hashtable.c b/src/python/metadata_hashtable.c index f131de7..34d2d89 100644 --- a/src/python/metadata_hashtable.c +++ b/src/python/metadata_hashtable.c @@ -184,6 +184,10 @@ keys(_MetadataHashtableObject *self, PyObject *args) return list; } +PyDoc_STRVAR(del_doc, +"del(key) -> bool\n\n" +"Delete a package specified by key from the hashtable."); + static PyObject * del(_MetadataHashtableObject *self, PyObject *args) { @@ -204,7 +208,7 @@ static struct PyMethodDef metadata_methods[] = { // {"add", (PyCFunction)add, METH_VARARGS, NULL}, {"has_key", (PyCFunction)has_key, METH_VARARGS, NULL}, {"keys", (PyCFunction)keys, METH_NOARGS, NULL}, - {"del", (PyCFunction)del, METH_VARARGS, NULL}, + {"del", (PyCFunction)del, METH_VARARGS, del_doc}, {NULL} /* sentinel */ }; diff --git a/src/python/misc-py.h b/src/python/misc-py.h index 78ebca5..75f11c5 100644 --- a/src/python/misc-py.h +++ b/src/python/misc-py.h @@ -22,6 +22,11 @@ #include "src/createrepo_c.h" +PyDoc_STRVAR(compress_file_with_stat__doc__, +"compress_file_with_stat(source, destination, compression_type, " +"contentstat_object) -> None\n\n" +"Compress file. destination and contentstat_object could be None"); + PyObject *py_compress_file_with_stat(PyObject *self, PyObject *args); #endif diff --git a/src/python/package-py.c b/src/python/package-py.c index 1240659..e573095 100644 --- a/src/python/package-py.c +++ b/src/python/package-py.c @@ -102,6 +102,11 @@ package_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return (PyObject *)self; } +PyDoc_STRVAR(package_init__doc__, +"Package object\n\n" +".. method:: __init__()\n\n" +" Default constructor\n"); + static int package_init(_PackageObject *self, PyObject *args, PyObject *kwds) { @@ -170,6 +175,10 @@ package_str(_PackageObject *self) /* Package methods */ +PyDoc_STRVAR(nvra__doc__, +"nvra() -> str\n\n" +"Package NVRA string (Name-Version-Release-Architecture)"); + static PyObject * nvra(_PackageObject *self, void *nothing) { @@ -183,6 +192,10 @@ nvra(_PackageObject *self, void *nothing) return pystr; } +PyDoc_STRVAR(nevra__doc__, +"nevra() -> str\n\n" +"Package NEVRA string (Name-Epoch-Version-Release-Architecture)"); + static PyObject * nevra(_PackageObject *self, void *nothing) { @@ -196,6 +209,10 @@ nevra(_PackageObject *self, void *nothing) return pystr; } +PyDoc_STRVAR(copy__doc__, +"copy() -> Package\n\n" +"Copy of the package object"); + static PyObject * copy_pkg(_PackageObject *self, void *nothing) { @@ -206,9 +223,9 @@ copy_pkg(_PackageObject *self, void *nothing) } static struct PyMethodDef package_methods[] = { - {"nvra", (PyCFunction)nvra, METH_NOARGS, NULL}, - {"nevra", (PyCFunction)nevra, METH_NOARGS, NULL}, - {"copy", (PyCFunction)copy_pkg, METH_NOARGS, NULL}, + {"nvra", (PyCFunction)nvra, METH_NOARGS, nvra__doc__}, + {"nevra", (PyCFunction)nevra, METH_NOARGS, nevra__doc__}, + {"copy", (PyCFunction)copy_pkg, METH_NOARGS, copy__doc__}, {NULL} /* sentinel */ }; @@ -433,37 +450,77 @@ set_list(_PackageObject *self, PyObject *list, void *conv) } static PyGetSetDef package_getsetters[] = { - {"pkgId", (getter)get_str, (setter)set_str, NULL, OFFSET(pkgId)}, - {"name", (getter)get_str, (setter)set_str, NULL, OFFSET(name)}, - {"arch", (getter)get_str, (setter)set_str, NULL, OFFSET(arch)}, - {"version", (getter)get_str, (setter)set_str, NULL, OFFSET(version)}, - {"epoch", (getter)get_str, (setter)set_str, NULL, OFFSET(epoch)}, - {"release", (getter)get_str, (setter)set_str, NULL, OFFSET(release)}, - {"summary", (getter)get_str, (setter)set_str, NULL, OFFSET(summary)}, - {"description", (getter)get_str, (setter)set_str, NULL, OFFSET(description)}, - {"url", (getter)get_str, (setter)set_str, NULL, OFFSET(url)}, - {"time_file", (getter)get_num, (setter)set_num, NULL, OFFSET(time_file)}, - {"time_build", (getter)get_num, (setter)set_num, NULL, OFFSET(time_build)}, - {"rpm_license", (getter)get_str, (setter)set_str, NULL, OFFSET(rpm_license)}, - {"rpm_vendor", (getter)get_str, (setter)set_str, NULL, OFFSET(rpm_vendor)}, - {"rpm_group", (getter)get_str, (setter)set_str, NULL, OFFSET(rpm_group)}, - {"rpm_buildhost", (getter)get_str, (setter)set_str, NULL, OFFSET(rpm_buildhost)}, - {"rpm_sourcerpm", (getter)get_str, (setter)set_str, NULL, OFFSET(rpm_sourcerpm)}, - {"rpm_header_start", (getter)get_num, (setter)set_num, NULL, OFFSET(rpm_header_start)}, - {"rpm_header_end", (getter)get_num, (setter)set_num, NULL, OFFSET(rpm_header_end)}, - {"rpm_packager", (getter)get_str, (setter)set_str, NULL, OFFSET(rpm_packager)}, - {"size_package", (getter)get_num, (setter)set_num, NULL, OFFSET(size_package)}, - {"size_installed", (getter)get_num, (setter)set_num, NULL, OFFSET(size_installed)}, - {"size_archive", (getter)get_num, (setter)set_num, NULL, OFFSET(size_archive)}, - {"location_href", (getter)get_str, (setter)set_str, NULL, OFFSET(location_href)}, - {"location_base", (getter)get_str, (setter)set_str, NULL, OFFSET(location_base)}, - {"checksum_type", (getter)get_str, (setter)set_str, NULL, OFFSET(checksum_type)}, - {"requires", (getter)get_list, (setter)set_list, NULL, &(list_convertors[0])}, - {"provides", (getter)get_list, (setter)set_list, NULL, &(list_convertors[1])}, - {"conflicts", (getter)get_list, (setter)set_list, NULL, &(list_convertors[2])}, - {"obsoletes", (getter)get_list, (setter)set_list, NULL, &(list_convertors[3])}, - {"files", (getter)get_list, (setter)set_list, NULL, &(list_convertors[4])}, - {"changelogs", (getter)get_list, (setter)set_list, NULL, &(list_convertors[5])}, + {"pkgId", (getter)get_str, (setter)set_str, + "Checksum of the package file", OFFSET(pkgId)}, + {"name", (getter)get_str, (setter)set_str, + "Name of the package", OFFSET(name)}, + {"arch", (getter)get_str, (setter)set_str, + "Architecture for which the package was built", OFFSET(arch)}, + {"version", (getter)get_str, (setter)set_str, + "Version of the packaged software", OFFSET(version)}, + {"epoch", (getter)get_str, (setter)set_str, + "Epoch", OFFSET(epoch)}, + {"release", (getter)get_str, (setter)set_str, + "Release number of the package", OFFSET(release)}, + {"summary", (getter)get_str, (setter)set_str, + "Short description of the packaged software", OFFSET(summary)}, + {"description", (getter)get_str, (setter)set_str, + "In-depth description of the packaged software", + OFFSET(description)}, + {"url", (getter)get_str, (setter)set_str, + "URL with more information about packaged software", OFFSET(url)}, + {"time_file", (getter)get_num, (setter)set_num, + "mtime of the package file", OFFSET(time_file)}, + {"time_build", (getter)get_num, (setter)set_num, + "Time when package was builded", OFFSET(time_build)}, + {"rpm_license", (getter)get_str, (setter)set_str, + "License term applicable to the package software (GPLv2, etc.)", + OFFSET(rpm_license)}, + {"rpm_vendor", (getter)get_str, (setter)set_str, + "Name of the organization producing the package", + OFFSET(rpm_vendor)}, + {"rpm_group", (getter)get_str, (setter)set_str, + "RPM group (See: http://fedoraproject.org/wiki/RPMGroups)", + OFFSET(rpm_group)}, + {"rpm_buildhost", (getter)get_str, (setter)set_str, + "Hostname of the system that built the package", + OFFSET(rpm_buildhost)}, + {"rpm_sourcerpm", (getter)get_str, (setter)set_str, + "Name of the source package from which this binary package was built", + OFFSET(rpm_sourcerpm)}, + {"rpm_header_start", (getter)get_num, (setter)set_num, + "First byte of the header", OFFSET(rpm_header_start)}, + {"rpm_header_end", (getter)get_num, (setter)set_num, + "Last byte of the header", OFFSET(rpm_header_end)}, + {"rpm_packager", (getter)get_str, (setter)set_str, + "Person or persons responsible for creating the package", + OFFSET(rpm_packager)}, + {"size_package", (getter)get_num, (setter)set_num, + "Size, in bytes, of the package", OFFSET(size_package)}, + {"size_installed", (getter)get_num, (setter)set_num, + "Total size, in bytes, of every file installed by this package", + OFFSET(size_installed)}, + {"size_archive", (getter)get_num, (setter)set_num, + "Size, in bytes, of the archive portion of the original package file", + OFFSET(size_archive)}, + {"location_href", (getter)get_str, (setter)set_str, + "Relative location of package to the repodata", OFFSET(location_href)}, + {"location_base", (getter)get_str, (setter)set_str, + "Base location of this package", OFFSET(location_base)}, + {"checksum_type", (getter)get_str, (setter)set_str, + "Type of checksum", OFFSET(checksum_type)}, + {"requires", (getter)get_list, (setter)set_list, + "Capabilities the package requires", &(list_convertors[0])}, + {"provides", (getter)get_list, (setter)set_list, + "Capabilities the package provides", &(list_convertors[1])}, + {"conflicts", (getter)get_list, (setter)set_list, + "Capability the package conflicts with", &(list_convertors[2])}, + {"obsoletes", (getter)get_list, (setter)set_list, + "Capability the package obsoletes", &(list_convertors[3])}, + {"files", (getter)get_list, (setter)set_list, + "Files that package contains", &(list_convertors[4])}, + {"changelogs", (getter)get_list, (setter)set_list, + "Changelogs that package contains", &(list_convertors[5])}, {NULL, NULL, NULL, NULL, NULL} /* sentinel */ }; @@ -491,7 +548,7 @@ PyTypeObject Package_Type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Package object", /* tp_doc */ + package_init__doc__, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ diff --git a/src/python/parsepkg-py.h b/src/python/parsepkg-py.h index cf337c3..732ec17 100644 --- a/src/python/parsepkg-py.h +++ b/src/python/parsepkg-py.h @@ -22,7 +22,18 @@ #include "src/createrepo_c.h" +PyDoc_STRVAR(package_from_rpm__doc__, +"package_from_rpm(filename, checksum_type, location_href, " +"location_base, changelog_limit) -> Package\n\n" +"Package object from the rpm package"); + PyObject *py_package_from_rpm(PyObject *self, PyObject *args); + +PyDoc_STRVAR(xml_from_rpm__doc__, +"xml_from_rpm(filename, checksum_type, location_href, " +"location_base, changelog_limit) -> (str, str, str)\n\n" +"XML for the package rpm package"); + PyObject *py_xml_from_rpm(PyObject *self, PyObject *args); #endif diff --git a/src/python/repomd-py.c b/src/python/repomd-py.c index 4e47257..3bdd79d 100644 --- a/src/python/repomd-py.c +++ b/src/python/repomd-py.c @@ -68,6 +68,9 @@ repomd_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return (PyObject *)self; } +PyDoc_STRVAR(repomd_init__doc__, +"Repomd object"); + static int repomd_init(_RepomdObject *self, PyObject *args, PyObject *kwds) { @@ -106,6 +109,10 @@ repomd_repr(_RepomdObject *self) /* Repomd methods */ +PyDoc_STRVAR(set_record__doc__, +"set_record(repomdrecord) -> None\n\n" +"Add RepomdRecord"); + static PyObject * set_record(_RepomdObject *self, PyObject *args) { @@ -123,6 +130,10 @@ set_record(_RepomdObject *self, PyObject *args) Py_RETURN_NONE; } +PyDoc_STRVAR(set_revision__doc__, +"set_revision(revision) -> None\n\n" +"Set revision string"); + static PyObject * set_revision(_RepomdObject *self, PyObject *args) { @@ -135,6 +146,10 @@ set_revision(_RepomdObject *self, PyObject *args) Py_RETURN_NONE; } +PyDoc_STRVAR(set_repoid__doc__, +"set_repoid(repoid, repoid_type) -> None\n\n" +"Set repoid value and repoid_type"); + static PyObject * set_repoid(_RepomdObject *self, PyObject *args) { @@ -147,7 +162,11 @@ set_repoid(_RepomdObject *self, PyObject *args) Py_RETURN_NONE; } - static PyObject * +PyDoc_STRVAR(add_distro_tag__doc__, +"add_distro_tag(tag[, cpeid=None]) -> None\n\n" +"Add distro tag"); + +static PyObject * add_distro_tag(_RepomdObject *self, PyObject *args, PyObject *kwargs) { static char *kwlist[] = { "tag", "cpeid", NULL }; @@ -162,6 +181,10 @@ add_distro_tag(_RepomdObject *self, PyObject *args, PyObject *kwargs) Py_RETURN_NONE; } +PyDoc_STRVAR(add_repo_tag__doc__, +"add_repo_tag(tag) -> None\n\n" +"Add repo tag"); + static PyObject * add_repo_tag(_RepomdObject *self, PyObject *args) { @@ -174,6 +197,10 @@ add_repo_tag(_RepomdObject *self, PyObject *args) Py_RETURN_NONE; } +PyDoc_STRVAR(add_content_tag__doc__, +"add_content_tag(tag) -> None\n\n" +"Add content tag"); + static PyObject * add_content_tag(_RepomdObject *self, PyObject *args) { @@ -186,6 +213,10 @@ add_content_tag(_RepomdObject *self, PyObject *args) Py_RETURN_NONE; } +PyDoc_STRVAR(xml_dump__doc__, +"xml_dump() -> str\n\n" +"Generate xml representation of the repomd"); + static PyObject * xml_dump(_RepomdObject *self, void *nothing) { @@ -203,13 +234,20 @@ xml_dump(_RepomdObject *self, void *nothing) } static struct PyMethodDef repomd_methods[] = { - {"set_record", (PyCFunction)set_record, METH_VARARGS, NULL}, - {"set_revision", (PyCFunction)set_revision, METH_VARARGS, NULL}, - {"set_repoid", (PyCFunction)set_repoid, METH_VARARGS, NULL}, - {"add_distro_tag", (PyCFunction)add_distro_tag, METH_VARARGS|METH_KEYWORDS, NULL}, - {"add_repo_tag", (PyCFunction)add_repo_tag, METH_VARARGS, NULL}, - {"add_content_tag", (PyCFunction)add_content_tag, METH_VARARGS, NULL}, - {"xml_dump", (PyCFunction)xml_dump, METH_NOARGS, NULL}, + {"set_record", (PyCFunction)set_record, METH_VARARGS, + set_record__doc__}, + {"set_revision", (PyCFunction)set_revision, METH_VARARGS, + set_revision__doc__}, + {"set_repoid", (PyCFunction)set_repoid, METH_VARARGS, + set_repoid__doc__}, + {"add_distro_tag", (PyCFunction)add_distro_tag, METH_VARARGS|METH_KEYWORDS, + add_distro_tag__doc__}, + {"add_repo_tag", (PyCFunction)add_repo_tag, METH_VARARGS, + add_repo_tag__doc__}, + {"add_content_tag", (PyCFunction)add_content_tag, METH_VARARGS, + add_content_tag__doc__}, + {"xml_dump", (PyCFunction)xml_dump, METH_NOARGS, + xml_dump__doc__}, {NULL} /* sentinel */ }; @@ -372,13 +410,20 @@ set_list(_RepomdObject *self, PyObject *list, void *conv) #define OFFSET(member) (void *) offsetof(cr_Repomd, member) static PyGetSetDef repomd_getsetters[] = { - {"revision", (getter)get_str, (setter)set_str, NULL, OFFSET(revision)}, - {"repoid", (getter)get_str, (setter)set_str, NULL, OFFSET(repoid)}, - {"repoid_type", (getter)get_str, (setter)set_str, NULL, OFFSET(repoid_type)}, - {"repo_tags", (getter)get_list, (setter)set_list, NULL, &(list_convertors[0])}, - {"distro_tags", (getter)get_list, (setter)set_list, NULL, &(list_convertors[1])}, - {"content_tags", (getter)get_list, (setter)set_list, NULL, &(list_convertors[2])}, - {"records", (getter)get_list, (setter)NULL, NULL, &(list_convertors[3])}, + {"revision", (getter)get_str, (setter)set_str, + "Revision value", OFFSET(revision)}, + {"repoid", (getter)get_str, (setter)set_str, + "Repoid value", OFFSET(repoid)}, + {"repoid_type", (getter)get_str, (setter)set_str, + "Repoid type value", OFFSET(repoid_type)}, + {"repo_tags", (getter)get_list, (setter)set_list, + "List of repo tags", &(list_convertors[0])}, + {"distro_tags", (getter)get_list, (setter)set_list, + "List of distro tags", &(list_convertors[1])}, + {"content_tags", (getter)get_list, (setter)set_list, + "List of content tags", &(list_convertors[2])}, + {"records", (getter)get_list, (setter)NULL, + "List of RepomdRecords", &(list_convertors[3])}, {NULL, NULL, NULL, NULL, NULL} /* sentinel */ }; @@ -407,7 +452,7 @@ PyTypeObject Repomd_Type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Repomd object", /* tp_doc */ + repomd_init__doc__, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ diff --git a/src/python/repomdrecord-py.c b/src/python/repomdrecord-py.c index 6f1c3e3..019e1e4 100644 --- a/src/python/repomdrecord-py.c +++ b/src/python/repomdrecord-py.c @@ -84,6 +84,11 @@ repomdrecord_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return (PyObject *)self; } +PyDoc_STRVAR(repomdrecord_init__doc__, +".. method:: __init__([type[, path]])\n\n" +" :arg type: String with type of the file (e.g. primary, primary_db, etc.)\n" +" :arg path: Path to the file\n"); + static int repomdrecord_init(_RepomdRecordObject *self, PyObject *args, PyObject *kwds) { @@ -129,6 +134,10 @@ repomdrecord_repr(_RepomdRecordObject *self) /* RepomdRecord methods */ +PyDoc_STRVAR(copy__doc__, +"copy() -> RepomdRecord\n\n" +"Return copy of the RepomdRecord object"); + static PyObject * copy_repomdrecord(_RepomdRecordObject *self, void *nothing) { @@ -138,6 +147,10 @@ copy_repomdrecord(_RepomdRecordObject *self, void *nothing) return Object_FromRepomdRecord(cr_repomd_record_copy(self->record)); } +PyDoc_STRVAR(fill__doc__, +"fill() -> None\n\n" +"Fill unfilled items in the RepomdRecord (sizes and checksums)"); + static PyObject * fill(_RepomdRecordObject *self, PyObject *args) { @@ -159,6 +172,13 @@ fill(_RepomdRecordObject *self, PyObject *args) Py_RETURN_NONE; } +PyDoc_STRVAR(compress_and_fill__doc__, +"compress_and_fill(empty_repomdrecord[, checksum_type, compression_type]) " +"-> None\n\n" +"Almost analogous to fill() but suitable for groupfile. " +"Record must be set with the path to existing non compressed groupfile. " +"Compressed file will be created and compressed_record updated."); + static PyObject * compress_and_fill(_RepomdRecordObject *self, PyObject *args) { @@ -189,6 +209,10 @@ compress_and_fill(_RepomdRecordObject *self, PyObject *args) Py_RETURN_NONE; } +PyDoc_STRVAR(rename_file__doc__, +"rename_file() -> None\n\n" +"Add (prepend) file checksum to the filename"); + static PyObject * rename_file(_RepomdRecordObject *self, void *nothing) { @@ -205,6 +229,12 @@ rename_file(_RepomdRecordObject *self, void *nothing) Py_RETURN_NONE; } +PyDoc_STRVAR(load_contentstat__doc__, +"load_contentstat(contentstat) -> None\n\n" +"Load some content statistics from the ContentStat object. " +"The statistics loaded from ContentStat doesn't have to be " +"calculated during a fill() method call and thus speed up the method."); + static PyObject * load_contentstat(_RepomdRecordObject *self, PyObject *args) { @@ -224,11 +254,16 @@ load_contentstat(_RepomdRecordObject *self, PyObject *args) } static struct PyMethodDef repomdrecord_methods[] = { - {"copy", (PyCFunction)copy_repomdrecord, METH_NOARGS, NULL}, - {"fill", (PyCFunction)fill, METH_VARARGS, NULL}, - {"compress_and_fill", (PyCFunction)compress_and_fill, METH_VARARGS, NULL}, - {"rename_file", (PyCFunction)rename_file, METH_NOARGS, NULL}, - {"load_contentstat", (PyCFunction)load_contentstat, METH_VARARGS, NULL}, + {"copy", (PyCFunction)copy_repomdrecord, METH_NOARGS, + copy__doc__}, + {"fill", (PyCFunction)fill, METH_VARARGS, + fill__doc__}, + {"compress_and_fill", (PyCFunction)compress_and_fill, METH_VARARGS, + compress_and_fill__doc__}, + {"rename_file", (PyCFunction)rename_file, METH_NOARGS, + rename_file__doc__}, + {"load_contentstat", (PyCFunction)load_contentstat, METH_VARARGS, + load_contentstat__doc__}, {NULL} /* sentinel */ }; @@ -323,18 +358,31 @@ set_str(_RepomdRecordObject *self, PyObject *value, void *member_offset) } static PyGetSetDef repomdrecord_getsetters[] = { - {"type", (getter)get_str, (setter)set_str, NULL, OFFSET(type)}, - {"location_real", (getter)get_str, (setter)set_str, NULL, OFFSET(location_real)}, - {"location_href", (getter)get_str, (setter)set_str, NULL, OFFSET(location_href)}, - {"location_base", (getter)get_str, (setter)set_str, NULL, OFFSET(location_base)}, - {"checksum", (getter)get_str, (setter)set_str, NULL, OFFSET(checksum)}, - {"checksum_type", (getter)get_str, (setter)set_str, NULL, OFFSET(checksum_type)}, - {"checksum_open", (getter)get_str, (setter)set_str, NULL, OFFSET(checksum_open)}, - {"checksum_open_type", (getter)get_str, (setter)set_str, NULL, OFFSET(checksum_open_type)}, - {"timestamp", (getter)get_num, (setter)set_num, NULL, OFFSET(timestamp)}, - {"size", (getter)get_num, (setter)set_num, NULL, OFFSET(size)}, - {"size_open", (getter)get_num, (setter)set_num, NULL, OFFSET(size_open)}, - {"db_ver", (getter)get_int, (setter)set_int, NULL, OFFSET(db_ver)}, + {"type", (getter)get_str, (setter)set_str, + "Record type", OFFSET(type)}, + {"location_real", (getter)get_str, (setter)set_str, + "Currentlocation of the file in the system", OFFSET(location_real)}, + {"location_href", (getter)get_str, (setter)set_str, + "Relative location of the file in a repository", OFFSET(location_href)}, + {"location_base", (getter)get_str, (setter)set_str, + "Base location of the file", OFFSET(location_base)}, + {"checksum", (getter)get_str, (setter)set_str, + "Checksum of the file", OFFSET(checksum)}, + {"checksum_type", (getter)get_str, (setter)set_str, + "Type of the file checksum", OFFSET(checksum_type)}, + {"checksum_open", (getter)get_str, (setter)set_str, + "Checksum of the archive content", OFFSET(checksum_open)}, + {"checksum_open_type", (getter)get_str, (setter)set_str, + "Type of the archive content checksum", OFFSET(checksum_open_type)}, + {"timestamp", (getter)get_num, (setter)set_num, + "Mtime of the file", OFFSET(timestamp)}, + {"size", (getter)get_num, (setter)set_num, + "Size of the file", OFFSET(size)}, + {"size_open", (getter)get_num, (setter)set_num, + "Size of the archive content", OFFSET(size_open)}, + {"db_ver", (getter)get_int, (setter)set_int, + "Database version (used only for sqlite databases like " + "primary.sqlite etc.)", OFFSET(db_ver)}, {NULL, NULL, NULL, NULL, NULL} /* sentinel */ }; @@ -362,7 +410,7 @@ PyTypeObject RepomdRecord_Type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ - "RepomdRecord object", /* tp_doc */ + repomdrecord_init__doc__, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ diff --git a/src/python/sqlite-py.c b/src/python/sqlite-py.c index b720ff6..cb8f373 100644 --- a/src/python/sqlite-py.c +++ b/src/python/sqlite-py.c @@ -61,6 +61,12 @@ sqlite_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return (PyObject *)self; } +PyDoc_STRVAR(sqlite_init__doc__, +"Sqlite object\n\n" +".. method:: __init__(path, db_type)\n\n" +" :arg path: Path to the database\n" +" :arg db_type: One from DB_PRIMARY, DB_FILELISTS, DB_OTHER constans\n"); + static int sqlite_init(_SqliteObject *self, PyObject *args, PyObject *kwds) { @@ -120,6 +126,10 @@ sqlite_repr(_SqliteObject *self) /* Sqlite methods */ +PyDoc_STRVAR(add_pkg__doc__, +"add_pkg(Package) -> None\n\n" +"Add Package to the database"); + static PyObject * add_pkg(_SqliteObject *self, PyObject *args) { @@ -141,6 +151,10 @@ add_pkg(_SqliteObject *self, PyObject *args) Py_RETURN_NONE; } +PyDoc_STRVAR(dbinfo_update__doc__, +"dbinfo_update(checksum) -> None\n\n" +"Set checksum of the xml file representing same data"); + static PyObject * dbinfo_update(_SqliteObject *self, PyObject *args) { @@ -162,6 +176,10 @@ dbinfo_update(_SqliteObject *self, PyObject *args) Py_RETURN_NONE; } +PyDoc_STRVAR(close__doc__, +"close() -> None\n\n" +"Close the sqlite database"); + static PyObject * close_db(_SqliteObject *self, void *nothing) { @@ -182,9 +200,12 @@ close_db(_SqliteObject *self, void *nothing) } static struct PyMethodDef sqlite_methods[] = { - {"add_pkg", (PyCFunction)add_pkg, METH_VARARGS, NULL}, - {"dbinfo_update", (PyCFunction)dbinfo_update, METH_VARARGS, NULL}, - {"close", (PyCFunction)close_db, METH_NOARGS, NULL}, + {"add_pkg", (PyCFunction)add_pkg, METH_VARARGS, + add_pkg__doc__}, + {"dbinfo_update", (PyCFunction)dbinfo_update, METH_VARARGS, + dbinfo_update__doc__}, + {"close", (PyCFunction)close_db, METH_NOARGS, + close__doc__}, {NULL} /* sentinel */ }; @@ -210,7 +231,7 @@ PyTypeObject Sqlite_Type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Sqlite object", /* tp_doc */ + sqlite_init__doc__, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ diff --git a/src/python/xml_dump-py.h b/src/python/xml_dump-py.h index 17c3170..8699e3a 100644 --- a/src/python/xml_dump-py.h +++ b/src/python/xml_dump-py.h @@ -22,9 +22,28 @@ #include "src/createrepo_c.h" +PyDoc_STRVAR(xml_dump_primary__doc__, +"xml_dump_primary(pkg) -> str\n\n" +"Generate primary xml chunk from the package"); + PyObject *py_xml_dump_primary(PyObject *self, PyObject *args); + +PyDoc_STRVAR(xml_dump_filelists__doc__, +"xml_dump_filelists(pkg) -> str\n\n" +"Generate filelists xml chunk from the package"); + PyObject *py_xml_dump_filelists(PyObject *self, PyObject *args); + +PyDoc_STRVAR(xml_dump_other__doc__, +"xml_dump_other(pkg) -> str\n\n" +"Generate other xml chunk from the package"); + PyObject *py_xml_dump_other(PyObject *self, PyObject *args); + +PyDoc_STRVAR(xml_dump__doc__, +"xml_dump(pkg) -> (str, str, str)\n\n" +"Generate primary, filelists and other xml chunks from the package"); + PyObject *py_xml_dump(PyObject *self, PyObject *args); #endif diff --git a/src/python/xml_file-py.c b/src/python/xml_file-py.c index d733be0..b5ff8fa 100644 --- a/src/python/xml_file-py.c +++ b/src/python/xml_file-py.c @@ -63,6 +63,15 @@ xmlfile_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return (PyObject *)self; } +PyDoc_STRVAR(xmlfile_init__doc__, +"XmlFile object represents a single XML file (primary, filelists or other).\n\n" +".. method:: __init__(path, type, compression_type, contentstat)\n\n" +" :arg path: Path to the database\n" +" :arg type: Type of the XML file. One from XMLFILE_PRIMARY,\n" +" XMLFILE_FILELISTS, XMLFILE_OTHER constants\n" +" :arg compression_type: Compression type specified by constant\n" +" :arg contentstat: ContentStat object to gather content statistics or None"); + static int xmlfile_init(_XmlFileObject *self, PyObject *args, PyObject *kwds) { @@ -153,6 +162,10 @@ xmlfile_repr(_XmlFileObject *self) /* XmlFile methods */ +PyDoc_STRVAR(set_num_of_pkgs__doc__, +"set_num_of_pkgs(number_of_packages) -> None\n\n" +"Set number of all packages"); + static PyObject * set_num_of_pkgs(_XmlFileObject *self, PyObject *args) { @@ -174,6 +187,10 @@ set_num_of_pkgs(_XmlFileObject *self, PyObject *args) Py_RETURN_NONE; } +PyDoc_STRVAR(add_pkg__doc__, +"add_pkg(Package) -> None\n\n" +"Add Package to the xml"); + static PyObject * add_pkg(_XmlFileObject *self, PyObject *args) { @@ -195,6 +212,10 @@ add_pkg(_XmlFileObject *self, PyObject *args) Py_RETURN_NONE; } +PyDoc_STRVAR(add_chunk__doc__, +"add_chunk(chunk) -> None\n\n" +"Add a string chunk to the xml"); + static PyObject * add_chunk(_XmlFileObject *self, PyObject *args) { @@ -216,6 +237,10 @@ add_chunk(_XmlFileObject *self, PyObject *args) Py_RETURN_NONE; } +PyDoc_STRVAR(close__doc__, +"close() -> None\n\n" +"Close the XML file"); + static PyObject * xmlfile_close(_XmlFileObject *self, void *nothing) { @@ -240,10 +265,14 @@ xmlfile_close(_XmlFileObject *self, void *nothing) } static struct PyMethodDef xmlfile_methods[] = { - {"set_num_of_pkgs", (PyCFunction)set_num_of_pkgs, METH_VARARGS, NULL}, - {"add_pkg", (PyCFunction)add_pkg, METH_VARARGS, NULL}, - {"add_chunk", (PyCFunction)add_chunk, METH_VARARGS, NULL}, - {"close", (PyCFunction)xmlfile_close, METH_NOARGS, NULL}, + {"set_num_of_pkgs", (PyCFunction)set_num_of_pkgs, METH_VARARGS, + set_num_of_pkgs__doc__}, + {"add_pkg", (PyCFunction)add_pkg, METH_VARARGS, + add_pkg__doc__}, + {"add_chunk", (PyCFunction)add_chunk, METH_VARARGS, + add_chunk__doc__}, + {"close", (PyCFunction)xmlfile_close, METH_NOARGS, + close__doc__}, {NULL} /* sentinel */ }; @@ -269,7 +298,7 @@ PyTypeObject XmlFile_Type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ - "XmlFile object", /* tp_doc */ + xmlfile_init__doc__, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ diff --git a/src/python/xml_parser-py.h b/src/python/xml_parser-py.h index c835afd..5e61f58 100644 --- a/src/python/xml_parser-py.h +++ b/src/python/xml_parser-py.h @@ -22,9 +22,28 @@ #include "src/createrepo_c.h" +PyDoc_STRVAR(xml_parse_primary__doc__, +"xml_parse_primary(filename, newpkgcb, pkgcb, warningcb, do_files) -> None\n\n" +"Parse primary.xml"); + PyObject *py_xml_parse_primary(PyObject *self, PyObject *args); + +PyDoc_STRVAR(xml_parse_filelists__doc__, +"xml_parse_filelists(filename, newpkgcb, pkgcb, warningcb) -> None\n\n" +"Parse filelists.xml"); + PyObject *py_xml_parse_filelists(PyObject *self, PyObject *args); + +PyDoc_STRVAR(xml_parse_other__doc__, +"xml_parse_other(filename, newpkgcb, pkgcb, warningcb) -> None\n\n" +"Parse other.xml"); + PyObject *py_xml_parse_other(PyObject *self, PyObject *args); + +PyDoc_STRVAR(xml_parse_repomd__doc__, +"xml_parse_repomd(filename, repomd_object, warningcb) -> None\n\n" +"Parse repomd.xml"); + PyObject *py_xml_parse_repomd(PyObject *self, PyObject *args); #endif diff --git a/src/repomd.h b/src/repomd.h index 6e1d9f9..cd4d5ee 100644 --- a/src/repomd.h +++ b/src/repomd.h @@ -145,7 +145,7 @@ int cr_repomd_record_fill(cr_RepomdRecord *record, cr_ChecksumType checksum_type, GError **err); -/** Almost analogue of cr_repomd_record_fill but suitable for groupfile. +/** Almost analogous to cr_repomd_record_fill but suitable for groupfile. * Record must be set with the path to existing non compressed groupfile. * Compressed file will be created and compressed_record updated. * @param record cr_RepomdRecord initialized to an existing