GEPS008: Combine db, name, referent and tree modules

svn: r19924
This commit is contained in:
Nick Hall 2012-06-26 14:22:22 +00:00
parent 449bb71a49
commit f381a707b0
32 changed files with 317 additions and 443 deletions

View File

@ -324,7 +324,6 @@ src/gen/simple/_simpletable.py
src/gen/utils/alive.py
src/gen/utils/keyword.py
src/gen/utils/lds.py
src/gen/utils/name.py
src/gen/utils/place.py
src/gen/utils/string.py
src/gen/utils/trans.py

View File

@ -218,8 +218,6 @@ src/gen/utils/debug.py
src/gen/utils/file.py
src/gen/utils/id.py
src/gen/utils/image.py
src/gen/utils/referent.py
src/gen/utils/tree.py
# gen.utils.docgen
src/gen/utils/docgen/__init__.py

View File

@ -32,7 +32,7 @@ from gen.ggettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from gen.utils.tree import for_each_ancestor
from gen.utils.db import for_each_ancestor
from gen.filters.rules import Rule
#-------------------------------------------------------------------------

View File

@ -32,7 +32,7 @@ from gen.ggettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from gen.utils.tree import for_each_ancestor
from gen.utils.db import for_each_ancestor
from _hascommonancestorwith import HasCommonAncestorWith
from _matchesfilter import MatchesFilter

View File

@ -35,7 +35,7 @@ LOG = logging.getLogger(".citationfilter")
# GRAMPS modules
#
#-------------------------------------------------------------------------
from gen.utils.referent import get_source_and_citation_referents
from gen.utils.db import get_source_and_citation_referents
from gen.filters.rules import Rule
#-------------------------------------------------------------------------

View File

@ -23,13 +23,10 @@ pkgpython_PYTHON = \
image.py \
keyword.py \
lds.py \
name.py \
mactrans.py \
place.py \
referent.py \
string.py \
trans.py \
tree.py \
unknown.py
pkgpyexecdir = @pkgpyexecdir@/gen/utils

View File

@ -23,13 +23,21 @@
"""
Utilities for getting information from the database.
"""
#-------------------------------------------------------------------------
#
# Standard python modules
#
#-------------------------------------------------------------------------
import logging
LOG = logging.getLogger(".gui.utils.db")
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
import gen.lib
from gen.display.name import displayer as name_displayer
from gen.utils.name import family_name
from gen.ggettext import sgettext as _
#-------------------------------------------------------------------------
@ -291,3 +299,282 @@ def navigation_label(db, nav_type, handle):
label = '[%s] %s' % (obj.get_gramps_id(), label)
return (label, obj)
#-------------------------------------------------------------------------
#
# Function to return children's list of a person
#
#-------------------------------------------------------------------------
def find_children(db,p):
"""
Return the list of all children's IDs for a person.
"""
childlist = []
for family_handle in p.get_family_handle_list():
family = db.get_family_from_handle(family_handle)
for child_ref in family.get_child_ref_list():
childlist.append(child_ref.ref)
return childlist
#-------------------------------------------------------------------------
#
# Function to return parent's list of a person
#
#-------------------------------------------------------------------------
def find_parents(db,p):
"""
Return the unique list of all parents' IDs for a person.
"""
parentlist = []
for f in p.get_parent_family_handle_list():
family = db.get_family_from_handle(f)
father_handle = family.get_father_handle()
mother_handle = family.get_mother_handle()
if father_handle not in parentlist:
parentlist.append(father_handle)
if mother_handle not in parentlist:
parentlist.append(mother_handle)
return parentlist
#-------------------------------------------------------------------------
#
# Function to return persons, that share the same event.
# This for example links witnesses to the tree
#
#-------------------------------------------------------------------------
def find_witnessed_people(db,p):
people = []
for event_ref in p.get_event_ref_list():
for l in db.find_backlink_handles( event_ref.ref):
if l[0] == 'Person' and l[1] != p.get_handle() and l[1] not in people:
people.append(l[1])
if l[0] == 'Family':
fam = db.get_family_from_handle(l[1])
if fam:
father_handle = fam.get_father_handle()
if father_handle and father_handle != p.get_handle() and father_handle not in people:
people.append(father_handle)
mother_handle = fam.get_mother_handle()
if mother_handle and mother_handle != p.get_handle() and mother_handle not in people:
people.append(mother_handle)
for f in p.get_family_handle_list():
family = db.get_family_from_handle(f)
for event_ref in family.get_event_ref_list():
for l in db.find_backlink_handles( event_ref.ref):
if l[0] == 'Person' and l[1] != p.get_handle() and l[1] not in people:
people.append(l[1])
for pref in p.get_person_ref_list():
if pref.ref != p.get_handle and pref.ref not in people:
people.append(pref.ref)
return people
#-------------------------------------------------------------------------
#
# Iterate over ancestors.
#
#-------------------------------------------------------------------------
def for_each_ancestor(db, start, func, data):
"""
Recursively iterate (breadth-first) over ancestors of
people listed in start.
Call func(data, pid) for the Id of each person encountered.
Exit and return 1, as soon as func returns true.
Return 0 otherwise.
"""
todo = start
done_ids = set()
while len(todo):
p_handle = todo.pop()
p = db.get_person_from_handle(p_handle)
# Don't process the same handle twice. This can happen
# if there is a cycle in the database, or if the
# initial list contains X and some of X's ancestors.
if p_handle in done_ids:
continue
done_ids.add(p_handle)
if func(data, p_handle):
return 1
for fam_handle in p.get_parent_family_handle_list():
fam = db.get_family_from_handle(fam_handle)
if fam:
f_handle = fam.get_father_handle()
m_handle = fam.get_mother_handle()
if f_handle: todo.append(f_handle)
if m_handle: todo.append(m_handle)
return 0
#-------------------------------------------------------------------------
#
# Preset a name with a name of family member
#
#-------------------------------------------------------------------------
def preset_name(basepers, name, sibling=False):
"""Fill up name with all family common names of basepers.
If sibling=True, pa/matronymics are retained.
"""
surnlist = []
primname = basepers.get_primary_name()
prim = False
for surn in primname.get_surname_list():
if (not sibling) and (surn.get_origintype().value in
[gen.lib.NameOriginType.PATRONYMIC,
gen.lib.NameOriginType.MATRONYMIC]):
continue
surnlist.append(gen.lib.Surname(source=surn))
if surn.primary:
prim=True
if not surnlist:
surnlist = [gen.lib.Surname()]
name.set_surname_list(surnlist)
if not prim:
name.set_primary_surname(0)
name.set_family_nick_name(primname.get_family_nick_name())
name.set_group_as(primname.get_group_as())
name.set_sort_as(primname.get_sort_as())
#-------------------------------------------------------------------------
#
# Short hand function to return either the person's name, or an empty
# string if the person is None
#
#-------------------------------------------------------------------------
def family_name(family, db, noname=_("unknown")):
"""Builds a name for the family from the parents names"""
father_handle = family.get_father_handle()
mother_handle = family.get_mother_handle()
father = db.get_person_from_handle(father_handle)
mother = db.get_person_from_handle(mother_handle)
if father and mother:
fname = name_displayer.display(father)
mname = name_displayer.display(mother)
name = _("%(father)s and %(mother)s") % {
"father" : fname,
"mother" : mname}
elif father:
name = name_displayer.display(father)
elif mother:
name = name_displayer.display(mother)
else:
name = noname
return name
#-------------------------------------------------------------------------
#
# Referents functions
#
#-------------------------------------------------------------------------
def get_referents(handle, db, primary_objects):
""" Find objects that refer to an object.
This function is the base for other get_<object>_referents functions.
"""
# Use one pass through the reference map to grab all the references
object_list = list(db.find_backlink_handles(handle))
# Then form the object-specific lists
the_lists = ()
for primary in primary_objects:
primary_list = [item[1] for item in object_list if item[0] == primary]
the_lists = the_lists + (primary_list, )
return the_lists
def get_source_referents(source_handle, db):
""" Find objects that refer the source.
This function finds all primary objects that refer (directly or through
secondary child-objects) to a given source handle in a given database.
Only Citations can refer to sources, so that is all we need to check
"""
_primaries = ('Citation',)
return (get_referents(source_handle, db, _primaries))
def get_citation_referents(citation_handle, db):
""" Find objects that refer the citation.
This function finds all primary objects that refer (directly or through
secondary child-objects) to a given citation handle in a given database.
"""
_primaries = ('Person', 'Family', 'Event', 'Place',
'Source', 'MediaObject', 'Repository')
return (get_referents(citation_handle, db, _primaries))
def get_source_and_citation_referents(source_handle, db):
"""
Find all citations that refer to the sources, and recursively, all objects
that refer to the sources.
This function finds all primary objects that refer (directly or through
secondary child-objects) to a given source handle in a given database.
Objects -> Citations -> Source
e.g.
Media object M1 -> Citation C1 -> Source S1
Media object M2 -> Citation C1 -> Source S1
Person object P1 -> Citation C2 -> Source S1
The returned structure is rather ugly, but provides all the information in
a way that is consistent with the other Util functions.
(
tuple of objects that refer to the source - only first element is present
([C1, C2],),
list of citations with objects that refer to them
[
(C1,
tuple of reference lists
P, F, E, Pl, S, M, R
([], [], [], [], [], [M1, M2]. [])
)
(C2,
tuple of reference lists
P, F, E, Pl, S, M, R
([P1], [], [], [], [], []. [])
)
]
)
"""
the_lists = get_source_referents(source_handle, db)
LOG.debug('source referents %s' % [the_lists])
# now, for each citation, get the objects that refer to that citation
citation_referents_list = []
for citation in the_lists[0]:
LOG.debug('citation %s' % citation)
refs = get_citation_referents(citation, db)
citation_referents_list += [(citation, refs)]
LOG.debug('citation_referents_list %s' % [citation_referents_list])
(citation_list) = the_lists
the_lists = (citation_list, citation_referents_list)
LOG.debug('the_lists %s' % [the_lists])
return the_lists
def get_media_referents(media_handle, db):
""" Find objects that refer the media object.
This function finds all primary objects that refer
to a given media handle in a given database.
"""
_primaries = ('Person', 'Family', 'Event', 'Place', 'Source', 'Citation')
return (get_referents(media_handle, db, _primaries))
def get_note_referents(note_handle, db):
""" Find objects that refer a note object.
This function finds all primary objects that refer
to a given note handle in a given database.
"""
_primaries = ('Person', 'Family', 'Event', 'Place',
'Source', 'Citation', 'MediaObject', 'Repository')
return (get_referents(note_handle, db, _primaries))

View File

@ -1,112 +0,0 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2007 Donald N. Allingham
# Copyright (C) 2009 Gary Burton
# Copyright (C) 2011 Tim G L Lyons
#
# 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
#
# $Id$
"""
Name related utility functions
"""
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
import gen.lib
from gen.display.name import displayer as name_displayer
from gen.ggettext import sgettext as _
#-------------------------------------------------------------------------
#
# Preset a name with a name of family member
#
#-------------------------------------------------------------------------
def preset_name(basepers, name, sibling=False):
"""Fill up name with all family common names of basepers.
If sibling=True, pa/matronymics are retained.
"""
surnlist = []
primname = basepers.get_primary_name()
prim = False
for surn in primname.get_surname_list():
if (not sibling) and (surn.get_origintype().value in
[gen.lib.NameOriginType.PATRONYMIC,
gen.lib.NameOriginType.MATRONYMIC]):
continue
surnlist.append(gen.lib.Surname(source=surn))
if surn.primary:
prim=True
if not surnlist:
surnlist = [gen.lib.Surname()]
name.set_surname_list(surnlist)
if not prim:
name.set_primary_surname(0)
name.set_family_nick_name(primname.get_family_nick_name())
name.set_group_as(primname.get_group_as())
name.set_sort_as(primname.get_sort_as())
#-------------------------------------------------------------------------
#
# Short hand function to return either the person's name, or an empty
# string if the person is None
#
#-------------------------------------------------------------------------
def family_name(family, db, noname=_("unknown")):
"""Builds a name for the family from the parents names"""
father_handle = family.get_father_handle()
mother_handle = family.get_mother_handle()
father = db.get_person_from_handle(father_handle)
mother = db.get_person_from_handle(mother_handle)
if father and mother:
fname = name_displayer.display(father)
mname = name_displayer.display(mother)
name = _("%(father)s and %(mother)s") % {
"father" : fname,
"mother" : mname}
elif father:
name = name_displayer.display(father)
elif mother:
name = name_displayer.display(mother)
else:
name = noname
return name
def family_upper_name(family, db):
"""Builds a name for the family from the parents names"""
father_handle = family.get_father_handle()
mother_handle = family.get_mother_handle()
father = db.get_person_from_handle(father_handle)
mother = db.get_person_from_handle(mother_handle)
if father and mother:
fname = father.get_primary_name().get_upper_name()
mname = mother.get_primary_name().get_upper_name()
name = _("%(father)s and %(mother)s") % {
'father' : fname,
'mother' : mname
}
elif father:
name = father.get_primary_name().get_upper_name()
else:
name = mother.get_primary_name().get_upper_name()
return name

View File

@ -1,161 +0,0 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2007 Donald N. Allingham
# Copyright (C) 2009 Gary Burton
# Copyright (C) 2011 Tim G L Lyons
#
# 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
#
# $Id$
"""
Functions to return referents of primary objects.
"""
#-------------------------------------------------------------------------
#
# Standard python modules
#
#-------------------------------------------------------------------------
import logging
LOG = logging.getLogger(".gui.utils.referents")
#-------------------------------------------------------------------------
#
# Referents functions
#
#-------------------------------------------------------------------------
def get_referents(handle, db, primary_objects):
""" Find objects that refer to an object.
This function is the base for other get_<object>_referents functions.
"""
# Use one pass through the reference map to grab all the references
object_list = list(db.find_backlink_handles(handle))
# Then form the object-specific lists
the_lists = ()
for primary in primary_objects:
primary_list = [item[1] for item in object_list if item[0] == primary]
the_lists = the_lists + (primary_list, )
return the_lists
def get_source_referents(source_handle, db):
""" Find objects that refer the source.
This function finds all primary objects that refer (directly or through
secondary child-objects) to a given source handle in a given database.
Only Citations can refer to sources, so that is all we need to check
"""
_primaries = ('Citation',)
return (get_referents(source_handle, db, _primaries))
def get_citation_referents(citation_handle, db):
""" Find objects that refer the citation.
This function finds all primary objects that refer (directly or through
secondary child-objects) to a given citation handle in a given database.
"""
_primaries = ('Person', 'Family', 'Event', 'Place',
'Source', 'MediaObject', 'Repository')
return (get_referents(citation_handle, db, _primaries))
def get_source_and_citation_referents(source_handle, db):
"""
Find all citations that refer to the sources, and recursively, all objects
that refer to the sources.
This function finds all primary objects that refer (directly or through
secondary child-objects) to a given source handle in a given database.
Objects -> Citations -> Source
e.g.
Media object M1 -> Citation C1 -> Source S1
Media object M2 -> Citation C1 -> Source S1
Person object P1 -> Citation C2 -> Source S1
The returned structure is rather ugly, but provides all the information in
a way that is consistent with the other Util functions.
(
tuple of objects that refer to the source - only first element is present
([C1, C2],),
list of citations with objects that refer to them
[
(C1,
tuple of reference lists
P, F, E, Pl, S, M, R
([], [], [], [], [], [M1, M2]. [])
)
(C2,
tuple of reference lists
P, F, E, Pl, S, M, R
([P1], [], [], [], [], []. [])
)
]
)
#47738: DEBUG: citationtreeview.py: line 428: source referents [(['bfe59e90dbb555d0d87'],)]
#47743: DEBUG: citationtreeview.py: line 432: citation bfe59e90dbb555d0d87
#47825: DEBUG: citationtreeview.py: line 435: citation_referents_list [[('bfe59e90dbb555d0d87', ([], [], ['ba77932bf0b2d59eccb'], [], [], [], []))]]
#47827: DEBUG: citationtreeview.py: line 440: the_lists [((['bfe59e90dbb555d0d87'],), [('bfe59e90dbb555d0d87', ([], [], ['ba77932bf0b2d59eccb'], [], [], [], []))])]
"""
the_lists = get_source_referents(source_handle, db)
LOG.debug('source referents %s' % [the_lists])
# now, for each citation, get the objects that refer to that citation
citation_referents_list = []
for citation in the_lists[0]:
LOG.debug('citation %s' % citation)
refs = get_citation_referents(citation, db)
citation_referents_list += [(citation, refs)]
LOG.debug('citation_referents_list %s' % [citation_referents_list])
(citation_list) = the_lists
the_lists = (citation_list, citation_referents_list)
LOG.debug('the_lists %s' % [the_lists])
return the_lists
def get_media_referents(media_handle, db):
""" Find objects that refer the media object.
This function finds all primary objects that refer
to a given media handle in a given database.
"""
_primaries = ('Person', 'Family', 'Event', 'Place', 'Source', 'Citation')
return (get_referents(media_handle, db, _primaries))
def get_note_referents(note_handle, db):
""" Find objects that refer a note object.
This function finds all primary objects that refer
to a given note handle in a given database.
"""
_primaries = ('Person', 'Family', 'Event', 'Place',
'Source', 'Citation', 'MediaObject', 'Repository')
return (get_referents(note_handle, db, _primaries))

View File

@ -1,130 +0,0 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2007 Donald N. Allingham
# Copyright (C) 2009 Gary Burton
# Copyright (C) 2011 Tim G L Lyons
#
# 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
#
# $Id$
"""
Tree related utility functions
"""
#-------------------------------------------------------------------------
#
# Function to return children's list of a person
#
#-------------------------------------------------------------------------
def find_children(db,p):
"""
Return the list of all children's IDs for a person.
"""
childlist = []
for family_handle in p.get_family_handle_list():
family = db.get_family_from_handle(family_handle)
for child_ref in family.get_child_ref_list():
childlist.append(child_ref.ref)
return childlist
#-------------------------------------------------------------------------
#
# Function to return parent's list of a person
#
#-------------------------------------------------------------------------
def find_parents(db,p):
"""
Return the unique list of all parents' IDs for a person.
"""
parentlist = []
for f in p.get_parent_family_handle_list():
family = db.get_family_from_handle(f)
father_handle = family.get_father_handle()
mother_handle = family.get_mother_handle()
if father_handle not in parentlist:
parentlist.append(father_handle)
if mother_handle not in parentlist:
parentlist.append(mother_handle)
return parentlist
#-------------------------------------------------------------------------
#
# Function to return persons, that share the same event.
# This for example links witnesses to the tree
#
#-------------------------------------------------------------------------
def find_witnessed_people(db,p):
people = []
for event_ref in p.get_event_ref_list():
for l in db.find_backlink_handles( event_ref.ref):
if l[0] == 'Person' and l[1] != p.get_handle() and l[1] not in people:
people.append(l[1])
if l[0] == 'Family':
fam = db.get_family_from_handle(l[1])
if fam:
father_handle = fam.get_father_handle()
if father_handle and father_handle != p.get_handle() and father_handle not in people:
people.append(father_handle)
mother_handle = fam.get_mother_handle()
if mother_handle and mother_handle != p.get_handle() and mother_handle not in people:
people.append(mother_handle)
for f in p.get_family_handle_list():
family = db.get_family_from_handle(f)
for event_ref in family.get_event_ref_list():
for l in db.find_backlink_handles( event_ref.ref):
if l[0] == 'Person' and l[1] != p.get_handle() and l[1] not in people:
people.append(l[1])
for pref in p.get_person_ref_list():
if pref.ref != p.get_handle and pref.ref not in people:
people.append(pref.ref)
return people
#-------------------------------------------------------------------------
#
# Iterate over ancestors.
#
#-------------------------------------------------------------------------
def for_each_ancestor(db, start, func, data):
"""
Recursively iterate (breadth-first) over ancestors of
people listed in start.
Call func(data, pid) for the Id of each person encountered.
Exit and return 1, as soon as func returns true.
Return 0 otherwise.
"""
todo = start
done_ids = set()
while len(todo):
p_handle = todo.pop()
p = db.get_person_from_handle(p_handle)
# Don't process the same handle twice. This can happen
# if there is a cycle in the database, or if the
# initial list contains X and some of X's ancestors.
if p_handle in done_ids:
continue
done_ids.add(p_handle)
if func(data, p_handle):
return 1
for fam_handle in p.get_parent_family_handle_list():
fam = db.get_family_from_handle(fam_handle)
if fam:
f_handle = fam.get_father_handle()
m_handle = fam.get_mother_handle()
if f_handle: todo.append(f_handle)
if m_handle: todo.append(m_handle)
return 0

View File

@ -37,8 +37,7 @@ from gen.ggettext import gettext as _
#
#-------------------------------------------------------------------------
from gen.display.name import displayer as name_displayer
from gen.utils.name import family_name
from gen.utils.db import get_participant_from_event
from gen.utils.db import family_name, get_participant_from_event
#-------------------------------------------------------------------------
#

View File

@ -62,7 +62,6 @@ import gobject
#-------------------------------------------------------------------------
from gen.config import config
from gen.display.name import displayer as name_displayer
from gen.utils.db import get_marriage_or_fallback
import gen.lib
from gen.db import DbTxn
from gen.errors import WindowActiveError
@ -80,10 +79,10 @@ from gui.widgets import (PrivacyButton, MonitoredEntry, MonitoredDataType,
from gen.plug import CATEGORY_QR_FAMILY
from gui.dialog import (ErrorDialog, RunDatabaseRepair, WarningDialog,
MessageHideDialog)
from gen.utils.db import get_birth_or_fallback, get_death_or_fallback
from gen.utils.db import (get_birth_or_fallback, get_death_or_fallback,
get_marriage_or_fallback, preset_name, family_name)
from gui.selectors import SelectorFactory
from gen.utils.id import create_id
from gen.utils.name import preset_name, family_name
SelectPerson = SelectorFactory('Person')

View File

@ -68,7 +68,7 @@ from gen.filters import rules
from gui.autocomp import StandardCustomSelector, fill_entry
from gui.selectors import SelectorFactory
from gen.display.name import displayer as _nd
from gen.utils.name import family_name
from gen.utils.db import family_name
from gen.utils.string import confidence
#-------------------------------------------------------------------------

View File

@ -52,7 +52,7 @@ import gtk
# GRAMPS modules
#
#-------------------------------------------------------------------------
from gen.utils.referent import get_source_referents
from gen.utils.db import get_source_referents
from gui.views.treemodels.treebasemodel import TreeBaseModel
from gui.views.treemodels.citationbasemodel import CitationBaseModel

View File

@ -43,9 +43,9 @@ import gtk
#-------------------------------------------------------------------------
import gen.datehandler
from gen.display.name import displayer as name_displayer
import gen.lib
from gen.lib import EventRoleType
from gen.lib import EventRoleType, FamilyRelType
from gui.views.treemodels.flatbasemodel import FlatBaseModel
from gen.utils.db import get_marriage_or_fallback
from gen.config import config
invalid_date_format = config.get('preferences.invalid-date-format')
@ -140,10 +140,9 @@ class FamilyModel(FlatBaseModel):
return u""
def column_type(self, data):
return unicode(gen.lib.FamilyRelType(data[5]))
return unicode(FamilyRelType(data[5]))
def column_marriage(self, data):
from gen.utils.db import get_marriage_or_fallback
family = self.db.get_family_from_handle(data[0])
event = get_marriage_or_fallback(self.db, family, "<i>%s</i>")
if event:
@ -157,7 +156,6 @@ class FamilyModel(FlatBaseModel):
return u''
def sort_marriage(self, data):
from gen.utils.db import get_marriage_or_fallback
family = self.db.get_family_from_handle(data[0])
event = get_marriage_or_fallback(self.db, family)
if event:

View File

@ -48,7 +48,7 @@ log = logging.getLogger(".ExportVCal")
#
#-------------------------------------------------------------------------
from gui.plug.export import WriterOptionBox
from gen.utils.name import family_name
from gen.utils.db import family_name
from gen.lib import Date, EventType
from gui.glade import Glade

View File

@ -55,7 +55,7 @@ if gtk.pygtk_version < (2,3,93):
from gen.display.name import displayer as name_displayer
from gen.ggettext import gettext as _
from gen.plug import Gramplet
from gen.utils.tree import (find_children, find_parents, find_witnessed_people)
from gen.utils.db import (find_children, find_parents, find_witnessed_people)
from libformatting import FormattingHelper
import gen.lib
from gen.errors import WindowActiveError

View File

@ -30,7 +30,7 @@ from gen.db import PERSON_KEY, FAMILY_KEY, TXNDEL
from gen.plug import Gramplet
from gen.ggettext import sgettext as _
from gen.display.name import displayer as name_displayer
from gen.utils.name import family_name
from gen.utils.db import family_name
#------------------------------------------------------------------------
#

View File

@ -49,7 +49,7 @@ from gen.db import DbTxn
from gen.db.write import CLASS_TO_KEY_MAP
from gen.errors import GrampsImportError
from gen.utils.id import create_id
from gen.utils.name import family_name
from gen.utils.db import family_name
from gen.utils.unknown import make_unknown, create_explanation_note
import gen.datehandler
from gen.display.name import displayer as name_displayer

View File

@ -66,7 +66,7 @@ import gen.lib
from gen.db import DbTxn
from gen.config import config
from gen.utils.id import create_id
from gen.utils.name import family_name
from gen.utils.db import family_name
from gen.utils.unknown import make_unknown
from gen.utils.file import (media_path_full, find_file, fix_encoding,
get_unicode_path_from_file_chooser)

View File

@ -46,7 +46,7 @@ from gen.ggettext import ngettext
from gui.managedwindow import ManagedWindow
import gen.lib
from gen.db import DbTxn
from gen.utils.name import family_name
from gen.utils.db import family_name
from gui.plug import tool
from gen.display.name import displayer as name_displayer

View File

@ -57,7 +57,7 @@ import gobject
import const
import gen.lib
from gui.editors import EditPerson, EditFamily
from gen.utils.name import family_name
from gen.utils.db import family_name
from gui.display import display_help
from gui.managedwindow import ManagedWindow
from gen.updatecallback import UpdateCallback

View File

@ -49,7 +49,7 @@ from gui.views.treemodels.citationlistmodel import CitationListModel
from gen.plug import CATEGORY_QR_CITATION
import gen.lib
from gui.views.listview import ListView
from gen.utils.referent import get_citation_referents
from gen.utils.db import get_citation_referents
from gui.views.bookmarks import CitationBookmarks
from gen.errors import WindowActiveError
from gui.ddtargets import DdTargets

View File

@ -50,7 +50,7 @@ from gui.views.treemodels.citationtreemodel import CitationTreeModel
from gen.plug import CATEGORY_QR_SOURCE_OR_CITATION
import gen.lib
from gui.views.listview import ListView
from gen.utils.referent import (get_source_and_citation_referents,
from gen.utils.db import (get_source_and_citation_referents,
get_citation_referents)
from gui.views.bookmarks import CitationBookmarks
from gen.errors import WindowActiveError

View File

@ -54,7 +54,7 @@ if gtk.pygtk_version < (2,3,93):
#
#-------------------------------------------------------------------------
from gen.display.name import displayer as name_displayer
from gen.utils.tree import (find_children, find_parents, find_witnessed_people)
from gen.utils.db import (find_children, find_parents, find_witnessed_people)
from libformatting import FormattingHelper
import gen.lib
from gui.views.navigationview import NavigationView

View File

@ -57,7 +57,7 @@ from gen.constfunc import win
from gen.config import config
from gen.utils.file import (media_path, relative_path, media_path_full,
fix_encoding)
from gen.utils.referent import get_media_referents
from gen.utils.db import get_media_referents
from gui.views.bookmarks import MediaBookmarks
import gen.mime
import gen.lib

View File

@ -47,7 +47,7 @@ import gtk
#-------------------------------------------------------------------------
from gui.views.listview import ListView
from gui.views.treemodels import NoteModel
from gen.utils.referent import get_note_referents
from gen.utils.db import get_note_referents
from gen.errors import WindowActiveError
from gui.views.bookmarks import NoteBookmarks
from gen.config import config

View File

@ -53,7 +53,7 @@ from gui.editors import FilterEditor
from gen.display.name import displayer as name_displayer
from gen.utils.alive import probably_alive
from gen.utils.file import media_path_full
from gen.utils.tree import find_children, find_parents, find_witnessed_people
from gen.utils.db import find_children, find_parents, find_witnessed_people
from libformatting import FormattingHelper
from gui.thumbnails import get_thumbnail_path
from gen.errors import WindowActiveError

View File

@ -37,7 +37,7 @@ from gui.views.treemodels.peoplemodel import PersonTreeModel
import gen.lib
from gen.errors import WindowActiveError
from gui.editors import EditPerson
from gen.utils.name import preset_name
from gen.utils.db import preset_name
#-------------------------------------------------------------------------
#

View File

@ -63,8 +63,8 @@ from gui.selectors import SelectorFactory
from gen.errors import WindowActiveError
from gui.views.bookmarks import PersonBookmarks
import const
from gen.utils.name import preset_name
from gen.utils.db import get_birth_or_fallback, get_death_or_fallback
from gen.utils.db import (get_birth_or_fallback, get_death_or_fallback,
preset_name)
from gui.listmodel import ListModel
from gui.managedwindow import ManagedWindow
from gui.glade import Glade

View File

@ -43,7 +43,7 @@ import gen.lib
from gen.config import config
from gui.views.listview import ListView
from gui.views.treemodels import SourceModel
from gen.utils.referent import get_source_and_citation_referents
from gen.utils.db import get_source_and_citation_referents
from gui.views.bookmarks import SourceBookmarks
from gen.errors import WindowActiveError
from gui.ddtargets import DdTargets

View File

@ -91,7 +91,7 @@ from gen.plug.report import MenuReportOptions
from gen.utils.config import get_researcher
from gen.utils.string import confidence
from gen.utils.file import media_path_full
from gen.utils.referent import get_source_and_citation_referents
from gen.utils.db import get_source_and_citation_referents
from gen.constfunc import win
from gui.thumbnails import get_thumbnail_path, run_thumbnailer
from gen.utils.image import image_size, resize_to_jpeg_buffer