@@ -108,8 +108,8 @@ async def _loc(results, org):
108
108
109
109
nursery .start_soon (_loc , results , org )
110
110
for org_repos in results :
111
- for org , repo in org_repos :
112
- yield org , repo
111
+ for org , repo , archived , private in org_repos :
112
+ yield org , repo , archived , private
113
113
114
114
115
115
async def list_repos_for_org (org ):
@@ -122,7 +122,9 @@ async def list_repos_for_org(org):
122
122
response .raise_for_status ()
123
123
repos = response .json ()
124
124
for repo in repos :
125
- reps .append ((org , repo ["name" ]))
125
+ archived = repo .get ("archived" , None )
126
+ private = repo .get ("private" , None )
127
+ reps .append ((org , repo ["name" ], archived , private ))
126
128
if len (repos ) < 100 :
127
129
break
128
130
return reps
@@ -161,6 +163,9 @@ async def main(config_file: str = "all_repos.txt"):
161
163
for item in items :
162
164
if item .startswith ("#" ) or not item .strip ():
163
165
continue
166
+ if item .count (":" ) == 0 :
167
+ print (f"Invalid line: { item } " )
168
+ exit (1 )
164
169
github_name , pypi_name = item .split (":" , maxsplit = 1 )
165
170
# pypi name may be empty for repo with no packages.
166
171
# and one repo can create multiple pypi packages.
@@ -225,12 +230,12 @@ async def _loc(targets, package_url):
225
230
)
226
231
227
232
known_org_rep = {k for k , v in known_mapping }
228
- async for org , repo in list_github_repos (default_orgs ):
233
+ async for org , repo , archived , private in list_github_repos (default_orgs ):
229
234
org_repo = f"{ org } /{ repo } "
230
235
if org_repo in known_org_rep :
231
236
continue
232
237
233
- todo .append ((org , repo ))
238
+ todo .append ((org , repo , archived , private ))
234
239
235
240
print ()
236
241
print (
@@ -242,9 +247,9 @@ async def _loc(targets, package_url):
242
247
async with trio .open_nursery () as nursery :
243
248
targets = []
244
249
semaphore = trio .Semaphore (15 ) # Throttle to 10 concurrent requests
245
- for org , repo in todo :
250
+ for org , repo , archived , private in todo :
246
251
247
- async def _loc (targets , org , repo ):
252
+ async def _loc (targets , org , repo , archived , private ):
248
253
async with semaphore : # Wait for semaphore to be available
249
254
# maintainers = await get_package_maintainers(repo)
250
255
maintainers = []
@@ -256,20 +261,25 @@ async def _loc(targets, org, repo):
256
261
await asks .get (f"https://pypi.org/pypi/{ repo } /json" )
257
262
).status_code ,
258
263
maintainers ,
264
+ archived ,
265
+ private ,
259
266
)
260
267
)
261
268
262
- nursery .start_soon (_loc , targets , org , repo )
269
+ nursery .start_soon (_loc , targets , org , repo , archived , private )
263
270
264
271
corg = ""
265
- for org , repo , status , maintainers in sorted (targets ):
272
+ for org , repo , status , maintainers , archived , private in sorted (targets ):
266
273
if org != corg :
267
274
print ()
268
275
corg = org
269
276
if status == 200 :
270
277
print (
271
- f"{ org } /{ repo } " .ljust (30 ),
278
+ f"{ org } /{ repo } " .ljust (40 ),
272
279
f" : https://pypi.org/project/{ repo } " ,
280
+ f"[yellow]{ '(archived)' if archived else '' } [/yellow] [red]{ '(private)' if private else '' } [/red]" .ljust (
281
+ 20
282
+ ),
273
283
)
274
284
275
285
# for maintainer in maintainers:
@@ -284,12 +294,15 @@ async def _loc(targets, org, repo):
284
294
"{pypi_url}` or `{org}/{repo}: <blank>` to config file."
285
295
)
286
296
corg = ""
287
- for org , repo , status , maintainers in sorted (targets ):
297
+ for org , repo , status , maintainers , archived , private in sorted (targets ):
288
298
if org != corg :
289
299
print ()
290
300
corg = org
291
301
if status != 200 :
292
- print (f"https://github.com/{ org } /{ repo } " )
302
+ print (
303
+ f"https://github.com/{ org } /{ repo } " .ljust (30 ),
304
+ f"[yellow]{ '(archived)' if archived else '' } [/yellow] [red]{ '(private)' if private else '' } [/red]" ,
305
+ )
293
306
294
307
295
308
trio .run (main )
0 commit comments