forked from fortran-lang/webpage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fortran_package.py
130 lines (111 loc) · 3.79 KB
/
fortran_package.py
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import yaml
from pathlib import Path
from collections import Counter
import json
import requests
root = Path(__file__).parent
with open(root / "data" / "package_index.yml", "r") as f:
fortran_index = yaml.safe_load(f)
with open(root / "data" / "learning.yml", "r") as f:
conf = yaml.safe_load(f)
fortran_index_tags = []
fortran_index_tags_50 = []
fortran_index_categories = []
fortran_index_libraries = []
fortran_index_data_types = []
fortran_index_strings = []
fortran_index_programming = []
fortran_index_graphics = []
fortran_index_interfaces = []
fortran_index_examples = []
fortran_index_scientific = []
fortran_index_io = []
fortran_index_numerical = []
for i in fortran_index:
try:
for j in str(i["tags"]).split():
fortran_index_tags.append(j)
except KeyError:
pass
if "libraries" in i["categories"].split():
fortran_index_libraries.append(i)
if "data-types" in i["categories"].split():
fortran_index_data_types.append(i)
if "strings" in i["categories"].split():
fortran_index_strings.append(i)
if "programming" in i["categories"].split():
fortran_index_programming.append(i)
if "graphics" in i["categories"].split():
fortran_index_graphics.append(i)
if "interfaces" in i["categories"].split():
fortran_index_interfaces.append(i)
if "examples" in i["categories"].split():
fortran_index_examples.append(i)
if "scientific" in i["categories"].split():
fortran_index_scientific.append(i)
if "io" in i["categories"].split():
fortran_index_io.append(i)
if "numerical" in i["categories"].split():
fortran_index_numerical.append(i)
fortran_tags = {"fortran_tags": "tags"}
fortran_index_tags = Counter(fortran_index_tags)
a = sorted(fortran_index_tags.items(), key=lambda x: x[1], reverse=True)
for i in a:
if i[0] == "None":
a.remove(i)
for k in range(50):
fortran_index_tags_50.append(a[k][0])
for i in fortran_index:
for j in i["categories"].split():
fortran_index_categories.append(j)
fortran_index_categories = list(set(fortran_index_categories))
fortran_tags["numerical"] = fortran_index_numerical
fortran_tags["io"] = fortran_index_io
fortran_tags["scientific"] = fortran_index_scientific
fortran_tags["examples"] = fortran_index_examples
fortran_tags["interfaces"] = fortran_index_interfaces
fortran_tags["graphics"] = fortran_index_graphics
fortran_tags["programming"] = fortran_index_programming
fortran_tags["strings"] = fortran_index_strings
fortran_tags["data_types"] = fortran_index_data_types
fortran_tags["libraries"] = fortran_index_libraries
fortran_tags["tags"] = fortran_index_tags_50
conf["reference_books"] = conf["reference-books"]
conf["reference_courses"] = conf["reference-courses"]
conf["reference_links"] = conf["reference-links"]
with open(root / "_data" / "fortran_package.json", "w") as f:
json.dump(fortran_tags, f)
with open(root / "_data" / "fortran_learn.json", "w") as f:
json.dump(conf, f)
fortran_monthly = []
fortran_commits = []
fpm_monthly = []
fpm_commits = []
stdlib_monthly = []
stdlib_commits = []
contributor = []
contributor_repo = {
"repo": "fortran-lang",
}
def contributors(repo):
info = requests.get(
f"https://api.github.com/repos/{repo}/contributors").text
d = json.loads(info)
if "message" in d:
raise Exception(d["message"])
for i in d:
contributor.append(i["login"])
graphs = [
"fortran-lang/fortran-lang.org",
"fortran-lang/webpage",
"fortran-lang/fpm",
"fortran-lang/stdlib",
"j3-fortran/fortran_proposals",
]
for i in graphs:
contributors(i)
contributor = list(set(contributor))
contributor.sort()
contributor_repo["contributor"] = contributor
with open(root / "_data" / "contributor.json", "w") as f:
json.dump(contributor_repo, f)