forked from mozilla/nss-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnss-code-review.py
More file actions
executable file
·62 lines (50 loc) · 1.83 KB
/
nss-code-review.py
File metadata and controls
executable file
·62 lines (50 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python3
from whaaaaat import prompt
import yaml
import pyperclip
import io, os
__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
resultData = {}
checklistData = {}
with open(os.path.join(__location__, "nss-code-review-checklist.yaml"), "r") as inFile:
checklistData = yaml.load(inFile, Loader=yaml.BaseLoader)
print("h for help. y=pass, s=skip, n=fail\n\n")
for segment in checklistData:
for heading in segment:
print("## {} ##".format(heading))
resultData[heading] = {}
for rule in segment[heading]:
answers = prompt(
[
{
"type": "expand",
"name": "checklist_item",
"message": rule,
"default": "s",
"choices": [
{"name": "Pass", "key": "y"},
{"name": "N/A", "key": "s"},
{"name": "Fail", "key": "n"},
],
},
]
)
resultData[heading][rule] = answers["checklist_item"]
with io.StringIO() as buf:
for heading in resultData:
print("**{}**".format(heading), file=buf)
for rule in resultData[heading]:
result = resultData[heading][rule]
if result == "Pass":
print("✅ " + rule, file=buf)
elif result == "N/A":
print("⏭ " + rule, file=buf)
else:
print("❌ " + rule, file=buf)
print("", file=buf)
print("", file=buf)
print("[[ https://github.com/mozilla/nss-tools | nss-code-review.py ]]", file=buf)
print("\n\n")
print(buf.getvalue())
pyperclip.copy(buf.getvalue())
print("(Copied to clipboard)")