@@ -23,15 +23,15 @@ def __init__(self, agency: str, verison: str, token: Optional[str] = None,):
23
23
def get_code_json (self , repo : Repository ) -> Optional [Dict ]:
24
24
try :
25
25
content = repo .get_contents ("code.json" , ref = "main" )
26
- except GithubException :
27
- print ("Problem with GitHub " )
26
+ except GithubException as e :
27
+ print (f"GitHub Error: { e . data . get ( 'message' , 'No message available' ) } " )
28
28
return None
29
29
30
30
try :
31
31
decoded_content = base64 .b64decode (content .content )
32
32
return json .loads (decoded_content )
33
- except (json .JSONDecodeError , ValueError ):
34
- print (f"Invalid JSON in { repo . full_name } " )
33
+ except (json .JSONDecodeError , ValueError ) as e :
34
+ print (f"JSON Error: { str ( e ) } " )
35
35
return None
36
36
37
37
def update_index (self , index : Dict , code_json : Dict , org_name : str , repo_name : str ) -> None :
@@ -57,10 +57,10 @@ def process_organization(self, org_name: str) -> None:
57
57
58
58
code_json = self .get_code_json (repo )
59
59
if code_json :
60
- print (f"Found code.json in { repo .name } " )
60
+ print (f"✅ Found code.json in { repo .name } " )
61
61
self .update_index (self .index , code_json , org_name , repo .name )
62
62
else :
63
- print (f"No code.json found in { repo .name } " )
63
+ print (f"❌ No code.json found in { repo .name } " )
64
64
65
65
except GithubException as e :
66
66
print (f"Error processing organization { org_name } : { str (e )} " )
@@ -75,9 +75,9 @@ def save_index(self, output_path: str) -> None:
75
75
def main ():
76
76
parser = argparse .ArgumentParser (
77
77
description = "Create an index of code.json files within agency organizations for code.gov compliance." ,
78
- epilog = "Examples:\n "
79
- " python script.py --agency DOE --orgs 'org1,org2' --output agency_code .json\n "
80
- " python script.py --agency NASA --orgs 'nasa,nasa-gov ' --version 2.0.0"
78
+ epilog = "Examples:"
79
+ " python script.py --agency CMS --orgs 'org1,org2' --output code .json --OR-- "
80
+ " python script.py --agency TTS --orgs 'GSA,USDC ' --version 2.0.0"
81
81
)
82
82
83
83
parser .add_argument (
0 commit comments