-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.py
More file actions
59 lines (50 loc) · 1.59 KB
/
main.py
File metadata and controls
59 lines (50 loc) · 1.59 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
import json
import base64
import argparse
import os
from codejson_index_generator import IndexGenerator
def main():
parser = argparse.ArgumentParser(
description = "Create an index of code.json files within agency organizations for code.gov compliance.",
epilog = "Examples:"
" python script.py --agency CMS --orgs 'org1,org2' --output code.json --OR-- "
" python script.py --agency TTS --orgs 'GSA,USDC' --version 2.0.0"
)
parser.add_argument(
"--agency",
required = True,
help = "Agency name for code.json index creation"
)
parser.add_argument(
"--orgs",
required = True,
help = "Comma-separated list of GitHub organizations in your agency"
)
parser.add_argument(
"--output",
default = "code.json",
help = "Output filename (default: code.json)"
)
parser.add_argument(
"--version",
default = "1.0.0",
help = "Code.json file version (e.g., 1.0.0, 2.1.0)"
)
args = parser.parse_args()
github_key = os.getenv("GITHUB_KEY")
try:
indexGen = IndexGenerator(
agency = args.agency,
version = args.version,
token = github_key
)
for org in args.orgs.split(","):
org = org.strip()
indexGen.process_github_org_files(org)
indexGen.save_index(args.output)
print(f"\nIndexing complete. Results saved to {args.output}")
except Exception as e:
print(f"Error: {e}")
return
if __name__ == "__main__":
main()