-
Notifications
You must be signed in to change notification settings - Fork 1
/
update_pypi_stats.py
60 lines (44 loc) · 1.95 KB
/
update_pypi_stats.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
"""
Searches for packages on pypi with SciKit-Surgery in the name, then
gets some statistics for them
"""
import os.path
import urllib.request
import subprocess
import json
import re
from datetime import datetime
import sksurgerystats.from_pypi as skspypi
from sksurgerystats.from_github import get_github_stats
from sksurgerystats.common import add_packages, update_package_information, \
get_package_information, get_list_of_packages
if __name__ == '__main__':
all_packages = os.listdir('libraries/')
packages = get_list_of_packages(all_packages)
package_dictionaries = []
for package in packages:
package_dictionaries.append(skspypi.get_json_from_pypi(package))
for dictionary in package_dictionaries:
package_name = dictionary.get('info').get('name')
number_of_releases, first_release_date, last_release_date,\
last_release_name = \
skspypi.get_release_information(dictionary)
update_package_information(package_name, 'Number of Releases',
number_of_releases,
overwrite = True)
update_package_information(package_name, 'First Release Date',
first_release_date,
overwrite = True)
update_package_information(package_name, 'Last Release Date',
last_release_date,
overwrite = True)
update_package_information(package_name, 'Last Release Name',
last_release_name,
overwrite = True)
homepage = get_package_information(package_name, 'home_page')
pypi_homepage = dictionary.get('info').get('home_page', None)
if pypi_homepage is not None and pypi_homepage != "":
homepage = pypi_homepage
if homepage is not None:
update_package_information(package_name, 'home_page',
homepage, overwrite = True)