-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_github_stats.py
More file actions
82 lines (74 loc) · 2.49 KB
/
update_github_stats.py
File metadata and controls
82 lines (74 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
"""
Searches for packages on pypi with SciKit-Surgery in the name, then
gets some statistics for them.
"""
import contextlib
import os.path
from sksurgerystats.common import get_package_information, update_package_information
from sksurgerystats.from_github import get_github_stats, get_token
if __name__ == "__main__":
all_packages = os.listdir("libraries/")
packages = []
for package in all_packages:
if (
not os.path.isdir("libraries/" + package)
and not package.endswith(".txt")
and not package.startswith(".")
):
packages.append(package)
token = None
token = get_token()
package_dictionaries = [] # type: list[str]
for package in packages:
print("Updating package information for " + package)
homepage = get_package_information(package, "home_page")
if homepage is not None:
(
rep,
stars,
watchers,
forks,
contributors,
create_date,
last_update_date,
) = get_github_stats(
homepage,
token,
)
update_package_information(
package, "Created Date", create_date, overwrite=True
)
update_package_information(
package, "Last Update", last_update_date, overwrite=True
)
update_package_information(package, "GitHub Stars", stars, overwrite=True)
update_package_information(
package,
"GitHub Watchers",
watchers,
overwrite=True,
)
update_package_information(package, "GitHub Forks", forks, overwrite=True)
update_package_information(
package,
"GitHub Contributors",
contributors,
overwrite=True,
)
try:
update_package_information(
package,
"GitHub User",
rep.organization.login,
overwrite=True,
)
except AttributeError:
with contextlib.suppress(Exception):
update_package_information(
package,
"GitHub User",
rep.owner.login,
overwrite=True,
)
except:
pass