2007-08-28 Don Allingham <don@gramps-project.org>
* src/ExportOptions.py: filter proxy first pass * src/GrampsDbUtils/_FilterProxyDb.py: filter proxy first pass * src/GrampsDbUtils/_WriteGedcom.py: filter proxy first pass * src/Filters/_GenericFilter.py: filter proxy first pass svn: r8886
This commit is contained in:
parent
9bc24a3cad
commit
daca21383a
@ -1,3 +1,9 @@
|
||||
2007-08-28 Don Allingham <don@gramps-project.org>
|
||||
* src/ExportOptions.py: filter proxy first pass
|
||||
* src/GrampsDbUtils/_FilterProxyDb.py: filter proxy first pass
|
||||
* src/GrampsDbUtils/_WriteGedcom.py: filter proxy first pass
|
||||
* src/Filters/_GenericFilter.py: filter proxy first pass
|
||||
|
||||
2007-08-29 Zsolt Foldvari <zfoldvar@users.sourceforge.net>
|
||||
* src/glade/printpreview.glade: Renamed and moved to src/docgen/
|
||||
* src/glade/Makefile.am: printpreview.glade removed.
|
||||
|
@ -85,7 +85,6 @@ class WriterOptionBox:
|
||||
|
||||
all = GenericFilter()
|
||||
all.set_name(_("Entire Database"))
|
||||
all.add_rule(Rules.Person.Everyone([]))
|
||||
|
||||
the_filters = [all]
|
||||
|
||||
|
@ -55,7 +55,7 @@ class GenericFilter:
|
||||
return True
|
||||
|
||||
def is_empty(self):
|
||||
return len(self.flist) == 1 and self.flist[0].is_empty()
|
||||
return len(self.flist) == 0 or (len(self.flist) == 1 and self.flist[0].is_empty())
|
||||
|
||||
def set_logical_op(self,val):
|
||||
if val in GenericFilter.logical_functions:
|
||||
|
@ -33,398 +33,335 @@ __revision__ = "$Revision: 8864 $"
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from RelLib import *
|
||||
from GrampsDb import DbBase
|
||||
from _ProxyDbBase import ProxyDbBase
|
||||
|
||||
class FilterProxyDb(DbBase):
|
||||
class FilterProxyDb(ProxyDbBase):
|
||||
"""
|
||||
A proxy to a Gramps database. This proxy will act like a Gramps database,
|
||||
but all data marked private will be hidden from the user.
|
||||
"""
|
||||
|
||||
def __init__(self,db):
|
||||
def __init__(self, db, person_filter=None, event_filter=None):
|
||||
"""
|
||||
Creates a new PrivateProxyDb instance.
|
||||
"""
|
||||
self.db = db
|
||||
ProxyDbBase.__init__(self, db)
|
||||
self.person_filter = person_filter
|
||||
|
||||
def is_open(self):
|
||||
"""
|
||||
Returns 1 if the database has been opened.
|
||||
"""
|
||||
return self.db.is_open
|
||||
if person_filter:
|
||||
self.plist = set(person_filter.apply(
|
||||
self.db, self.db.get_person_handles(sort_handles=False)))
|
||||
else:
|
||||
self.plist = self.db.get_person_handles(sort_handles=False)
|
||||
|
||||
def get_name_group_mapping(self, name):
|
||||
"""
|
||||
Returns the default grouping name for a surname
|
||||
"""
|
||||
return self.db.get_name_group_mapping(name)
|
||||
if event_filter:
|
||||
self.elist = set(event_filter.apply(
|
||||
self.db, self.db.get_event_handles()))
|
||||
else:
|
||||
self.elist = self.db.get_event_handles()
|
||||
|
||||
def get_name_group_keys(self):
|
||||
"""
|
||||
Returns the defined names that have been assigned to a default grouping
|
||||
"""
|
||||
return self.db.get_name_group_keys()
|
||||
self.flist = set()
|
||||
for handle in list(self.plist):
|
||||
person = self.db.get_person_from_handle(handle)
|
||||
for family_handle in person.get_family_handle_list():
|
||||
family = self.db.get_family_from_handle(family_handle)
|
||||
self.flist.add(family_handle)
|
||||
|
||||
def get_number_of_people(self):
|
||||
def get_person_from_handle(self, handle):
|
||||
"""
|
||||
Returns the number of people currently in the databse.
|
||||
Finds a Person in the database from the passed gramps' ID.
|
||||
If no such Person exists, None is returned.
|
||||
"""
|
||||
return len(self.get_person_handles())
|
||||
if handle in self.plist:
|
||||
person = self.db.get_person_from_handle(handle)
|
||||
|
||||
def get_number_of_families(self):
|
||||
"""
|
||||
Returns the number of families currently in the databse.
|
||||
"""
|
||||
return len(self.get_family_handles())
|
||||
person.set_person_ref_list(
|
||||
[ ref for ref in person.get_person_ref_list()
|
||||
if ref.ref in self.plist ])
|
||||
|
||||
def get_number_of_events(self):
|
||||
"""
|
||||
Returns the number of events currently in the databse.
|
||||
"""
|
||||
return len(self.get_event_handles())
|
||||
person.set_family_handle_list(
|
||||
[ hndl for hndl in person.get_family_handle_list()
|
||||
if hndl in self.flist ])
|
||||
|
||||
def get_number_of_places(self):
|
||||
"""
|
||||
Returns the number of places currently in the databse.
|
||||
"""
|
||||
return len(self.get_place_handles())
|
||||
person.set_parent_family_handle_list(
|
||||
[ hndl for hndl in person.get_parent_family_handle_list()
|
||||
if hndl in self.flist ])
|
||||
|
||||
def get_number_of_sources(self):
|
||||
eref_list = person.get_event_ref_list()
|
||||
bref = person.get_birth_ref()
|
||||
dref = person.get_death_ref()
|
||||
|
||||
new_eref_list = [ ref for ref in eref_list
|
||||
if ref.ref in self.elist]
|
||||
|
||||
person.set_event_ref_list(new_eref_list)
|
||||
if bref in new_eref_list:
|
||||
person.set_birth_ref(bref)
|
||||
if dref in new_eref_list:
|
||||
person.set_death_ref(dref)
|
||||
|
||||
return person
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_source_from_handle(self, handle):
|
||||
"""
|
||||
Returns the number of sources currently in the databse.
|
||||
Finds a Source in the database from the passed gramps' ID.
|
||||
If no such Source exists, None is returned.
|
||||
"""
|
||||
return len(self.get_source_handles())
|
||||
return self.db.get_source_from_handle(handle)
|
||||
|
||||
def get_number_of_media_objects(self):
|
||||
def get_object_from_handle(self, handle):
|
||||
"""
|
||||
Returns the number of media objects currently in the databse.
|
||||
Finds an Object in the database from the passed gramps' ID.
|
||||
If no such Object exists, None is returned.
|
||||
"""
|
||||
return len(self.get_object_handles())
|
||||
return self.db.get_object_from_handle(handle)
|
||||
|
||||
def get_number_of_repositories(self):
|
||||
def get_place_from_handle(self, handle):
|
||||
"""
|
||||
Returns the number of source repositories currently in the databse.
|
||||
Finds a Place in the database from the passed gramps' ID.
|
||||
If no such Place exists, None is returned.
|
||||
"""
|
||||
return len(self.get_repository_handles())
|
||||
return self.db.get_place_from_handle(handle)
|
||||
|
||||
def get_number_of_notes(self):
|
||||
def get_event_from_handle(self, handle):
|
||||
"""
|
||||
Returns the number of notes currently in the databse.
|
||||
Finds a Event in the database from the passed gramps' ID.
|
||||
If no such Event exists, None is returned.
|
||||
"""
|
||||
return self.db.get_number_of_notes()
|
||||
if handle in self.elist:
|
||||
return self.db.get_event_from_handle(handle)
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_save_path(self):
|
||||
"""returns the save path of the file, or "" if one does not exist"""
|
||||
return self.db.get_save_path()
|
||||
|
||||
def get_person_event_types(self):
|
||||
"""returns a list of all Event types assocated with Person
|
||||
instances in the database"""
|
||||
return self.db.get_person_event_types()
|
||||
|
||||
def get_person_attribute_types(self):
|
||||
"""returns a list of all Attribute types assocated with Person
|
||||
instances in the database"""
|
||||
return self.db.get_person_attribute_types()
|
||||
|
||||
def get_family_attribute_types(self):
|
||||
"""returns a list of all Attribute types assocated with Family
|
||||
instances in the database"""
|
||||
return self.db.get_family_attribute_types()
|
||||
|
||||
def get_family_event_types(self):
|
||||
"""returns a list of all Event types assocated with Family
|
||||
instances in the database"""
|
||||
return self.db.get_family_event_types()
|
||||
|
||||
def get_marker_types(self):
|
||||
"""return a list of all marker types available in the database"""
|
||||
return self.db.get_marker_types()
|
||||
def get_family_from_handle(self, handle):
|
||||
"""
|
||||
Finds a Family in the database from the passed gramps' ID.
|
||||
If no such Family exists, None is returned.
|
||||
"""
|
||||
if handle in self.flist:
|
||||
family = self.db.get_family_from_handle(handle)
|
||||
|
||||
def get_media_attribute_types(self):
|
||||
"""returns a list of all Attribute types assocated with Media
|
||||
and MediaRef instances in the database"""
|
||||
return self.db.get_media_attribute_types()
|
||||
eref_list = [ eref for eref in family.get_event_ref_list()
|
||||
if eref.ref in self.elist ]
|
||||
family.set_event_ref_list(eref_list)
|
||||
|
||||
def get_family_relation_types(self):
|
||||
"""returns a list of all relationship types assocated with Family
|
||||
instances in the database"""
|
||||
return self.db.get_family_relation_types()
|
||||
if family.get_father_handle() not in self.plist:
|
||||
family.set_father_handle(None)
|
||||
|
||||
if family.get_mother_handle() not in self.plist:
|
||||
family.set_mother_handle(None)
|
||||
|
||||
def get_child_reference_types(self):
|
||||
"""returns a list of all child reference types assocated with Family
|
||||
instances in the database"""
|
||||
return self.db.get_child_reference_types()
|
||||
clist = [ cref for cref in family.get_child_ref_list()
|
||||
if cref.ref in self.plist ]
|
||||
family.set_child_ref_list(clist)
|
||||
return family
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_event_roles(self):
|
||||
"""returns a list of all custom event role names assocated with Event
|
||||
instances in the database"""
|
||||
return self.db.get_event_roles()
|
||||
def get_repository_from_handle(self, handle):
|
||||
"""
|
||||
Finds a Repository in the database from the passed gramps' ID.
|
||||
If no such Repository exists, None is returned.
|
||||
"""
|
||||
return self.db.get_repository_from_handle(handle)
|
||||
|
||||
def get_name_types(self):
|
||||
"""returns a list of all custom names types assocated with Person
|
||||
instances in the database"""
|
||||
return self.db.get_name_types()
|
||||
def get_note_from_handle(self, handle):
|
||||
"""
|
||||
Finds a Note in the database from the passed gramps' ID.
|
||||
If no such Note exists, None is returned.
|
||||
"""
|
||||
return self.db.get_note_from_handle(handle)
|
||||
|
||||
def get_repository_types(self):
|
||||
"""returns a list of all custom repository types assocated with
|
||||
Repository instances in the database"""
|
||||
return self.db.get_repository_types()
|
||||
def get_person_from_gramps_id(self, val):
|
||||
"""
|
||||
Finds a Person in the database from the passed GRAMPS ID.
|
||||
If no such Person exists, None is returned.
|
||||
"""
|
||||
person = self.db.get_person_from_gramps_id(val)
|
||||
if person.get_handle() not in self.plist:
|
||||
return None
|
||||
else:
|
||||
return person
|
||||
|
||||
def get_note_types(self):
|
||||
"""returns a list of all custom note types assocated with
|
||||
Note instances in the database"""
|
||||
return self.db.get_note_types()
|
||||
def get_family_from_gramps_id(self, val):
|
||||
"""
|
||||
Finds a Family in the database from the passed GRAMPS ID.
|
||||
If no such Family exists, None is returned.
|
||||
"""
|
||||
return self.db.get_family_from_gramps_id(val)
|
||||
|
||||
def get_source_media_types(self):
|
||||
"""returns a list of all custom source media types assocated with
|
||||
Source instances in the database"""
|
||||
return self.db.get_source_media_types()
|
||||
def get_event_from_gramps_id(self, val):
|
||||
"""
|
||||
Finds an Event in the database from the passed GRAMPS ID.
|
||||
If no such Event exists, None is returned.
|
||||
"""
|
||||
event = self.db.get_event_from_gramps_id(val)
|
||||
if event.get_handle() not in self.elist:
|
||||
return None
|
||||
else:
|
||||
return event
|
||||
|
||||
def get_url_types(self):
|
||||
"""returns a list of all custom names types assocated with Url
|
||||
instances in the database"""
|
||||
return self.db.get_url_types()
|
||||
def get_place_from_gramps_id(self, val):
|
||||
"""
|
||||
Finds a Place in the database from the passed gramps' ID.
|
||||
If no such Place exists, None is returned.
|
||||
"""
|
||||
return self.db.get_place_from_gramps_id(val)
|
||||
|
||||
def get_raw_person_data(self, handle):
|
||||
return self.db.get_raw_person_data(handle)
|
||||
def get_source_from_gramps_id(self, val):
|
||||
"""
|
||||
Finds a Source in the database from the passed gramps' ID.
|
||||
If no such Source exists, None is returned.
|
||||
"""
|
||||
return self.db.get_source_from_gramps_id(val)
|
||||
|
||||
def get_raw_family_data(self, handle):
|
||||
return self.db.get_raw_family_data(handle)
|
||||
def get_object_from_gramps_id(self, val):
|
||||
"""
|
||||
Finds a MediaObject in the database from the passed gramps' ID.
|
||||
If no such MediaObject exists, None is returned.
|
||||
"""
|
||||
return self.db.get_object_from_gramps_id(val)
|
||||
|
||||
def get_raw_object_data(self, handle):
|
||||
return self.db.get_raw_object_data(handle)
|
||||
def get_repository_from_gramps_id(self, val):
|
||||
"""
|
||||
Finds a Repository in the database from the passed gramps' ID.
|
||||
If no such Repository exists, None is returned.
|
||||
"""
|
||||
return self.db.get_repository_from_gramps_id(val)
|
||||
|
||||
def get_raw_place_data(self, handle):
|
||||
return self.db.get_raw_place_data(handle)
|
||||
def get_note_from_gramps_id(self, val):
|
||||
"""
|
||||
Finds a Note in the database from the passed gramps' ID.
|
||||
If no such Note exists, None is returned.
|
||||
"""
|
||||
return self.db.get_note_from_gramps_id(val)
|
||||
|
||||
def get_raw_event_data(self, handle):
|
||||
return self.db.get_raw_event_data(handle)
|
||||
def get_person_handles(self, sort_handles=True):
|
||||
"""
|
||||
Returns a list of database handles, one handle for each Person in
|
||||
the database. If sort_handles is True, the list is sorted by surnames
|
||||
"""
|
||||
return list(self.plist)
|
||||
|
||||
def get_raw_source_data(self, handle):
|
||||
return self.db.get_raw_source_data(handle)
|
||||
def get_place_handles(self, sort_handles=True):
|
||||
"""
|
||||
Returns a list of database handles, one handle for each Place in
|
||||
the database. If sort_handles is True, the list is sorted by
|
||||
Place title.
|
||||
"""
|
||||
return self.db.get_place_handles(sort_handles)
|
||||
|
||||
def get_raw_repository_data(self, handle):
|
||||
return self.db.get_raw_repository_data(handle)
|
||||
def get_source_handles(self, sort_handles=True):
|
||||
"""
|
||||
Returns a list of database handles, one handle for each Source in
|
||||
the database. If sort_handles is True, the list is sorted by
|
||||
Source title.
|
||||
"""
|
||||
return self.db.get_source_handles(sort_handles)
|
||||
|
||||
def get_raw_note_data(self, handle):
|
||||
return self.db.get_raw_note_data(handle)
|
||||
def get_media_object_handles(self, sort_handles=True):
|
||||
"""
|
||||
Returns a list of database handles, one handle for each MediaObject in
|
||||
the database. If sort_handles is True, the list is sorted by title.
|
||||
"""
|
||||
return self.db.get_media_object_handles(sort_handles)
|
||||
|
||||
def get_event_handles(self):
|
||||
"""
|
||||
Returns a list of database handles, one handle for each Event in
|
||||
the database.
|
||||
"""
|
||||
return list(self.elist)
|
||||
|
||||
def get_family_handles(self):
|
||||
"""
|
||||
Returns a list of database handles, one handle for each Family in
|
||||
the database.
|
||||
"""
|
||||
return list(self.flist)
|
||||
|
||||
def get_repository_handles(self):
|
||||
"""
|
||||
Returns a list of database handles, one handle for each Repository in
|
||||
the database.
|
||||
"""
|
||||
return self.db.get_repository_handles()
|
||||
|
||||
def get_note_handles(self):
|
||||
"""
|
||||
Returns a list of database handles, one handle for each Note in
|
||||
the database.
|
||||
"""
|
||||
return self.db.get_note_handles()
|
||||
|
||||
def get_researcher(self):
|
||||
"""returns the Researcher instance, providing information about
|
||||
the owner of the database"""
|
||||
return self.db.get_researcher()
|
||||
|
||||
def get_default_person(self):
|
||||
"""returns the default Person of the database"""
|
||||
person = self.db.get_default_person()
|
||||
if person.get_handle() in self.plist:
|
||||
return person
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_default_handle(self):
|
||||
"""returns the default Person of the database"""
|
||||
handle = self.db.get_default_handle()
|
||||
if handle in self.plist:
|
||||
return handle
|
||||
else:
|
||||
return None
|
||||
|
||||
def has_person_handle(self, handle):
|
||||
"""
|
||||
returns True if the handle exists in the current Person database.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
return handle in self.plist
|
||||
|
||||
def has_event_handle(self, handle):
|
||||
"""
|
||||
returns True if the handle exists in the current Event database.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
return handle in self.elist
|
||||
|
||||
def has_source_handle(self, handle):
|
||||
"""
|
||||
returns True if the handle exists in the current Source database.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
return self.db.has_source_handle(handle)
|
||||
|
||||
def has_place_handle(self, handle):
|
||||
"""
|
||||
returns True if the handle exists in the current Place database.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
return self.db.has_place_handle(handle)
|
||||
|
||||
def has_family_handle(self, handle):
|
||||
"""
|
||||
returns True if the handle exists in the current Family database.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
return self.db.has_family_handle(handle)
|
||||
|
||||
def has_object_handle(self, handle):
|
||||
"""
|
||||
returns True if the handle exists in the current MediaObjectdatabase.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
return self.db.has_object_handle(handle)
|
||||
|
||||
def has_repository_handle(self, handle):
|
||||
"""
|
||||
returns True if the handle exists in the current Repository database.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
return self.db.has_repository_handle(handle)
|
||||
|
||||
def has_note_handle(self, handle):
|
||||
"""
|
||||
returns True if the handle exists in the current Note database.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
return self.db.has_note_handle(handle)
|
||||
|
||||
def set_column_order(self, col_list, name):
|
||||
raise NotImplementedError
|
||||
|
||||
def set_person_column_order(self, col_list):
|
||||
"""
|
||||
Stores the Person display common information in the
|
||||
database's metadata.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def set_family_list_column_order(self, col_list):
|
||||
"""
|
||||
Stores the Person display common information in the
|
||||
database's metadata.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def set_child_column_order(self, col_list):
|
||||
"""
|
||||
Stores the Person display common information in the
|
||||
database's metadata.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def set_place_column_order(self, col_list):
|
||||
"""
|
||||
Stores the Place display common information in the
|
||||
database's metadata.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def set_source_column_order(self, col_list):
|
||||
"""
|
||||
Stores the Source display common information in the
|
||||
database's metadata.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def set_media_column_order(self, col_list):
|
||||
"""
|
||||
Stores the Media display common information in the
|
||||
database's metadata.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def set_event_column_order(self, col_list):
|
||||
"""
|
||||
Stores the Event display common information in the
|
||||
database's metadata.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def set_repository_column_order(self, col_list):
|
||||
"""
|
||||
Stores the Repository display common information in the
|
||||
database's metadata.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def set_note_column_order(self, col_list):
|
||||
"""
|
||||
Stores the Note display common information in the
|
||||
database's metadata.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_person_column_order(self):
|
||||
"""
|
||||
Returns the Person display common information stored in the
|
||||
database's metadata.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_family_list_column_order(self):
|
||||
"""
|
||||
Returns the Person display common information stored in the
|
||||
database's metadata.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_child_column_order(self):
|
||||
"""
|
||||
Returns the Person display common information stored in the
|
||||
database's metadata.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_place_column_order(self):
|
||||
"""
|
||||
Returns the Place display common information stored in the
|
||||
database's metadata.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_source_column_order(self):
|
||||
"""
|
||||
Returns the Source display common information stored in the
|
||||
database's metadata.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_media_column_order(self):
|
||||
"""
|
||||
Returns the MediaObject display common information stored in the
|
||||
database's metadata.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_event_column_order(self):
|
||||
"""
|
||||
Returns the Event display common information stored in the
|
||||
database's metadata.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_repository_column_order(self):
|
||||
"""
|
||||
Returns the Repository display common information stored in the
|
||||
database's metadata.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_note_column_order(self):
|
||||
"""
|
||||
Returns the Note display common information stored in the
|
||||
database's metadata.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def delete_primary_from_reference_map(self, handle, transaction):
|
||||
"""Called each time an object is removed from the database. This can
|
||||
be used by subclasses to update any additional index tables that might
|
||||
need to be changed."""
|
||||
raise NotImplementedError
|
||||
|
||||
def update_reference_map(self, obj, transaction):
|
||||
"""Called each time an object is writen to the database. This can
|
||||
be used by subclasses to update any additional index tables that might
|
||||
need to be changed."""
|
||||
raise NotImplementedError
|
||||
|
||||
def reindex_reference_map(self, callback):
|
||||
"""
|
||||
Reindex all primary records in the database.
|
||||
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def find_backlink_handles(self, handle, include_classes=None):
|
||||
"""
|
||||
Find all objects that hold a reference to the object handle.
|
||||
Returns an interator over alist of (class_name, handle) tuples.
|
||||
|
||||
@param handle: handle of the object to search for.
|
||||
@type handle: database handle
|
||||
@param include_classes: list of class names to include in the results.
|
||||
Default: None means include all classes.
|
||||
@type include_classes: list of class names
|
||||
|
||||
This default implementation does a sequencial scan through all
|
||||
the primary object databases and is very slow. Backends can
|
||||
override this method to provide much faster implementations that
|
||||
make use of additional capabilities of the backend.
|
||||
|
||||
Note that this is a generator function, it returns a iterator for
|
||||
use in loops. If you want a list of the results use:
|
||||
|
||||
> result_list = [i for i in find_backlink_handles(handle)]
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
@ -253,6 +253,10 @@ class GedcomWriter(UpdateCallback):
|
||||
self.cl = cl
|
||||
self.filename = filename
|
||||
|
||||
self.slist = set()
|
||||
self.rlist = set()
|
||||
self.nlist = set()
|
||||
|
||||
if option_box:
|
||||
setup_func = self.gui_setup
|
||||
else:
|
||||
@ -262,19 +266,8 @@ class GedcomWriter(UpdateCallback):
|
||||
if not setup_func():
|
||||
return
|
||||
|
||||
self.flist = set()
|
||||
self.slist = set()
|
||||
self.rlist = set()
|
||||
self.nlist = set()
|
||||
|
||||
# Collect needed families
|
||||
for handle in list(self.plist):
|
||||
person = self.db.get_person_from_handle(handle)
|
||||
for family_handle in person.get_family_handle_list():
|
||||
family = self.db.get_family_from_handle(family_handle)
|
||||
self.flist.add(family_handle)
|
||||
|
||||
def __writeln(self, level, token, textlines="", limit=72):
|
||||
assert(token)
|
||||
if textlines:
|
||||
textlist = textlines.split('\n')
|
||||
token_level = level
|
||||
@ -305,25 +298,14 @@ class GedcomWriter(UpdateCallback):
|
||||
from _LivingProxyDb import LivingProxyDb
|
||||
self.db = LivingProxyDb(self.db, LivingProxyDb.MODE_RESTRICT)
|
||||
|
||||
if self.option_box.cfilter == None:
|
||||
self.plist = set(self.db.get_person_handles(sort_handles=False))
|
||||
else:
|
||||
try:
|
||||
self.plist = set(self.option_box.cfilter.apply(
|
||||
self.db, self.db.get_person_handles(sort_handles=False)))
|
||||
return True
|
||||
except Errors.FilterError, msg:
|
||||
(m1, m2) = msg.messages()
|
||||
ErrorDialog(m1, m2)
|
||||
return False
|
||||
if not self.option_box.cfilter.is_empty():
|
||||
from _FilterProxyDb import FilterProxyDb
|
||||
self.db = FilterProxyDb(self.db, self.option_box.cfilter)
|
||||
|
||||
def cli_setup(self):
|
||||
# use default settings
|
||||
self.restrict = 0
|
||||
self.private = 0
|
||||
|
||||
self.plist = set(self.db.get_person_handles(sort_handles=False))
|
||||
|
||||
return True
|
||||
|
||||
def export_data(self, filename):
|
||||
@ -339,7 +321,7 @@ class GedcomWriter(UpdateCallback):
|
||||
ErrorDialog(_("Could not create %s") % filename)
|
||||
return 0
|
||||
|
||||
self.set_total(len(self.plist) + len(self.flist))
|
||||
self.set_total(len(self.db.get_person_handles()) + len(self.db.get_family_handles()))
|
||||
|
||||
self.__write_header(filename)
|
||||
self.__write_submitter()
|
||||
@ -454,7 +436,7 @@ class GedcomWriter(UpdateCallback):
|
||||
INDIVIDUAL RECORDS
|
||||
"""
|
||||
sorted = []
|
||||
for handle in self.plist:
|
||||
for handle in self.db.get_person_handles():
|
||||
person = self.db.get_person_from_handle (handle)
|
||||
data = (person.get_gramps_id (), handle)
|
||||
sorted.append (data)
|
||||
@ -632,7 +614,7 @@ class GedcomWriter(UpdateCallback):
|
||||
value = attr.get_value().strip().replace('\r', ' ')
|
||||
|
||||
if key in ("AFN", "RFN", "REFN", "_UID"):
|
||||
self.__writeln(1, name, value)
|
||||
self.__writeln(1, key, value)
|
||||
continue
|
||||
|
||||
if key == "RESN":
|
||||
@ -677,8 +659,7 @@ class GedcomWriter(UpdateCallback):
|
||||
self.__write_photo(photo, level)
|
||||
|
||||
def __write_child_families(self, person):
|
||||
hndl_list = [ hndl for hndl in person.get_parent_family_handle_list() \
|
||||
if hndl and hndl in self.flist ]
|
||||
hndl_list = [ hndl for hndl in person.get_parent_family_handle_list() ]
|
||||
|
||||
for family_handle in hndl_list:
|
||||
family = self.db.get_family_from_handle(family_handle)
|
||||
@ -687,9 +668,8 @@ class GedcomWriter(UpdateCallback):
|
||||
|
||||
def __write_parent_families(self, person):
|
||||
for family_handle in person.get_family_handle_list():
|
||||
if family_handle in self.flist:
|
||||
family = self.db.get_family_from_handle(family_handle)
|
||||
self.__writeln(1, 'FAMS', '@%s@' % family.get_gramps_id())
|
||||
family = self.db.get_family_from_handle(family_handle)
|
||||
self.__writeln(1, 'FAMS', '@%s@' % family.get_gramps_id())
|
||||
|
||||
def __write_person_sources(self, person):
|
||||
for srcref in person.get_source_references():
|
||||
@ -714,7 +694,7 @@ class GedcomWriter(UpdateCallback):
|
||||
def __write_families(self):
|
||||
sorted = []
|
||||
|
||||
for family_handle in self.flist:
|
||||
for family_handle in self.db.get_family_handles():
|
||||
family = self.db.get_family_from_handle(family_handle)
|
||||
data = (family.get_gramps_id(), family_handle)
|
||||
sorted.append (data)
|
||||
@ -725,7 +705,7 @@ class GedcomWriter(UpdateCallback):
|
||||
self.__write_family(family)
|
||||
|
||||
def __write_family_reference(self, token, person_handle):
|
||||
if person_handle != None and person_handle in self.plist:
|
||||
if person_handle:
|
||||
person = self.db.get_person_from_handle(person_handle)
|
||||
gramps_id = person.get_gramps_id()
|
||||
self.__writeln(1, token, '@%s@' % gramps_id)
|
||||
@ -747,8 +727,7 @@ class GedcomWriter(UpdateCallback):
|
||||
|
||||
|
||||
child_list = [ self.db.get_person_from_handle(cref.ref).get_gramps_id()
|
||||
for cref in family.get_child_ref_list()
|
||||
if cref.ref in self.plist]
|
||||
for cref in family.get_child_ref_list() ]
|
||||
child_list.sort()
|
||||
|
||||
for gid in child_list:
|
||||
|
Loading…
Reference in New Issue
Block a user