|
GnuCash
5.6-150-g038405b370+
|
Public Member Functions | |
| def | __new__ (cls, args, kargs) |
| def | __init__ (self, args, kargs) |
| def | get_instance (self) |
| def | add_method (cls, function_name, method_name) |
| Add the function, method_name to this class as a method named name. More... | |
| def | ya_add_classmethod (cls, function_name, method_name) |
| Add the function, method_name to this class as a classmethod named name. More... | |
| def | ya_add_method (cls, function_name, method_name) |
| Add the function, method_name to this class as a method named name. More... | |
| def | add_methods_with_prefix (cls, prefix, exclude=[]) |
| def | add_constructor_and_methods_with_prefix (cls, prefix, constructor, exclude=[]) |
| def | decorate_functions (cls, decorator, args) |
| def | decorate_method (cls, decorator, method_name, args, kargs) |
| decorate method method_name of class cls with decorator decorator More... | |
Properties | |
| instance = property(get_instance) | |
Inherit this class to give yourself a python class that wraps a set of functions that together constitute the methods of the class. The method functions must all have as a first argument an object holding the instance data. There must also be a function that returns a new instance of the class, the constructor. Your subclass must define _module - The module where the method functions, including the constructor can be found _new_instance - The name of a function that serves as a constructor, returning the instance data. To access the instance data, use the read-only property instance. To add some functions from _module as methods, call classmethods like add_method and add_methods_with_prefix.
Definition at line 31 of file function_class.py.
| def python.function_class.ClassFromFunctions.__init__ | ( | self, | |
| args, | |||
| kargs | |||
| ) |
Construct a new instance, using either the function self._module[self._new_instance] or using existing instance data. (specified with the keyword argument, instance) if instance argument is None it will be ignored and the constructor will be called to get a new instance Pass the arguments that should be passed on to self._module[self._new_instance]. Any arguments of that are instances of ClassFromFunctions will be switched with the instance data. (by calling the .instance property)
Definition at line 57 of file function_class.py.
| def python.function_class.ClassFromFunctions.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. Don't add methods in array exclude.
Definition at line 196 of file function_class.py.
| def python.function_class.ClassFromFunctions.add_method | ( | cls, | |
| function_name, | |||
| method_name | |||
| ) |
Add the function, method_name to this class as a method named name.
arguments:
| cls | Class: class to add methods to |
| function_name | string: name of the function to add |
| method_name | string: name of the method that function will be called |
function will be wrapped by method_function
Definition at line 89 of file function_class.py.
| def python.function_class.ClassFromFunctions.add_methods_with_prefix | ( | cls, | |
| prefix, | |||
exclude = [] |
|||
| ) |
Add a group of functions with the same prefix, exclude methods in array exclude.
Definition at line 185 of file function_class.py.
| def python.function_class.ClassFromFunctions.decorate_method | ( | cls, | |
| decorator, | |||
| method_name, | |||
| args, | |||
| kargs | |||
| ) |
decorate method method_name of class cls with decorator decorator
in difference to decorate_functions() this allows to provide additional arguments for the decorator function.
arguments:
| cls | class |
| decorator | function to decorate method |
| method_name | name of method to decorate (string) |
| *args | positional arguments for decorator |
| **kargs | keyword arguments for decorator |
Definition at line 211 of file function_class.py.
| def python.function_class.ClassFromFunctions.get_instance | ( | self | ) |
Get the instance data. You can also call the instance property
Definition at line 77 of file function_class.py.
| def python.function_class.ClassFromFunctions.ya_add_classmethod | ( | cls, | |
| function_name, | |||
| method_name | |||
| ) |
Add the function, method_name to this class as a classmethod named name.
Taken from function_class and modified from add_method() to add classmethod instead of method and not to turn self argument to self.instance.
arguments:
| cls | Class: class to add methods to |
| function_name | string: name of the function to add |
| method_name | string: name of the classmethod that function will be called |
function will be wrapped by method_function
Definition at line 119 of file function_class.py.
| def python.function_class.ClassFromFunctions.ya_add_method | ( | cls, | |
| function_name, | |||
| method_name | |||
| ) |
Add the function, method_name to this class as a method named name.
Taken from function_class. Modified to not turn self to self.instance as add_method() does.
arguments:
| cls | Class: class to add methods to |
| function_name | string: name of the function to add |
| method_name | string: name of the method that function will be called |
function will be wrapped by method_function
Definition at line 152 of file function_class.py.
1.8.14