Skip to content

Commit 1d89829

Browse files
committed
list private or archived
1 parent d53d108 commit 1d89829

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

all_repos.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ jupyter-book/mystmd.org:
162162
jupyterhub/mybinder.org-deploy:
163163
jupyterhub/mybinder.org-user-guide:
164164
voila-gallery/voila-gallery.org-deploy:
165-
ipython/ipython-website
165+
ipython/ipython-website:
166166

167167
# various tutorials
168168
jupyter/ngcm-tutorial:

tools/all_repos.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ async def _loc(results, org):
108108

109109
nursery.start_soon(_loc, results, org)
110110
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
113113

114114

115115
async def list_repos_for_org(org):
@@ -122,7 +122,9 @@ async def list_repos_for_org(org):
122122
response.raise_for_status()
123123
repos = response.json()
124124
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))
126128
if len(repos) < 100:
127129
break
128130
return reps
@@ -161,6 +163,9 @@ async def main(config_file: str = "all_repos.txt"):
161163
for item in items:
162164
if item.startswith("#") or not item.strip():
163165
continue
166+
if item.count(":") == 0:
167+
print(f"Invalid line: {item}")
168+
exit(1)
164169
github_name, pypi_name = item.split(":", maxsplit=1)
165170
# pypi name may be empty for repo with no packages.
166171
# and one repo can create multiple pypi packages.
@@ -225,12 +230,12 @@ async def _loc(targets, package_url):
225230
)
226231

227232
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):
229234
org_repo = f"{org}/{repo}"
230235
if org_repo in known_org_rep:
231236
continue
232237

233-
todo.append((org, repo))
238+
todo.append((org, repo, archived, private))
234239

235240
print()
236241
print(
@@ -242,9 +247,9 @@ async def _loc(targets, package_url):
242247
async with trio.open_nursery() as nursery:
243248
targets = []
244249
semaphore = trio.Semaphore(15) # Throttle to 10 concurrent requests
245-
for org, repo in todo:
250+
for org, repo, archived, private in todo:
246251

247-
async def _loc(targets, org, repo):
252+
async def _loc(targets, org, repo, archived, private):
248253
async with semaphore: # Wait for semaphore to be available
249254
# maintainers = await get_package_maintainers(repo)
250255
maintainers = []
@@ -256,20 +261,25 @@ async def _loc(targets, org, repo):
256261
await asks.get(f"https://pypi.org/pypi/{repo}/json")
257262
).status_code,
258263
maintainers,
264+
archived,
265+
private,
259266
)
260267
)
261268

262-
nursery.start_soon(_loc, targets, org, repo)
269+
nursery.start_soon(_loc, targets, org, repo, archived, private)
263270

264271
corg = ""
265-
for org, repo, status, maintainers in sorted(targets):
272+
for org, repo, status, maintainers, archived, private in sorted(targets):
266273
if org != corg:
267274
print()
268275
corg = org
269276
if status == 200:
270277
print(
271-
f"{org}/{repo}".ljust(30),
278+
f"{org}/{repo}".ljust(40),
272279
f" : https://pypi.org/project/{repo}",
280+
f"[yellow]{'(archived)' if archived else ''}[/yellow] [red]{'(private)' if private else ''}[/red]".ljust(
281+
20
282+
),
273283
)
274284

275285
# for maintainer in maintainers:
@@ -284,12 +294,15 @@ async def _loc(targets, org, repo):
284294
"{pypi_url}` or `{org}/{repo}: <blank>` to config file."
285295
)
286296
corg = ""
287-
for org, repo, status, maintainers in sorted(targets):
297+
for org, repo, status, maintainers, archived, private in sorted(targets):
288298
if org != corg:
289299
print()
290300
corg = org
291301
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+
)
293306

294307

295308
trio.run(main)

0 commit comments

Comments
 (0)