Make exclusion of unlinked records optional
svn: r10883
This commit is contained in:
parent
96c1d044f3
commit
97170b5251
@ -2,6 +2,7 @@
|
|||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2006-2007 Donald N. Allingham
|
# Copyright (C) 2006-2007 Donald N. Allingham
|
||||||
|
# Copyright (C) 2008 Gary Burton
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -53,6 +54,7 @@ file, and provide a default value according to the value's type.
|
|||||||
|
|
||||||
EXPORT_NO_PRIVATE = ('export', 'no-private', 0)
|
EXPORT_NO_PRIVATE = ('export', 'no-private', 0)
|
||||||
EXPORT_RESTRICT = ('export', 'restrict-living', 0)
|
EXPORT_RESTRICT = ('export', 'restrict-living', 0)
|
||||||
|
EXPORT_NO_UNLINKED = ('export', 'no-unlinked', 0)
|
||||||
DEFAULT_SOURCE = ('preferences', 'default-source', 0)
|
DEFAULT_SOURCE = ('preferences', 'default-source', 0)
|
||||||
RELATION_SHADE = ('preferences', 'relation-shade', 0)
|
RELATION_SHADE = ('preferences', 'relation-shade', 0)
|
||||||
ONLINE_MAPS = ('preferences', 'online-maps', 0)
|
ONLINE_MAPS = ('preferences', 'online-maps', 0)
|
||||||
@ -281,6 +283,7 @@ default_value = {
|
|||||||
OWNER_WARN : False,
|
OWNER_WARN : False,
|
||||||
EXPORT_NO_PRIVATE : True,
|
EXPORT_NO_PRIVATE : True,
|
||||||
EXPORT_RESTRICT : True,
|
EXPORT_RESTRICT : True,
|
||||||
|
EXPORT_NO_UNLINKED : True,
|
||||||
DATE_BEFORE_RANGE : 10,
|
DATE_BEFORE_RANGE : 10,
|
||||||
DATE_AFTER_RANGE : 10,
|
DATE_AFTER_RANGE : 10,
|
||||||
DATE_ABOUT_RANGE : 10,
|
DATE_ABOUT_RANGE : 10,
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007-2008 Donald N. Allingham
|
# Copyright (C) 2007-2008 Donald N. Allingham
|
||||||
|
# Copyright (C) 2008 Gary Burton
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -57,11 +58,12 @@ class WriterOptionBox:
|
|||||||
self.cfilter = None
|
self.cfilter = None
|
||||||
self.restrict_check = None
|
self.restrict_check = None
|
||||||
self.private_check = None
|
self.private_check = None
|
||||||
|
self.unlinked_check = None
|
||||||
self.filter_obj = None
|
self.filter_obj = None
|
||||||
|
|
||||||
def get_option_box(self):
|
def get_option_box(self):
|
||||||
"""Build up a gtk.Table that contains the standard options."""
|
"""Build up a gtk.Table that contains the standard options."""
|
||||||
table = gtk.Table(3, 2)
|
table = gtk.Table(4, 2)
|
||||||
|
|
||||||
self.filter_obj = gtk.ComboBox()
|
self.filter_obj = gtk.ComboBox()
|
||||||
label = gtk.Label(_('Filt_er'))
|
label = gtk.Label(_('Filt_er'))
|
||||||
@ -72,9 +74,12 @@ class WriterOptionBox:
|
|||||||
_('_Do not include records marked private'))
|
_('_Do not include records marked private'))
|
||||||
self.restrict_check = gtk.CheckButton(
|
self.restrict_check = gtk.CheckButton(
|
||||||
_('_Restrict data on living people'))
|
_('_Restrict data on living people'))
|
||||||
|
self.unlinked_check = gtk.CheckButton(
|
||||||
|
_('_Do not include unlinked records'))
|
||||||
|
|
||||||
self.private_check.set_active(Config.get(Config.EXPORT_NO_PRIVATE))
|
self.private_check.set_active(Config.get(Config.EXPORT_NO_PRIVATE))
|
||||||
self.restrict_check.set_active(Config.get(Config.EXPORT_RESTRICT))
|
self.restrict_check.set_active(Config.get(Config.EXPORT_RESTRICT))
|
||||||
|
self.unlinked_check.set_active(Config.get(Config.EXPORT_NO_UNLINKED))
|
||||||
|
|
||||||
table.set_border_width(12)
|
table.set_border_width(12)
|
||||||
table.set_row_spacings(6)
|
table.set_row_spacings(6)
|
||||||
@ -83,6 +88,7 @@ class WriterOptionBox:
|
|||||||
table.attach(self.filter_obj, 1, 2, 0, 1, yoptions=0)
|
table.attach(self.filter_obj, 1, 2, 0, 1, yoptions=0)
|
||||||
table.attach(self.private_check, 1, 2, 1, 2, yoptions=0)
|
table.attach(self.private_check, 1, 2, 1, 2, yoptions=0)
|
||||||
table.attach(self.restrict_check, 1, 2, 2, 3, yoptions=0)
|
table.attach(self.restrict_check, 1, 2, 2, 3, yoptions=0)
|
||||||
|
table.attach(self.unlinked_check, 1, 2, 3, 4, yoptions=0)
|
||||||
|
|
||||||
entire_db = GenericFilter()
|
entire_db = GenericFilter()
|
||||||
entire_db.set_name(_("Entire Database"))
|
entire_db.set_name(_("Entire Database"))
|
||||||
@ -138,13 +144,16 @@ class WriterOptionBox:
|
|||||||
private = privacy requested
|
private = privacy requested
|
||||||
restrict = restrict information on living peoplel
|
restrict = restrict information on living peoplel
|
||||||
cfitler = return the GenericFilter selected
|
cfitler = return the GenericFilter selected
|
||||||
|
unlinked = restrict unlinked records
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self.restrict = self.restrict_check.get_active()
|
self.restrict = self.restrict_check.get_active()
|
||||||
self.private = self.private_check.get_active()
|
self.private = self.private_check.get_active()
|
||||||
|
self.unlinked = self.unlinked_check.get_active()
|
||||||
|
|
||||||
Config.set(Config.EXPORT_NO_PRIVATE, self.private)
|
Config.set(Config.EXPORT_NO_PRIVATE, self.private)
|
||||||
Config.set(Config.EXPORT_RESTRICT, self.restrict)
|
Config.set(Config.EXPORT_RESTRICT, self.restrict)
|
||||||
|
Config.set(Config.EXPORT_NO_UNLINKED, self.unlinked)
|
||||||
Config.sync()
|
Config.sync()
|
||||||
|
|
||||||
model = self.filter_obj.get_model()
|
model = self.filter_obj.get_model()
|
||||||
|
@ -314,6 +314,10 @@ class GedcomWriter(BasicUtils.UpdateCallback):
|
|||||||
self.cmd_line = cmd_line
|
self.cmd_line = cmd_line
|
||||||
self.dirname = None
|
self.dirname = None
|
||||||
self.gedcom_file = None
|
self.gedcom_file = None
|
||||||
|
|
||||||
|
# The number of different stages other than any of the optional filters
|
||||||
|
# which the write_gedcom_file method will call.
|
||||||
|
self.progress_cnt = 5
|
||||||
|
|
||||||
self.setup(option_box)
|
self.setup(option_box)
|
||||||
|
|
||||||
@ -324,15 +328,36 @@ class GedcomWriter(BasicUtils.UpdateCallback):
|
|||||||
to apply proxy databases.
|
to apply proxy databases.
|
||||||
"""
|
"""
|
||||||
if option_box:
|
if option_box:
|
||||||
|
|
||||||
option_box.parse_options()
|
option_box.parse_options()
|
||||||
|
|
||||||
|
# Increment the progress count for each filter type chosen
|
||||||
|
if option_box.private:
|
||||||
|
self.progress_cnt += 1
|
||||||
|
|
||||||
|
if option_box.restrict:
|
||||||
|
self.progress_cnt += 1
|
||||||
|
|
||||||
|
if not option_box.cfilter.is_empty():
|
||||||
|
self.progress_cnt += 1
|
||||||
|
|
||||||
|
if option_box.unlinked:
|
||||||
|
self.progress_cnt += 1
|
||||||
|
|
||||||
|
self.set_total(self.progress_cnt)
|
||||||
|
self.progress_cnt = 0
|
||||||
|
|
||||||
# If the private flag is set, apply the PrivateProxyDb
|
# If the private flag is set, apply the PrivateProxyDb
|
||||||
if option_box.private:
|
if option_box.private:
|
||||||
|
self.reset(_("Filtering private data"))
|
||||||
|
self.progress_cnt += 1
|
||||||
|
self.update(self.progress_cnt)
|
||||||
self.dbase = gen.proxy.PrivateProxyDb(self.dbase)
|
self.dbase = gen.proxy.PrivateProxyDb(self.dbase)
|
||||||
|
|
||||||
# If the restrict flag is set, apply the LivingProxyDb
|
# If the restrict flag is set, apply the LivingProxyDb
|
||||||
if option_box.restrict:
|
if option_box.restrict:
|
||||||
|
self.reset(_("Filtering living persons"))
|
||||||
|
self.progress_cnt += 1
|
||||||
|
self.update(self.progress_cnt)
|
||||||
self.dbase = gen.proxy.LivingProxyDb(
|
self.dbase = gen.proxy.LivingProxyDb(
|
||||||
self.dbase,
|
self.dbase,
|
||||||
gen.proxy.LivingProxyDb.MODE_INCLUDE_LAST_NAME_ONLY)
|
gen.proxy.LivingProxyDb.MODE_INCLUDE_LAST_NAME_ONLY)
|
||||||
@ -340,13 +365,18 @@ class GedcomWriter(BasicUtils.UpdateCallback):
|
|||||||
# If the filter returned by cfilter is not empty, apply the
|
# If the filter returned by cfilter is not empty, apply the
|
||||||
# FilterProxyDb
|
# FilterProxyDb
|
||||||
if not option_box.cfilter.is_empty():
|
if not option_box.cfilter.is_empty():
|
||||||
|
self.reset(_("Applying selected filter"))
|
||||||
|
self.progress_cnt += 1
|
||||||
|
self.update(self.progress_cnt)
|
||||||
self.dbase = gen.proxy.FilterProxyDb(
|
self.dbase = gen.proxy.FilterProxyDb(
|
||||||
self.dbase, option_box.cfilter)
|
self.dbase, option_box.cfilter)
|
||||||
|
|
||||||
# Apply the ReferencedProxyDb to remove any objects not referenced
|
# Apply the ReferencedProxyDb to remove any objects not referenced
|
||||||
# after any of the other proxies have been applied
|
# after any of the other proxies have been applied
|
||||||
if option_box.private or option_box.restrict \
|
if option_box.unlinked:
|
||||||
or not option_box.cfilter.is_empty():
|
self.reset(_("Filtering unlinked records"))
|
||||||
|
self.progress_cnt += 1
|
||||||
|
self.update(self.progress_cnt)
|
||||||
self.dbase = gen.proxy.ReferencedProxyDb(self.dbase)
|
self.dbase = gen.proxy.ReferencedProxyDb(self.dbase)
|
||||||
|
|
||||||
def write_gedcom_file(self, filename):
|
def write_gedcom_file(self, filename):
|
||||||
@ -514,25 +544,20 @@ class GedcomWriter(BasicUtils.UpdateCallback):
|
|||||||
people will be confused when the progress bar is idle.
|
people will be confused when the progress bar is idle.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
self.reset(_("Writing individuals"))
|
||||||
|
self.progress_cnt += 1
|
||||||
|
self.update(self.progress_cnt)
|
||||||
phandles = self.dbase.get_person_handles()
|
phandles = self.dbase.get_person_handles()
|
||||||
|
|
||||||
hcnt = len(phandles)
|
|
||||||
|
|
||||||
self.reset(_("Sorting"))
|
|
||||||
self.set_total(hcnt)
|
|
||||||
sorted_list = []
|
sorted_list = []
|
||||||
for handle in phandles:
|
for handle in phandles:
|
||||||
person = self.dbase.get_person_from_handle(handle)
|
person = self.dbase.get_person_from_handle(handle)
|
||||||
data = (person.get_gramps_id(), handle)
|
data = (person.get_gramps_id(), handle)
|
||||||
sorted_list.append(data)
|
sorted_list.append(data)
|
||||||
self.update()
|
|
||||||
sorted_list.sort()
|
sorted_list.sort()
|
||||||
|
|
||||||
self.set_total(hcnt + len(self.dbase.get_family_handles()))
|
|
||||||
self.reset(_("Writing"))
|
|
||||||
for data in sorted_list:
|
for data in sorted_list:
|
||||||
self.__person(self.dbase.get_person_from_handle(data[1]))
|
self.__person(self.dbase.get_person_from_handle(data[1]))
|
||||||
self.update()
|
|
||||||
|
|
||||||
def __person(self, person):
|
def __person(self, person):
|
||||||
"""
|
"""
|
||||||
@ -861,7 +886,9 @@ class GedcomWriter(BasicUtils.UpdateCallback):
|
|||||||
"""
|
"""
|
||||||
Write out the list of families, sorting by GRAMPS ID.
|
Write out the list of families, sorting by GRAMPS ID.
|
||||||
"""
|
"""
|
||||||
|
self.reset(_("Writing families"))
|
||||||
|
self.progress_cnt += 1
|
||||||
|
self.update(self.progress_cnt)
|
||||||
# generate a list of (GRAMPS_ID, HANDLE) pairs. This list
|
# generate a list of (GRAMPS_ID, HANDLE) pairs. This list
|
||||||
# can then be sorted by the sort routine, which will use the
|
# can then be sorted by the sort routine, which will use the
|
||||||
# first value of the tuple as the sort key.
|
# first value of the tuple as the sort key.
|
||||||
@ -901,7 +928,6 @@ class GedcomWriter(BasicUtils.UpdateCallback):
|
|||||||
self.__photos(family.get_media_list(), 1)
|
self.__photos(family.get_media_list(), 1)
|
||||||
self.__note_references(family.get_note_list(), 1)
|
self.__note_references(family.get_note_list(), 1)
|
||||||
self.__change(family.get_change_time(), 1)
|
self.__change(family.get_change_time(), 1)
|
||||||
self.update()
|
|
||||||
|
|
||||||
def __family_child_list(self, child_ref_list):
|
def __family_child_list(self, child_ref_list):
|
||||||
"""
|
"""
|
||||||
@ -1023,6 +1049,9 @@ class GedcomWriter(BasicUtils.UpdateCallback):
|
|||||||
"""
|
"""
|
||||||
Write out the list of sources, sorting by GRAMPS ID.
|
Write out the list of sources, sorting by GRAMPS ID.
|
||||||
"""
|
"""
|
||||||
|
self.reset(_("Writing sources"))
|
||||||
|
self.progress_cnt += 1
|
||||||
|
self.update(self.progress_cnt)
|
||||||
sorted_list = sort_handles_by_id(self.dbase.get_source_handles(),
|
sorted_list = sort_handles_by_id(self.dbase.get_source_handles(),
|
||||||
self.dbase.get_source_from_handle)
|
self.dbase.get_source_from_handle)
|
||||||
|
|
||||||
@ -1054,6 +1083,9 @@ class GedcomWriter(BasicUtils.UpdateCallback):
|
|||||||
"""
|
"""
|
||||||
Write out the list of notes, sorting by GRAMPS ID.
|
Write out the list of notes, sorting by GRAMPS ID.
|
||||||
"""
|
"""
|
||||||
|
self.reset(_("Writing notes"))
|
||||||
|
self.progress_cnt += 1
|
||||||
|
self.update(self.progress_cnt)
|
||||||
sorted_list = sort_handles_by_id(self.dbase.get_note_handles(),
|
sorted_list = sort_handles_by_id(self.dbase.get_note_handles(),
|
||||||
self.dbase.get_note_from_handle)
|
self.dbase.get_note_from_handle)
|
||||||
|
|
||||||
@ -1088,6 +1120,9 @@ class GedcomWriter(BasicUtils.UpdateCallback):
|
|||||||
+1 RIN <AUTOMATED_RECORD_ID> {0:1}
|
+1 RIN <AUTOMATED_RECORD_ID> {0:1}
|
||||||
+1 <<CHANGE_DATE>> {0:1}
|
+1 <<CHANGE_DATE>> {0:1}
|
||||||
"""
|
"""
|
||||||
|
self.reset(_("Writing repositories"))
|
||||||
|
self.progress_cnt += 1
|
||||||
|
self.update(self.progress_cnt)
|
||||||
sorted_list = sort_handles_by_id(self.dbase.get_repository_handles(),
|
sorted_list = sort_handles_by_id(self.dbase.get_repository_handles(),
|
||||||
self.dbase.get_repository_from_handle)
|
self.dbase.get_repository_from_handle)
|
||||||
|
|
||||||
@ -1460,17 +1495,20 @@ def export_data(database, filename, person, option_box, callback=None):
|
|||||||
External interface used to register with the plugin system.
|
External interface used to register with the plugin system.
|
||||||
"""
|
"""
|
||||||
ret = False
|
ret = False
|
||||||
try:
|
ged_write = GedcomWriter(database, person, 0,
|
||||||
ged_write = GedcomWriter(database, person, 0,
|
option_box, callback)
|
||||||
option_box, callback)
|
ret = ged_write.write_gedcom_file(filename)
|
||||||
ret = ged_write.write_gedcom_file(filename)
|
#try:
|
||||||
except IOError, msg:
|
# ged_write = GedcomWriter(database, person, 0,
|
||||||
msg2 = _("Could not create %s") % filename
|
# option_box, callback)
|
||||||
ErrorDialog(msg2, str(msg))
|
# ret = ged_write.write_gedcom_file(filename)
|
||||||
except Errors.DatabaseError, msg:
|
#except IOError, msg:
|
||||||
ErrorDialog(_("Export failed"), str(msg))
|
# msg2 = _("Could not create %s") % filename
|
||||||
except:
|
# ErrorDialog(msg2, str(msg))
|
||||||
ErrorDialog(_("Could not create %s") % filename)
|
#except Errors.DatabaseError, msg:
|
||||||
|
# ErrorDialog(_("Export failed"), str(msg))
|
||||||
|
#except:
|
||||||
|
# ErrorDialog(_("Could not create %s") % filename)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
@ -81,13 +81,10 @@ def export_data(database, filename, person, option_box, callback=None):
|
|||||||
|
|
||||||
option_box.parse_options()
|
option_box.parse_options()
|
||||||
|
|
||||||
restrict = option_box.restrict
|
if option_box.private:
|
||||||
private = option_box.private
|
|
||||||
|
|
||||||
if private:
|
|
||||||
database = gen.proxy.PrivateProxyDb(database)
|
database = gen.proxy.PrivateProxyDb(database)
|
||||||
|
|
||||||
if restrict:
|
if option_box.restrict:
|
||||||
database = gen.proxy.LivingProxyDb(
|
database = gen.proxy.LivingProxyDb(
|
||||||
database, gen.proxy.LivingProxyDb.MODE_INCLUDE_LAST_NAME_ONLY)
|
database, gen.proxy.LivingProxyDb.MODE_INCLUDE_LAST_NAME_ONLY)
|
||||||
|
|
||||||
@ -96,8 +93,7 @@ def export_data(database, filename, person, option_box, callback=None):
|
|||||||
|
|
||||||
# Apply the ReferencedProxyDb to remove any objects not referenced
|
# Apply the ReferencedProxyDb to remove any objects not referenced
|
||||||
# after any of the other proxies have been applied
|
# after any of the other proxies have been applied
|
||||||
if option_box.private or option_box.restrict \
|
if option_box.unlinked:
|
||||||
or not option_box.cfilter.is_empty():
|
|
||||||
database = gen.proxy.ReferencedProxyDb(database)
|
database = gen.proxy.ReferencedProxyDb(database)
|
||||||
|
|
||||||
g = XmlWriter(database, callback, 0, compress)
|
g = XmlWriter(database, callback, 0, compress)
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#
|
#
|
||||||
# Copyright (C) 2000-2008 Donald N. Allingham
|
# Copyright (C) 2000-2008 Donald N. Allingham
|
||||||
# Copyright (C) 2008 Brian G. Matherly
|
# Copyright (C) 2008 Brian G. Matherly
|
||||||
|
# Copyright (C) 2008 Gary Burton
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -70,19 +71,21 @@ import Utils
|
|||||||
def writeData(database, filename, person, option_box, callback=None):
|
def writeData(database, filename, person, option_box, callback=None):
|
||||||
option_box.parse_options()
|
option_box.parse_options()
|
||||||
|
|
||||||
restrict = option_box.restrict
|
if option_box.private:
|
||||||
private = option_box.private
|
|
||||||
|
|
||||||
if private:
|
|
||||||
database = gen.proxy.PrivateProxyDb(database)
|
database = gen.proxy.PrivateProxyDb(database)
|
||||||
|
|
||||||
if restrict:
|
if option_box.restrict:
|
||||||
database = gen.proxy.LivingProxyDb(
|
database = gen.proxy.LivingProxyDb(
|
||||||
database, gen.proxy.LivingProxyDb.MODE_INCLUDE_LAST_NAME_ONLY)
|
database, gen.proxy.LivingProxyDb.MODE_INCLUDE_LAST_NAME_ONLY)
|
||||||
|
|
||||||
if not option_box.cfilter.is_empty():
|
if not option_box.cfilter.is_empty():
|
||||||
database = gen.proxy.FilterProxyDb(database, option_box.cfilter)
|
database = gen.proxy.FilterProxyDb(database, option_box.cfilter)
|
||||||
|
|
||||||
|
# Apply the ReferencedProxyDb to remove any objects not referenced
|
||||||
|
# after any of the other proxies have been applied
|
||||||
|
if option_box.unlinked:
|
||||||
|
database = gen.proxy.ReferencedProxyDb(database)
|
||||||
|
|
||||||
writer = PackageWriter(database, filename, callback)
|
writer = PackageWriter(database, filename, callback)
|
||||||
return writer.export()
|
return writer.export()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user