summaryrefslogtreecommitdiffstats
path: root/python/netlink/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/netlink/util.py')
-rw-r--r--python/netlink/util.py23
1 files changed, 9 insertions, 14 deletions
diff --git a/python/netlink/util.py b/python/netlink/util.py
index 0f2e547..2394033 100644
--- a/python/netlink/util.py
+++ b/python/netlink/util.py
@@ -80,24 +80,19 @@ class MyFormatter(Formatter):
self._indent = indent
def _nlattr(self, key):
- value = getattr(self._obj, key)
- title_ = None
+ value = getattr(self._obj.__class__, key)
+ if not isinstance(value, property):
+ raise ValueError('Invalid formatting string {0}'.format(key))
- if isinstance(value, types.MethodType):
- value = value()
+ d = getattr(value.fget, 'formatinfo', dict())
- try:
- d = netlink.attrs[self._obj._name + '.' + key]
+ # value = value.fget() is exactly the same
+ value = getattr(self._obj, key)
- if 'fmt' in d:
- value = d['fmt'](value)
+ if 'fmt' in d:
+ value = d['fmt'](value)
- if 'title' in d:
- title_ = d['title']
- except KeyError:
- pass
- except AttributeError:
- pass
+ title_ = d.get('title', None)
return title_, str(value)