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


Python Place.name方法代码示例

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


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

示例1: get_or_create_place

# 需要导入模块: from gramps.gen.lib import Place [as 别名]
# 或者: from gramps.gen.lib.Place import name [as 别名]
 def get_or_create_place(self, place_name):
     "Return the requested place object tuple-packed with a new indicator."
     LOG.debug("get_or_create_place: looking for: %s", place_name)
     for place_handle in self.db.iter_place_handles():
         place = self.db.get_place_from_handle(place_handle)
         place_title = place_displayer.display(self.db, place)
         if place_title == place_name:
             return (0, place)
     place = Place()
     place.set_title(place_name)
     place.name = PlaceName(value=place_name)
     self.db.add_place(place, self.trans)
     return (1, place)
开发者ID:tecknicaltom,项目名称:gramps,代码行数:15,代码来源:importcsv.py

示例2: __add_place

# 需要导入模块: from gramps.gen.lib import Place [as 别名]
# 或者: from gramps.gen.lib.Place import name [as 别名]
 def __add_place(self, name, type_num, parent, title, trans):
     """
     Add a missing place to the database.
     """
     place = Place()
     place_name = PlaceName()
     place_name.set_value(name)
     place.name = place_name
     place.title = title
     place.place_type = PlaceType(7-type_num)
     if parent is not None:
         placeref = PlaceRef()
         placeref.ref = handle2internal(parent)
         place.set_placeref_list([placeref])
     handle = self.db.add_place(place, trans)
     self.db.commit_place(place, trans)
     return handle
开发者ID:nblock,项目名称:gramps,代码行数:19,代码来源:libplaceimport.py

示例3: on_res_ok_clicked

# 需要导入模块: from gramps.gen.lib import Place [as 别名]
# 或者: from gramps.gen.lib.Place import name [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.name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。