From: Ondrej Lichtner <olichtne(a)redhat.com>
Instances of this class do nothing. Calling any method will return None,
this is useful for improving LNST-PerfRepo integration where, if
PerfRepo is unavailable, we can simply replace all PerfRepo related
objects with Noop objects. This way python tasks that use PerfRepo will
work even if PerfRepo is unavailable without any additional logic
required.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Common/Utils.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lnst/Common/Utils.py b/lnst/Common/Utils.py
index 62b0521..727f82a 100644
--- a/lnst/Common/Utils.py
+++ b/lnst/Common/Utils.py
@@ -296,3 +296,9 @@ def indent(string, spaces):
for line in string.split('\n'):
ret_str.append(' '*spaces + line)
return '\n'.join(ret_str)
+
+class Noop(object):
+ def __getattr__(self, name):
+ def noop(*args, **kwargs):
+ pass
+ return noop
--
2.6.0