Created
September 1, 2022 14:00
-
-
Save AbhimanyuAryan/0b4bad79723a0e5c8645b8d1fbf39b22 to your computer and use it in GitHub Desktop.
Counting stars for Julia packages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using CSV | |
using GitHub | |
using Pkg | |
using ProgressMeter | |
using TOML | |
myauth = GitHub.authenticate(ENV["GITHUB_AUTH"]) | |
general = first(reg for reg in Pkg.Registry.reachable_registries() if reg.name == "General") | |
package_url = Dict{String,String}() | |
@showprogress for (toml_name, toml_file) in pairs(general.in_memory_registry) | |
if endswith(toml_name, "Package.toml") | |
package_info = TOML.parse(toml_file) | |
package_url[package_info["name"]] = package_info["repo"] | |
end | |
end | |
package_stars = Dict{String,Int}() | |
@showprogress for (name, url) in pairs(package_url) | |
trimmed_url = replace(url, "https://github.com/" => "", r".git$" => "") | |
try | |
package_stars[name] = length(stargazers(trimmed_url, auth=myauth)[1]) | |
catch e | |
@info "Repo not retrieved" trimmed_url | |
end | |
end | |
CSV.write("stars.csv", package_stars) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment