In [282]:
import string
from github import Github
g = Github('$USER','$PASSWORD')
In [293]:
github_astronomy = g.legacy_search_repos('astronomy')
github_space = g.legacy_search_repos('space')
github_astro = g.legacy_search_repos('astro')
github_astrophysics = g.legacy_search_repos('astrophysics')
In [294]:
def get_repo_dict(github_instance):
output_dict = {}
for repo in github_instance:
output_dict[repo.name] = repo._rawData
output_dict[repo.name].update({'updated_at':repo.updated_at})
return output_dict
In [295]:
output_dict = get_repo_dict(g.legacy_search_repos('astrophysics'))
In [318]:
output_dict.update(get_repo_dict(g.legacy_search_repos('radio astronomy')))
In [337]:
output_dict.update(get_repo_dict(g.legacy_search_repos('cosmology')))
In [372]:
output_dict.update(get_repo_dict(g.legacy_search_repos('gamma ray')))
In [377]:
output_dict.update(get_repo_dict(g.legacy_search_repos('hubble space telescope')))
In [394]:
github_astro = g.legacy_search_repos('astro')
In [395]:
def sort_by_key(key):
return sorted(output_dict.iteritems(), key=lambda item: item[1][key], reverse=True)
In [396]:
print 'Total Repos: {}'.format(len(output_dict))
In [397]:
def print_top_ten(key):
top_ten = ['{} : {}'.format(item[1]['name'],item[1][key]) for item in sort_by_key(key)][0:10]
for item in top_ten:
print item
In [398]:
print_top_ten('size')
In [399]:
print_top_ten('forks')
In [400]:
print_top_ten('watchers')
In [401]:
print_top_ten('open_issues')
In [402]:
print_top_ten('updated_at')
In [403]:
print output_dict['astroML']
In [386]:
ARTICLES = ['', 'a', 'an', 'at', 'the', 'that', 'this']
COMMON = ['as', 'astronomy', 'astrophysics', 'cosmology', 'cosmological']
CONJUNCTIONS = ['about', 'and', 'but', 'or']
PREPOSITIONS = ['by', 'from', 'for', 'in', 'of', 'on', 'with', 'to']
PRONOUNS = ['i', 'it', 'my', 'your']
VERBS = ['have', 'is', 'using']
SKIP_WORD_LIST = ARTICLES + COMMON + CONJUNCTIONS + PREPOSITIONS + PRONOUNS + VERBS
def get_word_dict():
word_dict = {}
for line in output_dict.itervalues():
if line['description'] != None:
for word in line['description'].split():
word = word.encode('ascii','replace')
word = word.translate(None, string.punctuation)
word = word.lower()
if word not in SKIP_WORD_LIST:
if word_dict.has_key(word):
word_dict[word] += 1
else:
word_dict[word] = 1
return word_dict
def plot_tuples(tuples_to_plot):
plt.clf()
plt.grid(True)
plt.plot(range(len(tuples_to_plot)), [item[1] for item in tuples_to_plot], 'r.')
for x, item in enumerate(tuples_to_plot):
plt.text(x, item[1] + 3, item[0], rotation=70)
plt.draw()
word_dict = get_word_dict()
tuples_to_plot = [item for item in word_dict.iteritems() if item[1] > 3]
tuples_to_plot.sort(key=lambda tup: tup[1], reverse=True)
In [388]:
%pylab
In [349]:
In [ ]: