Esempio n. 1
0
 def __init__(self,
              indent_increment=2,
              max_help_position=32,
              width=78,
              short_first=1):
     IndentedHelpFormatter.__init__(self, indent_increment,
                                    max_help_position, width, short_first)
Esempio n. 2
0
	def __init__(self, max_help_position=30, useColors=True, usageColor="\033[1;34m", headingColor="\033[1;33m", descriptionColor="\033[1;31m", optionsColor="\033[1;32m", epilogColor="\033[1;31m",):
		"""
		Constructor of the DwfHelpFormatter class.
		@param self : the object pointer.
		@param max_help_position : starting column of the help text. Default is 30.
		@param useColors : enable or disable the use of color formats. Default is True.
		@param usageColor : color of the command usage text.
		@param headingColor : color of the group heading text.
		@param descriptionColor : color of the command description text.
		@param optionsColor : color of the options.
		@param epilogColor : color of the help epilog text.

		Constructor of the DwfHelpFormatter class used to set formatting of help text and enable or disable this formatting.
		"""
		IndentedHelpFormatter.__init__(self, indent_increment=0, max_help_position=max_help_position, width=None, short_first=True)
		self._isLinuxKSL = False # Know if linux konsole
		self._useColors = useColors # Use console color str if available
		self._usageColor = usageColor
		self._descriptionColor = descriptionColor
		self._headingColor = headingColor
		self._optionsColor = optionsColor
		self._epilogColor = epilogColor
		self._noColor = "\033[0m"
		self.option_raw_strings = {}
		self._short_opt_fmt = "%s [%s]"
		self._long_opt_fmt = "%s=[%s]"
Esempio n. 3
0
 def __init__ (self,
               indent_increment=2,
               max_help_position=32, 
               width=78,
               short_first=1):
     IndentedHelpFormatter.__init__(
         self, indent_increment, max_help_position,
         width, short_first)
Esempio n. 4
0
 def __init__(self, *args, **kwargs):
     from textwrap import fill, wrap
     IndentedHelpFormatter.__init__(self, *args, **kwargs)
     tw = type('textwrap_mock', (object, ), dict(
         fill=staticmethod(fill),
         wrap=staticmethod(lambda *args, **kwargs:
             wrap(*args, **dict(kwargs, break_on_hyphens=False)),
         )))
     self.format_option.func_globals['textwrap'] = tw
Esempio n. 5
0
 def __init__(self, *args, **kwargs):
     from textwrap import fill, wrap
     IndentedHelpFormatter.__init__(self, *args, **kwargs)
     tw = type('textwrap_mock', (object, ), dict(
         fill=staticmethod(fill),
         wrap=staticmethod(lambda *args, **kwargs:
             wrap(*args, **dict(kwargs, break_on_hyphens=False)),
         )))
     self.format_option.__globals__['textwrap'] = tw
Esempio n. 6
0
 def __init__(self,
              indent_increment=0,
              max_help_position=80,
              width=None,
              short_first=1):
     IndentedHelpFormatter.__init__(self,
                                    indent_increment=indent_increment,
                                    max_help_position=max_help_position,
                                    width=width,
                                    short_first=short_first)
Esempio n. 7
0
 def __init__(self):
     IndentedHelpFormatter.__init__(self, indent_increment=2, max_help_position=30, width=80, short_first=1)
Esempio n. 8
0
 def __init__(self, *args, **kwargs):
     IndentedHelpFormatter.__init__(self, *args, **kwargs)
Esempio n. 9
0
 def __init__(self, output):
     IndentedHelpFormatter.__init__(self)
     self.output = output
Esempio n. 10
0
 def __init__(self):
     # indent incr, max_help_pos, width, short_first
     IndentedHelpFormatter.__init__(self, 2, 26, None, 1)
Esempio n. 11
0
    def __init__(self,
                 metavar_format=' <{}>',
                 metavar_column=None,
                 option_separator=', ',
                 align_long_opts=False,
                 help_string_formatter=None,
                 preformatted_description=True,
                 preformatted_epilog=True,
                 *args, **kw):
        """
        :arg metavar_format:
             Evaluated as `metavar_format.format(metavar)` if string.
             If callable, evaluated as `metavar_format(metavar)`.

        :arg metavar_column:
             Column to which all metavars should be aligned.

        :arg option_separator:
             String between short and long option. E.g: ', ' -> '-f, --format'.

        :arg align_long_opts:
             Align all long options on the current indent level to the same
             column. For example:

                align_long_opts=False         align_long_opts=True
             --------------------------    --------------------------
             -h, --help  show this  ...    -h, --help  show this  ...
             --fast      avoid slow ...        --fast  avoid slow ...

        :arg help_string_format:
             Function to call to call on help string after expansion. Called
             as `help_string_format(help, option)`.

        :arg preformatted_description:
             If True, description will be displayed as-is, instead of
             text-wrapping it first.

        :arg preformatted_description:
             If True, epilog will be displayed as-is, instead of
             text-wrapping it first.

        :arg width:
             Maximum help message width. Defaults to 78 unless $COLUMNS is set.
        """

        if not callable(metavar_format):
            func = partial(format_option_metavar, fmt=metavar_format)
        else:
            func = metavar_format

        self.metavar_format   = func
        self.metavar_column   = metavar_column
        self.align_long_opts  = align_long_opts
        self.option_separator = option_separator
        self.help_string_formatter = help_string_formatter

        if 'width' not in kw:
            try:
                kw['width'] = int(os.environ['COLUMNS']) - 2
            except (KeyError, ValueError):
                kw['width'] = 78

        kw['max_help_position'] = kw.get('max_help_position', kw['width'])
        kw['indent_increment']  = kw.get('indent_increment', 1)
        kw['short_first']       = kw.get('short_first', 1)

        # leave full control of description and epilog to us
        self.preformatted_description = preformatted_description
        self.preformatted_epilog      = preformatted_epilog

        IndentedHelpFormatter.__init__(self, *args, **kw)
Esempio n. 12
0
 def __init__(self):
     IndentedHelpFormatter.__init__(self)
     self.max_help_position = 50
     self.width = 120
Esempio n. 13
0
 def __init__(self):
     IndentedHelpFormatter.__init__(self,
                                    width=min(get_terminal_size()[0], 80) -
                                    2)
     self.default_tag = ''
Esempio n. 14
0
 def __init__(self, subcommand_arg_summaries, *args, **kwargs):
     self.subcommand_arg_summaries = subcommand_arg_summaries
     IndentedHelpFormatter.__init__(self, *args, **kwargs)
Esempio n. 15
0
 def __init__(self, *args, **kwargs):
     IndentedHelpFormatter.__init__(self, *args, **kwargs)
     self.help_position = 0
Esempio n. 16
0
 def __init__(self):
     # indent incr, max_help_pos, width, short_first
     IndentedHelpFormatter.__init__(self, 2, 26, None, 1)
Esempio n. 17
0
	def __init__(self):
		IndentedHelpFormatter.__init__(self)
 def __init__(self, *args, **kwargs):
     IndentedHelpFormatter.__init__(self, *args, **kwargs)
     self.envvar_tag = "%envvar"
Esempio n. 19
0
    def __init__(self,
                 metavar_format=' <{}>',
                 metavar_column=None,
                 option_separator=', ',
                 align_long_opts=False,
                 help_string_formatter=None,
                 preformatted_description=True,
                 preformatted_epilog=True,
                 *args,
                 **kw):
        """
        :arg metavar_format:
             Evaluated as `metavar_format.format(metavar)` if string.
             If callable, evaluated as `metavar_format(metavar)`.

        :arg metavar_column:
             Column to which all metavars should be aligned.

        :arg option_separator:
             String between short and long option. E.g: ', ' -> '-f, --format'.

        :arg align_long_opts:
             Align all long options on the current indent level to the same
             column. For example:

                align_long_opts=False         align_long_opts=True
             --------------------------    --------------------------
             -h, --help  show this  ...    -h, --help  show this  ...
             --fast      avoid slow ...        --fast  avoid slow ...

        :arg help_string_format:
             Function to call to call on help string after expansion. Called
             as `help_string_format(help, option)`.

        :arg preformatted_description:
             If True, description will be displayed as-is, instead of
             text-wrapping it first.

        :arg preformatted_description:
             If True, epilog will be displayed as-is, instead of
             text-wrapping it first.

        :arg width:
             Maximum help message width. Defaults to 78 unless $COLUMNS is set.
        """

        if not callable(metavar_format):
            func = partial(format_option_metavar, fmt=metavar_format)
        else:
            func = metavar_format

        self.metavar_format = func
        self.metavar_column = metavar_column
        self.align_long_opts = align_long_opts
        self.option_separator = option_separator
        self.help_string_formatter = help_string_formatter

        if 'width' not in kw:
            try:
                kw['width'] = int(os.environ['COLUMNS']) - 2
            except (KeyError, ValueError):
                kw['width'] = 78

        kw['max_help_position'] = kw.get('max_help_position', kw['width'])
        kw['indent_increment'] = kw.get('indent_increment', 1)
        kw['short_first'] = kw.get('short_first', 1)

        # leave full control of description and epilog to us
        self.preformatted_description = preformatted_description
        self.preformatted_epilog = preformatted_epilog

        IndentedHelpFormatter.__init__(self, *args, **kw)
Esempio n. 20
0
 def __init__(self, banner, *argv, **argd):
     self.banner = banner
     IndentedHelpFormatter.__init__(self, *argv, **argd)
Esempio n. 21
0
 def __init__(self, *args, **kwargs):
     IndentedHelpFormatter.__init__(self, *args, **kwargs)
Esempio n. 22
0
 def __init__(self):
     IndentedHelpFormatter.__init__(self,
         width=min(get_terminal_size()[0], 80) - 2)
     self.default_tag = ''
Esempio n. 23
0
 def __init__(self, subcommand_arg_summaries, *args, **kwargs):
     self.subcommand_arg_summaries = subcommand_arg_summaries
     IndentedHelpFormatter.__init__(self, *args, **kwargs)
Esempio n. 24
0
 def __init__(self, heading):
     self.heading = heading
     IndentedHelpFormatter.__init__(self)
Esempio n. 25
0
 def __init__(self, banner, *argv, **argd):
     self.banner = banner
     IndentedHelpFormatter.__init__(self, *argv, **argd)
Esempio n. 26
0
	def __init__(self, output):
		IndentedHelpFormatter.__init__(self)
		self.output = output
Esempio n. 27
0
 def __init__(self):
     IndentedHelpFormatter.__init__(self)
Esempio n. 28
0
 def __init__(self, *args, **kwargs):
     IndentedHelpFormatter.__init__(self, *args, **kwargs)
     self.help_position = 0