當前位置: 首頁>>代碼示例>>Python>>正文


Python StudyPerson.iter方法代碼示例

本文整理匯總了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)
開發者ID:yimsea,項目名稱:qiita,代碼行數:32,代碼來源:edit_handlers.py

示例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])
開發者ID:MarkBruns,項目名稱:qiita,代碼行數:16,代碼來源:test_study.py

示例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])
開發者ID:DarcyMyers,項目名稱:qiita,代碼行數:16,代碼來源:test_study.py

示例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)
開發者ID:ElDeveloper,項目名稱:qiita,代碼行數:24,代碼來源:study_person.py

示例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']
開發者ID:BrindhaBioinfo,項目名稱:qiita,代碼行數:26,代碼來源:edit_handlers.py


注:本文中的qiita_db.study.StudyPerson.iter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。