mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Merge Christoff Holterman's Bug 796137 repair into maint.
This commit is contained in:
commit
1a7c5b9a32
@ -125,19 +125,23 @@ class ClassFromFunctions(object):
|
|||||||
return method_function
|
return method_function
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def add_methods_with_prefix(cls, prefix):
|
def add_methods_with_prefix(cls, prefix, exclude=[]):
|
||||||
"""Add a group of functions with the same prefix
|
"""Add a group of functions with the same prefix, exclude methods
|
||||||
|
in array exclude.
|
||||||
"""
|
"""
|
||||||
for function_name, function_value, after_prefix in \
|
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)
|
cls.add_method(function_name, after_prefix)
|
||||||
|
|
||||||
@classmethod
|
@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
|
"""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
|
cls._new_instance = prefix + constructor
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -760,12 +760,19 @@ from gnucash.gnucash_core_c import \
|
|||||||
INVOICE_IS_PAID
|
INVOICE_IS_PAID
|
||||||
|
|
||||||
class Query(GnuCashCoreClass):
|
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_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_run', 'run')
|
||||||
Query.add_method('qof_query_add_term', 'add_term')
|
Query.add_method('qof_query_add_term', 'add_term')
|
||||||
Query.add_method('qof_query_add_boolean_match', 'add_boolean_match')
|
Query.add_method('qof_query_add_boolean_match', 'add_boolean_match')
|
||||||
|
@ -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 * {
|
%typemap(in) GSList *, QofQueryParamList * {
|
||||||
$1 = NULL;
|
$1 = NULL;
|
||||||
/* Check if is a list */
|
/* Check if is a list */
|
||||||
|
Loading…
Reference in New Issue
Block a user