CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
extend_argparse.py
Go to the documentation of this file.
1 import argparse as _argparse
2 import textwrap as _textwrap
3 
4 # argparse's formatters remove newlines from comand descriptions, so we define a new one
5 class HelpFormatterRespectNewlines(_argparse.HelpFormatter):
6  """Help message formatter which retains line breaks in argument descriptions.
7 
8  Only the name of this class is considered a public API. All the methods
9  provided by the class are considered an implementation detail.
10  """
11 
12  def _split_lines(self, text, width):
13  lines = []
14  for line in text.splitlines():
15  line = self._whitespace_matcher.sub(' ', line).strip()
16  lines.extend( _textwrap.wrap(line, width) )
17  return lines
18 
19 # argparse's formatters are not really able to discover the terminale size, so we override them
20 def FixedWidthFormatter(formatter, width):
21  """Adaptor for argparse formatters using an explicit fixed width
22  """
23  def f(*args, **keywords):
24  # add or replace the "width" parameter
25  keywords['width'] = width
26  return formatter(*args, **keywords)
27 
28  return f
29 
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
double f[11][100]