2007-02-09 Don Allingham <don@gramps-project.org>

* src/plugins/Check.py: fix illegal family events
	* src/GrampsDbUtils/_GedcomParse.py: improve parsing
	* src/GrampsDbUtils/_GedcomLex.py: improve parsing
	* src/GrampsDbUtils/_GedTokens.py: improve parsing



svn: r8079
This commit is contained in:
Don Allingham 2007-02-09 23:16:57 +00:00
parent f845b6f887
commit da92a9431b
5 changed files with 503 additions and 412 deletions

View File

@ -1,3 +1,9 @@
2007-02-09 Don Allingham <don@gramps-project.org>
* src/plugins/Check.py: fix illegal family events
* src/GrampsDbUtils/_GedcomParse.py: improve parsing
* src/GrampsDbUtils/_GedcomLex.py: improve parsing
* src/GrampsDbUtils/_GedTokens.py: improve parsing
2007-02-08 Don Allingham <don@gramps-project.org>
* src/GrampsDbUtils/_GedcomLex.py: make more table driven
* src/GrampsDbUtils/_GedcomParse.py: added

View File

@ -133,6 +133,9 @@ TOKEN_AGNC = 113
TOKEN_RESN = 114
TOKEN_ID = 115
TOKEN_GEVENT = 116
TOKEN_RNOTE = 117
TOKEN_GATTR = 118
TOKEN_ATTR = 119
tokens = {
"HEAD" : TOKEN_HEAD, "MEDI" : TOKEN_MEDI,

View File

@ -88,7 +88,12 @@ for _val in familyConstantEvents.keys():
if _key != "":
ged2gramps[_key] = _val
ged2attr = {}
for _val in personalConstantAttributes.keys():
_key = personalConstantAttributes[_val]
if _key != "":
ged2attr[_key] = _val
#-------------------------------------------------------------------------
#
# GedLine
@ -187,7 +192,7 @@ class GedLine:
"""
Converts the data field to a RelLib token indicating the gender
"""
self.data = _sex_map.get(self.data,RelLib.Person.UNKNOWN)
self.data = _sex_map.get(self.data.strip(),RelLib.Person.UNKNOWN)
def calc_date(self):
"""
@ -205,7 +210,28 @@ class GedLine:
if token:
self.token = TOKEN_GEVENT
self.data = token
else:
token = ged2attr.get(self.token_text)
if token:
attr = RelLib.Attribute()
attr.set_value(self.data)
attr.set_type(token)
self.token = TOKEN_ATTR
self.data = attr
def calc_note(self):
d = self.data.strip()
if len(d) > 2 and d[0] == '@' and d[-1] == '@':
self.token = TOKEN_RNOTE
self.data = d[1:-1]
def calc_nchi(self):
attr = RelLib.Attribute()
attr.set_value(self.data)
attr.set_type(RelLib.AttributeType.NUM_CHILD)
self.data = attr
self.token = TOKEN_ATTR
def __repr__(self):
return "%d: %d (%d:%s) %s" % (self.line, self.level, self.token,
self.token_text, self.data)
@ -220,6 +246,8 @@ MAP_DATA = {
TOKEN_UNKNOWN : GedLine.calc_unknown,
TOKEN_DATE : GedLine.calc_date,
TOKEN_SEX : GedLine.calc_sex,
TOKEN_NOTE : GedLine.calc_note,
TOKEN_NCHI : GedLine.calc_nchi,
}
#-------------------------------------------------------------------------
@ -356,7 +384,7 @@ class Reader:
line = line.split(None,2) + ['']
val = line[2]
val = line[2].rstrip('\r\n')
try:
level = int(line[0])
@ -379,11 +407,12 @@ if __name__ == "__main__":
a = Reader(sys.argv[1])
while True:
line = a.readline()
#print line
print line
if not line: break
import Utils
Utils.profile(run)
# import Utils
# Utils.profile(run)
run()
print extract_date("20 JAN 2000")
print extract_date("EST 20 JAN 2000")

File diff suppressed because it is too large Load Diff

View File

@ -696,7 +696,10 @@ class CheckIntegrity:
if not event:
# The event referenced by the family
# does not exist in the database
family.get_event_list().remove(event_ref)
print family.gramps_id
nlist = [ x for x in family.get_event_ref_list() \
if x.ref != event_handle]
family.set_event_ref_list(nlist)
self.db.commit_family(family,self.trans)
self.invalid_events.append(key)
elif type(family.get_event_ref_list()) != list: