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


Python lib.EventRef类代码示例

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


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

示例1: new_gwplus_pevent

    def new_gwplus_pevent(self, line):

        source = place = note = type = None
        date = self.parse_date(self.decode(line[6:]))

        idx = 0
        LOG.info((self.person, line, pevents_map.get(line[0:5])))
        type = pevents_map.get(line[0:5])
        data = line.split()
        date = self.parse_date(self.decode(line[6:]))
        for part in data:
            idx += 1
            if part == "#p":
                place = self.get_or_create_place(self.decode(data[idx]))
            if part == "#s":
                source = self.get_or_create_source(self.decode(data[idx]))
        self.current_event = self.create_event(type, None, None, None, None)
        print('new event', self.current_event.handle)
        if date:
            print(date)
            self.current_event.set_date_object(date)
        if place:
            print('place', place.handle)
            self.current_event.set_place_handle(place.get_handle())
        if source:
            print('source', source.handle)
            self.current_event.add_citation(source.get_handle())
        self.db.commit_event(self.current_event, self.trans)
        nev_ref = EventRef()
        nev_ref.set_reference_handle(self.current_event.get_handle())
        self.current_person.add_event_ref(nev_ref)
        self.db.commit_person(self.current_person, self.trans)
        return self.current_event
开发者ID:ewongbb,项目名称:gramps,代码行数:33,代码来源:importgeneweb.py

示例2: save

    def save(self, trans):
        """
        Save the census details to the database.
        """
        # Update people on the census
        all_people = []    
        for order, row in enumerate(self.model):
            all_people.append(row[0])
            person = self.db.get_person_from_handle(row[0])
            event_ref = self.get_census_event_ref(person)
            if event_ref is None:
                # Add new link to census
                event_ref = EventRef()
                event_ref.ref = self.event.get_handle()
                event_ref.set_role(EventRoleType.PRIMARY)
                person.add_event_ref(event_ref)
            # Write attributes
            attrs = event_ref.get_attribute_list()
            set_attribute(event_ref, attrs, ORDER_ATTR, str(order + 1))
            for offset, name in enumerate(self.columns):
                value = row[offset + 1]
                if name == _('Name'):
                    if value != name_displayer.display(person):
                        set_attribute(event_ref, attrs, name, value)
                else:
                    set_attribute(event_ref, attrs, name, value)
            self.db.commit_person(person, trans)

        # Remove links to people no longer on census
        for handle in (set(self.initial_people) - set(all_people)):
            person = self.db.get_person_from_handle(handle)
            ref_list = [event_ref for event_ref in person.get_event_ref_list()
                                if event_ref.ref != self.event.handle]
            person.set_event_ref_list(ref_list)
            self.db.commit_person(person, trans)
开发者ID:SNoiraud,项目名称:addons-source,代码行数:35,代码来源:CensusGramplet.py

示例3: handle_extra_type

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

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

示例5: read_children_lines

    def read_children_lines(self):
        father_surname = "Dummy"
        if not self.current_husband_handle:
            LOG.warning("Unknown father for child in line %d!" % self.lineno)
            return None
        husb = self.db.get_person_from_handle(self.current_husband_handle)
        father_surname = husb.get_primary_name().get_surname()
        if not self.current_family:
            LOG.warning("Unknown family of child in line %d!" % self.lineno)
            return None
        while 1:
            line = self.get_next_line()
            if line is None:
                break
            if line == "":
                continue

            fields = line.split(" ")
            if fields[0] == "-":
                LOG.debug("Child:")
                child = None
                if fields[1] == "h":
                    (idx,child) = self.parse_person(fields,2,Person.MALE,father_surname)
                elif fields[1] == "f":
                    (idx,child) = self.parse_person(fields,2,Person.FEMALE,father_surname)
                else:
                    (idx,child) = self.parse_person(fields,1,Person.UNKNOWN,father_surname)

                if child:
                    childref = ChildRef()
                    childref.set_reference_handle(child.get_handle())
                    self.current_family.add_child_ref( childref)
                    self.db.commit_family(self.current_family,self.trans)
                    child.add_parent_family_handle( self.current_family.get_handle())
                    if self.current_child_birthplace_handle:
                        birth = None
                        birth_ref = child.get_birth_ref()
                        if birth_ref:
                            birth = self.db.get_event_from_handle(birth_ref.ref)
                        if not birth:
                            birth = self.create_event(EventType.BIRTH)
                            birth_ref = EventRef()
                            birth_ref.set_reference_handle(birth.get_handle())
                            child.set_birth_ref(birth_ref)
                        birth.set_place_handle(self.current_child_birthplace_handle)
                        self.db.commit_event(birth,self.trans)
                    if self.current_child_source_handle:
                        child.add_citation(self.current_child_source_handle)
                    self.db.commit_person(child,self.trans)
            else:
                break
        self.current_mode = None
        return None
开发者ID:ewongbb,项目名称:gramps,代码行数:53,代码来源:importgeneweb.py

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

示例7: read_witness_line

 def read_witness_line(self,line,fields):
     LOG.debug("Witness:")
     if fields[1] == "m:":
         (idx,wit_p) = self.parse_person(fields,2,Person.MALE,None)
     elif fields[1] == "f:":
         (idx,wit_p) = self.parse_person(fields,2,Person.FEMALE,None)
     else:
         (idx,wit_p) = self.parse_person(fields,1,None,None)
     if wit_p:
         mev = None
         # search marriage event
         for evr in self.current_family.get_event_ref_list():
             ev = self.db.get_event_from_handle(evr.get_reference_handle())
             if ev.get_type() == EventType.MARRIAGE:
                 mev = ev # found.
         if not mev: # No marriage event found create a new one
             mev = self.create_event(EventType.MARRIAGE, None, None, None, None)
             mar_ref = EventRef()
             mar_ref.set_reference_handle(mev.get_handle())
             self.current_family.add_event_ref(mar_ref)
         wit_ref = EventRef()
         wit_ref.set_role(EventRoleType(EventRoleType.WITNESS))
         wit_ref.set_reference_handle(mev.get_handle())
         wit_p.add_event_ref(wit_ref)
         self.db.commit_person(wit_p,self.trans)
     return None
开发者ID:ewongbb,项目名称:gramps,代码行数:26,代码来源:importgeneweb.py

示例8: share_button_clicked

    def share_button_clicked(self, obj):
        SelectEvent = SelectorFactory('Event')

        sel = SelectEvent(self.dbstate, self.uistate, self.track)
        event = sel.run()
        if event:
            try:
                ref = EventRef()
                ref.set_role(self.default_role())
                self.get_ref_editor()(
                    self.dbstate, self.uistate, self.track,
                    event, ref, self.object_added)
            except WindowActiveError:
                from ...dialog import WarningDialog
                WarningDialog(_("Cannot share this reference"),
                              self.__blocked_text())
开发者ID:DaAwesomeP,项目名称:gramps,代码行数:16,代码来源:eventembedlist.py

示例9: get_event_ref

def get_event_ref(event, obj, role):
    """
    Return the event reference for a given person or family that points
    to the event being edited.
    """
    for event_ref in obj.get_event_ref_list():
        if (event_ref.ref == event.get_handle() and
            event_ref.get_role() == role):
            return event_ref

    # Add new event reference
    event_ref = EventRef()
    event_ref.ref = event.get_handle()
    event_ref.set_role(role)
    obj.add_event_ref(event_ref)
    return event_ref
开发者ID:daleathan,项目名称:addons-source,代码行数:16,代码来源:editform.py

示例10: column_death_place

    def column_death_place(self, data):
        index = data[COLUMN_DEATH]
        if index != -1:
            try:
                local = data[COLUMN_EVENT][index]
                dr = EventRef()
                dr.unserialize(local)
                event = self.db.get_event_from_handle(dr.ref)
                if event:
                    place_title = place_displayer.display_event(self.db, event)
                    if place_title:
                        return escape(place_title)
            except:
                return ''
        
        for event_ref in data[COLUMN_EVENT]:
            er = EventRef()
            er.unserialize(event_ref)
            event = self.db.get_event_from_handle(er.ref)
            etype = event.get_type()
            if (etype in [EventType.BURIAL, EventType.CREMATION,
                          EventType.CAUSE_DEATH]
                and er.get_role() == EventRoleType.PRIMARY):

                    place_title = place_displayer.display_event(self.db, event)
                    if place_title:
                        return "<i>%s</i>" % escape(place_title)
        return ""
开发者ID:gogglesguy,项目名称:gramps,代码行数:28,代码来源:peoplemodel.py

示例11: column_birth_place

    def column_birth_place(self, data):
        index = data[COLUMN_BIRTH]
        if index != -1:
            try:
                local = data[COLUMN_EVENT][index]
                br = EventRef()
                br.unserialize(local)
                event = self.db.get_event_from_handle(br.ref)
                if event:
                    place_title = place_displayer.display_event(self.db, event)
                    if place_title:
                        return escape(place_title)
            except:
                return ''
        
        for event_ref in data[COLUMN_EVENT]:
            er = EventRef()
            er.unserialize(event_ref)
            event = self.db.get_event_from_handle(er.ref)
            etype = event.get_type()
            if (etype in [EventType.BAPTISM, EventType.CHRISTEN] and
                er.get_role() == EventRoleType.PRIMARY):

                    place_title = place_displayer.display_event(self.db, event)
                    if place_title:
                        return "<i>%s</i>" % escape(place_title)
        return ""
开发者ID:gogglesguy,项目名称:gramps,代码行数:27,代码来源:peoplemodel.py

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

示例13: column_death_place

    def column_death_place(self, data):
        handle = data[0]
        cached, value = self.get_cached_value(handle, "DEATH_PLACE")
        if cached:
            return value
        else:
            index = data[COLUMN_DEATH]
            if index != -1:
                try:
                    local = data[COLUMN_EVENT][index]
                    dr = EventRef()
                    dr.unserialize(local)
                    event = self.db.get_event_from_handle(dr.ref)
                    if event:
                        place_title = place_displayer.display_event(self.db, event)
                        if place_title:
                            value = escape(place_title)
                            self.set_cached_value(handle, "DEATH_PLACE", value)
                            return value
                except:
                    value = ""
                    self.set_cached_value(handle, "DEATH_PLACE", value)
                    return value

            for event_ref in data[COLUMN_EVENT]:
                er = EventRef()
                er.unserialize(event_ref)
                event = self.db.get_event_from_handle(er.ref)
                etype = event.get_type()
                if (
                    etype in [EventType.BURIAL, EventType.CREMATION, EventType.CAUSE_DEATH]
                    and er.get_role() == EventRoleType.PRIMARY
                ):

                    place_title = place_displayer.display_event(self.db, event)
                    if place_title:
                        value = "<i>%s</i>" % escape(place_title)
                        self.set_cached_value(handle, "DEATH_PLACE", value)
                        return value
            value = ""
            self.set_cached_value(handle, "DEATH_PLACE", value)
            return value
开发者ID:tester0077,项目名称:gramps,代码行数:42,代码来源:peoplemodel.py

示例14: _get_birth_data

    def _get_birth_data(self, data, sort_mode):
        index = data[COLUMN_BIRTH]
        if index != -1:
            try:
                local = data[COLUMN_EVENT][index]
                b = EventRef()
                b.unserialize(local)
                birth = self.db.get_event_from_handle(b.ref)
                if sort_mode:
                    retval = "%09d" % birth.get_date_object().get_sort_value()
                else:
                    date_str = get_date(birth)
                    if date_str != "":
                        retval = escape(date_str)
                if not get_date_valid(birth):
                    return invalid_date_format % retval
                else:
                    return retval
            except:
                return ""

        for event_ref in data[COLUMN_EVENT]:
            er = EventRef()
            er.unserialize(event_ref)
            event = self.db.get_event_from_handle(er.ref)
            etype = event.get_type()
            date_str = get_date(event)
            if (
                etype in [EventType.BAPTISM, EventType.CHRISTEN]
                and er.get_role() == EventRoleType.PRIMARY
                and date_str != ""
            ):
                if sort_mode:
                    retval = "%09d" % event.get_date_object().get_sort_value()
                else:
                    retval = "<i>%s</i>" % escape(date_str)
                if not get_date_valid(event):
                    return invalid_date_format % retval
                else:
                    return retval

        return ""
开发者ID:tester0077,项目名称:gramps,代码行数:42,代码来源:peoplemodel.py

示例15: _get_death_data

 def _get_death_data(self, data, sort_mode):
     index = data[COLUMN_DEATH]
     if index != -1:
         try:
             local = data[COLUMN_EVENT][index]
             ref = EventRef()
             ref.unserialize(local)
             event = self.db.get_event_from_handle(ref.ref)
             if sort_mode:
                 retval = "%09d" % event.get_date_object().get_sort_value()
             else:
                 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
         except:
             return ''
     
     for event_ref in data[COLUMN_EVENT]:
         er = EventRef()
         er.unserialize(event_ref)
         event = self.db.get_event_from_handle(er.ref)
         etype = event.get_type()
         date_str = get_date(event)
         if (etype in [EventType.BURIAL,
                       EventType.CREMATION,
                       EventType.CAUSE_DEATH]
             and er.get_role() == EventRoleType.PRIMARY
             and date_str):
             if sort_mode:
                 retval = "%09d" % event.get_date_object().get_sort_value()
             else:
                 retval = "<i>%s</i>" % escape(date_str)
             if not get_date_valid(event):
                 return invalid_date_format % retval
             else:
                 return retval
     return ""
开发者ID:gogglesguy,项目名称:gramps,代码行数:41,代码来源:peoplemodel.py


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