Skip to content
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

ceph.in: allow 'flags' to not be present in cmddescs #12540

Merged
merged 1 commit into from
Dec 20, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/ceph.in
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,9 @@ def format_help(cmddict, partial=None):

if not cmd['help']:
continue
if cmd['flags'] is not None and ((cmd['flags'] & (FLAG_OBSOLETE | FLAG_DEPRECATED)) != 0):
flags = cmd.get('flags')
if (flags is not None and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this explicit check for flags is not None is clearly fixing the issue, but this is extremely hard to parse due to the uncommon usage of Python's bitwise operators.

Is it really that necessary to use logical bitwise operators to check if a flag is obsolete or deprecated?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it can be changed without chagning hte json schema...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, it is not necessary to use &, |, or << here. Regular Python operators would do just fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just saw this. It seems like idiomatic usage to me, but then I'm a C programmer first

(flags & (FLAG_OBSOLETE | FLAG_DEPRECATED)) != 0):
continue
concise = concise_sig(cmd['sig'])
if partial and not concise.startswith(partial):
Expand Down