-
Notifications
You must be signed in to change notification settings - Fork 65
Fix cn_metrics.py not to fail on empty yaml input #342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Greg Becker <[email protected]>
|
This hack should get SQA back on track, maybe some Python experts can help me out :-) |
| try: | ||
| from typing import OrderedDict | ||
| except ImportError: | ||
| from typing import Dict as OrderedDict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the dict have to be ordered?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only to preserve column order...
tools/scripts/cn_metrics.py
Outdated
| # TODO: How to test if ybuf[] contain at least one "nodes" stanza? | ||
| # | ||
| try: | ||
| for node in ybuf["nodes"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if "nodes" in ybuf?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, that only works if "nodes" is in ybuf...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ybuf is some kind of monstrosity i don't grok, it returns NoneType if "nodes" is not in ybuf, but you shouldn't test explicitly for None/NoneType, not to mention the none stuff seems to vary depending on Python version, uhg...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"nodes" in ybuf
tells you that there is a key called "nodes". If you are looking to make sure there is a node in the array, then do this:
if ybuf.get("nodes", []): return
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't work, it always returns true.
Cuz.. I'm an idiot, thanks Tristan!
Signed-off-by: Greg Becker <[email protected]>
Signed-off-by: Greg Becker [email protected]