diff --git a/ChangeLog b/ChangeLog index 1815abdcc..2db8c5bf9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,6 @@ 2006-08-20 Alex Roitman + * src/GrampsDb/_ReadGedcom.py (GedcomParser.__init__): Use config + setting to determine whether to set default source. * src/Config/_GrampsConfigKeys.py: Regenerate file. * src/GrampsCfg.py (add_behavior_panel): Use new key. * data/gramps.schemas.in: Add default-source key. diff --git a/src/GrampsDb/_ReadGedcom.py b/src/GrampsDb/_ReadGedcom.py index b350c07e4..ea30c29a5 100644 --- a/src/GrampsDb/_ReadGedcom.py +++ b/src/GrampsDb/_ReadGedcom.py @@ -55,6 +55,7 @@ log = logging.getLogger(".GedcomImport") #------------------------------------------------------------------------- import const import Errors +import Config import RelLib from DateHandler._DateParser import DateParser import NameDisplay @@ -69,9 +70,6 @@ from QuestionDialog import ErrorDialog, WarningDialog from _GrampsDbBase import EVENT_KEY from BasicUtils import UpdateCallback -# FIXME: This needs soon to become a preference setting -use_def_src = True - #------------------------------------------------------------------------- # # Address/Place constants @@ -238,9 +236,7 @@ def import2(database, filename, callback, codeset, use_trans): use_trans = False try: - t = time.time() close = g.parse_gedcom_file(use_trans) - print time.time() - t except IOError,msg: errmsg = _("%s could not be opened\n") % filename ErrorDialog(errmsg,str(msg)) @@ -514,7 +510,8 @@ class GedcomParser(UpdateCallback): self.added = set() self.gedmap = GedcomInfoDB() self.gedsource = self.gedmap.get_from_source_tag('GEDCOM 5.5') - if use_def_src: + self.use_def_src = Config.get(Config.DEFAULT_SOURCE) + if self.use_def_src: self.def_src = RelLib.Source() fname = os.path.basename(filename).split('\\')[-1] self.def_src.set_title(_("Import from %s") % unicode(fname)) @@ -848,7 +845,7 @@ class GedcomParser(UpdateCallback): try: self.parse_header() self.parse_submitter() - if use_def_src: + if self.use_def_src: self.db.add_source(self.def_src,self.trans) self.parse_record() self.parse_trailer() @@ -895,7 +892,7 @@ class GedcomParser(UpdateCallback): if self.level_is_finished(matches,level): break elif matches[1] == TOKEN_NAME: - if use_def_src: + if self.use_def_src: self.def_src.set_author(matches[2]) elif matches[1] == TOKEN_ADDR: self.ignore_sub_junk(level+1) @@ -1316,7 +1313,7 @@ class GedcomParser(UpdateCallback): self.db.commit_person(child, self.trans) # add default reference if no reference exists - if use_def_src and len(self.family.get_source_references()) == 0: + if self.use_def_src and len(self.family.get_source_references()) == 0: sref = RelLib.SourceRef() sref.set_reference_handle(self.def_src.handle) self.family.add_source_reference(sref) @@ -1554,7 +1551,7 @@ class GedcomParser(UpdateCallback): # Add the default reference if no source has found - if use_def_src and len(self.media.get_source_references()) == 0: + if self.use_def_src and len(self.media.get_source_references()) == 0: sref = RelLib.SourceRef() sref.set_reference_handle(self.def_src.handle) self.media.add_source_reference(sref) @@ -1625,7 +1622,7 @@ class GedcomParser(UpdateCallback): func(matches, state) # Add the default reference if no source has found - if use_def_src and len(self.person.get_source_references()) == 0: + if self.use_def_src and len(self.person.get_source_references()) == 0: sref = RelLib.SourceRef() sref.set_reference_handle(self.def_src.handle) self.person.add_source_reference(sref) @@ -2148,15 +2145,15 @@ class GedcomParser(UpdateCallback): elif matches[1] == TOKEN_NAME: pass elif matches[1] == TOKEN_VERS: - if use_def_src: + if self.use_def_src: self.def_src.set_data_item('Generated by',"%s %s" % (genby,matches[2])) elif matches[1] == TOKEN_FILE: - if use_def_src: + if self.use_def_src: filename = os.path.basename(matches[2]).split('\\')[-1] self.def_src.set_title(_("Import from %s") % filename) elif matches[1] == TOKEN_COPR: - if use_def_src: + if self.use_def_src: self.def_src.set_publication_info(matches[2]) elif matches[1] == TOKEN_SUBM: self.parse_subm(2) @@ -2182,10 +2179,10 @@ class GedcomParser(UpdateCallback): elif matches[1] == TOKEN_DATE: date = self.parse_date(2) date.date = matches[2] - if use_def_src: + if self.use_def_src: self.def_src.set_data_item('Creation date',matches[2]) elif matches[1] == TOKEN_NOTE: - if use_def_src: + if self.use_def_src: note = self.parse_note(matches,self.def_src,2,'') elif matches[1] == TOKEN_UNKNOWN: self.ignore_sub_junk(2) @@ -2199,7 +2196,7 @@ class GedcomParser(UpdateCallback): if self.level_is_finished(matches, level): break elif matches[1] == TOKEN_NAME: - if use_def_src: + if self.use_def_src: self.def_src.set_author(matches[2]) else: self.ignore_sub_junk(2)