Added Config::load() and Config::save()
This commit is contained in:
parent
c90d082b6c
commit
2f6fa84a68
|
@ -34,9 +34,13 @@ static void _libsystem_config_delete(PyObject * self);
|
|||
static PyObject * _libsystem_config_get(PyObject * self, PyObject * args);
|
||||
static PyObject * _libsystem_config_set(PyObject * self, PyObject * args);
|
||||
|
||||
static PyObject * _libsystem_config_load(PyObject * self, PyObject * args);
|
||||
static PyObject * _libsystem_config_save(PyObject * self, PyObject * args);
|
||||
|
||||
/* Event */
|
||||
static PyObject * _libsystem_event_new(PyObject * self, PyObject * args);
|
||||
static void _libsystem_event_delete(PyObject * self);
|
||||
|
||||
static PyObject * _libsystem_event_loop(PyObject * self, PyObject * args);
|
||||
|
||||
|
||||
|
@ -49,6 +53,10 @@ static PyMethodDef _libsystem_methods[] =
|
|||
"Obtains a value from the Config object." },
|
||||
{ "config_set", _libsystem_config_set, METH_VARARGS,
|
||||
"Sets a value in the Config object." },
|
||||
{ "config_load", _libsystem_config_load, METH_VARARGS,
|
||||
"Load values in the Config object from a file." },
|
||||
{ "config_save", _libsystem_config_save, METH_VARARGS,
|
||||
"Save values in the Config object to a file." },
|
||||
{ "event_new", _libsystem_event_new, METH_VARARGS,
|
||||
"Instantiates an Event object." },
|
||||
{ "event_loop", _libsystem_event_loop, METH_VARARGS,
|
||||
|
@ -136,6 +144,40 @@ static PyObject * _libsystem_config_set(PyObject * self, PyObject * args)
|
|||
}
|
||||
|
||||
|
||||
/* libsystem_config_load */
|
||||
static PyObject * _libsystem_config_load(PyObject * self, PyObject * args)
|
||||
{
|
||||
Config * config;
|
||||
int ret;
|
||||
char const * filename;
|
||||
|
||||
if((config = PyCapsule_GetPointer(self, _libsystem_config_name))
|
||||
== NULL)
|
||||
return NULL;
|
||||
if(!PyArg_ParseTuple(args, "s", &filename))
|
||||
return NULL;
|
||||
ret = config_load(config, filename);
|
||||
return Py_BuildValue("i", ret);
|
||||
}
|
||||
|
||||
|
||||
/* libsystem_config_save */
|
||||
static PyObject * _libsystem_config_save(PyObject * self, PyObject * args)
|
||||
{
|
||||
Config * config;
|
||||
int ret;
|
||||
char const * filename;
|
||||
|
||||
if((config = PyCapsule_GetPointer(self, _libsystem_config_name))
|
||||
== NULL)
|
||||
return NULL;
|
||||
if(!PyArg_ParseTuple(args, "s", &filename))
|
||||
return NULL;
|
||||
ret = config_save(config, filename);
|
||||
return Py_BuildValue("i", ret);
|
||||
}
|
||||
|
||||
|
||||
/* Event */
|
||||
/* libsystem_event_new */
|
||||
static PyObject * _libsystem_event_new(PyObject * self, PyObject * args)
|
||||
|
|
|
@ -30,6 +30,14 @@ class Config:
|
|||
def set(self, section, variable, value):
|
||||
return _libSystem.config_set(self.config, section, variable,
|
||||
value)
|
||||
|
||||
def load(self, filename):
|
||||
return _libSystem.config_load(self.config, filename)
|
||||
|
||||
def save(self, filename):
|
||||
return _libSystem.config_save(self.config, filename)
|
||||
|
||||
|
||||
#Event
|
||||
class Event:
|
||||
def __init__(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user