Fixed gedcom export/import for long titles

svn: r424
This commit is contained in:
Don Allingham 2001-09-23 21:21:13 +00:00
parent d1b70cfad6
commit 0cc35fe527
3 changed files with 18 additions and 5 deletions

View File

@ -186,7 +186,7 @@ if __name__ == "__main__":
database = RelDataBase() database = RelDataBase()
t1 = time.time() t1 = time.time()
#profile.run('loadData(database, sys.argv[1])') profile.run('loadData(database, sys.argv[1])')
loadData(database,sys.argv[1]) #loadData(database,sys.argv[1])
t2 = time.time() t2 = time.time()
print t2-t1 print t2-t1

View File

@ -228,6 +228,7 @@ class GedcomParser:
match = lineRE.match(line) match = lineRE.match(line)
if not match: if not match:
raise GedcomParser.SyntaxError, self.lines[self.index] raise GedcomParser.SyntaxError, self.lines[self.index]
self.index = self.index + 1 self.index = self.index + 1
return match.groups() return match.groups()
@ -335,7 +336,9 @@ class GedcomParser:
elif matches[1] == "DATA" or matches[1] == "TEXT": elif matches[1] == "DATA" or matches[1] == "TEXT":
self.ignore_sub_junk(2) self.ignore_sub_junk(2)
elif matches[1] == "TITL": elif matches[1] == "TITL":
self.source.setTitle(matches[2] + self.parse_continue_data(2)) title = matches[2] + self.parse_continue_data(2)
title = string.replace(title,'\n',' ')
self.source.setTitle(title)
elif matches[1] == "AUTH": elif matches[1] == "AUTH":
self.source.setAuthor(matches[2] + self.parse_continue_data(2)) self.source.setAuthor(matches[2] + self.parse_continue_data(2))
elif matches[1] == "PUBL": elif matches[1] == "PUBL":

View File

@ -273,6 +273,17 @@ def dump_event_stats(g,event):
if event.getSourceRef() != None: if event.getSourceRef() != None:
write_source_ref(g,2,event.getSourceRef()) write_source_ref(g,2,event.getSourceRef())
def fmtline(text,limit,level):
new_text = []
text = cnvtxt(text)
while len(text) > limit:
new_text.append(text[0:limit-1])
text = text[limit:]
if len(text) > 0:
new_text.append(text)
app = "\n%d CONC " % (level+1)
return string.join(new_text,app)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# #
@ -543,10 +554,9 @@ def exportData(database, filename):
g.write("1 CHIL @I%s@\n" % person.getId()) g.write("1 CHIL @I%s@\n" % person.getId())
for source in source_list: for source in source_list:
print source
g.write("0 @S%s@ SOUR\n" % source.getId()) g.write("0 @S%s@ SOUR\n" % source.getId())
if source.getTitle() != "": if source.getTitle() != "":
g.write("1 TITL %s\n" % cnvtxt(source.getTitle())) g.write("1 TITL %s\n" % fmtline(source.getTitle(),248,1))
if source.getAuthor() != "": if source.getAuthor() != "":
g.write("1 AUTH %s\n" % cnvtxt(source.getAuthor())) g.write("1 AUTH %s\n" % cnvtxt(source.getAuthor()))
if source.getPubInfo() != "": if source.getPubInfo() != "":