MCPcopy Create free account
hub / github.com/Kitware/ParaView / _create_decorator

Function _create_decorator

Wrapping/Python/paraview/detail/pythonalgorithm.py:60–93  ·  view source on GitHub ↗

internal: used to create decorator for class or function objects. `kwargs`: these are typically the keyword arguments passed to the decorator itself. must be a `dict`. The decorator will often update the dict to have defaults or overrides to the parameters passed to

(kwargs={}, update_func=None, generate_xml_func=None)

Source from the content-addressed store, hash-verified

58
59
60def _create_decorator(kwargs={}, update_func=None, generate_xml_func=None):
61 """internal: used to create decorator for class or function objects.
62
63 `kwargs`: these are typically the keyword arguments passed to the decorator itself.
64 must be a `dict`. The decorator will often update the dict to have
65 defaults or overrides to the parameters passed to the decorator, as appropriate.
66
67 `update_func`: if non-None, must be a callable that takes 2 arguments `(decoratedobj, kwargs)`.
68 The purpose of this callback is to update the kwargs (and return updated version)
69 for required-yet-missing attributes that can be deduced by introspecting
70 the `decoratedobj`.
71
72 `generate_xml_func`: must be non-None and must be a callable that takes 2 arguments `(decoratedobj, kwargs)`.
73 The kwargs can be expected to have been updated by calling `update_func`, if non-None.
74 The callback typically adds an attribute on the decoratedobj for further processing later.
75 """
76 attrs = kwargs.copy()
77
78 def decorator(func):
79 original_func = _undecorate(func)
80 if update_func is not None:
81 updated_attrs = update_func(original_func, attrs)
82 else:
83 updated_attrs = attrs
84 generate_xml_func(original_func, updated_attrs)
85
86 @wraps(func)
87 def wrapper(*args, **kwargs):
88 return func(*args, **kwargs)
89
90 setattr(wrapper, "_pv_original_func", original_func)
91 return wrapper
92
93 return decorator
94
95
96class smproperty(object):

Callers 15

xmlMethod · 0.85
intvectorMethod · 0.85
doublevectorMethod · 0.85
idtypevectorMethod · 0.85
stringvectorMethod · 0.85
proxyMethod · 0.85
inputMethod · 0.85
dataarrayselectionMethod · 0.85
xmlMethod · 0.85
doublerangeMethod · 0.85
intrangeMethod · 0.85
booleanMethod · 0.85

Calls 1

copyMethod · 0.45

Tested by

no test coverage detected