2007-11-29 16:06:57 +08:00
|
|
|
/** \ingroup py_c
|
|
|
|
* \file python/rpmmacro-py.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "system.h"
|
|
|
|
|
2008-01-30 23:05:29 +08:00
|
|
|
#include <structmember.h>
|
2007-11-29 16:06:57 +08:00
|
|
|
|
2007-12-08 20:02:32 +08:00
|
|
|
#include <rpm/rpmmacro.h>
|
2007-11-29 16:06:57 +08:00
|
|
|
|
2008-01-30 23:05:29 +08:00
|
|
|
#include "rpmmacro-py.h"
|
|
|
|
|
2007-11-29 16:06:57 +08:00
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
PyObject *
|
|
|
|
rpmmacro_AddMacro(PyObject * self, PyObject * args, PyObject * kwds)
|
|
|
|
{
|
|
|
|
char * name, * val;
|
|
|
|
char * kwlist[] = {"name", "value", NULL};
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwds, "ss:AddMacro", kwlist,
|
|
|
|
&name, &val))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
addMacro(NULL, name, NULL, val, -1);
|
|
|
|
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
PyObject *
|
|
|
|
rpmmacro_DelMacro(PyObject * self, PyObject * args, PyObject * kwds)
|
|
|
|
{
|
|
|
|
char * name;
|
|
|
|
char * kwlist[] = {"name", NULL};
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s:DelMacro", kwlist, &name))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
delMacro(NULL, name);
|
|
|
|
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
PyObject *
|
|
|
|
rpmmacro_ExpandMacro(PyObject * self, PyObject * args, PyObject * kwds)
|
|
|
|
{
|
2008-07-03 00:00:56 +08:00
|
|
|
char *macro, *str;
|
|
|
|
PyObject *res;
|
2007-11-29 16:06:57 +08:00
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "s", ¯o))
|
|
|
|
return NULL;
|
|
|
|
|
2008-07-03 00:00:56 +08:00
|
|
|
str = rpmExpand(macro, NULL);
|
|
|
|
res = Py_BuildValue("s", str);
|
|
|
|
free(str);
|
|
|
|
return res;
|
2007-11-29 16:06:57 +08:00
|
|
|
}
|
|
|
|
|