Test Failed
Push — master ( 1bab60...8e0a9b )
by Jan
02:31 queued 11s
created

utils.gen_multiple_reference_tables   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 32
dl 0
loc 46
ccs 0
cts 26
cp 0
rs 10
c 0
b 0
f 0
wmc 2

2 Functions

Rating   Name   Duplication   Size   Complexity  
A parse_args() 0 6 1
A update_parser() 0 11 1
1
#!/usr/bin/python3
2
3
import os
4
import re
5
import glob
6
import argparse
7
8
import ssg.build_yaml
9
import ssg.constants
10
11
from utils import gen_reference_table
12
13
14
def update_parser(parser):
15
    parser.add_argument("--build-dir", default="build", help="Path to the build directory")
16
    parser.add_argument(
17
        "product", help="The product to be built")
18
    parser.add_argument(
19
        "output_template", help="Template of the filename to generate. "
20
        "Occurrence of '{ref_id}' will be substituted by the respective reference ID "
21
        "that the generated table describes.")
22
    parser.add_argument(
23
        "refcategory", metavar="REFERENCE_ID", nargs="+",
24
        help="Category of the rule reference")
25
26
27
def parse_args():
28
    parser = argparse.ArgumentParser(
29
        description="Render multiple reference tables at once "
30
        "using the gen_reference_table script functionality")
31
    update_parser(parser)
32
    return parser.parse_args()
33
34
35
if __name__ == "__main__":
36
    args = parse_args()
37
    renderer = gen_reference_table.HtmlOutput(args.product, args.build_dir)
38
    for reference in args.refcategory:
39
        reference = ssg.constants.REFERENCES[reference]
40
41
        renderer.process_rules(reference)
42
        result = renderer.get_result()
43
        output = args.output_template.format(ref_id=reference.id)
44
        with open(output, "w") as outfile:
45
            outfile.write(result)
46