当前位置: 首页>>代码示例>>Python>>正文


Python Place.gramps_id方法代码示例

本文整理汇总了Python中gramps.gen.lib.Place.gramps_id方法的典型用法代码示例。如果您正苦于以下问题:Python Place.gramps_id方法的具体用法?Python Place.gramps_id怎么用?Python Place.gramps_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gramps.gen.lib.Place的用法示例。


在下文中一共展示了Place.gramps_id方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_editreference

# 需要导入模块: from gramps.gen.lib import Place [as 别名]
# 或者: from gramps.gen.lib.Place import gramps_id [as 别名]
 def test_editreference(self):
     dbstate = DbState()
     dbstate.db = self.db
     source = Place() 
     source.gramps_id = "P0001"
     self.db.place_map[source.handle] = source
     editor = MockEditReference(dbstate, uistate=None, track=[], 
                                source=source, source_ref=None, update=None)
     with patch('gramps.gui.editors.editreference.ErrorDialog') as MockED:
         editor.check_for_duplicate_id("Place")
         self.assertTrue(MockED.called)
开发者ID:bastienjacquet,项目名称:gramps,代码行数:13,代码来源:test_editreference.py

示例2: test_editreference

# 需要导入模块: from gramps.gen.lib import Place [as 别名]
# 或者: from gramps.gen.lib.Place import gramps_id [as 别名]
 def test_editreference(self):
     dbstate = DbState()
     db = make_database("bsddb")
     path = "/tmp/edit_ref_test"
     try:
         os.mkdir(path)
     except:
         pass
     db.load(path)
     dbstate.change_database(db)
     source = Place()
     source.gramps_id = "P0001"
     dbstate.db.place_map[source.handle] = source.serialize()
     editor = MockEditReference(dbstate, uistate=None, track=[],
                                source=source, source_ref=None, update=None)
     with patch('gramps.gui.editors.editreference.ErrorDialog') as MockED:
         editor.check_for_duplicate_id("Place")
         self.assertTrue(MockED.called)
开发者ID:SNoiraud,项目名称:gramps,代码行数:20,代码来源:editreference_test.py

示例3: __get_place

# 需要导入模块: from gramps.gen.lib import Place [as 别名]
# 或者: from gramps.gen.lib.Place import gramps_id [as 别名]
    def __get_place(self, gov_id, type_dic, preferred_lang):
        gov_url = 'http://gov.genealogy.net/semanticWeb/about/' + quote(gov_id)

        response = urlopen(gov_url)
        data = response.read()

        dom = parseString(data)
        top = dom.getElementsByTagName('gov:GovObject')

        place = Place()
        place.gramps_id = gov_id
        if not len(top) :
            return place, []

        count = 0
        for element in top[0].getElementsByTagName('gov:hasName'):
            count += 1
            place_name = self.__get_hasname(element)
            if count == 1:
                place.set_name(place_name)
            else:
                if place_name.lang == preferred_lang:
                    place.add_alternative_name(place.get_name())
                    place.set_name(place_name)
                else:
                    place.add_alternative_name(place_name)
        for element in top[0].getElementsByTagName('gov:hasType'):
            curr_lang = place.get_name().get_language()
            place_type = self.__get_hastype(element,curr_lang, type_dic, preferred_lang)
            place.set_type(place_type)
        for element in top[0].getElementsByTagName('gov:position'):
            latitude, longitude = self.__get_position(element)
            place.set_latitude(latitude)
            place.set_longitude(longitude)
        ref_list = []
        for element in top[0].getElementsByTagName('gov:isPartOf'):
            ref, date = self.__get_ispartof(element)
            ref_list.append((ref, date))
        for element in top[0].getElementsByTagName('gov:hasURL'):
            url = self.__get_hasurl(element)
            place.add_url(url)

        return place, ref_list
开发者ID:daleathan,项目名称:addons-source,代码行数:45,代码来源:getgov.py

示例4: __get_place

# 需要导入模块: from gramps.gen.lib import Place [as 别名]
# 或者: from gramps.gen.lib.Place import gramps_id [as 别名]
    def __get_place(self, gov_id, type_dic, preferred_lang):
        gov_url = 'http://gov.genealogy.net/semanticWeb/about/' + quote(gov_id)

        response = urlopen(gov_url)
        data = response.read()

        dom = parseString(data)
        top = dom.getElementsByTagName('gov:GovObject')

        place = Place()
        place.gramps_id = gov_id
        if not len(top) :
            return place, []

        types = []
        for element in top[0].getElementsByTagName('gov:hasName'):
            place_name = self.__get_hasname(element)
            place.add_name(place_name)
        for element in top[0].getElementsByTagName('gov:hasType'):
            place_type = self.__get_hastype(element, type_dic,
                                            preferred_lang)
            types.append(place_type)
        types.sort(key=lambda typ: typ.date.get_sort_value(), reverse=True)
        place.set_types(types)
        for element in top[0].getElementsByTagName('gov:position'):
            latitude, longitude = self.__get_position(element)
            place.set_latitude(latitude)
            place.set_longitude(longitude)
        ref_list = []
        for element in top[0].getElementsByTagName('gov:isPartOf'):
            ref, date = self.__get_ispartof(element)
            ref_list.append((ref, date))
        for element in top[0].getElementsByTagName('gov:hasURL'):
            url = self.__get_hasurl(element)
            place.add_url(url)

        return place, ref_list
开发者ID:gramps-project,项目名称:addons-source,代码行数:39,代码来源:getgov.py

示例5: on_res_ok_clicked

# 需要导入模块: from gramps.gen.lib import Place [as 别名]
# 或者: from gramps.gen.lib.Place import gramps_id [as 别名]
 def on_res_ok_clicked(self, dummy):
     """ Accept changes displayed and commit to place.
     Also find or create a new enclosing place from parent. """
     # do the names
     namelist = []
     for row in self.alt_store:
         if row[0] == 'P':
             self.place.name = self.newplace.names[row[4]]
         elif row[0] == '\u2714':
             namelist.append(self.newplace.names[row[4]])
     self.place.alt_names = namelist
     # Lat/lon/ID/code/type
     self.place.lat = self.top.get_object('latitude').get_text()
     self.place.long = self.top.get_object('longitude').get_text()
     self.place.gramps_id = self.top.get_object('grampsid').get_text()
     self.place.code = self.top.get_object('postal').get_text()
     self.place.place_type.set(self.type_combo.get_values())
     # Add in URLs if wanted
     if self.keepweb:
         for url in self.newplace.links:
             self.place.add_url(url)
     # Enclose in the next level place
     next_place = False
     parent = None
     if not self.keep_enclosure or not self.place.placeref_list:
         if self.newplace.parent_ids:
             # we might have a parent with geo id 'GEO12345'
             parent = self.dbstate.db.get_place_from_gramps_id(
                 self.newplace.parent_ids[0])
         if not parent and self.newplace.parent_names:
             # make one, will have to be examined/cleaned later
             parent = Place()
             parent.title = ', '.join(self.newplace.parent_names)
             name = PlaceName()
             name.value = parent.title
             parent.name = name
             parent.gramps_id = self.newplace.parent_ids[0]
             with DbTxn(_("Add Place (%s)") % parent.title,
                        self.dbstate.db) as trans:
                 self.dbstate.db.add_place(parent, trans)
                 next_place = True
         if parent:
             if located_in(self.dbstate.db, parent.handle,
                           self.place.handle):
                 # attempting to create a place loop, not good!
                 ErrorDialog(_('Place cycle detected'),
                             msg2=_("The place you chose is enclosed in the"
                                    " place you are workin on!\n"
                                    "Please cancel and choose another "
                                    "place."),
                             parent=self.uistate.window)
                 return
             # check to see if we already have the enclosing place
             already_there = False
             for pref in self.place.placeref_list:
                 if parent.handle == pref.ref:
                     already_there = True
                     break
             if not already_there:
                 placeref = PlaceRef()
                 placeref.set_reference_handle(parent.handle)
                 self.place.set_placeref_list([placeref])
     # Add in Citation/Source if wanted
     if self.addcitation and self.newplace.geoid:
         src_hndl = self.find_or_make_source()
         cit = Citation()
         cit.set_reference_handle(src_hndl)
         cit.set_page("GeoNames ID: %s" %
                      self.newplace.geoid.replace('GEO', ''))
         with DbTxn(_("Add Citation (%s)") % "GeoNames",
                    self.dbstate.db) as trans:
             self.dbstate.db.add_citation(cit, trans)
         self.place.add_citation(cit.handle)
     # We're finally ready to commit the updated place
     with DbTxn(_("Edit Place (%s)") % self.place.title,
                self.dbstate.db) as trans:
         self.dbstate.db.commit_place(self.place, trans)
     # Jump to enclosing place to clean it if necessary
     if next_place:
         self.set_active('Place', parent.handle)
         self.place = parent
         # if geoparse fails, leave us at main view
         if self.newplace.parent_ids and \
             self.geoparse(self.newplace.parent_ids[0],
                           _(", ").join(self.newplace.parent_names),
                           self.newplace.parent_ids,
                           self.newplace.parent_names):
             # geoparse worked, lets put up the results view
             self.gui.get_child().remove(self.mainwin)
             self.gui.get_child().add(self.results_win)
             self.res_gui()
             return
     self.reset_main()
     if self.gui.get_child().get_child() == self.results_win:
         self.gui.get_child().remove(self.results_win)
         self.gui.get_child().add(self.mainwin)
开发者ID:daleathan,项目名称:addons-source,代码行数:98,代码来源:placecleanup.py


注:本文中的gramps.gen.lib.Place.gramps_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。