Example #1
0
 def test_parse_format_options_errors(self, options_string, expected_error):
     defaults = {'foo': {'bar': 1}}
     with pytest.raises(argparse.ArgumentTypeError, match=expected_error):
         parse_format_options(s=options_string, defaults=defaults)
Example #2
0
 def _process_format_options(self):
     parsed_options = PARSED_DEFAULT_FORMAT_OPTIONS
     for options_group in self.args.format_options or []:
         parsed_options = parse_format_options(options_group,
                                               defaults=parsed_options)
     self.args.format_options = parsed_options
Example #3
0
 def test_parse_format_options(self, defaults, options_string, expected):
     actual = parse_format_options(s=options_string, defaults=defaults)
     assert expected == actual
Example #4
0
    For non-{auto_style} styles to work properly, please make sure that the
    $TERM environment variable is set to "xterm-256color" or similar
    (e.g., via `export TERM=xterm-256color' in your ~/.bashrc).

    """.format(
        default=DEFAULT_STYLE,
        available_styles='\n'.join(
            '{0}{1}'.format(8 * ' ', line.strip())
            for line in wrap(', '.join(sorted(AVAILABLE_STYLES)), 60)).strip(),
        auto_style=AUTO_STYLE,
    ))

output_processing.add_argument(
    '--format-options',
    type=lambda s: parse_format_options(
        s=s, defaults=PARSED_DEFAULT_FORMAT_OPTIONS),
    default=PARSED_DEFAULT_FORMAT_OPTIONS,
    help="""
    Controls output formatting. Only relevant when formatting is enabled
    through (explicit or implied) --pretty=all or --pretty=format.
    The following are the default options:

        {option_list}

    You can specify multiple comma-separated options. For example, this modifies
    the settings to disable the sorting of JSON keys and headers:

        --format-options json.sort_keys:false,headers.sort:false

    This is something you will typically put into your config file.