* src/ReadGedcom.py (parse_trailer): Catch EOF to warn about premature EOF only once; Always close file;

(parse_record): Properly catch premature EOF instead of unknown level 0 records; Support single line SOUR records;
(parse_address): Support PHON and NOTE, ignore _NAME.


svn: r4601
This commit is contained in:
Martin Hawlisch 2005-05-16 20:56:25 +00:00
parent 8165bf3974
commit e4e817de57
2 changed files with 21 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2005-05-16 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/ReadGedcom.py (parse_trailer): Catch EOF to warn about premature
EOF only once; Always close file; (parse_record): Properly catch
premature EOF instead of unknown level 0 records; Support single line
SOUR records; (parse_address): Support PHON and NOTE, ignore _NAME.
2005-05-16 Alex Roitman <shura@gramps-project.org>
* src/ansel_utf8.py: Convert to Unix end-of-line.

View File

@ -528,7 +528,7 @@ class GedcomParser:
def parse_trailer(self):
matches = self.get_next()
if matches[1] != "TRLR":
if matches[0] >= 0 and matches[1] != "TRLR":
self.barf(0)
self.f.close()
@ -654,6 +654,12 @@ class GedcomParser:
self.ignore_sub_junk(1)
elif matches[2] == "SOUR":
self.parse_source(matches[1],1)
elif matches[2].startswith("SOUR "):
# A source formatted in a single line, for example:
# 0 @S62@ SOUR This is the title of the source
source = self.find_or_create_source(matches[1][1:-1])
source.set_title( matches[2][5:])
self.db.commit_source(source, self.trans)
elif matches[2][0:4] == "NOTE":
if self.nmap.has_key(matches[1]):
noteobj = self.nmap[matches[1]]
@ -668,7 +674,7 @@ class GedcomParser:
# TODO: Add support for extended Locations.
# See: http://en.wiki.genealogy.net/index.php/Gedcom_5.5EL
self.ignore_sub_junk(1)
elif matches[0] < 1 or matches[1] == "TRLR":
elif matches[0] < 0 or matches[1] == "TRLR":
self.backup()
return
else:
@ -1296,8 +1302,14 @@ class GedcomParser:
address.set_postal_code(matches[2])
elif matches[1] == "CTRY":
address.set_country(matches[2])
elif matches[1] == "PHON":
address.set_phone(matches[2])
elif matches[1] == "NOTE":
note = self.parse_note(matches,address,level+1,note)
elif matches[1] == "_LOC":
pass # ignore unsupported extended location syntax
elif matches[1] == "_NAME":
pass # ignore
else:
self.barf(level+1)