File indexing completed on 2024-04-06 12:15:59
0001 import argparse as _argparse
0002 import textwrap as _textwrap
0003
0004
0005 class HelpFormatterRespectNewlines(_argparse.HelpFormatter):
0006 """Help message formatter which retains line breaks in argument descriptions.
0007
0008 Only the name of this class is considered a public API. All the methods
0009 provided by the class are considered an implementation detail.
0010 """
0011
0012 def _split_lines(self, text, width):
0013 lines = []
0014 for line in text.splitlines():
0015 line = self._whitespace_matcher.sub(' ', line).strip()
0016 lines.extend( _textwrap.wrap(line, width) )
0017 return lines
0018
0019
0020 def FixedWidthFormatter(formatter, width):
0021 """Adaptor for argparse formatters using an explicit fixed width
0022 """
0023 def f(*args, **keywords):
0024
0025 keywords['width'] = width
0026 return formatter(*args, **keywords)
0027
0028 return f
0029