python: Accept loadparm filename rather than loadparm object, too.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 14 Jan 2008 15:11:36 +0000 (16:11 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 14 Jan 2008 18:53:07 +0000 (19:53 +0100)
source/param/param.i
source/param/param_wrap.c

index fdc9de233ff502adec7e3c90aba9b5705cc8972a..eeecb0e5b90a53be15f848c3d5a15982ec259397 100644 (file)
@@ -296,7 +296,16 @@ struct loadparm_context *global_loadparm;
 struct loadparm_context *lp_from_py_object(PyObject *py_obj)
 {
     struct loadparm_context *lp_ctx;
-    if (SWIG_ConvertPtr(py_obj, &lp_ctx, SWIGTYPE_p_loadparm_context, 0 |  0 ) < 0)
+    if (PyString_Check(py_obj)) {
+        lp_ctx = loadparm_init(NULL);
+        if (!lp_load(lp_ctx, PyString_AsString(py_obj))) {
+            talloc_free(lp_ctx);
+            return NULL;
+        }
+        return lp_ctx;
+    }
+
+    if (SWIG_ConvertPtr(py_obj, (void *)&lp_ctx, SWIGTYPE_p_loadparm_context, 0 |  0 ) < 0)
         return NULL;
     return lp_ctx;
 }
index e9fe8a3df57a05063cc62789180ace1e76047244..d8be725c5e9a6aee0f308de749d1cfca183325ca 100644 (file)
@@ -2765,7 +2765,16 @@ SWIGINTERN struct param_opt *param_section_next_parameter(param_section *self,st
 struct loadparm_context *lp_from_py_object(PyObject *py_obj)
 {
     struct loadparm_context *lp_ctx;
-    if (SWIG_ConvertPtr(py_obj, &lp_ctx, SWIGTYPE_p_loadparm_context, 0 |  0 ) < 0)
+    if (PyString_Check(py_obj)) {
+        lp_ctx = loadparm_init(NULL);
+        if (!lp_load(lp_ctx, PyString_AsString(py_obj))) {
+            talloc_free(lp_ctx);
+            return NULL;
+        }
+        return lp_ctx;
+    }
+
+    if (SWIG_ConvertPtr(py_obj, (void *)&lp_ctx, SWIGTYPE_p_loadparm_context, 0 |  0 ) < 0)
         return NULL;
     return lp_ctx;
 }