mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
add option to exclude specified methods
an exclude option is being added to add_constructor_and_methods_with_prefix and add_methods_with_prefix
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user