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


Python lib.Event类代码示例

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


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

示例1: 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

示例2: 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

示例3: column_place

 def column_place(self,data):
     if data[COLUMN_PLACE]:
         event = Event()
         event.unserialize(data)
         return place_displayer.display_event(self.db, event)
     else:
         return ''
开发者ID:gogglesguy,项目名称:gramps,代码行数:7,代码来源:eventmodel.py

示例4: __new_census

 def __new_census(self, widget):
     """
     Create a new census and invoke the editor.
     """
     event = Event()
     event.set_type(EventType.CENSUS)
     try:
         CensusEditor(self.gui.dbstate, self.gui.uistate, [], event)
     except WindowActiveError:
         pass
开发者ID:SNoiraud,项目名称:addons-source,代码行数:10,代码来源:CensusGramplet.py

示例5: add_button_clicked

 def add_button_clicked(self, obj):
     try:
         ref = EventRef()
         event = Event()
         ref.set_role(self.default_role())
         event.set_type(self.default_type())
         self.get_ref_editor()(
             self.dbstate, self.uistate, self.track,
             event, ref, self.object_added)
     except WindowActiveError:
         pass
开发者ID:DaAwesomeP,项目名称:gramps,代码行数:11,代码来源:eventembedlist.py

示例6: sort_date

    def sort_date(self,data):
        if data[COLUMN_DATE]:
            event = Event()
            event.unserialize(data)
            retval = "%09d" % event.get_date_object().get_sort_value()
            if not get_date_valid(event):
                return INVALID_DATE_FORMAT % retval
            else:
                return retval

        return ''
开发者ID:tester0077,项目名称:gramps,代码行数:11,代码来源:eventmodel.py

示例7: column_place

 def column_place(self,data):
     if data[COLUMN_PLACE]:
         cached, value = self.get_cached_value(data[0], "PLACE")
         if not cached:
             event = Event()
             event.unserialize(data)
             value = place_displayer.display_event(self.db, event)
             self.set_cached_value(data[0], "PLACE", value)
         return value
     else:
         return ''
开发者ID:tester0077,项目名称:gramps,代码行数:11,代码来源:eventmodel.py

示例8: column_date

 def column_date(self,data):
     if data[COLUMN_DATE]:
         event = Event()
         event.unserialize(data)
         date_str =  get_date(event)
         if date_str != "":
             retval = escape(date_str)
         if not get_date_valid(event):
             return INVALID_DATE_FORMAT % retval
         else:
             return retval
     return ''
开发者ID:tester0077,项目名称:gramps,代码行数:12,代码来源:eventmodel.py

示例9: __init__

    def __init__(self, dbstate, uistate, clicked):
        self.clicked_func = clicked
        self.filter_id = widgets.BasicEntry()
        self.filter_desc = widgets.BasicEntry()
        self.filter_event = Event()
        self.filter_event.set_type((EventType.CUSTOM, ''))
        self.etype = Gtk.ComboBox(has_entry=True)
        self.custom_types = dbstate.db.get_event_types()

        self.event_menu = widgets.MonitoredDataType(
            self.etype,
            self.filter_event.set_type,
            self.filter_event.get_type,
            custom_values=self.custom_types)

        self.filter_mainparts = widgets.BasicEntry()
        self.filter_date = widgets.DateEntry(uistate, [])
        self.filter_place = 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, "Event")
开发者ID:DaAwesomeP,项目名称:gramps,代码行数:26,代码来源:_eventsidebarfilter.py

示例10: __init__

    def __init__(self, dbstate, uistate, clicked):
        self.clicked_func = clicked
        self.filter_id = widgets.BasicEntry()
        self.filter_father = widgets.BasicEntry()
        self.filter_mother = widgets.BasicEntry()
        self.filter_child = widgets.BasicEntry()

        self.filter_event = Event()
        self.filter_event.set_type((EventType.CUSTOM, ''))
        self.etype = Gtk.ComboBox(has_entry=True)

        self.family_stub = Family()
        self.family_stub.set_relationship((FamilyRelType.CUSTOM, ''))
        self.rtype = Gtk.ComboBox(has_entry=True)

        self.event_menu = widgets.MonitoredDataType(
            self.etype,
            self.filter_event.set_type,
            self.filter_event.get_type)

        self.rel_menu = widgets.MonitoredDataType(
            self.rtype,
            self.family_stub.set_relationship,
            self.family_stub.get_relationship)

        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, "Family")
开发者ID:tester0077,项目名称:gramps,代码行数:33,代码来源:_familysidebarfilter.py

示例11: __init__

    def __init__(self, dbstate, uistate, clicked):
        self.clicked_func = clicked
        self.filter_name = widgets.BasicEntry()
        self.filter_id = widgets.BasicEntry()
        self.filter_birth = widgets.DateEntry(uistate, [])
        self.filter_death = widgets.DateEntry(uistate, [])
        self.filter_event = Event()
        self.filter_event.set_type((EventType.CUSTOM, ''))
        self.etype = Gtk.ComboBox(has_entry=True)
        if dbstate.is_open():
            self.custom_types = dbstate.db.get_event_types()
        else:
            self.custom_types = []
        self.event_menu = widgets.MonitoredDataType(
            self.etype,
            self.filter_event.set_type,
            self.filter_event.get_type,
            custom_values=self.custom_types)

        self.filter_note = widgets.BasicEntry()
        self.filter_gender = Gtk.ComboBoxText()
        list(map(self.filter_gender.append_text,
            [ _('any'), _('male'), _('female'), _('unknown') ]))
        self.filter_gender.set_active(0)

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

        self.tag = Gtk.ComboBox()
        self.generic = Gtk.ComboBox()

        SidebarFilter.__init__(self, dbstate, uistate, "Person")
开发者ID:SNoiraud,项目名称:gramps,代码行数:31,代码来源:_personsidebarfilter.py

示例12: 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

示例13: add_occupation

    def add_occupation(self, fields, data):
        """Read the ROLE property of a VCard."""
        occupation = data.strip()
        if occupation:
            event = Event()
            event.set_type(EventType(EventType.OCCUPATION))
            event.set_description(self.unesc(occupation))
            self.database.add_event(event, self.trans)

            event_ref = EventRef()
            event_ref.set_reference_handle(event.get_handle())
            self.person.add_event_ref(event_ref)
开发者ID:SNoiraud,项目名称:gramps,代码行数:12,代码来源:importvcard.py

示例14: get_or_create_event

 def get_or_create_event(self, object_, type_, date=None, place=None,
                         source=None):
     """ Add or find a type event on object """
     # first, see if it exists
     LOG.debug("get_or_create_event")
     ref_list = object_.get_event_ref_list()
     LOG.debug("refs: %s", ref_list)
     # look for a match, and possible correction
     for ref in ref_list:
         event = self.db.get_event_from_handle(ref.ref)
         LOG.debug("   compare event type %s == %s", int(event.get_type()),
                   type_)
         if int(event.get_type()) == type_:
             # Match! Let's update
             if date:
                 event.set_date_object(date)
             if place:
                 event.set_place_handle(place.get_handle())
             if source:
                 self.find_and_set_citation(event, source)
             self.db.commit_event(event, self.trans)
             LOG.debug("   returning existing event")
             return (0, event)
     # else create it:
     LOG.debug("   creating event")
     event = Event()
     if type_:
         event.set_type(EventType(type_))
     if date:
         event.set_date_object(date)
     if place:
         event.set_place_handle(place.get_handle())
     if source:
         self.find_and_set_citation(event, source)
     self.db.add_event(event, self.trans)
     return (1, event)
开发者ID:tecknicaltom,项目名称:gramps,代码行数:36,代码来源:importcsv.py

示例15: add_birthday

    def add_birthday(self, fields, data):
        """Read the BDAY property of a VCard."""
        date_str = data.strip()
        date_match = VCardParser.DATE_RE.match(date_str)
        date = Date()
        if date_match:
            if date_match.group(2):
                date_str = "%s-%s-%s" % (date_match.group(2),
                                       date_match.group(3), date_match.group(4))
            else:
                date_str = date_match.group(1)
            y, m, d = [int(x, 10) for x in date_str.split('-')]
            try:
                date.set(value=(d, m, y, False))
            except DateError:
                # TRANSLATORS: leave the {vcard_snippet} untranslated
                # in the format string, but you may re-order it if needed.
                self.__add_msg(_(
                    "Invalid date in BDAY {vcard_snippet}, "
                    "preserving date as text."
                    ).format(vcard_snippet=data), self.line_num - 1)
                date.set(modifier=Date.MOD_TEXTONLY, text=data)
        else:
            if date_str:
                # TRANSLATORS: leave the {vcard_snippet} untranslated.
                self.__add_msg(_(
                    "Date {vcard_snippet} not in appropriate format "
                    "yyyy-mm-dd, preserving date as text."
                    ).format(vcard_snippet=date_str), self.line_num - 1)
                date.set(modifier=Date.MOD_TEXTONLY, text=date_str)
            else:  # silently ignore an empty BDAY record
                return
        event = Event()
        event.set_type(EventType(EventType.BIRTH))
        event.set_date_object(date)
        self.database.add_event(event, self.trans)

        event_ref = EventRef()
        event_ref.set_reference_handle(event.get_handle())
        self.person.set_birth_ref(event_ref)
开发者ID:SNoiraud,项目名称:gramps,代码行数:40,代码来源:importvcard.py


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