From 1c55edca96d5db761f8546b36ac420d68d8c6a28 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Mon, 19 Feb 2007 22:50:09 +0000 Subject: [PATCH] svn: r8173 --- src/DisplayTabs/_NoteTab.py | 3 +++ src/GrampsDbUtils/_GedcomParse.py | 43 +++++++++++++++++++++++++++++++ src/GrampsDbUtils/_ReadGedcom.py | 6 ++++- 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/DisplayTabs/_NoteTab.py b/src/DisplayTabs/_NoteTab.py index cdc7e5b34..de87a4aa4 100644 --- a/src/DisplayTabs/_NoteTab.py +++ b/src/DisplayTabs/_NoteTab.py @@ -143,6 +143,9 @@ class NoteTab(GrampsTab): hbox.pack_start(button, False) else: hbox.pack_start(gtk.VSeparator(), False) + hbox.pack_start(gtk.Label(_('Additional Notes:')),False) + self.menu = gtk.ComboBox() + hbox.pack_start(self.menu, True) if self.note_obj: self.empty = False diff --git a/src/GrampsDbUtils/_GedcomParse.py b/src/GrampsDbUtils/_GedcomParse.py index 38d9b46ef..87bc01bb5 100644 --- a/src/GrampsDbUtils/_GedcomParse.py +++ b/src/GrampsDbUtils/_GedcomParse.py @@ -263,6 +263,49 @@ CONT_RE = re.compile(r"\s*\d+\s+CONT\s?(.*)$") CONC_RE = re.compile(r"\s*\d+\s+CONC\s?(.*)$") PERSON_RE = re.compile(r"\s*\d+\s+\@(\S+)\@\s+INDI(.*)$") +class StageOne: + def __init__(self, ifile): + self.ifile = ifile + self.famc = {} + self.fams = {} + self.enc = "" + + def parse(self): + current = "" + for line in self.ifile: + data = line.split(None,2) + [''] + (level, key, value) = data[:3] + value = value.strip() + level = int(level) + key = key.strip() + + if level == 0 and value == "FAM": + current = key.strip() + current = current[1:-1] + elif key in ("HUSB", "WIFE") and value[0] == '@': + value = value[1:-1] + if self.fams.has_key(current): + self.fams[current].append(value) + else: + self.fams[current] = [value] + elif key == "CHIL" and value[0] == '@': + value = value[1:-1] + if self.famc.has_key(current): + self.famc[current].append(value) + else: + self.famc[current] = [value] + elif key == 'CHAR': + self.enc = value + + def get_famc_map(self): + return self.famc + + def get_fams_map(self): + return self.fams + + def get_encoding(self): + return self.enc + #------------------------------------------------------------------------- # # diff --git a/src/GrampsDbUtils/_ReadGedcom.py b/src/GrampsDbUtils/_ReadGedcom.py index 154c9fae0..e613a01c3 100644 --- a/src/GrampsDbUtils/_ReadGedcom.py +++ b/src/GrampsDbUtils/_ReadGedcom.py @@ -26,7 +26,7 @@ import os import gtk import Errors -from _GedcomParse import GedcomParser, NoteParser +from _GedcomParse import GedcomParser, NoteParser, StageOne from QuestionDialog import ErrorDialog from bsddb import db @@ -73,6 +73,10 @@ def import2(database, filename, callback, code_set, use_trans): # add some checking here try: ifile = open(filename,"rU") + np = StageOne(ifile) + np.parse() + print np.get_encoding() + ifile.seek(0) np = NoteParser(ifile, False, code_set) ifile.seek(0) gedparse = GedcomParser(database, ifile, filename, callback, code_set,