Ejemplo n.º 1
0
def main():
    debug_imports = bool(sys.argv[1]) if len(sys.argv) > 1 else False
    print("Scanning for workflow files...")
    list_workflows = scan_workflows(debug_imports)

    print("Processing arguments...")
    parser = CommandLineBase.init_parser(ignore_conflicts=True)
    arguments = parser._actions
    list_lines = [obj[-1] for obj in sorted(
        [convert_argument(*ia) for ia in enumerate(arguments)])]

    defaults = {}
    html = ''.join(list_lines)
    loader = template.Loader(os.path.join(WEB_FOLDER, "templates"))
    opts, positional_opts, choices, defaults_opt = generate_opts(arguments)

    path_to_out = os.path.join(WEB_FOLDER, "frontend.html")
    print("Writing %s..." % path_to_out)
    sout = loader.load("frontend.html").generate(
        arguments=html, workflows=list_workflows,
        cmdline_states=json.dumps(defaults),
        opts=json.dumps(opts), positional_opts=json.dumps(positional_opts),
        choices=json.dumps(choices), defaults_opt=json.dumps(defaults_opt),
        special_opts=json.dumps(CommandLineBase.SPECIAL_OPTS))
    with open(path_to_out, "wb") as fout:
        fout.write(sout)
    return 0
Ejemplo n.º 2
0
def main():
    debug_imports = bool(sys.argv[1]) if len(sys.argv) > 1 else False
    print("Scanning for workflow files...")
    list_workflows = scan_workflows(debug_imports)

    print("Processing arguments...")
    parser = CommandLineBase.init_parser(ignore_conflicts=True)
    arguments = parser._actions
    list_lines = [
        obj[-1] for obj in sorted(
            [convert_argument(*ia) for ia in enumerate(arguments)])
    ]

    defaults = {}
    html = ''.join(list_lines)
    loader = template.Loader(os.path.join(WEB_FOLDER, "templates"))
    opts, positional_opts, choices, defaults_opt = generate_opts(arguments)

    path_to_out = os.path.join(WEB_FOLDER, "frontend.html")
    print("Writing %s..." % path_to_out)
    sout = loader.load("frontend.html").generate(
        arguments=html,
        workflows=list_workflows,
        cmdline_states=json.dumps(defaults),
        opts=json.dumps(opts),
        positional_opts=json.dumps(positional_opts),
        choices=json.dumps(choices),
        defaults_opt=json.dumps(defaults_opt),
        special_opts=json.dumps(CommandLineBase.SPECIAL_OPTS))
    with open(path_to_out, "wb") as fout:
        fout.write(sout)
    return 0
Ejemplo n.º 3
0
def filter_argv(argv, *blacklist):
    ptree = StringTrie({v: i for i, v in enumerate(blacklist)})
    filtered = []
    maybe_value = False
    boolean_args = set(chain.from_iterable(
        a.option_strings for a in CommandLineBase.init_parser()._actions
        if isinstance(a, (argparse._StoreTrueAction,
                          argparse._StoreFalseAction))))
    i = -1
    while i + 1 < len(argv):
        i += 1
        arg = argv[i]
        has_value = arg.startswith("-") and arg not in boolean_args \
            and '=' not in arg and arg != "-"
        if ptree.longest_prefix(arg, None) is None:
            filtered.append(arg)
            if has_value:
                i += 1
                filtered.append(argv[i])
        elif has_value:
            i += 1
    return filtered
Ejemplo n.º 4
0
def filter_argv(argv, *blacklist):
    ptree = StringTrie({v: i for i, v in enumerate(blacklist)})
    filtered = []
    maybe_value = False
    boolean_args = set(
        chain.from_iterable(a.option_strings
                            for a in CommandLineBase.init_parser()._actions
                            if isinstance(a, (argparse._StoreTrueAction,
                                              argparse._StoreFalseAction))))
    i = -1
    while i + 1 < len(argv):
        i += 1
        arg = argv[i]
        has_value = arg.startswith("-") and arg not in boolean_args \
            and '=' not in arg and arg != "-"
        if ptree.longest_prefix(arg, None) is None:
            filtered.append(arg)
            if has_value:
                i += 1
                filtered.append(argv[i])
        elif has_value:
            i += 1
    return filtered
Ejemplo n.º 5
0
def create_args_parser_sphinx():
    """
    This is a top-level function to please Sphinx.
    """
    return CommandLineBase.init_parser(True)
Ejemplo n.º 6
0
def create_args_parser_sphinx():
    """
    This is a top-level function to please Sphinx.
    """
    return CommandLineBase.init_parser(True)