Decorator for LMIClass, which first fetches a wrapped CIMClass object and then executes a wrapped method.
Parameters: | fn (instancemethod) – wrapped method |
---|
Decorator, which returns None, if provided test expression is True.
Parameters: |
|
---|
Example of usage:
class Foo:
def __init__(self, deleted):
self._deleted = deleted
@lmi_possibly_deleted(lambda obj: obj._member, lambda: False)
def some_method(self):
print "some_method called"
return True
f = Foo(None)
f.some_method() == False
f = Foo(True)
f.some_method() == True
Decorator, which calls a specified expression and returns its return value instead of calling the decorated method, if provided test expression is False; otherwise a method is called.
Parameters: |
|
---|
Example of usage:
class Foo:
def __init__(self, member):
self._member = member
def failed(self):
print "expression failed"
return False
# NOTE: the self parameter to the method call needs to be passed via expr_ret_args,
# therefore, there is a dummy lambda obj: obj, which is basically self variable.
@lmi_return_expr_if_fail(lambda obj: obj._member, failed, lambda obj: obj)
def some_method(self):
print "some_method called"
return True
f = Foo(None)
f.some_method() == False
f = Foo(True)
f.some_method() == True
Decorator, which returns None and no method call is performed, if provided test expression is False; otherwise a method is called.
Parameters: | expr_test – if the expression expr_test returns True, a method is called |
---|
Example of usage:
class Foo:
def __init__(self, member):
self._member = member
@lmi_return_if_fail(lambda obj: obj._member)
def some_method(self):
print "some_method called"
return True
f = Foo(None)
f.some_method() == None
f = Foo(True)
f.some_method() == True
Decorator, which returns a specified value and no method call is performed, if provided test expression is False; otherwise a method is called.
Parameters: |
|
---|
Example of usage:
class Foo:
def __init__(self, member):
self._member = member
@lmi_return_val_if_fail(lambda obj: obj._member, False)
def some_method(self):
print "some_method called"
return True
f = Foo(None)
f.some_method() == False
f = Foo(True)
f.some_method() == True