| Total Complexity | 2 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 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 |