Skip to content

cli

mfile()

MFile tools

Source code in process/core/io/mfile/cli.py
10
11
12
13
@click.group()
@help_opt
def mfile():
    """MFile tools"""

convert(mfile, variables, format_, scan, verbose)

Convert MFile to other formats.

Currently all variables must be specified

Source code in process/core/io/mfile/cli.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
@mfile.command("convert", no_args_is_help=True)
@help_opt
@mfile_opt(exists=True)
@click.option(
    "-v",
    "--variables",
    default="",
    type=str,
    help="Optional list of variables or json file with list of variables to extract",
)
@click.option(
    "-fmt",
    "--format",
    "format_",
    type=click.Choice(["json", "csv", "toml"]),
)
@scan_opt
@click.option("--verbose", is_flag=True)
def convert(mfile, variables, format_, scan, verbose):
    """Convert MFile to other formats.

    Currently all variables must be specified
    """
    if variables.endswith(".json"):
        with open(variables) as f:
            variables = json.load(f)["variables"]
    else:
        variables = list(filter(None, variables.replace(" ", ":").split(":")))

    getattr(MFile(mfile), f"to_{format_}")(
        keys_to_write=variables, scan=scan, verbose=verbose
    )

compare(mfiles, save, comparison, acc, verbose)

Produce a comparison between two PROCESS MFILEs.

User Can specify level of differences to show.

Source code in process/core/io/mfile/cli.py
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
@mfile.command("compare", no_args_is_help=True)
@help_opt
@mfile_arg
@save("Save output to file called comp.txt")
@click.option(
    "-t",
    "--comparison-type",
    "comparison",
    type=click.Choice(["defaults", "baseline", "blanket", "generic", "all"]),
    default="all",
    help="Comparison output sets",
)
@click.option("-v", "--verbose", default=False, is_flag=True)
@click.option("--acc", type=float, default=5.0)
def compare(mfiles, save, comparison, acc, verbose):
    """Produce a comparison between two PROCESS MFILEs.

    User Can specify level of differences to show.

    """
    compare_mfiles(mfiles, comparison, acc, save, verbose)