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