Add qof queries to python bindings and set PYTHON_PATH in gnucash-env

Patch by Hendrik van Antwerpen

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21215 57a11ea4-9604-0410-9ed3-97b8803252fd
pull/1/head
Geert Janssens 15 years ago
parent 31a79474df
commit 56441aabda

@ -136,6 +136,28 @@ typedef char gchar;
}
}
%typemap(in) GSList *, QofQueryParamList * {
$1 = NULL;
/* Check if is a list */
if (PyList_Check($input)) {
int i;
int size = PyList_Size($input);
for (i = size-1; i >= 0; i--) {
PyObject *o = PyList_GetItem($input, i);
if (PyString_Check(o)) {
$1 = g_slist_prepend($1,PyString_AsString(PyList_GetItem($input, i)));
} else {
PyErr_SetString(PyExc_TypeError, "list must contain strings");
g_slist_free($1);
return NULL;
}
}
} else {
PyErr_SetString(PyExc_TypeError, "not a list");
return NULL;
}
}
%typemap(out) GList *, CommodityList *, SplitList *, AccountList *, LotList *,
MonetaryList *, PriceList *, EntryList * {
guint i;
@ -158,6 +180,8 @@ typedef char gchar;
PyList_Append(list, SWIG_NewPointerObj(data, SWIGTYPE_p_GNCLot, 0));
else if (GNC_IS_PRICE(data))
PyList_Append(list, SWIG_NewPointerObj(data, SWIGTYPE_p_GNCPrice, 0));
else if (GNC_IS_INVOICE(data))
PyList_Append(list, SWIG_NewPointerObj(data, SWIGTYPE_p__gncInvoice, 0));
else if (GNC_IS_ENTRY(data))
PyList_Append(list, SWIG_NewPointerObj(data, SWIGTYPE_p__gncEntry, 0));
else if ($1_descriptor == $descriptor(MonetaryList *))

@ -35,7 +35,8 @@ gnucash-env: gnucash-env.in ${top_builddir}/config.status Makefile
-e 's#@-GNC_SCM_INSTALL_DIR-@#${GNC_SCM_INSTALL_DIR}#g' \
-e 's#@-GNC_LIB_INSTALLDIR-@#${libdir}#' \
-e 's#@-GNC_PKGLIB_INSTALLDIR-@#${pkglibdir}#g' \
-e 's#@-GNC_SCRIPT_OVERRIDE_DIR-@#${gncoverridedir}#g'
-e 's#@-GNC_SCRIPT_OVERRIDE_DIR-@#${gncoverridedir}#g' \
-e 's#@-GNC_PYTHON_DIR-@#${pythondir}#g'
mv $@.tmp $@
chmod u+x $@
CLEANFILES += gnucash-env

@ -18,9 +18,12 @@ EXTRA_LIBS="${EXTRA_LIBS}:@-GNC_PKGLIB_INSTALLDIR-@"
LD_LIBRARY_PATH="${EXTRA_LIBS}:${LD_LIBRARY_PATH}"
DYLD_LIBRARY_PATH="${EXTRA_LIBS}:${DYLD_LIBRARY_PATH}"
PYTHONPATH="${PYTHONPATH}:@-GNC_PYTHON_DIR-@"
export GNC_MODULE_PATH
export GUILE_LOAD_PATH
export LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH
export PYTHONPATH
exec "$@"

@ -42,7 +42,7 @@ from gnucash_core_c import GNC_OWNER_CUSTOMER, GNC_OWNER_JOB, \
GNC_PAYMENT_CASH, GNC_PAYMENT_CARD, \
GNC_DISC_PRETAX, GNC_DISC_SAMETIME, GNC_DISC_POSTTAX, \
GNC_TAXINCLUDED_YES, GNC_TAXINCLUDED_NO, GNC_TAXINCLUDED_USEGLOBAL, \
GNC_AMT_TYPE_VALUE, GNC_AMT_TYPE_PERCENT
GNC_AMT_TYPE_VALUE, GNC_AMT_TYPE_PERCENT, GNC_ID_INVOICE
import datetime

@ -54,6 +54,8 @@
#include "qofutil.h"
#include "qofid.h"
#include "guid.h"
#include "qofquery.h"
#include "qofquerycore.h"
#include "gnc-module/gnc-module.h"
#include "engine/gnc-engine.h"
#include "Transaction.h"
@ -93,6 +95,10 @@
%include <qofid.h>
%include <qofquery.h>
%include <qofquerycore.h>
/* SWIG doesn't like this macro, so redefine it to simply mean const */
#define G_CONST_RETURN const
%include <guid.h>
@ -201,6 +207,7 @@
%init %{
qof_log_init();
qof_init();
qof_query_init();
gnc_module_system_init();
char * no_args[1] = { NULL };
gnc_engine_init(0, no_args);

@ -655,3 +655,15 @@ guid_dict = {
}
methods_return_instance(GUID, guid_dict)
#Query
from gnucash_core_c import \
QOF_QUERY_AND, \
QOF_QUERY_OR, \
QOF_QUERY_NAND, \
QOF_QUERY_NOR, \
QOF_QUERY_XOR
class Query(GnuCashCoreClass):
pass
Query.add_constructor_and_methods_with_prefix('qof_query_', 'create')
Loading…
Cancel
Save