How to use the flattentool.output.FORMATS function in flattentool

To help you get started, we’ve selected a few flattentool examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpenDataServices / flatten-tool / flattentool / cli.py View on Github external
def create_parser():
    """
    Create an argparse ArgumentParser for our commandline arguments

    Defaults are not set here, but rather given in the appropriate function.

    (This is split out as it's own function primarily so it can be tested.)

    """

    parser = argparse.ArgumentParser()
    subparsers = parser.add_subparsers(dest="subparser_name")

    output_formats = sorted(OUTPUT_FORMATS) + ["all"]
    input_formats = sorted(INPUT_FORMATS)

    parser.add_argument(
        "-v",
        "--verbose",
        action="store_true",
        help="Print detailed output when warnings or errors occur.",
    )

    parser_create_template = subparsers.add_parser(
        "create-template", help="Create a template from the given schema"
    )
    parser_create_template.add_argument(
        "-s",
        "--schema",
        help="Path to the schema file you want to use to create the template",
github OpenDataServices / flatten-tool / flattentool / __init__.py View on Github external
sheet_prefix=sheet_prefix,
        )
        spreadsheet_output.write_sheets()

    if output_format == "all":
        if not output_name:
            output_name = "flattened"
        for format_name, spreadsheet_output_class in OUTPUT_FORMATS.items():
            spreadsheet_output(
                spreadsheet_output_class, output_name + FORMATS_SUFFIX[format_name]
            )

    elif output_format in OUTPUT_FORMATS.keys():  # in dictionary of allowed formats
        if not output_name:
            output_name = "flattened" + FORMATS_SUFFIX[output_format]
        spreadsheet_output(OUTPUT_FORMATS[output_format], output_name)

    else:
        raise Exception("The requested format is not available")