diff options
author | steven.bethard <devnull@localhost> | 2009-09-13 00:01:52 +0000 |
---|---|---|
committer | steven.bethard <devnull@localhost> | 2009-09-13 00:01:52 +0000 |
commit | 6964050e4ae3122748b8fc207f1a44aa6a917d1a (patch) | |
tree | 0e9a26e017f433c4b0391e71daf8ad64c165dc41 /argparse.py | |
parent | d1ce37550e67bc777504f3cde9a2c2c5bd7951ec (diff) | |
download | argparse-6964050e4ae3122748b8fc207f1a44aa6a917d1a.tar.gz |
Fix a bug that was preventing % from being used in help messages.
Diffstat (limited to 'argparse.py')
-rw-r--r-- | argparse.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/argparse.py b/argparse.py index 75a9043..ce1adb9 100644 --- a/argparse.py +++ b/argparse.py @@ -306,7 +306,7 @@ class HelpFormatter(object): # Help-formatting methods # ======================= def format_help(self): - help = self._root_section.format_help() % dict(prog=self._prog) + help = self._root_section.format_help() if help: help = self._long_break_matcher.sub('\n\n', help) help = help.strip('\n') + '\n' @@ -321,9 +321,13 @@ class HelpFormatter(object): if prefix is None: prefix = _('usage: ') + # if usage is specified, use that + if usage is not None: + usage = usage % dict(prog=self._prog) + # if no optionals or positionals are available, usage is just prog - if usage is None and not actions: - usage = '%(prog)s' + elif usage is None and not actions: + usage = '%(prog)s' % dict(prog=self._prog) # if optionals and positionals are available, calculate usage elif usage is None: |