2007-08-22 Don Allingham <don@gramps-project.org>
* src/GrampsDbUtils/_GedcomParse.py: use FACT for custom attributes, handle custom event descriptions as notes * src/GrampsDbUtils/_WriteGedcom.py: use FACT for custom attributes, handle custom event descriptions as notes * src/GrampsDbUtils/_GedTokens.py: add TOKEN_FACT svn: r8855
This commit is contained in:
parent
7a5c4a8871
commit
2f85845d32
@ -1,3 +1,10 @@
|
||||
2007-08-22 Don Allingham <don@gramps-project.org>
|
||||
* src/GrampsDbUtils/_GedcomParse.py: use FACT for custom attributes, handle
|
||||
custom event descriptions as notes
|
||||
* src/GrampsDbUtils/_WriteGedcom.py: use FACT for custom attributes, handle
|
||||
custom event descriptions as notes
|
||||
* src/GrampsDbUtils/_GedTokens.py: add TOKEN_FACT
|
||||
|
||||
2007-08-21 Don Allingham <don@gramps-project.org>
|
||||
* src/GrampsDbUtils/_GedcomParse.py: code cleanup
|
||||
* src/GrampsDbUtils/_GedcomLex.py: code cleanup
|
||||
|
@ -421,6 +421,7 @@ class GedcomParser(UpdateCallback):
|
||||
# +1 <<INDIVIDUAL_ATTRIBUTE_STRUCTURE>> {0:M}
|
||||
# +1 AFN <ANCESTRAL_FILE_NUMBER> {0:1}
|
||||
TOKEN_ATTR : self.__person_std_attr,
|
||||
TOKEN_FACT : self.__person_fact,
|
||||
#+1 <<LDS_INDIVIDUAL_ORDINANCE>> {0:M}
|
||||
TOKEN_BAPL : self.__person_bapl,
|
||||
TOKEN_CONL : self.__person_conl,
|
||||
@ -519,7 +520,7 @@ class GedcomParser(UpdateCallback):
|
||||
# n <<MULTIMEDIA_LINK>> {0:M} p.*,*
|
||||
TOKEN_OBJE : self.__event_object,
|
||||
# n <<NOTE_STRUCTURE>> {0:M} p.
|
||||
TOKEN_NOTE : self.__event_note,
|
||||
TOKEN_NOTE : self.__event_inline_note,
|
||||
TOKEN_RNOTE : self.__event_note,
|
||||
# Other
|
||||
TOKEN__PRIV : self.__event_privacy,
|
||||
@ -601,6 +602,10 @@ class GedcomParser(UpdateCallback):
|
||||
TOKEN_TYPE : self.__ignore,
|
||||
}
|
||||
|
||||
self.person_fact_parse_tbl = {
|
||||
TOKEN_TYPE : self.__person_fact_type,
|
||||
}
|
||||
|
||||
self.person_attr_parse_tbl = {
|
||||
TOKEN_TYPE : self.__person_attr_type,
|
||||
TOKEN_CAUS : self.__ignore,
|
||||
@ -2059,6 +2064,28 @@ class GedcomParser(UpdateCallback):
|
||||
self.__parse_level(sub_state, self.person_attr_parse_tbl,
|
||||
self.__ignore)
|
||||
|
||||
def __person_fact(self, line, state):
|
||||
"""
|
||||
Parses an TOKEN that GRAMPS recognizes as an Attribute
|
||||
|
||||
@param line: The current line in GedLine format
|
||||
@type line: GedLine
|
||||
@param state: The current state
|
||||
@type state: CurrentState
|
||||
"""
|
||||
sub_state = GedcomUtils.CurrentState()
|
||||
sub_state.person = state.person
|
||||
sub_state.attr = RelLib.Attribute()
|
||||
sub_state.attr.set_value(line.data)
|
||||
sub_state.level = state.level+1
|
||||
state.person.add_attribute(sub_state.attr)
|
||||
self.__parse_level(sub_state, self.person_fact_parse_tbl,
|
||||
self.__ignore)
|
||||
|
||||
def __person_fact_type(self, line, state):
|
||||
state.attr.set_type(line.data)
|
||||
self.__skip_subordinate_levels(state.level)
|
||||
|
||||
def __person_bapl(self, line, state):
|
||||
"""
|
||||
Parses an BAPL TOKEN, producing a GRAMPS LdsOrd instance
|
||||
@ -3133,6 +3160,22 @@ class GedcomParser(UpdateCallback):
|
||||
@type state: CurrentState
|
||||
"""
|
||||
self.__parse_note(line, state.event, state.level+1)
|
||||
|
||||
def __event_inline_note(self, line, state):
|
||||
"""
|
||||
@param line: The current line in GedLine format
|
||||
@type line: GedLine
|
||||
@param state: The current state
|
||||
@type state: CurrentState
|
||||
"""
|
||||
if line.data[0:13] == "Description: ":
|
||||
state.event.set_description(line.data[13:])
|
||||
else:
|
||||
new_note = RelLib.Note(line.data)
|
||||
new_note.set_handle(Utils.create_id())
|
||||
self.dbase.add_note(new_note, self.trans)
|
||||
self.__skip_subordinate_levels(level+2)
|
||||
obj.add_note(new_note.get_handle())
|
||||
|
||||
def __event_source(self, line, state):
|
||||
"""
|
||||
|
@ -138,6 +138,7 @@ TOKEN_ATTR = 119
|
||||
TOKEN_MAP = 120
|
||||
TOKEN_LATI = 121
|
||||
TOKEN_LONG = 122
|
||||
TOKEN_FACT = 123
|
||||
|
||||
tokens = {
|
||||
"HEAD" : TOKEN_HEAD, "MEDI" : TOKEN_MEDI,
|
||||
@ -238,4 +239,5 @@ tokens = {
|
||||
"MAP" : TOKEN_MAP, "LATI" : TOKEN_LATI,
|
||||
"LONG" : TOKEN_LONG, "_ITALIC" : TOKEN_IGNORE,
|
||||
"_PAREN" : TOKEN_IGNORE,"_PLACE" : TOKEN_IGNORE,
|
||||
"FACT" : TOKEN_FACT,
|
||||
}
|
||||
|
@ -680,6 +680,9 @@ class GedcomWriter(UpdateCallback):
|
||||
self.__writeln(2, 'TYPE', val)
|
||||
else:
|
||||
self.__writeln(2, 'TYPE', str(event.get_type()))
|
||||
descr = event.get_description()
|
||||
if descr:
|
||||
self.__writeln(2, 'NOTE', "Description: " + descr)
|
||||
|
||||
self.dump_event_stats(event, event_ref)
|
||||
|
||||
@ -732,13 +735,11 @@ class GedcomWriter(UpdateCallback):
|
||||
|
||||
if name and name.strip():
|
||||
self.__writeln(1, name, value)
|
||||
elif value:
|
||||
self.__writeln(1, 'FACT', value)
|
||||
self.__writeln(2, 'TYPE', key)
|
||||
else:
|
||||
self.__writeln(1, 'EVEN')
|
||||
if value:
|
||||
self.__writeln(2, 'TYPE', "%s %s" % (key , value))
|
||||
else:
|
||||
self.__writeln(2, 'TYPE', key)
|
||||
|
||||
continue
|
||||
self.__write_note_references(attr.get_note_list(), 2)
|
||||
self.__write_source_references(attr.get_source_references(), 2)
|
||||
|
||||
@ -885,6 +886,9 @@ class GedcomWriter(UpdateCallback):
|
||||
the_type = str(event.get_type())
|
||||
if the_type:
|
||||
self.__writeln(2, 'TYPE', the_type)
|
||||
descr = event.get_description()
|
||||
if descr:
|
||||
self.__writeln(2, 'NOTE', "Description: " + descr)
|
||||
|
||||
self.dump_event_stats(event, event_ref)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user