Skip to content

Commit

Permalink
Merge pull request #3 from wxy/wxy-patch-2
Browse files Browse the repository at this point in the history
合并 repo 和 analy 命令,采用可变参数来决定行为
  • Loading branch information
wxy authored Oct 9, 2018
2 parents cb7ea77 + db73f92 commit f4996f5
Showing 1 changed file with 26 additions and 30 deletions.
56 changes: 26 additions & 30 deletions grank/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,41 +47,37 @@ def checklogin():
click.echo('Your Username is %s' % result["data"]["viewer"]["login"])
pass


@main.command()
@click.argument('owner')
@click.argument('repo')
def repo(owner, repo):
"""Analyse a Github Repository"""
config = helpers.get_config()
data = crawler.fetch_repo_data(owner, repo, config)
activity.analyse_repo(owner, repo, data, config)
social.analyse_email(data,config)
social.analyse_repo(owner, repo, data, config)
helpers.generate_repository_fig(config['time']['start_time'], config['time']['end_time'], owner, repo)
helpers.generate_top_fig(config['time']['start_time'], config['time']['end_time'], int(config['rank']['top']))
pass

@main.command()
@click.argument('name')
def analy(name):
@click.argument('args', nargs=-1)
def analy(args):
"""Analyse a Github User or Organization"""
config = helpers.get_config()
if helpers.get_user_type(name) is True:
repository_array = crawler.fetch_user_data(name, config)
if len(args) == 0:
click.echo('grank analy owner [repo]')
elif len(args) == 1:
owner = args[0]
if helpers.get_user_type(owner) is True:
repository_array = crawler.fetch_user_data(owner, config)
else:
repository_array = crawler.fetch_organ_data(owner, config)
for item in repository_array["repositoryArray"]:
if os.path.exists('output/activity/' + item["owner"] + '/' + item["repository"] + ".csv"):
continue
data = crawler.fetch_repo_data(item["owner"], item["repository"], config)
activity.analyse_repo(item["owner"], item["repository"], data, config)
social.analyse_email(data,config)
social.analyse_repo(item["owner"], item["repository"], data, config)
# 生成折线图
helpers.generate_repository_fig(config['time']['start_time'], config['time']['end_time'], item['owner'], item['repository'])
else:
repository_array = crawler.fetch_organ_data(name, config)
for item in repository_array["repositoryArray"]:
if os.path.exists('output/activity/' + item["owner"] + '/' + item["repository"] + ".csv"):
continue
data = crawler.fetch_repo_data(
item["owner"], item["repository"], config)
activity.analyse_repo(item["owner"], item["repository"], data, config)
owner = args[0]
repo = args[1]
data = crawler.fetch_repo_data(owner, repo, config)
activity.analyse_repo(owner, repo, data, config)
social.analyse_email(data,config)
social.analyse_repo(item["owner"], item["repository"], data, config)
# 生成折线图
helpers.generate_repository_fig(config['time']['start_time'], config['time']['end_time'], item['owner'], item['repository'])

social.analyse_repo(owner, repo, data, config)
helpers.generate_repository_fig(config['time']['start_time'], config['time']['end_time'], owner, repo)

helpers.generate_top_fig(config['time']['start_time'], config['time']['end_time'], int(config['rank']['top']))
pass

Expand Down

0 comments on commit f4996f5

Please sign in to comment.