#NEWLINE# def parse_args( argv , description = '' , commands = None , print_help = True ) : #NEWLINE# #INDENT# '\n    Parse the given commandline-arguments.\n\n    :param argv: list of command-line arguments as in ``sys.argv``\n    :type argv: list[str]\n    :param description: description of the experiment (docstring) to be used\n                        in the help text.\n    :type description: str\n    :param commands: list of commands that are supported by this experiment\n    :type commands: dict[str, func] | None\n    :param print_help: if True (default) this function will print the help-text\n                       and exit if that is required by the parsed arguments.\n    :type print_help: bool\n    :return: parsed values for all command-line options.\n             See ``docopt`` for more details.\n    :rtype: dict[str, str | bool | None]\n    ' #NEWLINE# options = gather_command_line_options ( ) #NEWLINE# usage = _format_usage ( argv [ 0 ] , description , commands , options ) #NEWLINE# args = docopt ( usage , [ str ( a ) for a in argv [ 1 : ] ] , help = print_help ) #NEWLINE# if ( ( not args [ 'help' ] ) or ( not print_help ) ) : #NEWLINE# #INDENT# return args #NEWLINE# #UNINDENT# if ( args [ 'COMMAND' ] is None ) : #NEWLINE# #INDENT# print ( usage ) #NEWLINE# sys . exit ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# print ( help_for_command ( commands [ args [ 'COMMAND' ] ] ) ) #NEWLINE# sys . exit ( )