summaryrefslogtreecommitdiff
path: root/python/xrelfo.py
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2022-10-04 13:30:04 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2022-10-06 15:34:32 +0200
commit9eebf97e3d3fe8bff0d3c5ecdae39f15bd93f40b (patch)
tree04b57dbd4183fd0f0b415a022e12cb72e29fdf16 /python/xrelfo.py
parent53d8bf6d7a233ccc97e0f466374878f2b8e3f657 (diff)
lib: make cmd_element->attr a bitmask & clarify
It already "looks" like a bitmask, but we currently can't flag a command both YANG and HIDDEN at the same time. It really should be a bitmask. Also clarify DEPRECATED behaviour (or the absence thereof.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'python/xrelfo.py')
-rw-r--r--python/xrelfo.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/python/xrelfo.py b/python/xrelfo.py
index 17262da8d9..3bfe9950d7 100644
--- a/python/xrelfo.py
+++ b/python/xrelfo.py
@@ -26,7 +26,7 @@ import argparse
from clippy.uidhash import uidhash
from clippy.elf import *
-from clippy import frr_top_src
+from clippy import frr_top_src, CmdAttr
from tiabwarfo import FieldApplicator
try:
@@ -196,8 +196,6 @@ Xref.containers[XREFT_LOGMSG] = XrefLogmsg
class CmdElement(ELFDissectStruct, XrelfoJson):
struct = 'cmd_element'
- cmd_attrs = { 0: None, 1: 'deprecated', 2: 'hidden'}
-
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@@ -207,10 +205,14 @@ class CmdElement(ELFDissectStruct, XrelfoJson):
jsobj.update({
'string': self.string,
'doc': self.doc,
- 'attr': self.cmd_attrs.get(self.attr, self.attr),
})
- if jsobj['attr'] is None:
- del jsobj['attr']
+ if self.attr:
+ jsobj['attr'] = attr = self.attr
+ for attrname in CmdAttr.__members__:
+ val = CmdAttr[attrname]
+ if attr & val:
+ jsobj.setdefault('attrs', []).append(attrname.lower())
+ attr &= ~val
jsobj['defun'] = dict([(i, getattr(self.xref, i)) for i in ['file', 'line', 'func']])