-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-129911: pygettext: Fix the keyword entry in help output #129914
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
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.
Why hard code them? We can just get the keywords from the dictionary.
__doc__ = __doc__ % {"DEFAULTKEYWORDS": ", ".join(DEFAULTKEYWORDS.keys())}
--- pygettext.py 2025-02-09 21:26:04.337335656 +0000
+++ pygettext-proposed.py 2025-02-09 21:27:36.552807306 +0000
@@ -171,7 +171,7 @@
def usage(code, msg=''):
- print(__doc__ % globals(), file=sys.stderr)
+ print(__doc__, file=sys.stderr)
if msg:
print(msg, file=sys.stderr)
sys.exit(code)
@@ -295,6 +295,7 @@
'dnpgettext': {1: 'msgctxt', 2: 'msgid', 3: 'msgid_plural'},
}
+__doc__ = __doc__ % {"DEFAULTKEYWORDS": ", ".join(DEFAULTKEYWORDS.keys())}
def matches_spec(message, spec):
"""Check if a message has all the keys defined by the keyword spec."""
Good question! Several reasons:
|
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.
Good enough explanation for me
"""Test that the help text is displayed.""" | ||
res = assert_python_ok(self.script, '--help') | ||
self.assertEqual(res.out, b'') | ||
self.assertIn(b'pygettext -- Python equivalent of xgettext(1)', res.err) |
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.
I only test that the --help
argument works, not that the help text matches a snapshot exactly, though I can add it
@AA-Turner is it ok if I request your review on PRs related to pygettext? I don't want to create too much noise if you'd prefer not to 🙂 |
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.
LGTM.
Note also the output of Using |
This simply replaces the interpolated value
%(DEFAULTKEYWORDS)s
with the list of default keywords.The default keywords are unlikely to change often so there is no advantage to keeping the help text parametrized.