summaryrefslogtreecommitdiffstats
path: root/libmount/python/tab.c
diff options
context:
space:
mode:
authorKarel Zak2013-08-19 17:10:07 +0200
committerKarel Zak2013-08-19 17:10:07 +0200
commit5c7664f73572b365b9b014c5afdd0a0109e69846 (patch)
tree87fdfae75855d2c912b8b3564ab184e2c6feb468 /libmount/python/tab.c
parentpylibmount: coding style changes in tab.c (diff)
downloadkernel-qcow2-util-linux-5c7664f73572b365b9b014c5afdd0a0109e69846.tar.gz
kernel-qcow2-util-linux-5c7664f73572b365b9b014c5afdd0a0109e69846.tar.xz
kernel-qcow2-util-linux-5c7664f73572b365b9b014c5afdd0a0109e69846.zip
pylibmount: cleanup object names
Cxt -> Context Tab -> Table Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/python/tab.c')
-rw-r--r--libmount/python/tab.c193
1 files changed, 97 insertions, 96 deletions
diff --git a/libmount/python/tab.c b/libmount/python/tab.c
index 67a1b2bd2..3316ef46d 100644
--- a/libmount/python/tab.c
+++ b/libmount/python/tab.c
@@ -20,11 +20,11 @@
*/
#include "pylibmount.h"
-static PyMemberDef Tab_members[] = {
+static PyMemberDef Table_members[] = {
{ NULL }
};
-static int Tab_set_parser_errcb(TabObject *self, PyObject *func, void *closure __attribute__((unused)))
+static int Table_set_parser_errcb(TableObject *self, PyObject *func, void *closure __attribute__((unused)))
{
PyObject *tmp;
@@ -43,12 +43,12 @@ static int Tab_set_parser_errcb(TabObject *self, PyObject *func, void *closure _
return 0;
}
-static PyObject *Tab_get_intro_comment(TabObject *self, void *closure __attribute__((unused)))
+static PyObject *Table_get_intro_comment(TableObject *self, void *closure __attribute__((unused)))
{
return PyObjectResultStr(mnt_table_get_intro_comment(self->tab));
}
-static int Tab_set_intro_comment(TabObject *self, PyObject *value, void *closure __attribute__((unused)))
+static int Table_set_intro_comment(TableObject *self, PyObject *value, void *closure __attribute__((unused)))
{
char *comment = NULL;
int rc = 0;
@@ -67,12 +67,12 @@ static int Tab_set_intro_comment(TabObject *self, PyObject *value, void *closure
return 0;
}
-static PyObject *Tab_get_trailing_comment(TabObject *self, void *closure __attribute__((unused)))
+static PyObject *Table_get_trailing_comment(TableObject *self, void *closure __attribute__((unused)))
{
return PyObjectResultStr(mnt_table_get_trailing_comment(self->tab));
}
-static int Tab_set_trailing_comment(TabObject *self, PyObject *value, void *closure __attribute__((unused)))
+static int Table_set_trailing_comment(TableObject *self, PyObject *value, void *closure __attribute__((unused)))
{
char *comment = NULL;
int rc = 0;
@@ -91,7 +91,7 @@ static int Tab_set_trailing_comment(TabObject *self, PyObject *value, void *clos
return 0;
}
-#define Tab_enable_comments_HELP "enable_comments(enable)\n\n\
+#define Table_enable_comments_HELP "enable_comments(enable)\n\n\
Enables parsing of comments.\n\n\
The initial (intro) file comment is accessible by\n\
Tab.intro_comment. The intro and the comment of the first fstab\
@@ -112,10 +112,11 @@ LABEL=bar /mnt/bar auto defaults 1 2 \n\
# tailing comment\n\
</programlisting>\n\
</informalexample>"
-static PyObject *Tab_enable_comments(TabObject *self, PyObject *args, PyObject *kwds)
+static PyObject *Table_enable_comments(TableObject *self, PyObject *args, PyObject *kwds)
{
int enable = 0;
char *kwlist[] = {"enable", NULL};
+
if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", kwlist, &enable)) {
PyErr_SetString(PyExc_TypeError, ARG_ERR);
return NULL;
@@ -125,9 +126,9 @@ static PyObject *Tab_enable_comments(TabObject *self, PyObject *args, PyObject *
return (PyObject *)self;
}
-#define Tab_replace_file_HELP "replace_file(filename)\n\n\
-This function replaces filename with the new content from TabObject."
-static PyObject *Tab_replace_file(TabObject *self, PyObject *args, PyObject *kwds)
+#define Table_replace_file_HELP "replace_file(filename)\n\n\
+This function replaces filename with the new content from TableObject."
+static PyObject *Table_replace_file(TableObject *self, PyObject *args, PyObject *kwds)
{
int rc;
char *filename = NULL;
@@ -141,9 +142,9 @@ static PyObject *Tab_replace_file(TabObject *self, PyObject *args, PyObject *kwd
return rc ? UL_RaiseExc(-rc) : UL_IncRef(self);
}
-#define Tab_write_file_HELP "write_file(file)\n\n\
+#define Table_write_file_HELP "write_file(file)\n\n\
This function writes tab to file(stream)"
-static PyObject *Tab_write_file(TabObject *self, PyObject *args, PyObject *kwds)
+static PyObject *Table_write_file(TableObject *self, PyObject *args, PyObject *kwds)
{
int rc;
PyFileObject *stream = NULL;
@@ -159,11 +160,11 @@ static PyObject *Tab_write_file(TabObject *self, PyObject *args, PyObject *kwds)
return rc ? UL_RaiseExc(-rc) : UL_IncRef(self);
}
-#define Tab_find_devno_HELP "find_devno(devno, [direction])\n\n\
+#define Table_find_devno_HELP "find_devno(devno, [direction])\n\n\
Note that zero could be valid device number for root pseudo filesystem (e.g.\
tmpfs\n\
Returns a tab entry or None"
-static PyObject *Tab_find_devno(TabObject *self, PyObject *args, PyObject *kwds)
+static PyObject *Table_find_devno(TableObject *self, PyObject *args, PyObject *kwds)
{
dev_t devno;
int direction = MNT_ITER_BACKWARD;
@@ -176,9 +177,9 @@ static PyObject *Tab_find_devno(TabObject *self, PyObject *args, PyObject *kwds)
return PyObjectResultFs(mnt_table_find_devno(self->tab, devno, direction));
}
-#define Tab_find_mountpoint_HELP "find_mountpoint(path, [direction])\n\n\
+#define Table_find_mountpoint_HELP "find_mountpoint(path, [direction])\n\n\
Returns a tab entry or None."
-static PyObject *Tab_find_mountpoint(TabObject *self, PyObject *args, PyObject *kwds)
+static PyObject *Table_find_mountpoint(TableObject *self, PyObject *args, PyObject *kwds)
{
char *path;
int direction = MNT_ITER_BACKWARD;
@@ -191,9 +192,9 @@ static PyObject *Tab_find_mountpoint(TabObject *self, PyObject *args, PyObject *
return PyObjectResultFs(mnt_table_find_mountpoint(self->tab, path, direction));
}
-#define Tab_find_pair_HELP "find_pair(source, target, [direction])\n\n\
+#define Table_find_pair_HELP "find_pair(source, target, [direction])\n\n\
Returns a tab entry or None."
-static PyObject *Tab_find_pair(TabObject *self, PyObject *args, PyObject *kwds)
+static PyObject *Table_find_pair(TableObject *self, PyObject *args, PyObject *kwds)
{
char *kwlist[] = {"source", "target", "direction", NULL};
char *source;
@@ -207,9 +208,9 @@ static PyObject *Tab_find_pair(TabObject *self, PyObject *args, PyObject *kwds)
return PyObjectResultFs(mnt_table_find_pair(self->tab, source, target, direction));
}
-#define Tab_find_source_HELP "find_source(source, [direction])\n\n\
+#define Table_find_source_HELP "find_source(source, [direction])\n\n\
Returns a tab entry or None."
-static PyObject *Tab_find_source(TabObject *self, PyObject *args, PyObject *kwds)
+static PyObject *Table_find_source(TableObject *self, PyObject *args, PyObject *kwds)
{
char *kwlist[] = {"source", "direction", NULL};
char *source;
@@ -222,14 +223,14 @@ static PyObject *Tab_find_source(TabObject *self, PyObject *args, PyObject *kwds
return PyObjectResultFs(mnt_table_find_source(self->tab, source, direction));
}
-#define Tab_find_target_HELP "find_target(target, [direction])\n\n\
+#define Table_find_target_HELP "find_target(target, [direction])\n\n\
Try to lookup an entry in given tab, possible are three iterations, first\n\
with path, second with realpath(path) and third with realpath(path)\n\
against realpath(fs->target). The 2nd and 3rd iterations are not performed\n\
when tb cache is not set (cache not implemented yet).n\
\n\
Returns a tab entry or None."
-static PyObject *Tab_find_target(TabObject *self, PyObject *args, PyObject *kwds)
+static PyObject *Table_find_target(TableObject *self, PyObject *args, PyObject *kwds)
{
char *kwlist[] = {"target", "direction", NULL};
char *target;
@@ -242,7 +243,7 @@ static PyObject *Tab_find_target(TabObject *self, PyObject *args, PyObject *kwds
return PyObjectResultFs(mnt_table_find_target(self->tab, target, direction));
}
-#define Tab_find_srcpath_HELP "find_srcpath(srcpath, [direction])\n\n\
+#define Table_find_srcpath_HELP "find_srcpath(srcpath, [direction])\n\n\
Try to lookup an entry in given tab, possible are four iterations, first\n\
with path, second with realpath(path), third with tags (LABEL, UUID, ..)\n\
from path and fourth with realpath(path) against realpath(entry->srcpath).\n\
@@ -254,7 +255,7 @@ Note that None is a valid source path; it will be replaced with \"none\". The\n\
\"none\" is used in /proc/{mounts,self/mountinfo} for pseudo filesystems.\n\
\n\
Returns a tab entry or None."
-static PyObject *Tab_find_srcpath(TabObject *self, PyObject *args, PyObject *kwds)
+static PyObject *Table_find_srcpath(TableObject *self, PyObject *args, PyObject *kwds)
{
char *kwlist[] = {"srcpath", "direction", NULL};
char *srcpath;
@@ -267,14 +268,14 @@ static PyObject *Tab_find_srcpath(TabObject *self, PyObject *args, PyObject *kwd
return PyObjectResultFs(mnt_table_find_srcpath(self->tab, srcpath, direction));
}
-#define Tab_find_tag_HELP "find_tag(tag, val, [direction])\n\n\
+#define Table_find_tag_HELP "find_tag(tag, val, [direction])\n\n\
Try to lookup an entry in given tab, first attempt is lookup by tag and\n\
val, for the second attempt the tag is evaluated (converted to the device\n\
name) and Tab.find_srcpath() is preformed. The second attempt is not\n\
performed when tb cache is not set (not implemented yet).\n\
\n\
Returns a tab entry or NULL."
-static PyObject *Tab_find_tag(TabObject *self, PyObject *args, PyObject *kwds)
+static PyObject *Table_find_tag(TableObject *self, PyObject *args, PyObject *kwds)
{
char *kwlist[] = {"tag", "val", "direction", NULL};
char *tag;
@@ -288,12 +289,12 @@ static PyObject *Tab_find_tag(TabObject *self, PyObject *args, PyObject *kwds)
return PyObjectResultFs(mnt_table_find_tag(self->tab, tag, val, direction));
}
-static PyObject *Tab_get_nents(TabObject *self)
+static PyObject *Table_get_nents(TableObject *self)
{
return PyObjectResultInt(mnt_table_get_nents(self->tab));
}
-#define Tab_is_fs_mounted_HELP "is_fs_mounted(fstab_fs)\n\n\
+#define Table_is_fs_mounted_HELP "is_fs_mounted(fstab_fs)\n\n\
Checks if the fstab_fs entry is already in the tb table. The \"swap\" is\n\
ignored. This function explicitly compares source, target and root of the\n\
filesystems.\n\
@@ -308,7 +309,7 @@ Tab.find_source() for the device.\n\
This function is designed mostly for \"mount -a\".\n\
\n\
Returns a boolean value."
-static PyObject *Tab_is_fs_mounted(TabObject *self, PyObject *args, PyObject *kwds)
+static PyObject *Table_is_fs_mounted(TableObject *self, PyObject *args, PyObject *kwds)
{
FsObject *fs;
char *kwlist[] = {"fstab_fs", NULL};
@@ -320,14 +321,14 @@ static PyObject *Tab_is_fs_mounted(TabObject *self, PyObject *args, PyObject *kw
return PyBool_FromLong(mnt_table_is_fs_mounted(self->tab, fs->fs));
}
-#define Tab_parse_file_HELP "parse_file(file)\n\n\
+#define Table_parse_file_HELP "parse_file(file)\n\n\
Parses whole table (e.g. /etc/mtab) and appends new records to the tab.\n\
\n\
The libmount parser ignores broken (syntax error) lines, these lines are\n\
reported to caller by errcb() function (see Tab.parser_errcb).\n\
\n\
Returns self or raises an exception in case of an error."
-static PyObject *Tab_parse_file(TabObject *self, PyObject* args, PyObject *kwds)
+static PyObject *Table_parse_file(TableObject *self, PyObject* args, PyObject *kwds)
{
int rc;
char *file = NULL;
@@ -340,14 +341,14 @@ static PyObject *Tab_parse_file(TabObject *self, PyObject* args, PyObject *kwds)
return rc ? UL_RaiseExc(-rc) : UL_IncRef(self);
}
-#define Tab_parse_fstab_HELP "parse_fstab([fstab])\n\n\
+#define Table_parse_fstab_HELP "parse_fstab([fstab])\n\n\
This function parses /etc/fstab and appends new lines to the tab. If the\n\
filename is a directory then Tab.parse_dir() is called.\n\
\n\
See also Tab.parser_errcb.\n\
\n\
Returns self or raises an exception in case of an error."
-static PyObject *Tab_parse_fstab(TabObject *self, PyObject* args, PyObject *kwds)
+static PyObject *Table_parse_fstab(TableObject *self, PyObject* args, PyObject *kwds)
{
int rc;
char *fstab = NULL;
@@ -361,14 +362,14 @@ static PyObject *Tab_parse_fstab(TabObject *self, PyObject* args, PyObject *kwds
return rc ? UL_RaiseExc(-rc) : UL_IncRef(self);
}
-#define Tab_parse_mtab_HELP "parse_mtab([mtab])\n\n\
+#define Table_parse_mtab_HELP "parse_mtab([mtab])\n\n\
This function parses /etc/mtab or /proc/self/mountinfo\n\
/run/mount/utabs or /proc/mounts.\n\
\n\
See also Tab.parser_errcb().\n\
\n\
Returns self or raises an exception in case of an error."
-static PyObject *Tab_parse_mtab(TabObject *self, PyObject* args, PyObject *kwds)
+static PyObject *Table_parse_mtab(TableObject *self, PyObject* args, PyObject *kwds)
{
int rc;
char *mtab = NULL;
@@ -382,14 +383,14 @@ static PyObject *Tab_parse_mtab(TabObject *self, PyObject* args, PyObject *kwds)
return rc ? UL_RaiseExc(-rc) : UL_IncRef(self);
}
-#define Tab_parse_dir_HELP "parse_dir(dir)\n\n\
+#define Table_parse_dir_HELP "parse_dir(dir)\n\n\
The directory:\n\
- files are sorted by strverscmp(3)\n\
- files that start with \".\" are ignored (e.g. \".10foo.fstab\")\n\
- files without the \".fstab\" extension are ignored\n\
\n\
Returns self or raises an exception in case of an error."
-static PyObject *Tab_parse_dir(TabObject *self, PyObject* args, PyObject *kwds)
+static PyObject *Table_parse_dir(TableObject *self, PyObject* args, PyObject *kwds)
{
int rc;
char *dir = NULL;
@@ -403,9 +404,9 @@ static PyObject *Tab_parse_dir(TabObject *self, PyObject* args, PyObject *kwds)
return rc ? UL_RaiseExc(-rc) : UL_IncRef(self);
}
-#define Tab_parse_swaps_HELP "parse_swaps(swaps)\n\n\
+#define Table_parse_swaps_HELP "parse_swaps(swaps)\n\n\
This function parses /proc/swaps and appends new lines to the tab"
-static PyObject *Tab_parse_swaps(TabObject *self, PyObject* args, PyObject *kwds)
+static PyObject *Table_parse_swaps(TableObject *self, PyObject* args, PyObject *kwds)
{
int rc;
char *swaps = NULL;
@@ -419,9 +420,9 @@ static PyObject *Tab_parse_swaps(TabObject *self, PyObject* args, PyObject *kwds
return rc ? UL_RaiseExc(-rc) : UL_IncRef(self);
}
-#define Tab_parse_stream_HELP "parse_stream(stream, filename)\n\n\
+#define Table_parse_stream_HELP "parse_stream(stream, filename)\n\n\
Returns self or raises an exception in case of an error."
-static PyObject *Tab_parse_stream(TabObject *self, PyObject* args, PyObject *kwds)
+static PyObject *Table_parse_stream(TableObject *self, PyObject* args, PyObject *kwds)
{
int rc;
PyFileObject *stream = NULL;
@@ -437,10 +438,10 @@ static PyObject *Tab_parse_stream(TabObject *self, PyObject* args, PyObject *kwd
rc = mnt_table_parse_stream(self->tab, f, filename);
return rc ? UL_RaiseExc(-rc) : UL_IncRef(self);
}
-#define Tab_add_fs_HELP "add_fs(fs)\n\nAdds a new entry to tab.\n\
+#define Table_add_fs_HELP "add_fs(fs)\n\nAdds a new entry to tab.\n\
Returns self or raises an exception in case of an error."
-static PyObject *Tab_add_fs(TabObject *self, PyObject* args, PyObject *kwds)
+static PyObject *Table_add_fs(TableObject *self, PyObject* args, PyObject *kwds)
{
int rc;
FsObject *fs = NULL;
@@ -455,9 +456,9 @@ static PyObject *Tab_add_fs(TabObject *self, PyObject* args, PyObject *kwds)
return rc ? UL_RaiseExc(-rc) : UL_IncRef(self);
}
-#define Tab_remove_fs_HELP "remove_fs(fs)\n\n\
+#define Table_remove_fs_HELP "remove_fs(fs)\n\n\
Returns self or raises an exception in case of an error."
-static PyObject *Tab_remove_fs(TabObject *self, PyObject* args, PyObject *kwds)
+static PyObject *Table_remove_fs(TableObject *self, PyObject* args, PyObject *kwds)
{
int rc;
FsObject *fs = NULL;
@@ -472,7 +473,7 @@ static PyObject *Tab_remove_fs(TabObject *self, PyObject* args, PyObject *kwds)
return rc ? UL_RaiseExc(-rc) : UL_IncRef(self);
}
-#define Tab_next_fs_HELP "next_fs()\n\n\
+#define Table_next_fs_HELP "next_fs()\n\n\
Returns the next Fs on success, raises an exception in case of an error and None at end of list.\n\
\n\
Example:\n\
@@ -488,7 +489,7 @@ for fs in iter(functools.partial(tb.next_fs), None): {\n\
</informalexample>\n\
\n\
lists all mountpoints from fstab in backward order."
-static PyObject *Tab_next_fs(TabObject *self)
+static PyObject *Table_next_fs(TableObject *self)
{
struct libmnt_fs *fs;
int rc;
@@ -504,27 +505,27 @@ static PyObject *Tab_next_fs(TabObject *self)
return PyObjectResultFs(fs);
}
-static PyMethodDef Tab_methods[] = {
- {"enable_comments", (PyCFunction)Tab_enable_comments, METH_VARARGS|METH_KEYWORDS, Tab_enable_comments_HELP},
- {"find_pair", (PyCFunction)Tab_find_pair, METH_VARARGS|METH_KEYWORDS, Tab_find_pair_HELP},
- {"find_source", (PyCFunction)Tab_find_source, METH_VARARGS|METH_KEYWORDS, Tab_find_source_HELP},
- {"find_srcpath", (PyCFunction)Tab_find_srcpath, METH_VARARGS|METH_KEYWORDS, Tab_find_srcpath_HELP},
- {"find_tag", (PyCFunction)Tab_find_tag, METH_VARARGS|METH_KEYWORDS, Tab_find_tag_HELP},
- {"find_target", (PyCFunction)Tab_find_target, METH_VARARGS|METH_KEYWORDS, Tab_find_target_HELP},
- {"find_devno", (PyCFunction)Tab_find_devno, METH_VARARGS|METH_KEYWORDS, Tab_find_devno_HELP},
- {"find_mountpoint", (PyCFunction)Tab_find_mountpoint, METH_VARARGS|METH_KEYWORDS, Tab_find_mountpoint_HELP},
- {"parse_file", (PyCFunction)Tab_parse_file, METH_VARARGS|METH_KEYWORDS, Tab_parse_file_HELP},
- {"parse_fstab", (PyCFunction)Tab_parse_fstab, METH_VARARGS|METH_KEYWORDS, Tab_parse_fstab_HELP},
- {"parse_mtab", (PyCFunction)Tab_parse_mtab, METH_VARARGS|METH_KEYWORDS, Tab_parse_mtab_HELP},
- {"parse_dir", (PyCFunction)Tab_parse_dir, METH_VARARGS|METH_KEYWORDS, Tab_parse_dir_HELP},
- {"parse_swaps", (PyCFunction)Tab_parse_swaps, METH_VARARGS|METH_KEYWORDS, Tab_parse_swaps_HELP},
- {"is_fs_mounted", (PyCFunction)Tab_is_fs_mounted, METH_VARARGS|METH_KEYWORDS, Tab_is_fs_mounted_HELP},
- {"parse_stream", (PyCFunction)Tab_parse_stream, METH_VARARGS|METH_KEYWORDS, Tab_parse_stream_HELP},
- {"add_fs", (PyCFunction)Tab_add_fs, METH_VARARGS|METH_KEYWORDS, Tab_add_fs_HELP},
- {"remove_fs", (PyCFunction)Tab_remove_fs, METH_VARARGS|METH_KEYWORDS, Tab_remove_fs_HELP},
- {"next_fs", (PyCFunction)Tab_next_fs, METH_NOARGS, Tab_next_fs_HELP},
- {"write_file", (PyCFunction)Tab_write_file, METH_VARARGS|METH_KEYWORDS, Tab_write_file_HELP},
- {"replace_file", (PyCFunction)Tab_replace_file, METH_VARARGS|METH_KEYWORDS, Tab_replace_file_HELP},
+static PyMethodDef Table_methods[] = {
+ {"enable_comments", (PyCFunction)Table_enable_comments, METH_VARARGS|METH_KEYWORDS, Table_enable_comments_HELP},
+ {"find_pair", (PyCFunction)Table_find_pair, METH_VARARGS|METH_KEYWORDS, Table_find_pair_HELP},
+ {"find_source", (PyCFunction)Table_find_source, METH_VARARGS|METH_KEYWORDS, Table_find_source_HELP},
+ {"find_srcpath", (PyCFunction)Table_find_srcpath, METH_VARARGS|METH_KEYWORDS, Table_find_srcpath_HELP},
+ {"find_tag", (PyCFunction)Table_find_tag, METH_VARARGS|METH_KEYWORDS, Table_find_tag_HELP},
+ {"find_target", (PyCFunction)Table_find_target, METH_VARARGS|METH_KEYWORDS, Table_find_target_HELP},
+ {"find_devno", (PyCFunction)Table_find_devno, METH_VARARGS|METH_KEYWORDS, Table_find_devno_HELP},
+ {"find_mountpoint", (PyCFunction)Table_find_mountpoint, METH_VARARGS|METH_KEYWORDS, Table_find_mountpoint_HELP},
+ {"parse_file", (PyCFunction)Table_parse_file, METH_VARARGS|METH_KEYWORDS, Table_parse_file_HELP},
+ {"parse_fstab", (PyCFunction)Table_parse_fstab, METH_VARARGS|METH_KEYWORDS, Table_parse_fstab_HELP},
+ {"parse_mtab", (PyCFunction)Table_parse_mtab, METH_VARARGS|METH_KEYWORDS, Table_parse_mtab_HELP},
+ {"parse_dir", (PyCFunction)Table_parse_dir, METH_VARARGS|METH_KEYWORDS, Table_parse_dir_HELP},
+ {"parse_swaps", (PyCFunction)Table_parse_swaps, METH_VARARGS|METH_KEYWORDS, Table_parse_swaps_HELP},
+ {"is_fs_mounted", (PyCFunction)Table_is_fs_mounted, METH_VARARGS|METH_KEYWORDS, Table_is_fs_mounted_HELP},
+ {"parse_stream", (PyCFunction)Table_parse_stream, METH_VARARGS|METH_KEYWORDS, Table_parse_stream_HELP},
+ {"add_fs", (PyCFunction)Table_add_fs, METH_VARARGS|METH_KEYWORDS, Table_add_fs_HELP},
+ {"remove_fs", (PyCFunction)Table_remove_fs, METH_VARARGS|METH_KEYWORDS, Table_remove_fs_HELP},
+ {"next_fs", (PyCFunction)Table_next_fs, METH_NOARGS, Table_next_fs_HELP},
+ {"write_file", (PyCFunction)Table_write_file, METH_VARARGS|METH_KEYWORDS, Table_write_file_HELP},
+ {"replace_file", (PyCFunction)Table_replace_file, METH_VARARGS|METH_KEYWORDS, Table_replace_file_HELP},
{NULL}
};
@@ -546,7 +547,7 @@ void pymnt_free_table(struct libmnt_table *tab)
mnt_free_table(tab);
}
-static void Tab_destructor(TabObject *self)
+static void Table_destructor(TableObject *self)
{
pymnt_free_table(self->tab);
mnt_free_iter(self->iter);
@@ -554,10 +555,10 @@ static void Tab_destructor(TabObject *self)
self->ob_type->tp_free((PyObject*)self);
}
-static PyObject *Tab_new(PyTypeObject *type, PyObject *args __attribute__((unused)),
+static PyObject *Table_new(PyTypeObject *type, PyObject *args __attribute__((unused)),
PyObject *kwds __attribute__((unused)))
{
- TabObject *self = (TabObject*)type->tp_alloc(type, 0);
+ TableObject *self = (TableObject*)type->tp_alloc(type, 0);
if (self) {
self->tab = NULL;
@@ -568,8 +569,8 @@ static PyObject *Tab_new(PyTypeObject *type, PyObject *args __attribute__((unuse
}
/* explicit tab.__init__() serves as mnt_reset_table(tab) would in C
* and as mnt_new_table{,_from_dir,_from_file}() with proper arguments */
-#define Tab_HELP "Tab(path=None, errcb=None)"
-static int Tab_init(TabObject *self, PyObject *args, PyObject *kwds)
+#define Table_HELP "Tab(path=None, errcb=None)"
+static int Table_init(TableObject *self, PyObject *args, PyObject *kwds)
{
struct libmnt_cache *cache;
char *path = NULL;
@@ -635,13 +636,13 @@ int pymnt_table_parser_errcb(struct libmnt_table *tb, const char *filename, int
int rc = 0;
PyObject *arglist, *result;
- if (tb->userdata && ((TabObject*)(tb->userdata))->errcb) {
+ if (tb->userdata && ((TableObject*)(tb->userdata))->errcb) {
arglist = Py_BuildValue("(Osi)", tb->userdata, filename, line);
if (!arglist)
return -ENOMEM;
/* A python callback was set, so tb is definitely encapsulated in an object */
- result = PyEval_CallObject(((TabObject *)(tb->userdata))->errcb, arglist);
+ result = PyEval_CallObject(((TableObject *)(tb->userdata))->errcb, arglist);
Py_DECREF(arglist);
if (!result)
@@ -666,7 +667,7 @@ PyObject *PyObjectResultTab(struct libmnt_table *tab)
return (PyObject *)tab->userdata;
}
- TabObject *result = PyObject_New(TabObject, &TabType);
+ TableObject *result = PyObject_New(TableObject, &TableType);
if (!result) {
UL_RaiseExc(ENOMEM);
return NULL;
@@ -684,16 +685,16 @@ PyObject *PyObjectResultTab(struct libmnt_table *tab)
return (PyObject *)result;
}
-static PyGetSetDef Tab_getseters[] = {
- {"nents", (getter)Tab_get_nents, NULL, "number of valid entries in tab", NULL},
- {"intro_comment", (getter)Tab_get_intro_comment, (setter)Tab_set_intro_comment, "fstab intro comment", NULL},
- {"trailing_comment", (getter)Tab_get_trailing_comment, (setter)Tab_set_trailing_comment, "fstab trailing comment", NULL},
- {"errcb", NULL, (setter)Tab_set_parser_errcb, "parser error callback", NULL},
+static PyGetSetDef Table_getseters[] = {
+ {"nents", (getter)Table_get_nents, NULL, "number of valid entries in tab", NULL},
+ {"intro_comment", (getter)Table_get_intro_comment, (setter)Table_set_intro_comment, "fstab intro comment", NULL},
+ {"trailing_comment", (getter)Table_get_trailing_comment, (setter)Table_set_trailing_comment, "fstab trailing comment", NULL},
+ {"errcb", NULL, (setter)Table_set_parser_errcb, "parser error callback", NULL},
{NULL}
};
-static PyObject *Table_repr(TabObject *self)
+static PyObject *Table_repr(TableObject *self)
{
return PyString_FromFormat(
"<libmount.Table object at %p, entries=%d, comments_enabled=%s, errcb=%s>",
@@ -703,13 +704,13 @@ static PyObject *Table_repr(TabObject *self)
self->errcb ? pystos(PyObject_Repr(self->errcb)) : "None");
}
-PyTypeObject TabType = {
+PyTypeObject TableType = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
- "libmount.Tab", /*tp_name*/
- sizeof(TabObject), /*tp_basicsize*/
+ "libmount.Table", /*tp_name*/
+ sizeof(TableObject), /*tp_basicsize*/
0, /*tp_itemsize*/
- (destructor)Tab_destructor, /*tp_dealloc*/
+ (destructor)Table_destructor, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
@@ -725,32 +726,32 @@ PyTypeObject TabType = {
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
- Tab_HELP, /* tp_doc */
+ Table_HELP, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
- Tab_methods, /* tp_methods */
- Tab_members, /* tp_members */
- Tab_getseters, /* tp_getset */
+ Table_methods, /* tp_methods */
+ Table_members, /* tp_members */
+ Table_getseters, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
- (initproc)Tab_init, /* tp_init */
+ (initproc)Table_init, /* tp_init */
0, /* tp_alloc */
- Tab_new, /* tp_new */
+ Table_new, /* tp_new */
};
void pymnt_init_table(PyObject *mod)
{
- if (PyType_Ready(&TabType) < 0)
+ if (PyType_Ready(&TableType) < 0)
return;
- Py_INCREF(&TabType);
- PyModule_AddObject(mod, "Tab", (PyObject *)&TabType);
+ Py_INCREF(&TableType);
+ PyModule_AddObject(mod, "Table", (PyObject *)&TableType);
}