Total Complexity | 5 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | #!/usr/bin/env python |
||
2 | import argparse |
||
3 | import ssg.utils |
||
4 | |||
5 | |||
6 | def parse_args(): |
||
7 | p = argparse.ArgumentParser() |
||
8 | p.add_argument("--output", help="Path to output regexified banner") |
||
9 | p.add_argument("input", help="Path to file with banner to regexify") |
||
10 | |||
11 | return p.parse_args() |
||
12 | |||
13 | |||
14 | def main(): |
||
15 | |||
16 | args = parse_args() |
||
17 | with open(args.input, "r") as file_in: |
||
18 | # rstrip is used to remove newline at the end of file |
||
19 | banner_text = file_in.read().rstrip() |
||
20 | |||
21 | banner_regex = ssg.utils.banner_regexify(banner_text) |
||
22 | banner_regex = ssg.utils.banner_anchor_wrap(banner_regex) |
||
23 | |||
24 | if args.output: |
||
25 | with open(args.output, "w") as file_out: |
||
26 | file_out.write(banner_regex) |
||
27 | else: |
||
28 | print(banner_regex) |
||
29 | |||
30 | |||
31 | if __name__ == "__main__": |
||
32 | main() |
||
33 |