Skip to content

Main

yaml_to_other(input_files=['04_Powers.yaml', '05_Vulnerabilities.yaml', '06_Bestiary.yaml', '07_Items.yaml', '08_PCs.yaml'], writing=['md', 'csv', 'png'], out_delim='\t', run_samples=False)

Execute all write functions based on inputs at top of script

Parameters:

Name Type Description Default
input_files list

Local relative paths. If len=2, also make combined csv

['04_Powers.yaml', '05_Vulnerabilities.yaml', '06_Bestiary.yaml', '07_Items.yaml', '08_PCs.yaml']
writing list

List of output formats.

['md', 'csv', 'png']
out_delim str

CSV delimiter - or ,

'\t'
Source code in automation/templates/main.py
 7
 8
 9
10
11
12
13
14
15
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
48
49
50
def yaml_to_other(
    input_files: list = [
        "04_Powers.yaml",
        "05_Vulnerabilities.yaml",
        "06_Bestiary.yaml",
        "07_Items.yaml",
        "08_PCs.yaml",
    ],
    writing: list = ["md", "csv", "png"],
    out_delim: str = "\t",  # or ','
    run_samples=False,
):
    """Execute all write functions based on inputs at top of script

    Args:
        input_files (list, optional): Local relative paths.
            If len=2, also make combined csv
        writing (list, optional): List of output formats.
        out_delim (str, optional): CSV delimiter - `\t` or `,`
    """
    for file in input_files:
        if run_samples and "Vuln" not in file:
            file = file.split(".")[0] + "_SAMPLE.yaml"

        logger.debug(f"Started {file}")

        if "best" in file.lower() or "pc" in file.lower():
            my_class = Bestiary(file)
            if "png" in writing:
                for pc in my_class.categories.get(("PC",), []):
                    my_class.as_dict[pc].make_pc_img()
        elif "power" in file.lower() or "vuln" in file.lower():
            my_class = Powers(file)
        elif "item" in file.lower():
            my_class = Items(file)
        else:
            raise ValueError("Could not infer ingestion routine by file name.")

        if "md" in writing:
            my_class.write_md(output_fp=None, TOC=False)
        if "csv" in writing:
            my_class.write_csv(delimiter=out_delim)
    if "04_Powers.yaml" in input_files and "05_Vulnerabilities.yaml" in input_files:
        Powers(input_files=["04_Powers.yaml", "05_Vulnerabilities.yaml"]).write_csv()