python: Accept loadparm filename rather than loadparm object, too.
[ira/wip.git] / source / param / param.i
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;
 }