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


Python lib.Place类代码示例

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


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

示例1: instance_from_struct

    def instance_from_struct(cls, struct):
        """
        Given a struct with metadata, create a Gramps object.

        self is class when called as a classmethod.
        """
        from  gramps.gen.lib import (Person, Family, Event, Source, Place, Citation,
                                     Repository, Media, Note, Tag, Date)
        if isinstance(struct, dict):
            if "_class" in struct.keys():
                if struct["_class"] == "Person":
                    return Person.create(Person.from_struct(struct))
                elif struct["_class"] == "Family":
                    return Family.create(Family.from_struct(struct))
                elif struct["_class"] == "Event":
                    return Event.create(Event.from_struct(struct))
                elif struct["_class"] == "Source":
                    return Source.create(Source.from_struct(struct))
                elif struct["_class"] == "Place":
                    return Place.create(Place.from_struct(struct))
                elif struct["_class"] == "Citation":
                    return Citation.create(Citation.from_struct(struct))
                elif struct["_class"] == "Repository":
                    return Repository.create(Repository.from_struct(struct))
                elif struct["_class"] == "Media":
                    return Media.create(Media.from_struct(struct))
                elif struct["_class"] == "Note":
                    return Note.create(Note.from_struct(struct))
                elif struct["_class"] == "Tag":
                    return Tag.create(Tag.from_struct(struct))
                elif struct["_class"] == "Date":
                    return Date().unserialize(Date.from_struct(struct, full=True))
        raise AttributeError("invalid struct: %s" % struct)
开发者ID:belissent,项目名称:gramps,代码行数:33,代码来源:struct.py

示例2: from_struct

def from_struct(struct):
    """
    Given a struct with metadata, create a Gramps object.
    """
    from  gramps.gen.lib import (Person, Family, Event, Source, Place, Citation,
                                 Repository, MediaObject, Note, Tag)
    if isinstance(struct, dict):
        if "_class" in struct.keys():
            if struct["_class"] == "Person":
                return Person.create(Person.from_struct(struct))
            elif struct["_class"] == "Family":
                return Family.create(Family.from_struct(struct))
            elif struct["_class"] == "Event":
                return Event.create(Event.from_struct(struct))
            elif struct["_class"] == "Source":
                return Source.create(Source.from_struct(struct))
            elif struct["_class"] == "Place":
                return Place.create(Place.from_struct(struct))
            elif struct["_class"] == "Citation":
                return Citation.create(Citation.from_struct(struct))
            elif struct["_class"] == "Repository":
                return Repository.create(Repository.from_struct(struct))
            elif struct["_class"] == "MediaObject":
                return MediaObject.create(MediaObject.from_struct(struct))
            elif struct["_class"] == "Note":
                return Note.create(Note.from_struct(struct))
            elif struct["_class"] == "Tag":
                return Tag.create(Tag.from_struct(struct))
    raise AttributeError("invalid struct: %s" % struct)
开发者ID:cicl06,项目名称:gramps,代码行数:29,代码来源:diff.py

示例3: create_place

 def create_place(self):
     """ Used to create a new person we know doesn't exist """
     place = Place()
     if self.default_tag:
         place.add_tag(self.default_tag.handle)
     self.db.add_place(place, self.trans)
     self.place_count += 1
     return place
开发者ID:tecknicaltom,项目名称:gramps,代码行数:8,代码来源:importcsv.py

示例4: column_title

 def column_title(self, data):
     handle = data[0]
     cached, value = self.get_cached_value(handle, "PLACE")
     if not cached:
         place = Place()
         place.unserialize(data)
         value = place_displayer.display(self.db, place)
         self.set_cached_value(handle, "PLACE", value)
     return value
开发者ID:DaAwesomeP,项目名称:gramps,代码行数:9,代码来源:placemodel.py

示例5: __add_place

 def __add_place(self, parent, plat, plon):
     """
     Add a new place using longitude and latitude of location centered
     on the map
     """
     self.select_fct.close()
     new_place = Place()
     new_place.set_latitude(str(plat))
     new_place.set_longitude(str(plon))
     if parent:
         if isinstance(parent, Place):
             placeref = PlaceRef()
             placeref.ref = parent
             new_place.add_placeref(placeref)
         else:
             found = None
             for place in self.dbstate.db.iter_places():
                 found = place
                 if place.name.get_value() == parent:
                     break
             placeref = PlaceRef()
             placeref.ref = found.get_handle()
             new_place.add_placeref(placeref)
     try:
         EditPlace(self.dbstate, self.uistate, [], new_place)
         self.add_marker(None, None, plat, plon, None, True, 0)
     except WindowActiveError:
         pass
开发者ID:DaAwesomeP,项目名称:gramps,代码行数:28,代码来源:geography.py

示例6: test_editreference

 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,代码行数:11,代码来源:test_editreference.py

示例7: get_or_create_place

 def get_or_create_place(self,place_name):
     place = None
     if place_name in self.pkeys:
         place = self.db.get_place_from_handle(self.pkeys[place_name])
     else:
         place = Place()
         place.set_title(place_name)
         self.db.add_place(place,self.trans)
         self.db.commit_place(place,self.trans)
         self.pkeys[place_name] = place.get_handle()
     return place
开发者ID:ewongbb,项目名称:gramps,代码行数:11,代码来源:importgeneweb.py

示例8: get_or_create_place

 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)
     self.db.add_place(place, self.trans)
     return (1, place)
开发者ID:nblock,项目名称:gramps,代码行数:12,代码来源:importcsv.py

示例9: __init__

    def __init__(self, dbstate, uistate, clicked):
        self.clicked_func = clicked

        self.filter_id = widgets.BasicEntry()
        self.filter_name = widgets.BasicEntry()
        self.filter_place = Place()
        self.filter_place.set_type((PlaceType.CUSTOM, ''))
        self.ptype = Gtk.ComboBox(has_entry=True)
        if dbstate.is_open():
            self.custom_types = dbstate.db.get_place_types()
        else:
            self.custom_types = []

        self.place_menu = widgets.MonitoredDataType(
            self.ptype,
            self.filter_place.set_type,
            self.filter_place.get_type,
            False, # read-only
            self.custom_types
        )
        self.filter_code = widgets.BasicEntry()
        self.filter_enclosed = widgets.PlaceEntry(dbstate, uistate, [])
        self.filter_note = widgets.BasicEntry()

        self.filter_regex = Gtk.CheckButton(label=_('Use regular expressions'))
        self.tag = Gtk.ComboBox()
        self.generic = Gtk.ComboBox()

        SidebarFilter.__init__(self, dbstate, uistate, "Place")
开发者ID:belissent,项目名称:gramps,代码行数:29,代码来源:_placesidebarfilter.py

示例10: importData

def importData(db, filename, user):
    """Function called by Gramps to import data on persons in CSV format."""
    db.disable_signals()
    try:
        with DbTxn(_("JSON import"), db, batch=True) as trans:
            with OpenFileOrStdin(filename, encoding="utf-8") as fp:
                line = fp.readline()
                while line:
                    data = json.loads(line)
                    if data["_class"] == "Person":
                        obj = Person.create(Person.from_struct(data))
                        db.add_person(obj, trans)
                    elif data["_class"] == "Family":
                        obj = Family.create(Family.from_struct(data))
                        db.add_family(obj, trans)
                    elif data["_class"] == "Event":
                        obj = Event.create(Event.from_struct(data))
                        db.add_event(obj, trans)
                    elif data["_class"] == "Media":
                        obj = Media.create(Media.from_struct(data))
                        db.add_media(obj, trans)
                    elif data["_class"] == "Repository":
                        obj = Repository.create(Repository.from_struct(data))
                        db.add_repository(obj, trans)
                    elif data["_class"] == "Tag":
                        obj = Tag.create(Tag.from_struct(data))
                        db.add_tag(obj, trans)
                    elif data["_class"] == "Source":
                        obj = Source.create(Source.from_struct(data))
                        db.add_source(obj, trans)
                    elif data["_class"] == "Citation":
                        obj = Citation.create(Citation.from_struct(data))
                        db.add_citation(obj, trans)
                    elif data["_class"] == "Note":
                        obj = Note.create(Note.from_struct(data))
                        db.add_note(obj, trans)
                    elif data["_class"] == "Place":
                        obj = Place.create(Place.from_struct(data))
                        db.add_place(obj, trans)
                    else:
                        LOG.warn("ignored: " + data)
                    line = fp.readline()
    except EnvironmentError as err:
        user.notify_error(_("%s could not be opened\n") % filename, str(err))

    db.enable_signals()
    db.request_rebuild()
开发者ID:sam-m888,项目名称:addons-source,代码行数:47,代码来源:JSONImport.py

示例11: add

    def add(self, obj):
        """
        Add a new place.  Use the currently selected rows as parent places.
        """
        parent_list = []
        for handle in self.selected_handles():
            placeref = PlaceRef()
            placeref.ref = handle
            parent_list.append(placeref)

        place = Place()
        if len(parent_list) > 0:
            place.placeref_list = parent_list
        
        try:
            EditPlace(self.dbstate, self.uistate, [], place)
        except WindowActiveError:
            pass
开发者ID:ondrokrc,项目名称:gramps,代码行数:18,代码来源:placetreeview.py

示例12: test_editreference

 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,代码行数:18,代码来源:editreference_test.py

示例13: add_place_from_kml

    def add_place_from_kml(self, menu, event, lat, lon):
        """
        Add new place(s) from a kml file

        1 - ask for a kml file ?
        2 - Read the kml file.
        3 - create the place(s) with name and title found in the kml marker.

        """
        # Ask for the kml file
        filtering = Gtk.FileFilter()
        filtering.add_pattern("*.kml")
        kml = Gtk.FileChooserDialog(
            _("Select a kml file used to add places"),
            action=Gtk.FileChooserAction.OPEN,
            parent=self.uistate.window,
            buttons=(_('_Cancel'), Gtk.ResponseType.CANCEL,
                     _('_Apply'), Gtk.ResponseType.OK))
        mpath = HOME_DIR
        kml.set_current_folder(os.path.dirname(mpath))
        kml.set_filter(filtering)

        status = kml.run()
        if status == Gtk.ResponseType.OK:
            val = kml.get_filename()
            if val:
                kmlfile = Kml(val)
                points = kmlfile.add_points()
                for place in points:
                    (name, coords) = place
                    latlong = coords.pop()
                    (lat, lon) = latlong
                    place_name = PlaceName()
                    place_name.set_value(name)
                    new_place = Place()
                    new_place.set_name(place_name)
                    new_place.set_title(name)
                    new_place.set_latitude(str(lat))
                    new_place.set_longitude(str(lon))
                    try:
                        EditPlace(self.dbstate, self.uistate, [], new_place)
                    except WindowActiveError:
                        pass
        kml.destroy()
开发者ID:cz172638,项目名称:gramps,代码行数:44,代码来源:geography.py

示例14: __add_place

 def __add_place(self, parent, plat, plon):
     """
     Add a new place using longitude and latitude of location centered
     on the map
     """
     self.select_fct.close()
     new_place = Place()
     new_place.set_latitude(str(plat))
     new_place.set_longitude(str(plon))
     if parent:
         placeref = PlaceRef()
         placeref.ref = parent
         new_place.add_placeref(placeref)
     try:
         EditPlace(self.dbstate, self.uistate, [], new_place)
         self.add_marker(None, None, plat, plon, None, True, 0)
     except WindowActiveError:
         pass
开发者ID:aignas,项目名称:gramps,代码行数:18,代码来源:geography.py

示例15: __init__

    def __init__(self, dbstate, uistate, clicked):
        self.clicked_func = clicked

        self.filter_id = widgets.BasicEntry()
        self.filter_title = widgets.BasicEntry()
        self.filter_name = widgets.BasicEntry()
        self.filter_place = Place()
        self.filter_place.set_type((PlaceType.CUSTOM, ''))
        self.ptype = Gtk.ComboBox(has_entry=True)
       
        self.place_menu = widgets.MonitoredDataType(
            self.ptype,
            self.filter_place.set_type,
            self.filter_place.get_type)
        self.filter_code = widgets.BasicEntry()
        self.filter_note = widgets.BasicEntry()
        
        self.filter_regex = Gtk.CheckButton(label=_('Use regular expressions'))
        self.tag = Gtk.ComboBox()
        self.generic = Gtk.ComboBox()

        SidebarFilter.__init__(self, dbstate, uistate, "Place")
开发者ID:bastienjacquet,项目名称:gramps,代码行数:22,代码来源:_placesidebarfilter.py


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