gnucash maint: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Sat Sep 8 16:53:46 EDT 2018
Updated via https://github.com/Gnucash/gnucash/commit/1a7c5b9a (commit)
via https://github.com/Gnucash/gnucash/commit/3ab66623 (commit)
via https://github.com/Gnucash/gnucash/commit/63848543 (commit)
via https://github.com/Gnucash/gnucash/commit/0551ee36 (commit)
from https://github.com/Gnucash/gnucash/commit/148f2413 (commit)
commit 1a7c5b9a32df1d0ccd7e739a70b3d0f38e4dda36
Merge: 148f241 3ab6662
Author: John Ralls <jralls at ceridwen.us>
Date: Sat Sep 8 13:20:51 2018 -0700
Merge Christoff Holterman's Bug 796137 repair into maint.
commit 3ab66623cda4b65630e2c0902a231eb9c8a45624
Author: Christoph Holtermann <c.holtermann at gmx.de>
Date: Fri Sep 7 00:09:47 2018 +0200
Bug 796137 - implement search_for as method of Python Query
The last three commits fix the main part of Bug 796137. An inconvenience
with GSList remains as for the moment qof_query_add_boolean_match only
accepts bytes as parameter and no strings. This still needs to be fixed.
diff --git a/bindings/python/gnucash_core.py b/bindings/python/gnucash_core.py
index 6420a17..bcd34f7 100644
--- a/bindings/python/gnucash_core.py
+++ b/bindings/python/gnucash_core.py
@@ -760,12 +760,19 @@ from gnucash.gnucash_core_c import \
INVOICE_IS_PAID
class Query(GnuCashCoreClass):
- pass
-Query.add_constructor_and_methods_with_prefix('qof_query_', 'create')
+ def search_for(self, obj_type):
+ """Set search_for to obj_type
+
+ calls qof_query_search_for. Buffers search string for queries lifetime.
+ @see https://bugs.gnucash.org/show_bug.cgi?id=796137"""
+ self.__search_for_buf = obj_type
+ self._search_for(self.__search_for_buf)
+
+Query.add_constructor_and_methods_with_prefix('qof_query_', 'create', exclude=["qof_query_search_for"])
Query.add_method('qof_query_set_book', 'set_book')
-Query.add_method('qof_query_search_for', 'search_for')
+Query.add_method('qof_query_search_for', '_search_for')
Query.add_method('qof_query_run', 'run')
Query.add_method('qof_query_add_term', 'add_term')
Query.add_method('qof_query_add_boolean_match', 'add_boolean_match')
commit 638485431910a314d9e174619bddd5c0e1b57144
Author: Christoph Holtermann <c.holtermann at gmx.de>
Date: Fri Sep 7 15:06:22 2018 +0200
Bug 796137 - Fix QofIdType and QofIdTypeConst to work with python3
Patch by David Osguthorpe to provide typemaps so that SWIG doesn't
free buffers mem when buffer is saved as part of query struct leading
to garbage content. See https://bugs.gnucash.org/show_bug.cgi?id=796137
diff --git a/common/base-typemaps.i b/common/base-typemaps.i
index ddddb55..5b410c1 100644
--- a/common/base-typemaps.i
+++ b/common/base-typemaps.i
@@ -220,6 +220,28 @@ typedef char gchar;
}
}
+%typemap(in) QofIdType {
+ if (PyUnicode_Check($input)) {
+ $1 = PyUnicode_AsUTF8($input);
+ } else if (PyBytes_Check($input)) {
+ $1 = PyBytes_AsString($input);
+ } else {
+ PyErr_SetString(PyExc_TypeError, "not a string or bytes object");
+ return NULL;
+ }
+}
+
+%typemap(in) QofIdTypeConst {
+ if (PyUnicode_Check($input)) {
+ $1 = PyUnicode_AsUTF8($input);
+ } else if (PyBytes_Check($input)) {
+ $1 = PyBytes_AsString($input);
+ } else {
+ PyErr_SetString(PyExc_TypeError, "not a string or bytes object");
+ return NULL;
+ }
+}
+
%typemap(in) GSList *, QofQueryParamList * {
$1 = NULL;
/* Check if is a list */
commit 0551ee36e8e87fac3cf6cbd3d614aa7fa2fc0ba0
Author: Christoph Holtermann <c.holtermann at gmx.de>
Date: Fri Sep 7 00:07:29 2018 +0200
add option to exclude specified methods
an exclude option is being added to add_constructor_and_methods_with_prefix and
add_methods_with_prefix
diff --git a/bindings/python/function_class.py b/bindings/python/function_class.py
index db159ff..b0c41d7 100644
--- a/bindings/python/function_class.py
+++ b/bindings/python/function_class.py
@@ -125,19 +125,23 @@ class ClassFromFunctions(object):
return method_function
@classmethod
- def add_methods_with_prefix(cls, prefix):
- """Add a group of functions with the same prefix
+ def add_methods_with_prefix(cls, prefix, exclude=[]):
+ """Add a group of functions with the same prefix, exclude methods
+ in array exclude.
"""
for function_name, function_value, after_prefix in \
- extract_attributes_with_prefix(cls._module, prefix):
+ extract_attributes_with_prefix(cls._module, prefix):
+
+ if not (function_name in exclude):
cls.add_method(function_name, after_prefix)
@classmethod
- def add_constructor_and_methods_with_prefix(cls, prefix, constructor):
+ def add_constructor_and_methods_with_prefix(cls, prefix, constructor, exclude=[]):
"""Add a group of functions with the same prefix, and set the
- _new_instance attribute to prefix + constructor
+ _new_instance attribute to prefix + constructor. Don't add methods
+ in array exclude.
"""
- cls.add_methods_with_prefix(prefix)
+ cls.add_methods_with_prefix(prefix, exclude=exclude)
cls._new_instance = prefix + constructor
@classmethod
Summary of changes:
bindings/python/function_class.py | 16 ++++++++++------
bindings/python/gnucash_core.py | 13 ++++++++++---
common/base-typemaps.i | 22 ++++++++++++++++++++++
3 files changed, 42 insertions(+), 9 deletions(-)
More information about the gnucash-changes
mailing list