s4-python: Implement LoadParm.dump().
authorJelmer Vernooij <jelmer@samba.org>
Sun, 20 Jun 2010 11:29:35 +0000 (13:29 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Sun, 20 Jun 2010 11:29:35 +0000 (13:29 +0200)
source4/param/pyparam.c
source4/scripting/bin/testparm

index 40d25f7dcd76499789879b8f9b0328e47dacf746..3335dd9a64a62aa77b00124d015469295c16ee6b 100644 (file)
@@ -246,6 +246,27 @@ static PyObject *py_lp_ctx_services(py_talloc_Object *self)
        return ret;
 }
 
+static PyObject *py_lp_dump(PyObject *self, PyObject *args)
+{
+       PyObject *py_stream;
+       bool show_defaults = false;
+       FILE *f;
+       struct loadparm_context *lp_ctx = PyLoadparmContext_AsLoadparmContext(self);
+
+       if (!PyArg_ParseTuple(args, "O|b", &py_stream, &show_defaults))
+               return NULL;
+
+       f = PyFile_AsFile(py_stream);
+       if (f == NULL) {
+               PyErr_SetString(PyExc_TypeError, "Not a file stream");
+               return NULL;
+       }
+
+       lp_dump(lp_ctx, f, show_defaults, lp_numservices(lp_ctx));
+
+       Py_RETURN_NONE;
+}
+
 static PyMethodDef py_lp_ctx_methods[] = {
        { "load", (PyCFunction)py_lp_ctx_load, METH_VARARGS, 
                "S.load(filename) -> None\n"
@@ -269,6 +290,8 @@ static PyMethodDef py_lp_ctx_methods[] = {
                "S.private_path(name) -> path\n" },
        { "services", (PyCFunction)py_lp_ctx_services, METH_NOARGS,
                "S.services() -> list" },
+       { "dump", (PyCFunction)py_lp_dump, METH_VARARGS, 
+               "S.dump(stream, show_defaults=False)" },
        { NULL }
 };
 
index 0ea36d941bc11a4ad00fbdf1d5d89627cc73e79a..43d8ee06735ecbb82e7bfa620d3c3794d39d6819 100755 (executable)
@@ -192,6 +192,6 @@ if __name__ == '__main__':
         check_client_access(lp, cname, caddr)
     else:
         dump(lp, opts.section_name, opts.parameter_name, 
-                not opts.suppress_prompt, opts.verbose)
+                not opts.suppress_prompt, opts.verbose or False)
 
     sys.exit(0)