gh-129911: pygettext: Fix the keyword entry in help output#129914
gh-129911: pygettext: Fix the keyword entry in help output#129914serhiy-storchaka merged 3 commits intopython:mainfrom
Conversation
There was a problem hiding this comment.
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:
|
StanFromIreland
left a comment
There was a problem hiding this comment.
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.
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 🙂 |
|
Note also the output of Using |
This simply replaces the interpolated value
%(DEFAULTKEYWORDS)swith the list of default keywords.The default keywords are unlikely to change often so there is no advantage to keeping the help text parametrized.