Exemple #1
0
def update_tool_run(context: Context, tool: str, run: bool) -> None:
    """Sets run field of tool to RUN. Default to no ignore if tool not in config
    """
    # Check that TOOL is valid
    if tool not in {t.tool_id() for t in bento.extra.TOOLS}:
        echo_error(
            f"No tool named '{tool}'. See help text for list of available tools."
        )
        sys.exit(3)

    config = context.config
    tool_config = config["tools"]
    if tool not in tool_config:
        # Read default ignore from default config file
        with (open(
                os.path.join(os.path.dirname(__file__),
                             "configs/default.yml"))) as template:
            yml = yaml.safe_load(template)

        default_ignore: List[str] = []
        if tool in yml["tools"]:
            default_ignore = yml["tools"][tool]["ignore"]

        tool_config[tool] = {"ignore": default_ignore}

    tool_config[tool]["run"] = run
    context.config = config
Exemple #2
0
def update_tool_run(context: Context, tool: str, run: bool) -> None:
    """Sets run field of tool to RUN. Default to no ignore if tool not in config
    """

    config = context.config
    tool_config = config["tools"]
    all_tools = ", ".join(f"'{k}'" for k in tool_config.keys())
    # Check that TOOL is valid
    if tool not in {t.tool_id() for t in bento.extra.TOOLS}:
        raise InvalidToolException(tool, all_tools)

    if tool not in tool_config:
        # Read default ignore from default config file
        with (open(
                os.path.join(os.path.dirname(__file__),
                             "configs/default.yml"))) as template:
            yml = yaml.safe_load(template)

        default_ignore: List[str] = []
        if tool in yml["tools"]:
            default_ignore = yml["tools"][tool]["ignore"]

        tool_config[tool] = {"ignore": default_ignore}

    tool_config[tool]["run"] = run
    context.config = config
Exemple #3
0
def update_ignores(context: Context, tool: str,
                   update_func: Callable[[Set[str]], None]) -> None:
    config = context.config
    tool_config = config["tools"]
    if tool not in tool_config:
        all_tools = ", ".join(f"'{k}'" for k in tool_config.keys())
        raise InvalidToolException(tool, all_tools)

    ignores = set(tool_config[tool].get("ignore", []))
    update_func(ignores)

    tool_config[tool]["ignore"] = sorted(list(ignores))

    context.config = config
Exemple #4
0
def update_ignores(context: Context, tool: str,
                   update_func: Callable[[Set[str]], None]) -> None:
    config = context.config
    tool_config = config["tools"]
    if tool not in tool_config:
        all_tools = ", ".join(f"'{k}'" for k in tool_config.keys())
        echo_error(f"No tool named '{tool}'. Configured tools are {all_tools}")
        sys.exit(3)

    ignores = set(tool_config[tool].get("ignore", []))
    update_func(ignores)

    tool_config[tool]["ignore"] = list(ignores)

    context.config = config
Exemple #5
0
def _configure_block(context: Context, block: bool) -> None:
    config = context.config
    autorun_config = config.get(constants.AUTORUN, {})
    autorun_config[constants.AUTORUN_BLOCK] = block
    config[constants.AUTORUN] = autorun_config
    context.config = config