Passed
Push — master ( 42467a...9d011f )
by Matěj
03:19 queued 11s
created

utils.regexify_banner   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 33
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0
wmc 5

2 Functions

Rating   Name   Duplication   Size   Complexity  
A parse_args() 0 6 1
A main() 0 15 4
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