-
Notifications
You must be signed in to change notification settings - Fork 431
/
main.py
60 lines (45 loc) · 1.71 KB
/
main.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
import numpy as np
from github import Github
from terminaltables import AsciiTable
from terminaltables import GithubFlavoredMarkdownTable
import pickle
import codecs
# Insert you username and password
g = Github("**", "***")
# Settings
number_of_reps = 100
names_of_props = ["Id", "Name", "Description", "Language", "Stars", "Forks"]
github_server_link = "https://github.com/"
last_tables_file_name = 'last_table_data.pickle'
md_file_name = 'readme.md'
# Main query
seach_query = g.search_repositories("deep-learning", sort="stars", order="desc")
results = []
for index, rep in enumerate(seach_query):
# print(rep.url) # Everything are here as json file (You can use it instead of the API)
rep_prop = [index+1]
link = github_server_link + rep.full_name
rep_prop.append("[{}]({})".format(rep.name, link))
rep_prop.append(rep.description)
rep_prop.append(rep.language)
rep_prop.append(rep.stargazers_count)
rep_prop.append(rep.forks)
results.append(rep_prop)
if(index > number_of_reps-2):
break
# Creating the table
table_data = [["" for x in range(len(names_of_props))] for y in range(number_of_reps + 1)]
for i in range(len(names_of_props)):
table_data[0][i] = names_of_props[i]
for i in range(number_of_reps):
for j in range(len(names_of_props)):
table_data[i+1][j] = results[i][j]
# Saving Table data (For further analysis)
with open(last_tables_file_name, 'wb') as handle:
pickle.dump(table_data, handle, protocol=pickle.HIGHEST_PROTOCOL)
# Generating the ascii table
table = GithubFlavoredMarkdownTable(table_data)
table_str = table.table
# Wrting the md file
with codecs.open(md_file_name, "w", "utf-8") as f:
f.write(table_str)