本文整理汇总了Python中gramps.gen.lib.EventRef.set_reference_handle方法的典型用法代码示例。如果您正苦于以下问题:Python EventRef.set_reference_handle方法的具体用法?Python EventRef.set_reference_handle怎么用?Python EventRef.set_reference_handle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gramps.gen.lib.EventRef
的用法示例。
在下文中一共展示了EventRef.set_reference_handle方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read_witness_line
# 需要导入模块: from gramps.gen.lib import EventRef [as 别名]
# 或者: from gramps.gen.lib.EventRef import set_reference_handle [as 别名]
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
示例2: new_gwplus_pevent
# 需要导入模块: from gramps.gen.lib import EventRef [as 别名]
# 或者: from gramps.gen.lib.EventRef import set_reference_handle [as 别名]
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
示例3: read_children_lines
# 需要导入模块: from gramps.gen.lib import EventRef [as 别名]
# 或者: from gramps.gen.lib.EventRef import set_reference_handle [as 别名]
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
示例4: add_occupation
# 需要导入模块: from gramps.gen.lib import EventRef [as 别名]
# 或者: from gramps.gen.lib.EventRef import set_reference_handle [as 别名]
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)
示例5: add_birthday
# 需要导入模块: from gramps.gen.lib import EventRef [as 别名]
# 或者: from gramps.gen.lib.EventRef import set_reference_handle [as 别名]
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)
示例6: parse_person
# 需要导入模块: from gramps.gen.lib import EventRef [as 别名]
# 或者: from gramps.gen.lib.EventRef import set_reference_handle [as 别名]
#.........这里部分代码省略.........
if field.startswith('('):
LOG.debug("Public Name: %s" % field)
public_name = self.decode(field[1:-1])
elif field.startswith('{'):
LOG.debug("Firstsname Alias: %s" % field)
firstname_aliases.append(self.decode(field[1:-1]))
elif field.startswith('['):
LOG.debug("Title: %s" % field)
titleparts = self.decode(field[1:-1]).split(":")
tname = ttitle = tplace = tstart = tend = tnth = None
try:
tname = titleparts[0]
ttitle = titleparts[1]
if titleparts[2]:
tplace = self.get_or_create_place(titleparts[2])
tstart = self.parse_date(titleparts[3])
tend = self.parse_date(titleparts[4])
tnth = titleparts[5]
except IndexError: # not all parts are written all the time
pass
if tnth: # Append title numer to title
ttitle += ", " + tnth
title = self.create_event(
EventType.NOB_TITLE, ttitle, tstart, tplace)
# TODO: Geneweb has a start date and an end date, and therefore
# supports stuff like: FROM about 1955 TO between 1998 and 1999
# gramps only supports one single date or range.
if tname and tname != "*":
n = Note()
n.set(tname)
self.db.add_note(n,self.trans)
title.add_note( n.handle)
title_ref = EventRef()
title_ref.set_reference_handle(title.get_handle())
person.add_event_ref(title_ref)
elif field == '#nick' and idx < len(fields):
LOG.debug("Nick Name: %s" % fields[idx])
nick_names.append(self.decode(fields[idx]))
idx += 1
elif field == '#occu' and idx < len(fields):
LOG.debug("Occupation: %s" % fields[idx])
occu = self.create_event(
EventType.OCCUPATION, self.decode(fields[idx]))
occu_ref = EventRef()
occu_ref.set_reference_handle(occu.get_handle())
person.add_event_ref(occu_ref)
idx += 1
elif field == '#alias' and idx < len(fields):
LOG.debug("Name Alias: %s" % fields[idx])
name_aliases.append(self.decode(fields[idx]))
idx += 1
elif field == '#salias' and idx < len(fields):
LOG.debug("Surname Alias: %s" % fields[idx])
surname_aliases.append(self.decode(fields[idx]))
idx += 1
elif field == '#image' and idx < len(fields):
LOG.debug("Image: %s" % fields[idx])
idx += 1
elif field == '#src' and idx < len(fields):
LOG.debug("Source: %s" % fields[idx])
source = self.get_or_create_source(self.decode(fields[idx]))
idx += 1
elif field == '#bs' and idx < len(fields):
LOG.debug("Birth Source: %s" % fields[idx])
birth_source = self.get_or_create_source(self.decode(fields[idx]))
idx += 1
示例7: parse_marriage
# 需要导入模块: from gramps.gen.lib import EventRef [as 别名]
# 或者: from gramps.gen.lib.EventRef import set_reference_handle [as 别名]
def parse_marriage(self,fields,idx):
mariageDataRe = re.compile("^[+#-0-9].*$")
mar_date = None
mar_place = None
mar_source = None
sep_date = None
div_date = None
married = 1
engaged = 0
# skip to marriage date in case person contained unmatches tokens
#Alex: this failed when fields[idx] was an empty line. Fixed.
#while idx < len(fields) and not fields[idx][0] == "+":
while idx < len(fields) and not (fields[idx] and fields[idx][0] == "+"):
if fields[idx]:
LOG.warning(("parse_marriage(): Unknown field: " +
"'%s' in line %d!") % (fields[idx], self.lineno))
idx += 1
while idx < len(fields) and mariageDataRe.match(fields[idx]):
field = fields[idx]
idx += 1
if field.startswith("+"):
field = field[1:]
mar_date = self.parse_date(self.decode(field))
LOG.debug(" Married at: %s" % field)
elif field.startswith("-"):
field = field[1:]
div_date = self.parse_date(self.decode(field))
LOG.debug(" Div at: %s" % field)
elif field == "#mp" and idx < len(fields):
mar_place = self.get_or_create_place(self.decode(fields[idx]))
LOG.debug(" Marriage place: %s" % fields[idx])
idx += 1
elif field == "#ms" and idx < len(fields):
mar_source = self.get_or_create_source(self.decode(fields[idx]))
LOG.debug(" Marriage source: %s" % fields[idx])
idx += 1
elif field == "#sep" and idx < len(fields):
sep_date = self.parse_date(self.decode(fields[idx]))
LOG.debug(" Seperated since: %s" % fields[idx])
idx += 1
elif field == "#nm":
LOG.debug(" Are not married.")
married = 0
elif field == "#noment":
LOG.debug(" Not mentioned.")
elif field == "#eng":
LOG.debug(" Are engaged.")
engaged = 1
else:
LOG.warning(("parse_marriage(): Unknown field " +
"'%s'for mariage in line %d!") % (field, self.lineno))
if mar_date or mar_place or mar_source:
mar = self.create_event(
EventType.MARRIAGE, None, mar_date, mar_place, mar_source)
mar_ref = EventRef()
mar_ref.set_reference_handle(mar.get_handle())
mar_ref.set_role(EventRoleType.FAMILY)
self.current_family.add_event_ref(mar_ref)
self.current_family.set_relationship(
FamilyRelType(FamilyRelType.MARRIED))
if div_date:
div = self.create_event(
EventType.DIVORCE, None, div_date, None, None)
div_ref = EventRef()
div_ref.set_reference_handle(div.get_handle())
div_ref.set_role(EventRoleType.FAMILY)
self.current_family.add_event_ref(div_ref)
if sep_date or engaged:
sep = self.create_event(
EventType.ENGAGEMENT, None, sep_date, None, None)
sep_ref = EventRef()
sep_ref.set_reference_handle(sep.get_handle())
sep_ref.set_role(EventRoleType.FAMILY)
self.current_family.add_event_ref(sep_ref)
if not married:
self.current_family.set_relationship(
FamilyRelType(FamilyRelType.UNMARRIED))
self.db.commit_family(self.current_family,self.trans)
return idx
示例8: run_tool
# 需要导入模块: from gramps.gen.lib import EventRef [as 别名]
# 或者: from gramps.gen.lib.EventRef import set_reference_handle [as 别名]
#.........这里部分代码省略.........
# dates.append( d)
# except:
# d = Date()
# d.set_as_text("Date.set Exception %s" % ("".join(traceback.format_exception(*sys.exc_info())),))
# dates.append( d)
#self.progress.step()
#d = Date()
#d.set(Date.QUAL_NONE,Date.MOD_NONE,
# Date.CAL_GREGORIAN,(44,7,1789,False),"Text comment")
#dates.append( d)
#d = Date()
#d.set(Date.QUAL_NONE,Date.MOD_NONE,
# Date.CAL_GREGORIAN,(4,77,1789,False),"Text comment")
#dates.append( d)
#d = Date()
#d.set(Date.QUAL_NONE,Date.MOD_SPAN,
# Date.CAL_GREGORIAN,
# (4,7,1789,False,55,8,1876,False),"Text comment")
#dates.append( d)
#d = Date()
#d.set(Date.QUAL_NONE,Date.MOD_SPAN,
# Date.CAL_GREGORIAN,
# (4,7,1789,False,5,88,1876,False),"Text comment")
#dates.append( d)
with DbTxn(_("Date Test Plugin"), self.db, batch=True) as self.trans:
self.db.disable_signals()
self.progress.set_pass(_('Generating dates'),
len(dates))
# create pass and fail tags
pass_handle = self.create_tag(_('Pass'), '#0000FFFF0000')
fail_handle = self.create_tag(_('Fail'), '#FFFF00000000')
# now add them as birth to new persons
i = 1
for dateval in dates:
person = Person()
surname = Surname()
surname.set_surname("DateTest")
name = Name()
name.add_surname(surname)
name.set_first_name("Test %d" % i)
person.set_primary_name(name)
self.db.add_person(person, self.trans)
bevent = Event()
bevent.set_type(EventType.BIRTH)
bevent.set_date_object(dateval)
bevent.set_description("Date Test %d (source)" % i)
bevent_h = self.db.add_event(bevent, self.trans)
bevent_ref = EventRef()
bevent_ref.set_reference_handle(bevent_h)
# for the death event display the date as text and parse it back to a new date
ndate = None
try:
datestr = _dd.display( dateval)
try:
ndate = _dp.parse( datestr)
if not ndate:
ndate = Date()
ndate.set_as_text("DateParser None")
person.add_tag(fail_handle)
else:
person.add_tag(pass_handle)
except:
ndate = Date()
ndate.set_as_text("DateParser Exception %s" % ("".join(traceback.format_exception(*sys.exc_info())),))
person.add_tag(fail_handle)
else:
person.add_tag(pass_handle)
except:
ndate = Date()
ndate.set_as_text("DateDisplay Exception: %s" % ("".join(traceback.format_exception(*sys.exc_info())),))
person.add_tag(fail_handle)
if dateval.get_modifier() != Date.MOD_TEXTONLY \
and ndate.get_modifier() == Date.MOD_TEXTONLY:
# parser was unable to correctly parse the string
ndate.set_as_text( "TEXTONLY: "+ndate.get_text())
person.add_tag(fail_handle)
if dateval.get_modifier() == Date.MOD_TEXTONLY \
and dateval.get_text().count("Traceback") \
and pass_handle in person.get_tag_list():
person.add_tag(fail_handle)
devent = Event()
devent.set_type(EventType.DEATH)
devent.set_date_object(ndate)
devent.set_description("Date Test %d (result)" % i)
devent_h = self.db.add_event(devent, self.trans)
devent_ref = EventRef()
devent_ref.set_reference_handle(devent_h)
person.set_birth_ref(bevent_ref)
person.set_death_ref(devent_ref)
self.db.commit_person(person, self.trans)
i = i + 1
self.progress.step()
self.db.enable_signals()
self.db.request_rebuild()
self.progress.close()
示例9: apply_selection
# 需要导入模块: from gramps.gen.lib import EventRef [as 别名]
# 或者: from gramps.gen.lib.EventRef import set_reference_handle [as 别名]
def apply_selection(self, *args, **kwargs):
# Do not add birth or death event if one exists, no matter what
if self.table.treeview.get_model() is None:
return
with DbTxn("", self.db, batch=True) as self.trans:
self.pre_run()
source_text = self.options.handler.options_dict['source_text']
select_col = self.table.model_index_of_column[_("Select")]
source = self.get_or_create_source(source_text)
self.db.disable_signals()
self.results_write(_("Selecting... "))
self.progress.set_pass((_("Adding events '%s'...") % source_text),
len(self.table.treeview.get_model()))
count = 0
for row in self.table.treeview.get_model():
self.progress.step()
select = row[select_col] # live select value
if not select:
continue
pupdate = False
index = row[0] # order put in
row_data = self.table.get_raw_data(index)
person = row_data[1] # check, person, action, date1, date2
date1 = row_data[3] # date
date2 = row_data[4] # date
evidence = row_data[5] # evidence
other = row_data[6] # other person
if other:
other_name = self.sdb.name(other)
else:
other_name = None
add_birth_event, add_death_event = self.action[person.handle]
birth_ref = person.get_birth_ref()
death_ref = person.get_death_ref()
if not birth_ref and add_birth_event:
if other_name:
explanation = _("Added birth event based on %(evidence)s, from %(name)s") % {
'evidence' : evidence, 'name' : other_name }
else:
explanation = _("Added birth event based on %s") % evidence
modifier = self.get_modifier("birth")
birth = self.create_event(_("Estimated birth date"),
EventType.BIRTH,
date1, source, explanation, modifier)
event_ref = EventRef()
event_ref.set_reference_handle(birth.get_handle())
person.set_birth_ref(event_ref)
pupdate = True
count += 1
if not death_ref and add_death_event:
if other_name:
explanation = _("Added death event based on %(evidence)s, from %(person)s") % {
'evidence' : evidence, 'person' : other_name }
else:
explanation = _("Added death event based on %s") % evidence
modifier = self.get_modifier("death")
death = self.create_event(_("Estimated death date"),
EventType.DEATH,
date2, source, explanation, modifier)
event_ref = EventRef()
event_ref.set_reference_handle(death.get_handle())
person.set_death_ref(event_ref)
pupdate = True
count += 1
if pupdate:
self.db.commit_person(person, self.trans)
self.results_write(_(" Done! Committing..."))
self.results_write("\n")
self.db.enable_signals()
self.db.request_rebuild()
self.results_write(_("Added %d events.") % count)
self.results_write("\n\n")
self.progress.close()
示例10: _parse_person
# 需要导入模块: from gramps.gen.lib import EventRef [as 别名]
# 或者: from gramps.gen.lib.EventRef import set_reference_handle [as 别名]
#.........这里部分代码省略.........
person.gramps_id = self.db.id2user_format(person_ref[1:-1])
if (person.get_gender() == Person.UNKNOWN and
gender is not None):
gender = gender.lower()
if gender == gender_map[Person.MALE].lower():
gender = Person.MALE
elif gender == gender_map[Person.FEMALE].lower():
gender = Person.FEMALE
else:
gender = Person.UNKNOWN
person.set_gender(gender)
#########################################################
# add if new, replace if different
# Birth:
if birthdate is not None:
birthdate = _dp.parse(birthdate)
if birthplace and birthplace_id:
raise Error("Error in person: can't have a birthplace and birthplace_id")
if birthplace is not None:
new, birthplace = self.get_or_create_place(birthplace)
elif birthplace_id:
# better exist already, locally or in database:
birthplace = self.lookup("place", birthplace_id)
if birthsource is not None:
new, birthsource = self.get_or_create_source(birthsource)
if birthdate or birthplace or birthsource:
new, birth = self.get_or_create_event(person,
EventType.BIRTH, birthdate,
birthplace, birthsource)
birth_ref = person.get_birth_ref()
if birth_ref is None:
# new
birth_ref = EventRef()
birth_ref.set_reference_handle( birth.get_handle())
person.set_birth_ref( birth_ref)
# Baptism:
if baptismdate is not None:
baptismdate = _dp.parse(baptismdate)
if baptismplace and baptismplace_id:
raise Error("Error in person: can't have a baptismplace and baptismplace_id")
if baptismplace is not None:
new, baptismplace = self.get_or_create_place(baptismplace)
elif baptismplace_id:
# better exist already, locally or in database:
baptismplace = self.lookup("place", baptismplace_id)
if baptismsource is not None:
new, baptismsource = self.get_or_create_source(baptismsource)
if baptismdate or baptismplace or baptismsource:
new, baptism = self.get_or_create_event(person,
EventType.BAPTISM, baptismdate,
baptismplace, baptismsource)
baptism_ref = get_primary_event_ref_from_type(self.db, person,
"Baptism")
if baptism_ref is None:
# new
baptism_ref = EventRef()
baptism_ref.set_reference_handle( baptism.get_handle())
person.add_event_ref( baptism_ref)
# Death:
if deathdate is not None:
deathdate = _dp.parse(deathdate)
if deathplace and deathplace_id:
raise Error("Error in person: can't have a deathplace and deathplace_id")
if deathplace is not None:
new, deathplace = self.get_or_create_place(deathplace)
elif deathplace_id:
示例11: _parse_marriage
# 需要导入模块: from gramps.gen.lib import EventRef [as 别名]
# 或者: from gramps.gen.lib.EventRef import set_reference_handle [as 别名]
def _parse_marriage(self, line_number, row, col):
"Parse the content of a Marriage,Husband,Wife line."
marriage_ref = rd(line_number, row, col, "marriage")
husband = rd(line_number, row, col, "husband")
wife = rd(line_number, row, col, "wife")
marriagedate = rd(line_number, row, col, "date")
marriageplace = rd(line_number, row, col, "place")
marriageplace_id = rd(line_number, row, col, "place_id")
marriagesource = rd(line_number, row, col, "source")
note = rd(line_number, row, col, "note")
wife = self.lookup("person", wife)
husband = self.lookup("person", husband)
if husband is None and wife is None:
# might have children, so go ahead and add
LOG.warn("no parents on line %d; adding family anyway" %
line_number)
family = self.get_or_create_family(marriage_ref, husband, wife)
# adjust gender, if not already provided
if husband:
# this is just a guess, if unknown
if husband.get_gender() == Person.UNKNOWN:
husband.set_gender(Person.MALE)
self.db.commit_person(husband, self.trans)
if wife:
# this is just a guess, if unknown
if wife.get_gender() == Person.UNKNOWN:
wife.set_gender(Person.FEMALE)
self.db.commit_person(wife, self.trans)
if marriage_ref:
self.storeup("family", marriage_ref.lower(), family)
if marriagesource:
# add, if new
new, marriagesource = self.get_or_create_source(marriagesource)
if marriageplace and marriageplace_id:
raise Error("Error in marriage: can't have a place and place_id")
if marriageplace:
# add, if new
new, marriageplace = self.get_or_create_place(marriageplace)
elif marriageplace_id:
# better exist already, locally or in database:
marriageplace = self.lookup("place", marriageplace_id)
if marriagedate:
marriagedate = _dp.parse(marriagedate)
if marriagedate or marriageplace or marriagesource or note:
# add, if new; replace, if different
new, marriage = self.get_or_create_event(family,
EventType.MARRIAGE, marriagedate,
marriageplace, marriagesource)
if new:
mar_ref = EventRef()
mar_ref.set_reference_handle(marriage.get_handle())
family.add_event_ref(mar_ref)
self.db.commit_family(family, self.trans)
# only add note to event:
# append notes, if previous notes
if note:
previous_notes_list = marriage.get_note_list()
updated_note = False
for note_handle in previous_notes_list:
previous_note = self.db.get_note_from_handle(
note_handle)
if previous_note.type == NoteType.EVENT:
previous_text = previous_note.get()
if note not in previous_text:
note = previous_text + "\n" + note
previous_note.set(note)
self.db.commit_note(previous_note, self.trans)
updated_note = True
break
if not updated_note:
# add new note here
new_note = Note()
new_note.handle = create_id()
new_note.type.set(NoteType.EVENT)
new_note.set(note)
if self.default_tag:
new_note.add_tag(self.default_tag.handle)
self.db.add_note(new_note, self.trans)
marriage.add_note(new_note.handle)
self.db.commit_event(marriage, self.trans)