def convert(config):
    if not isinstance(config, Config):
        raise TypeError("Expected Config, got '%s' instead" % type(config))

    # Check restrictions
    if config.scope is not None and config.excluded is not None:
        raise ValueError("Scope and excluded can't be set simultaneously")

    if config.excluded:
        excluded_hosts = [x.strip().replace("\n", "").replace("\t", "").replace("\r", "") for x in open(config.excluded, "rU").readlines()]
    else:
        excluded_hosts = None

    if config.scope:
        scope_hosts = [x.strip().replace("\n", "").replace("\t", "").replace("\r", "") for x in open(config.scope, "rU").readlines()]
    else:
        scope_hosts = None

    # --------------------------------------------------------------------------
    # Load OpenVas info
    # --------------------------------------------------------------------------
    openvas_info = openvas_parser(config.input_files, excluded_hosts=excluded_hosts, scope_hosts=scope_hosts)

    # Output config
    output_file = config.output_file
    lang = config.lang

    # --------------------------------------------------------------------------
    # Generate Word file
    # --------------------------------------------------------------------------
    if output_file.endswith("docx"):
        from .libs.exporters.word import export_to_word

        template = config.template
        export_to_word(openvas_info, output_file, template)

    elif output_file.endswith("xlsx"):
        from .libs.exporters.excel import export_to_excel

        export_to_excel(openvas_info, output_file, lang)

    else:
        raise ValueError("Extension not found!")
Convert a file to selected format.
dataset/ETHPy150Open cr0hn/openvas_to_report/openvas_to_report/api.py/convert