@@ -29,7 +29,7 @@ def status_message(message: str) -> None:
2929def load_schema () -> Dict [str , Any ]:
3030 """Load the JSON schema for validation"""
3131 try :
32- with open (SCHEMA_PATH , 'r' ) as f :
32+ with open (SCHEMA_PATH , "r" ) as f :
3333 return json .load (f )
3434 except json .JSONDecodeError as e :
3535 error_exit (f"Invalid JSON in schema file: { e } " )
@@ -42,7 +42,7 @@ def load_schema() -> Dict[str, Any]:
4242def load_manifest (manifest_path : Path ) -> Dict [str , Any ]:
4343 """Load and parse a manifest file with schema validation"""
4444 try :
45- with open (manifest_path , 'r' ) as f :
45+ with open (manifest_path , "r" ) as f :
4646 manifest = json .load (f )
4747
4848 # Get the schema
@@ -70,7 +70,7 @@ def find_server_manifests(servers_dir: Path) -> List[Path]:
7070 error_exit (f"Servers directory not found: { servers_dir } " )
7171
7272 server_files = []
73- for file_path in servers_dir .glob (' *.json' ):
73+ for file_path in servers_dir .glob (" *.json" ):
7474 if file_path .is_file ():
7575 server_files .append (file_path )
7676
@@ -86,39 +86,39 @@ def extract_github_repos(server_manifests: List[Path]) -> Dict[str, str]:
8686 manifest = load_manifest (manifest_path )
8787
8888 # Check if manifest has GitHub repository URL
89- if ' repository' in manifest :
90- repo_url = manifest [' repository' ]
89+ if " repository" in manifest :
90+ repo_url = manifest [" repository" ]
9191
9292 # Handle both string and dictionary repository formats
93- if isinstance (repo_url , str ) and repo_url .startswith (' https://github.com/' ):
93+ if isinstance (repo_url , str ) and repo_url .startswith (" https://github.com/" ):
9494 github_repos [server_name ] = repo_url
95- elif (isinstance (repo_url , dict ) and ' url' in repo_url and
96- isinstance (repo_url [' url' ], str ) and
97- repo_url [' url' ].startswith (' https://github.com/' )):
98- github_repos [server_name ] = repo_url [' url' ]
95+ elif (isinstance (repo_url , dict ) and " url" in repo_url and
96+ isinstance (repo_url [" url" ], str ) and
97+ repo_url [" url" ].startswith (" https://github.com/" )):
98+ github_repos [server_name ] = repo_url [" url" ]
9999
100100 return github_repos
101101
102102
103103def fetch_github_stars_batch (repo_urls : List [str ]) -> Dict [str , int ]:
104104 """Fetch GitHub stars for multiple repositories using GraphQL API"""
105105 # Get GitHub token from environment variable
106- github_token = os .environ .get (' GITHUB_TOKEN' )
106+ github_token = os .environ .get (" GITHUB_TOKEN" )
107107
108108 # Prepare headers
109109 headers = {
110- ' Content-Type' : ' application/json' ,
110+ " Content-Type" : " application/json" ,
111111 }
112112
113113 # Add authorization if token is provided
114114 if github_token :
115- headers [' Authorization' ] = f"Bearer { github_token } "
115+ headers [" Authorization" ] = f"Bearer { github_token } "
116116
117117 # Extract owner and repo from URLs
118118 repos = []
119119 for url in repo_urls :
120- if url .startswith (' https://github.com/' ):
121- parts = url .replace (' https://github.com/' , '' ).split ('/' )
120+ if url .startswith (" https://github.com/" ):
121+ parts = url .replace (" https://github.com/" , "" ).split ("/" )
122122 if len (parts ) >= 2 :
123123 owner , repo = parts [0 ], parts [1 ]
124124 repos .append ((owner , repo ))
@@ -147,9 +147,9 @@ def fetch_github_stars_batch(repo_urls: List[str]) -> Dict[str, int]:
147147 variables [f"repo{ i } " ] = repo
148148
149149 # Join the query parts with proper line length
150- variable_defs = ', ' .join (f' $owner{ i } : String!, $repo{ i } : String!'
150+ variable_defs = ", " .join (f" $owner{ i } : String!, $repo{ i } : String!"
151151 for i in range (len (batch )))
152- query_body = ' ' .join (query_parts )
152+ query_body = " " .join (query_parts )
153153
154154 query = f"""query ({ variable_defs } ) {{
155155 { query_body }
@@ -160,7 +160,7 @@ def fetch_github_stars_batch(repo_urls: List[str]) -> Dict[str, int]:
160160 response = requests .post (
161161 GITHUB_API_URL ,
162162 headers = headers ,
163- json = {' query' : query , ' variables' : variables }
163+ json = {" query" : query , " variables" : variables }
164164 )
165165
166166 # Check for errors
@@ -179,20 +179,20 @@ def fetch_github_stars_batch(repo_urls: List[str]) -> Dict[str, int]:
179179 data = response .json ()
180180
181181 # Check for GraphQL errors
182- if ' errors' in data :
182+ if " errors" in data :
183183 print (f"⚠️ GraphQL errors: { data ['errors' ]} " )
184184 continue
185185
186186 # Extract star counts
187187 for i , (owner , repo ) in enumerate (batch ):
188188 repo_key = f"repo{ i } "
189- if repo_key in data [' data' ] and data [' data' ][repo_key ]:
190- url = data [' data' ][repo_key ][' url' ]
191- star_count = data [' data' ][repo_key ][' stargazerCount' ]
189+ if repo_key in data [" data" ] and data [" data" ][repo_key ]:
190+ url = data [" data" ][repo_key ][" url" ]
191+ star_count = data [" data" ][repo_key ][" stargazerCount" ]
192192 stars [url ] = star_count
193- if url .startswith (' https://github.com/' ):
193+ if url .startswith (" https://github.com/" ):
194194 returned_parts = url .replace (
195- ' https://github.com/' , '' ).split ('/' )
195+ " https://github.com/" , "" ).split ("/" )
196196 if len (returned_parts ) >= 2 :
197197 returned_owner , returned_repo = returned_parts [0 ], returned_parts [1 ]
198198 if owner != returned_owner :
@@ -243,13 +243,13 @@ def generate_servers_json(server_manifests: List[Path], output_path: Path) -> Di
243243
244244 # Use the entire manifest as is, preserving all fields
245245 # Ensure the name field at minimum is present
246- if ' name' not in manifest :
247- manifest [' name' ] = server_name
246+ if " name" not in manifest :
247+ manifest [" name" ] = server_name
248248
249249 servers_data [server_name ] = manifest
250250
251251 # Write servers.json
252- with open (output_path , 'w' ) as f :
252+ with open (output_path , "w" ) as f :
253253 json .dump (servers_data , f , indent = 2 )
254254
255255 return servers_data
@@ -260,7 +260,7 @@ def generate_stars_json(stars: Dict[str, int], output_path: Path) -> None:
260260 status_message ("Generating stars.json..." )
261261
262262 # Write stars.json
263- with open (output_path , 'w' ) as f :
263+ with open (output_path , "w" ) as f :
264264 json .dump (stars , f , indent = 2 )
265265
266266
0 commit comments