本文整理匯總了Python中repository.Repository.repository_name方法的典型用法代碼示例。如果您正苦於以下問題:Python Repository.repository_name方法的具體用法?Python Repository.repository_name怎麽用?Python Repository.repository_name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類repository.Repository
的用法示例。
在下文中一共展示了Repository.repository_name方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: add_endpoint
# 需要導入模塊: from repository import Repository [as 別名]
# 或者: from repository.Repository import repository_name [as 別名]
def add_endpoint(my_request):
if not my_request.pmh_url:
return None
endpoint_with_this_id = Endpoint.query.filter(Endpoint.repo_request_id==my_request.id).first()
if endpoint_with_this_id:
print u"one already matches {}".format(my_request.id)
return None
raw_endpoint = my_request.pmh_url
clean_endpoint = raw_endpoint.strip()
clean_endpoint = clean_endpoint.strip("?")
clean_endpoint = re.sub(u"\?verb=.*$", "", clean_endpoint, re.IGNORECASE)
print u"raw endpoint is {}, clean endpoint is {}".format(raw_endpoint, clean_endpoint)
matching_endpoint = Endpoint()
matching_endpoint.pmh_url = clean_endpoint
repo_matches = my_request.matching_repositories()
if repo_matches:
matching_repo = repo_matches[0]
print u"yay! for {} {} matches repository {}".format(
my_request.institution_name, my_request.repo_name, matching_repo)
else:
print u"no matching repository for {}: {}".format(
my_request.institution_name, my_request.repo_name)
matching_repo = Repository()
# overwrite stuff with request
matching_repo.institution_name = my_request.institution_name
matching_repo.repository_name = my_request.repo_name
matching_repo.home_page = my_request.repo_home_page
matching_endpoint.repo_unique_id = matching_repo.id
matching_endpoint.email = my_request.email
matching_endpoint.repo_request_id = my_request.id
matching_endpoint.ready_to_run = True
matching_endpoint.set_identify_and_initial_query()
db.session.merge(matching_endpoint)
db.session.merge(matching_repo)
print u"added {} {}".format(matching_endpoint, matching_repo)
print u"see at url http://unpaywall.org/sources/repository/{}".format(matching_endpoint.id)
safe_commit(db)
print "saved"
print "now sending email"
# get the endpoint again, so it gets with all the meta info etc
matching_endpoint = Endpoint.query.get(matching_endpoint.id)
matching_endpoint.contacted_text = "automated welcome email"
matching_endpoint.contacted = datetime.datetime.utcnow().isoformat()
safe_commit(db)
send_announcement_email(matching_endpoint)
print "email sent"
return matching_endpoint