0007014: Errors handling owner/submitter information in GEDCOM files.
Only import researcher from GEDCOM or XML if the family tree was originally empty.
This commit is contained in:
parent
55c7becb68
commit
3b5e3cbe6e
@ -297,7 +297,10 @@ class CLIManager(object):
|
||||
# apply preferred researcher if loaded file has none
|
||||
res = self.dbstate.db.get_researcher()
|
||||
owner = get_researcher()
|
||||
if res.get_name() == "" and owner.get_name() != "":
|
||||
# If the DB Owner Info is empty and
|
||||
# [default] Researcher is not empty and
|
||||
# database is empty, then copy default researcher to DB owner
|
||||
if res.is_empty() and not owner.is_empty() and self.dbstate.db.is_empty():
|
||||
self.dbstate.db.set_researcher(owner)
|
||||
|
||||
name_displayer.set_name_format(self.dbstate.db.name_formats)
|
||||
|
@ -1014,6 +1014,18 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
"""
|
||||
return self.get_number_of_records(self.tag_map)
|
||||
|
||||
def is_empty(self):
|
||||
"""
|
||||
Return true if there are no [primary] records in the database
|
||||
"""
|
||||
for obj_map in [self.person_map, self.family_map, self.event_map,
|
||||
self.place_map, self.source_map, self.citation_map,
|
||||
self.media_map, self.repository_map, self.note_map,
|
||||
self.tag_map]:
|
||||
if self.get_number_of_records(obj_map) > 0:
|
||||
return False
|
||||
return True
|
||||
|
||||
def all_handles(self, table):
|
||||
""" return all the keys of a database table
|
||||
|
||||
|
@ -166,3 +166,10 @@ class Researcher(LocationBase):
|
||||
['name', 'addr', 'locality', 'city', 'state',
|
||||
'country', 'postal', 'phone', 'email']
|
||||
]
|
||||
|
||||
def is_empty(self):
|
||||
for attr in ['name', 'addr', 'locality', 'city', 'state',
|
||||
'country', 'postal', 'phone', 'email']:
|
||||
if getattr(self, attr) != "":
|
||||
return False
|
||||
return True
|
||||
|
@ -517,6 +517,10 @@ class GrampsParser(UpdateCallback):
|
||||
self.replace_import_handle = (self.db.get_number_of_people() > 0 and
|
||||
not LOG.isEnabledFor(logging.DEBUG))
|
||||
|
||||
# Similarly, if the data is imported into an empty family tree, we also
|
||||
# import the Researcher; if the tree was not empty, the existing
|
||||
# Researcher is retained
|
||||
self.import_researcher = self.db.is_empty()
|
||||
self.ord = None
|
||||
self.objref = None
|
||||
self.object = None
|
||||
@ -955,7 +959,10 @@ class GrampsParser(UpdateCallback):
|
||||
# Register new formats
|
||||
name_displayer.set_name_format(self.db.name_formats)
|
||||
|
||||
self.db.set_researcher(self.owner)
|
||||
# If the database was originally empty we update the researcher from
|
||||
# the XML (or initialised to no researcher)
|
||||
if self.import_researcher:
|
||||
self.db.set_researcher(self.owner)
|
||||
if self.home is not None:
|
||||
person = self.db.get_person_from_handle(self.home)
|
||||
self.db.set_default_person_handle(person.handle)
|
||||
|
@ -1868,6 +1868,7 @@ class GedcomParser(UpdateCallback):
|
||||
self.number_of_errors = 0
|
||||
self.maxpeople = stage_one.get_person_count()
|
||||
self.dbase = dbase
|
||||
self.import_researcher = self.dbase.is_empty()
|
||||
self.emapper = IdFinder(dbase.get_gramps_ids(EVENT_KEY),
|
||||
dbase.event_prefix)
|
||||
self.famc_map = stage_one.get_famc_map()
|
||||
@ -3317,7 +3318,7 @@ class GedcomParser(UpdateCallback):
|
||||
self.__parse_level(state, self.subm_parse_tbl, self.__undefined)
|
||||
# If this is the submitter that we were told about in the HEADer, then
|
||||
# we will need to update the researcher
|
||||
if line.token_text == self.subm:
|
||||
if line.token_text == self.subm and self.import_researcher:
|
||||
self.dbase.set_researcher(state.res)
|
||||
|
||||
submitter_name = _("SUBM (Submitter): @%s@") % line.token_text
|
||||
|
Loading…
Reference in New Issue
Block a user