|
4 | 4 | from core import Layer |
5 | 5 |
|
6 | 6 | if __name__ == '__main__': |
7 | | - parser = argparse.ArgumentParser(description='Export an Att&ck layer as a svg image') |
| 7 | + parser = argparse.ArgumentParser(description='Export an Att&ck layer as a svg image or excel file') |
8 | 8 | parser.add_argument('-m', '--mode', choices=['svg', 'excel'], required=True, help='The form to export the layers in') |
9 | 9 | parser.add_argument('input', nargs='+', help='Path(s) to the file to export') |
10 | 10 | parser.add_argument('-s','--source', choices=['taxii', 'local'], default='taxii', help='What source to utilize when building the matrix') |
11 | 11 | parser.add_argument('--local', help='Path to the local resource if --source=local', default=None) |
12 | 12 | parser.add_argument('-o','--output', nargs='+', help='Path(s) to the exported svg file', required=True) |
13 | 13 | args = parser.parse_args() |
14 | | - print(args) |
15 | 14 | if len(args.output) != len(args.input): |
16 | 15 | print('Mismatched number of output filepaths to input file paths. Exiting...') |
17 | 16 |
|
18 | | - for entry in args.input: |
19 | | - print('{}/{} - Beginning processing {}'.format(args.input.index(entry) + 1, len(args.input), entry)) |
| 17 | + for i in range(0, len(args.input)): |
| 18 | + entry = args.input[i] |
| 19 | + print('{}/{} - Beginning processing {}'.format(i + 1, len(args.input), entry)) |
20 | 20 | lay = Layer() |
21 | 21 | try: |
22 | 22 | lay.from_file(entry) |
|
25 | 25 | continue |
26 | 26 | if args.mode=='excel': |
27 | 27 | exy = ToExcel(domain=lay.layer.domain, source=args.source, local=args.local) |
28 | | - exy.to_xlsx(lay, filepath=args.output[args.input.index(entry)]) |
| 28 | + exy.to_xlsx(lay, filepath=args.output[i]) |
29 | 29 | else: |
30 | 30 | svy = ToSvg(domain=lay.layer.domain, source=args.source, local=args.local) |
31 | | - svy.to_svg(lay, filepath=args.output[args.input.index(entry)]) |
32 | | - print('{}/{} - Finished processing {}'.format(args.input.index(entry) + 1, len(args.input), entry)) |
| 31 | + svy.to_svg(lay, filepath=args.output[i]) |
| 32 | + print('{}/{} - Finished processing {}'.format(i + 1, len(args.input), entry)) |
33 | 33 |
|
34 | 34 |
|
35 | 35 | else: |
|
0 commit comments