From 0cc35fe527ae74ae94cdd7251780449c8be9804c Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sun, 23 Sep 2001 21:21:13 +0000 Subject: [PATCH] Fixed gedcom export/import for long titles svn: r424 --- gramps/src/ReadXML.py | 4 ++-- gramps/src/plugins/ReadGedcom.py | 5 ++++- gramps/src/plugins/WriteGedcom.py | 14 ++++++++++++-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/gramps/src/ReadXML.py b/gramps/src/ReadXML.py index 53ce062ef..ae47ebad0 100644 --- a/gramps/src/ReadXML.py +++ b/gramps/src/ReadXML.py @@ -186,7 +186,7 @@ if __name__ == "__main__": database = RelDataBase() t1 = time.time() - #profile.run('loadData(database, sys.argv[1])') - loadData(database,sys.argv[1]) + profile.run('loadData(database, sys.argv[1])') + #loadData(database,sys.argv[1]) t2 = time.time() print t2-t1 diff --git a/gramps/src/plugins/ReadGedcom.py b/gramps/src/plugins/ReadGedcom.py index 0f543c1bd..154f456b4 100644 --- a/gramps/src/plugins/ReadGedcom.py +++ b/gramps/src/plugins/ReadGedcom.py @@ -228,6 +228,7 @@ class GedcomParser: match = lineRE.match(line) if not match: raise GedcomParser.SyntaxError, self.lines[self.index] + self.index = self.index + 1 return match.groups() @@ -335,7 +336,9 @@ class GedcomParser: elif matches[1] == "DATA" or matches[1] == "TEXT": self.ignore_sub_junk(2) 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": self.source.setAuthor(matches[2] + self.parse_continue_data(2)) elif matches[1] == "PUBL": diff --git a/gramps/src/plugins/WriteGedcom.py b/gramps/src/plugins/WriteGedcom.py index c98a148ed..e3477dc64 100644 --- a/gramps/src/plugins/WriteGedcom.py +++ b/gramps/src/plugins/WriteGedcom.py @@ -273,6 +273,17 @@ def dump_event_stats(g,event): if event.getSourceRef() != None: 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()) for source in source_list: - print source g.write("0 @S%s@ SOUR\n" % source.getId()) 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() != "": g.write("1 AUTH %s\n" % cnvtxt(source.getAuthor())) if source.getPubInfo() != "":