Reordering gramps's ids and privacy fixes for gedcom export
svn: r306
This commit is contained in:
80
gramps/src/plugins/ReorderIds.py
Normal file
80
gramps/src/plugins/ReorderIds.py
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
#
|
||||||
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
|
#
|
||||||
|
# Copyright (C) 2000 Donald N. Allingham
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
|
||||||
|
"Database Processing/Reorder gramps IDs"
|
||||||
|
|
||||||
|
import utils
|
||||||
|
import intl
|
||||||
|
|
||||||
|
_ = intl.gettext
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
def runTool(database,active_person,callback):
|
||||||
|
|
||||||
|
for prefix in ["xyzzytemporaryid%d", "I%d"] :
|
||||||
|
index = 0
|
||||||
|
pmap = database.getPersonMap()
|
||||||
|
for id in pmap.keys():
|
||||||
|
newid = prefix % index
|
||||||
|
person = pmap[id]
|
||||||
|
person.setId(newid)
|
||||||
|
pmap[newid] = person
|
||||||
|
del pmap[id]
|
||||||
|
index = index + 1
|
||||||
|
|
||||||
|
for prefix in ["xyzzytemporaryid%d", "F%d"] :
|
||||||
|
index = 0
|
||||||
|
pmap = database.getFamilyMap()
|
||||||
|
for id in pmap.keys():
|
||||||
|
newid = prefix % index
|
||||||
|
person = pmap[id]
|
||||||
|
person.setId(newid)
|
||||||
|
pmap[newid] = person
|
||||||
|
del pmap[id]
|
||||||
|
index = index + 1
|
||||||
|
|
||||||
|
for prefix in ["xyzzytemporaryid%d", "S%d"] :
|
||||||
|
index = 0
|
||||||
|
pmap = database.getSourceMap()
|
||||||
|
for id in pmap.keys():
|
||||||
|
newid = prefix % index
|
||||||
|
person = pmap[id]
|
||||||
|
person.setId(newid)
|
||||||
|
pmap[newid] = person
|
||||||
|
del pmap[id]
|
||||||
|
index = index + 1
|
||||||
|
|
||||||
|
utils.modified()
|
||||||
|
callback(1)
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
def get_description():
|
||||||
|
return _("Reorders the gramps IDs according to gramps' default rules.")
|
||||||
|
|
||||||
|
def get_name():
|
||||||
|
return _("Database Processing/Reorder gramps IDs")
|
@@ -194,11 +194,12 @@ def walk(person):
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
def add_persons_sources(person):
|
def add_persons_sources(person):
|
||||||
elist = person.getEventList()[:]
|
elist = person.getEventList()[:]
|
||||||
if person.getBirth():
|
|
||||||
elist.append(person.getBirth())
|
elist.append(person.getBirth())
|
||||||
if person.getDeath():
|
elist.append(person.getDeath())
|
||||||
elist.append(person.getDeath())
|
|
||||||
for event in elist:
|
for event in elist:
|
||||||
|
if private and event.getPrivacy():
|
||||||
|
continue
|
||||||
source_ref = event.getSourceRef()
|
source_ref = event.getSourceRef()
|
||||||
if source_ref != None:
|
if source_ref != None:
|
||||||
source_list.append(source_ref)
|
source_list.append(source_ref)
|
||||||
@@ -209,12 +210,9 @@ def add_persons_sources(person):
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
def add_familys_sources(family):
|
def add_familys_sources(family):
|
||||||
elist = family.getEventList()[:]
|
for event in family.getEventList():
|
||||||
if family.getMarriage():
|
if private and event.getPrivacy():
|
||||||
elist.append(family.getMarriage())
|
continue
|
||||||
if family.getDivorce():
|
|
||||||
elist.append(family.getDivorce())
|
|
||||||
for event in elist:
|
|
||||||
source_ref = event.getSourceRef()
|
source_ref = event.getSourceRef()
|
||||||
if source_ref != None:
|
if source_ref != None:
|
||||||
source_list.append(source_ref)
|
source_list.append(source_ref)
|
||||||
@@ -369,20 +367,24 @@ def write_person(g,person):
|
|||||||
if not probably_alive(person):
|
if not probably_alive(person):
|
||||||
|
|
||||||
birth = person.getBirth()
|
birth = person.getBirth()
|
||||||
if birth.getSaveDate() != "" or birth.getPlace() != "":
|
if not (private and birth.getPrivacy()):
|
||||||
g.write("1 BIRT\n")
|
if birth.getSaveDate() != "" or birth.getPlace() != "":
|
||||||
dump_event_stats(g,birth)
|
g.write("1 BIRT\n")
|
||||||
|
dump_event_stats(g,birth)
|
||||||
|
|
||||||
death = person.getDeath()
|
death = person.getDeath()
|
||||||
if death.getSaveDate() != "" or death.getPlace() != "":
|
if not (private and death.getPrivacy()):
|
||||||
g.write("1 DEAT\n")
|
if death.getSaveDate() != "" or death.getPlace() != "":
|
||||||
dump_event_stats(g,death)
|
g.write("1 DEAT\n")
|
||||||
|
dump_event_stats(g,death)
|
||||||
|
|
||||||
uid = person.getPafUid()
|
uid = person.getPafUid()
|
||||||
if uid != "":
|
if uid != "":
|
||||||
g.write("1 _UID %s\n" % uid)
|
g.write("1 _UID %s\n" % uid)
|
||||||
|
|
||||||
for event in person.getEventList():
|
for event in person.getEventList():
|
||||||
|
if private and event.getPrivacy():
|
||||||
|
continue
|
||||||
name = event.getName()
|
name = event.getName()
|
||||||
if const.personalConstantEvents.has_key(name):
|
if const.personalConstantEvents.has_key(name):
|
||||||
val = const.personalConstantEvents[name]
|
val = const.personalConstantEvents[name]
|
||||||
@@ -396,6 +398,8 @@ def write_person(g,person):
|
|||||||
dump_event_stats(g,event)
|
dump_event_stats(g,event)
|
||||||
|
|
||||||
for attr in person.getAttributeList():
|
for attr in person.getAttributeList():
|
||||||
|
if private and attr.getPrivacy():
|
||||||
|
continue
|
||||||
name = attr.getType()
|
name = attr.getType()
|
||||||
if const.personalConstantAttributes.has_key(name):
|
if const.personalConstantAttributes.has_key(name):
|
||||||
val = const.personalConstantAttributes[name]
|
val = const.personalConstantAttributes[name]
|
||||||
@@ -413,6 +417,8 @@ def write_person(g,person):
|
|||||||
write_source_ref(g,2,attr.getSourceRef())
|
write_source_ref(g,2,attr.getSourceRef())
|
||||||
|
|
||||||
for addr in person.getAddressList():
|
for addr in person.getAddressList():
|
||||||
|
if private and addr.getPrivacy():
|
||||||
|
continue
|
||||||
write_long_text(g,"RESI",1,addr.getStreet())
|
write_long_text(g,"RESI",1,addr.getStreet())
|
||||||
if addr.getCity() != "":
|
if addr.getCity() != "":
|
||||||
g.write("2 CITY %s\n" % addr.getCity())
|
g.write("2 CITY %s\n" % addr.getCity())
|
||||||
@@ -512,17 +518,9 @@ def exportData(database, filename):
|
|||||||
father = family.getFather()
|
father = family.getFather()
|
||||||
mother = family.getMother()
|
mother = family.getMother()
|
||||||
if not probably_alive(father) or not probably_alive(mother):
|
if not probably_alive(father) or not probably_alive(mother):
|
||||||
event = family.getMarriage()
|
|
||||||
if event != None:
|
|
||||||
g.write("1 MARR\n");
|
|
||||||
dump_event_stats(g,event)
|
|
||||||
|
|
||||||
event = family.getDivorce()
|
|
||||||
if event != None:
|
|
||||||
g.write("1 DIV\n");
|
|
||||||
dump_event_stats(g,event)
|
|
||||||
|
|
||||||
for event in family.getEventList():
|
for event in family.getEventList():
|
||||||
|
if private and event.getPrivacy():
|
||||||
|
continue
|
||||||
name = event.getName()
|
name = event.getName()
|
||||||
|
|
||||||
if const.familyConstantEvents.has_key(name):
|
if const.familyConstantEvents.has_key(name):
|
||||||
@@ -618,9 +616,11 @@ def on_ok_clicked(obj):
|
|||||||
global db
|
global db
|
||||||
global topDialog
|
global topDialog
|
||||||
global restrict
|
global restrict
|
||||||
|
global private
|
||||||
global cnvtxt
|
global cnvtxt
|
||||||
|
|
||||||
restrict = topDialog.get_widget("restrict").get_active()
|
restrict = topDialog.get_widget("restrict").get_active()
|
||||||
|
private = topDialog.get_widget("private").get_active()
|
||||||
filter_obj = topDialog.get_widget("filter").get_menu().get_active()
|
filter_obj = topDialog.get_widget("filter").get_menu().get_active()
|
||||||
filter = filter_obj.get_data("filter")
|
filter = filter_obj.get_data("filter")
|
||||||
|
|
||||||
|
@@ -239,13 +239,40 @@
|
|||||||
</child>
|
</child>
|
||||||
|
|
||||||
<widget>
|
<widget>
|
||||||
<class>GtkCheckButton</class>
|
<class>GtkVBox</class>
|
||||||
<name>restrict</name>
|
<name>vbox3</name>
|
||||||
<border_width>5</border_width>
|
<homogeneous>False</homogeneous>
|
||||||
<can_focus>True</can_focus>
|
<spacing>0</spacing>
|
||||||
<label>Restrict data on living people</label>
|
|
||||||
<active>True</active>
|
<widget>
|
||||||
<draw_indicator>True</draw_indicator>
|
<class>GtkCheckButton</class>
|
||||||
|
<name>private</name>
|
||||||
|
<border_width>3</border_width>
|
||||||
|
<can_focus>True</can_focus>
|
||||||
|
<label>Do not include records marked "Private"</label>
|
||||||
|
<active>True</active>
|
||||||
|
<draw_indicator>True</draw_indicator>
|
||||||
|
<child>
|
||||||
|
<padding>0</padding>
|
||||||
|
<expand>False</expand>
|
||||||
|
<fill>False</fill>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
|
|
||||||
|
<widget>
|
||||||
|
<class>GtkCheckButton</class>
|
||||||
|
<name>restrict</name>
|
||||||
|
<border_width>3</border_width>
|
||||||
|
<can_focus>True</can_focus>
|
||||||
|
<label>Restrict data on living people</label>
|
||||||
|
<active>True</active>
|
||||||
|
<draw_indicator>True</draw_indicator>
|
||||||
|
<child>
|
||||||
|
<padding>0</padding>
|
||||||
|
<expand>False</expand>
|
||||||
|
<fill>False</fill>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
Reference in New Issue
Block a user