本文整理汇总了Python中models.Author.dump方法的典型用法代码示例。如果您正苦于以下问题:Python Author.dump方法的具体用法?Python Author.dump怎么用?Python Author.dump使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Author
的用法示例。
在下文中一共展示了Author.dump方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fetch
# 需要导入模块: from models import Author [as 别名]
# 或者: from models.Author import dump [as 别名]
def fetch():
sys.stdout.write('loading')
sys.stdout.flush()
repos = Repo.load_sample()
authors = {author.login: author for author in Author.load(FILE)}
seen = 0
total = len(repos)
failures = []
last_write = datetime.datetime.now()
el = Elaborator()
for repo in repos:
seen += 1
if repo.username in authors:
logging.info("already fetched %s", repo.username)
continue
try:
gh_data = el._gh_request(
'GET',
'/users/' + repo.username
)
except:
#loop really needs to keep running
logging.exception("problem! %s", repo)
failures.append(repo)
continue
authors[repo.username] = Author(**{key: gh_data.get(key, None) for key in
['login', # "octocat"
'id', # 1
'avatar_url', # "https://github.com/images/error/octocat_happy.gif"
'gravatar_id', # "somehexcode"
'url', # "https://api.github.com/users/octocat"
'name', # "monalisa octocat"
'company', # "GitHub"
'blog', # "https://github.com/blog"
'location', # "San Francisco"
'email', # "[email protected]"
'hireable', # false
'bio', # "There once was..."
'public_repos', # 2
'public_gists', # 1
'followers', # 20
'following', # 0
'html_url', # "https://github.com/octocat"
'created_at', # "2008-01-14T04:33:35Z"
'type', # "User"
]})
logging.info("fetched %s", repo.username)
progress_bar(seen, total)
since_write = datetime.datetime.now() - last_write
if since_write > datetime.timedelta(minutes=5):
sys.stdout.write("\r(writing results)")
sys.stdout.flush()
Author.dump(authors.values(), FILE)
last_write = datetime.datetime.now()
print # from progress bar line
if failures:
print "%s failures:" % len(failures)
for f in failures:
print " %s" % f
print
print 'writing out...'
Author.dump(authors.values(), FILE)