|
|
@@ -11,50 +11,69 @@ if __name__ == "__main__":
|
|
|
argparser = argparse.ArgumentParser(
|
|
|
description = "Parses .drawio files as Process Models and writes them as OML descriptions.")
|
|
|
argparser.add_argument('inputfile', help="A drawio-diagram containing a process model on the first layer of the first page.")
|
|
|
- argparser.add_argument('--out-drawio', metavar='FILE', nargs=1, help="Output file of generated OML description of drawio-diagram. If not specified, output will be omitted.")
|
|
|
- argparser.add_argument('--out-pm', metavar='FILE', nargs=1, help="Output file of generated OML description of process model. If not specified, output will be omitted.")
|
|
|
- argparser.add_argument('--out-trace', metavar='FILE', nargs=1, help="Output file of generated OML description of traceability links. If not specified, output will be omitted.")
|
|
|
+ argparser.add_argument('--outdir', metavar='DIRECTORY', nargs=1, help="Output directory for generated OML files. If not specified, output will be printed to stdout.")
|
|
|
args = argparser.parse_args() # exits on error
|
|
|
|
|
|
-
|
|
|
import os
|
|
|
args.inputfile = os.path.abspath(args.inputfile)
|
|
|
|
|
|
# parse drawio
|
|
|
dio_asyntax = dio_parser.Parser.parse(args.inputfile)
|
|
|
|
|
|
- # parse PM
|
|
|
- layer_to_parse = dio_asyntax.pages[0].root.children[0] # 1st layer of 1st page
|
|
|
+ # for every page, parse the first layer:
|
|
|
+ triples = [(dio_page, pm_parser.parsePM(dio_page.root.children[0])) for dio_page in dio_asyntax.pages]
|
|
|
|
|
|
- pm_asyntax, traceability_links = pm_parser.parsePM(layer_to_parse)
|
|
|
+ for (dio_page, (pm_asyntax, traceability_links)) in triples:
|
|
|
+ dio_names = dio_oml_generator.assign_names(dio_page)
|
|
|
+ pm_names = pm_oml_generator.assign_names(pm_asyntax)
|
|
|
|
|
|
- import pprint
|
|
|
- print("Abstract syntax of PM:")
|
|
|
- pprint.pprint(pm_asyntax)
|
|
|
+ if args.outdir != None:
|
|
|
+ args.outdir = os.path.abspath(args.outdir[0])
|
|
|
+ dio_oml_file = args.outdir + "/" + dio_page.name + "_drawio.oml"
|
|
|
+ pm_oml_file = args.outdir + "/" + dio_page.name + "_pm.oml"
|
|
|
+ corr_oml_file = args.outdir + "/" + dio_page.name + "_corr.oml"
|
|
|
|
|
|
- dio_names = dio_oml_generator.assign_names(dio_asyntax)
|
|
|
- pm_names = pm_oml_generator.assign_names(pm_asyntax)
|
|
|
+ print("The following files will be (over)written:")
|
|
|
+ print(dio_oml_file)
|
|
|
+ print(pm_oml_file)
|
|
|
+ print(corr_oml_file)
|
|
|
+ input("Proceed? (Enter)")
|
|
|
|
|
|
- if args.out_drawio != None:
|
|
|
- with open(args.out_drawio[0], 'wt') as file:
|
|
|
+ with open(dio_oml_file, 'wt') as file:
|
|
|
+ dio_oml_generator.write_oml(
|
|
|
+ filename=args.inputfile,
|
|
|
+ drawio_page=dio_page,
|
|
|
+ names=dio_names,
|
|
|
+ ostream=file)
|
|
|
+ with open(pm_oml_file, 'wt') as file:
|
|
|
+ pm_oml_generator.write_pm_oml(
|
|
|
+ input_filename=args.inputfile,
|
|
|
+ input_page=dio_page,
|
|
|
+ pm_model=pm_asyntax,
|
|
|
+ pm_names=pm_names,
|
|
|
+ ostream=file)
|
|
|
+ with open(corr_oml_file, 'wt') as file:
|
|
|
+ pm_oml_generator.write_corr_oml(
|
|
|
+ input_filename=args.inputfile,
|
|
|
+ input_page=dio_page,
|
|
|
+ traceability_links=traceability_links,
|
|
|
+ drawio_names=dio_names,
|
|
|
+ pm_names=pm_names,
|
|
|
+ ostream=file)
|
|
|
+ else:
|
|
|
dio_oml_generator.write_oml(
|
|
|
- drawio_file=dio_asyntax,
|
|
|
+ filename=args.inputfile,
|
|
|
+ drawio_page=dio_page,
|
|
|
drawio_names=dio_names,
|
|
|
- ostream=file)
|
|
|
-
|
|
|
- if args.out_pm != None:
|
|
|
- with open(args.out_pm[0], 'wt') as file:
|
|
|
+ ostream=sys.stdout)
|
|
|
pm_oml_generator.write_pm_oml(
|
|
|
input_filename=args.inputfile,
|
|
|
pm_model=pm_asyntax,
|
|
|
pm_names=pm_names,
|
|
|
- ostream=file)
|
|
|
-
|
|
|
- if args.out_trace != None:
|
|
|
- with open(args.out_trace[0], 'wt') as file:
|
|
|
+ ostream=sys.stdout)
|
|
|
pm_oml_generator.write_corr_oml(
|
|
|
input_filename=args.inputfile,
|
|
|
traceability_links=traceability_links,
|
|
|
drawio_names=dio_names,
|
|
|
pm_names=pm_names,
|
|
|
- ostream=file)
|
|
|
+ ostream=sys.stdout)
|