本文整理汇总了Python中qiita_db.study.StudyPerson.iter方法的典型用法代码示例。如果您正苦于以下问题:Python StudyPerson.iter方法的具体用法?Python StudyPerson.iter怎么用?Python StudyPerson.iter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qiita_db.study.StudyPerson
的用法示例。
在下文中一共展示了StudyPerson.iter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from qiita_db.study import StudyPerson [as 别名]
# 或者: from qiita_db.study.StudyPerson import iter [as 别名]
def __init__(self, study=None, **kwargs):
super(StudyEditorForm, self).__init__(**kwargs)
# Get people from the study_person table to populate the PI and
# lab_person fields
choices = [(sp.id, u"%s, %s"
% (sp.name.decode('utf-8'),
sp.affiliation.decode('utf-8')))
for sp in StudyPerson.iter()]
choices.insert(0, ('', ''))
self.lab_person.choices = choices
self.principal_investigator.choices = choices
# If a study is provided, put its values in the form
if study:
study_info = study.info
self.study_title.data = study.title.decode('utf-8')
self.study_alias.data = study_info['study_alias'].decode('utf-8')
self.publication_doi.data = ",".join(
[doi for doi, _ in study.publications]).decode('utf-8')
self.study_abstract.data = study_info[
'study_abstract'].decode('utf-8')
self.study_description.data = study_info[
'study_description'].decode('utf-8')
self.principal_investigator.data = study_info[
'principal_investigator'].id
self.lab_person.data = (study_info['lab_person'].id
if study_info['lab_person'] else None)
示例2: test_iter
# 需要导入模块: from qiita_db.study import StudyPerson [as 别名]
# 或者: from qiita_db.study.StudyPerson import iter [as 别名]
def test_iter(self):
"""Make sure that each and every StudyPerson is retrieved"""
expected = [
('LabDude', '[email protected]', 'knight lab', '123 lab street',
'121-222-3333'),
('empDude', '[email protected]', 'broad', None, '444-222-3333'),
('PIDude', '[email protected]', 'Wash U', '123 PI street', None)]
for i, person in enumerate(StudyPerson.iter()):
self.assertEqual(person.id, i+1)
self.assertEqual(person.name, expected[i][0])
self.assertEqual(person.email, expected[i][1])
self.assertEqual(person.affiliation, expected[i][2])
self.assertEqual(person.address, expected[i][3])
self.assertEqual(person.phone, expected[i][4])
示例3: test_iter
# 需要导入模块: from qiita_db.study import StudyPerson [as 别名]
# 或者: from qiita_db.study.StudyPerson import iter [as 别名]
def test_iter(self):
"""Make sure that each and every StudyPerson is retrieved"""
expected = [
("LabDude", "[email protected]", "knight lab", "123 lab street", "121-222-3333"),
("empDude", "[email protected]", "broad", None, "444-222-3333"),
("PIDude", "[email protected]", "Wash U", "123 PI street", None),
]
for i, person in enumerate(StudyPerson.iter()):
self.assertTrue(person.id == i + 1)
self.assertTrue(person.name == expected[i][0])
self.assertTrue(person.email == expected[i][1])
self.assertTrue(person.affiliation == expected[i][2])
self.assertTrue(person.address == expected[i][3])
self.assertTrue(person.phone == expected[i][4])
示例4: get
# 需要导入模块: from qiita_db.study import StudyPerson [as 别名]
# 或者: from qiita_db.study.StudyPerson import iter [as 别名]
def get(self, *args, **kwargs):
name = self.get_argument('name', None)
affiliation = self.get_argument('affiliation', None)
if name is None and affiliation is None:
# Retrieve the list of all the StudyPerson
sp = [{'name': p.name, 'affiliation': p.affiliation}
for p in StudyPerson.iter()]
self.write(json_encode(sp))
self.finish()
elif name is not None and affiliation is not None:
try:
p = StudyPerson.from_name_and_affiliation(name, affiliation)
except QiitaDBLookupError:
self.fail('Person not found', 404)
return
self.write({'address': p.address, 'phone': p.phone,
'email': p.email, 'id': p.id})
self.finish()
else:
arg_name = 'name' if name is None else 'affiliation'
raise MissingArgumentError(arg_name)
示例5: __init__
# 需要导入模块: from qiita_db.study import StudyPerson [as 别名]
# 或者: from qiita_db.study.StudyPerson import iter [as 别名]
def __init__(self, study=None, **kwargs):
super(StudyEditorForm, self).__init__(**kwargs)
# Get people from the study_person table to populate the PI and
# lab_person fields
choices = [(sp.id, "%s, %s" % (sp.name, sp.affiliation))
for sp in StudyPerson.iter()]
choices.insert(0, ('', ''))
self.lab_person.choices = choices
self.principal_investigator.choices = choices
# If a study is provided, put its values in the form
if study:
study_info = study.info
self.study_title.data = study.title
self.study_alias.data = study_info['study_alias']
self.pubmed_id.data = ",".join(study.pmids)
self.study_abstract.data = study_info['study_abstract']
self.study_description.data = study_info['study_description']
self.principal_investigator.data = study_info[
'principal_investigator_id']
self.lab_person.data = study_info['lab_person_id']