GEPS008: Create module for database utilities
svn: r19921
This commit is contained in:
parent
cfe03f3b60
commit
a072c989b2
@ -212,6 +212,7 @@ src/gen/utils/__init__.py
|
|||||||
src/gen/utils/callback.py
|
src/gen/utils/callback.py
|
||||||
src/gen/utils/callman.py
|
src/gen/utils/callman.py
|
||||||
src/gen/utils/cast.py
|
src/gen/utils/cast.py
|
||||||
|
src/gen/utils/db.py
|
||||||
src/gen/utils/file.py
|
src/gen/utils/file.py
|
||||||
src/gen/utils/id.py
|
src/gen/utils/id.py
|
||||||
src/gen/utils/image.py
|
src/gen/utils/image.py
|
||||||
|
139
src/Utils.py
139
src/Utils.py
@ -41,12 +41,9 @@ LOG = logging.getLogger(".")
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import gen.lib
|
import gen.lib
|
||||||
from gen.display.name import displayer as name_displayer
|
|
||||||
from gen.datehandler import codeset
|
from gen.datehandler import codeset
|
||||||
from gen.config import config
|
from gen.config import config
|
||||||
from gen.constfunc import mac, win
|
from gen.constfunc import mac, win
|
||||||
from gen.ggettext import sgettext as _
|
|
||||||
from gen.utils.name import family_name
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -224,139 +221,3 @@ def get_researcher():
|
|||||||
owner.set_email(email)
|
owner.set_email(email)
|
||||||
|
|
||||||
return owner
|
return owner
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
# Function to return the name of the main participant of an event
|
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
def get_participant_from_event(db, event_handle, all_=False):
|
|
||||||
"""
|
|
||||||
Obtain the first primary or family participant to an event we find in the
|
|
||||||
database. Note that an event can have more than one primary or
|
|
||||||
family participant, only one is returned, adding ellipses if there are
|
|
||||||
more. If the all_ parameter is true a comma-space separated string with
|
|
||||||
the names of all primary participants is returned and no ellipses is used.
|
|
||||||
"""
|
|
||||||
participant = ""
|
|
||||||
ellipses = False
|
|
||||||
result_list = list(db.find_backlink_handles(event_handle,
|
|
||||||
include_classes=['Person', 'Family']))
|
|
||||||
#obtain handles without duplicates
|
|
||||||
people = set([x[1] for x in result_list if x[0] == 'Person'])
|
|
||||||
families = set([x[1] for x in result_list if x[0] == 'Family'])
|
|
||||||
for personhandle in people:
|
|
||||||
person = db.get_person_from_handle(personhandle)
|
|
||||||
if not person:
|
|
||||||
continue
|
|
||||||
for event_ref in person.get_event_ref_list():
|
|
||||||
if event_handle == event_ref.ref and \
|
|
||||||
event_ref.get_role().is_primary():
|
|
||||||
if participant:
|
|
||||||
if all_:
|
|
||||||
participant += ', %s' % name_displayer.display(person)
|
|
||||||
else:
|
|
||||||
ellipses = True
|
|
||||||
else:
|
|
||||||
participant = name_displayer.display(person)
|
|
||||||
break
|
|
||||||
if ellipses:
|
|
||||||
break
|
|
||||||
if ellipses:
|
|
||||||
return _('%s, ...') % participant
|
|
||||||
|
|
||||||
for familyhandle in families:
|
|
||||||
family = db.get_family_from_handle(familyhandle)
|
|
||||||
for event_ref in family.get_event_ref_list():
|
|
||||||
if event_handle == event_ref.ref and \
|
|
||||||
event_ref.get_role().is_family():
|
|
||||||
if participant:
|
|
||||||
if all_:
|
|
||||||
participant += ', %s' % family_name(family, db)
|
|
||||||
else:
|
|
||||||
ellipses = True
|
|
||||||
else:
|
|
||||||
participant = family_name(family, db)
|
|
||||||
break
|
|
||||||
if ellipses:
|
|
||||||
break
|
|
||||||
|
|
||||||
if ellipses:
|
|
||||||
return _('%s, ...') % participant
|
|
||||||
else:
|
|
||||||
return participant
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
# Function to return a label to display the active object in the status bar
|
|
||||||
# and to describe bookmarked objects.
|
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
def navigation_label(db, nav_type, handle):
|
|
||||||
|
|
||||||
label = None
|
|
||||||
obj = None
|
|
||||||
if nav_type == 'Person':
|
|
||||||
obj = db.get_person_from_handle(handle)
|
|
||||||
if obj:
|
|
||||||
label = name_displayer.display(obj)
|
|
||||||
elif nav_type == 'Family':
|
|
||||||
obj = db.get_family_from_handle(handle)
|
|
||||||
if obj:
|
|
||||||
label = family_name(obj, db)
|
|
||||||
elif nav_type == 'Event':
|
|
||||||
obj = db.get_event_from_handle(handle)
|
|
||||||
if obj:
|
|
||||||
try:
|
|
||||||
who = get_participant_from_event(db, handle)
|
|
||||||
except:
|
|
||||||
# get_participants_from_event fails when called during a magic
|
|
||||||
# batch transaction because find_backlink_handles tries to
|
|
||||||
# access the reference_map_referenced_map which doesn't exist
|
|
||||||
# under those circumstances. Since setting the navigation_label
|
|
||||||
# is inessential, just accept this and go on.
|
|
||||||
who = ''
|
|
||||||
desc = obj.get_description()
|
|
||||||
label = obj.get_type()
|
|
||||||
if desc:
|
|
||||||
label = '%s - %s' % (label, desc)
|
|
||||||
if who:
|
|
||||||
label = '%s - %s' % (label, who)
|
|
||||||
elif nav_type == 'Place':
|
|
||||||
obj = db.get_place_from_handle(handle)
|
|
||||||
if obj:
|
|
||||||
label = obj.get_title()
|
|
||||||
elif nav_type == 'Source':
|
|
||||||
obj = db.get_source_from_handle(handle)
|
|
||||||
if obj:
|
|
||||||
label = obj.get_title()
|
|
||||||
elif nav_type == 'Citation':
|
|
||||||
obj = db.get_citation_from_handle(handle)
|
|
||||||
if obj:
|
|
||||||
label = obj.get_page()
|
|
||||||
src = db.get_source_from_handle(obj.get_reference_handle())
|
|
||||||
if src:
|
|
||||||
label = src.get_title() + " " + label
|
|
||||||
elif nav_type == 'Repository':
|
|
||||||
obj = db.get_repository_from_handle(handle)
|
|
||||||
if obj:
|
|
||||||
label = obj.get_name()
|
|
||||||
elif nav_type == 'Media' or nav_type == 'MediaObject':
|
|
||||||
obj = db.get_object_from_handle(handle)
|
|
||||||
if obj:
|
|
||||||
label = obj.get_description()
|
|
||||||
elif nav_type == 'Note':
|
|
||||||
obj = db.get_note_from_handle(handle)
|
|
||||||
if obj:
|
|
||||||
label = obj.get()
|
|
||||||
# When strings are cut, make sure they are unicode
|
|
||||||
#otherwise you may end of with cutting within an utf-8 sequence
|
|
||||||
label = unicode(label)
|
|
||||||
label = " ".join(label.split())
|
|
||||||
if len(label) > 40:
|
|
||||||
label = label[:40] + "..."
|
|
||||||
|
|
||||||
if label and obj:
|
|
||||||
label = '[%s] %s' % (obj.get_gramps_id(), label)
|
|
||||||
|
|
||||||
return (label, obj)
|
|
||||||
|
@ -42,7 +42,7 @@ from gen.ggettext import gettext as _
|
|||||||
#
|
#
|
||||||
#---------------------------------------------------------------
|
#---------------------------------------------------------------
|
||||||
import const
|
import const
|
||||||
from gen.utils import ConfigManager
|
from gen.utils.configmanager import ConfigManager
|
||||||
|
|
||||||
#---------------------------------------------------------------
|
#---------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
@ -27,7 +27,7 @@ Provide the database state class
|
|||||||
|
|
||||||
from gen.db import DbBsddbRead
|
from gen.db import DbBsddbRead
|
||||||
from gen.proxy.proxybase import ProxyDbBase
|
from gen.proxy.proxybase import ProxyDbBase
|
||||||
from gen.utils import Callback
|
from gen.utils.callback import Callback
|
||||||
from gen.config import config
|
from gen.config import config
|
||||||
|
|
||||||
class DbState(Callback):
|
class DbState(Callback):
|
||||||
|
@ -35,7 +35,7 @@ from gen.ggettext import gettext as _
|
|||||||
import gen.datehandler
|
import gen.datehandler
|
||||||
from gen.lib import EventType
|
from gen.lib import EventType
|
||||||
from gen.filters.rules import Rule
|
from gen.filters.rules import Rule
|
||||||
from Utils import get_participant_from_event
|
from gen.utils.db import get_participant_from_event
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
@ -46,7 +46,6 @@ from gen.ggettext import gettext as _
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gen.config import config
|
from gen.config import config
|
||||||
import gen.utils
|
|
||||||
from gen.plug import PluginRegister
|
from gen.plug import PluginRegister
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
@ -29,14 +29,14 @@ The base option class for all other option classes.
|
|||||||
# gramps modules
|
# gramps modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import gen.utils
|
from gen.utils.callback import Callback
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Option class
|
# Option class
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class Option(gen.utils.Callback):
|
class Option(Callback):
|
||||||
"""
|
"""
|
||||||
This class serves as a base class for all options. All Options must
|
This class serves as a base class for all options. All Options must
|
||||||
minimally provide the services provided by this class. Options are allowed
|
minimally provide the services provided by this class. Options are allowed
|
||||||
@ -56,7 +56,7 @@ class Option(gen.utils.Callback):
|
|||||||
@type value: The type will depend on the type of option.
|
@type value: The type will depend on the type of option.
|
||||||
@return: nothing
|
@return: nothing
|
||||||
"""
|
"""
|
||||||
gen.utils.Callback.__init__(self)
|
Callback.__init__(self)
|
||||||
self.__value = value
|
self.__value = value
|
||||||
self.__label = label
|
self.__label = label
|
||||||
self.__help_str = ""
|
self.__help_str = ""
|
||||||
|
@ -31,7 +31,7 @@ from types import NoneType
|
|||||||
import gen.lib
|
import gen.lib
|
||||||
import gen.datehandler
|
import gen.datehandler
|
||||||
from gen.utils.string import gender as gender_map
|
from gen.utils.string import gender as gender_map
|
||||||
import gen.utils
|
from gen.utils.db import get_birth_or_fallback, get_death_or_fallback
|
||||||
from gen.plug.report.utils import place_name
|
from gen.plug.report.utils import place_name
|
||||||
|
|
||||||
from gen.display.name import displayer as name_displayer
|
from gen.display.name import displayer as name_displayer
|
||||||
@ -524,8 +524,7 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
if type(person) in [str, unicode]:
|
if type(person) in [str, unicode]:
|
||||||
person = self.dbase.get_person_from_handle(person)
|
person = self.dbase.get_person_from_handle(person)
|
||||||
event = gen.utils.get_birth_or_fallback(self.dbase,
|
event = get_birth_or_fallback(self.dbase, person, "<i>%s</i>")
|
||||||
person, "<i>%s</i>")
|
|
||||||
if get_event:
|
if get_event:
|
||||||
return event
|
return event
|
||||||
elif event:
|
elif event:
|
||||||
@ -583,8 +582,7 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
if type(person) in [str, unicode]:
|
if type(person) in [str, unicode]:
|
||||||
person = self.dbase.get_person_from_handle(person)
|
person = self.dbase.get_person_from_handle(person)
|
||||||
event = gen.utils.get_death_or_fallback(self.dbase,
|
event = get_death_or_fallback(self.dbase, person, "<i>%s</i>")
|
||||||
person, "<i>%s</i>")
|
|
||||||
if get_event:
|
if get_event:
|
||||||
return event
|
return event
|
||||||
elif event:
|
elif event:
|
||||||
|
@ -40,7 +40,7 @@ import locale
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gen.lib import Date
|
from gen.lib import Date
|
||||||
from gen.utils import get_birth_or_fallback
|
from gen.utils.db import get_birth_or_fallback
|
||||||
from gen.display.name import displayer as _nd
|
from gen.display.name import displayer as _nd
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
@ -15,7 +15,7 @@ pkgpython_PYTHON = \
|
|||||||
callman.py \
|
callman.py \
|
||||||
cast.py \
|
cast.py \
|
||||||
configmanager.py \
|
configmanager.py \
|
||||||
fallback.py \
|
db.py \
|
||||||
file.py \
|
file.py \
|
||||||
id.py \
|
id.py \
|
||||||
image.py \
|
image.py \
|
||||||
|
@ -24,7 +24,3 @@
|
|||||||
"""
|
"""
|
||||||
Generic utilities useful for users of the gen package
|
Generic utilities useful for users of the gen package
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from callback import Callback
|
|
||||||
from configmanager import ConfigManager
|
|
||||||
from fallback import *
|
|
||||||
|
293
src/gen/utils/db.py
Normal file
293
src/gen/utils/db.py
Normal file
@ -0,0 +1,293 @@
|
|||||||
|
#
|
||||||
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
|
#
|
||||||
|
# Copyright (C) 2000-2007 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
|
||||||
|
#
|
||||||
|
|
||||||
|
# $Id$
|
||||||
|
|
||||||
|
"""
|
||||||
|
Utilities for getting information from the database.
|
||||||
|
"""
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Gramps modules
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
from gen.display.name import displayer as name_displayer
|
||||||
|
from gen.utils.name import family_name
|
||||||
|
from gen.ggettext import sgettext as _
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Fallback functions
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
def get_birth_or_fallback(db, person, format=None):
|
||||||
|
"""
|
||||||
|
Get BIRTH event from a person, or fallback to an event around
|
||||||
|
the time of birth.
|
||||||
|
"""
|
||||||
|
birth_ref = person.get_birth_ref()
|
||||||
|
if birth_ref: # regular birth found
|
||||||
|
event = db.get_event_from_handle(birth_ref.ref)
|
||||||
|
if event:
|
||||||
|
return event
|
||||||
|
# now search the event list for fallbacks
|
||||||
|
for event_ref in person.get_primary_event_ref_list():
|
||||||
|
if event_ref:
|
||||||
|
event = db.get_event_from_handle(event_ref.ref)
|
||||||
|
if (event
|
||||||
|
and event.type.is_birth_fallback()
|
||||||
|
and event_ref.role.is_primary()):
|
||||||
|
if format:
|
||||||
|
event.date.format = format
|
||||||
|
return event
|
||||||
|
return None
|
||||||
|
|
||||||
|
def get_death_or_fallback(db, person, format=None):
|
||||||
|
"""
|
||||||
|
Get a DEATH event from a person, or fallback to an
|
||||||
|
event around the time of death.
|
||||||
|
"""
|
||||||
|
death_ref = person.get_death_ref()
|
||||||
|
if death_ref: # regular death found
|
||||||
|
event = db.get_event_from_handle(death_ref.ref)
|
||||||
|
if event:
|
||||||
|
return event
|
||||||
|
# now search the event list for fallbacks
|
||||||
|
for event_ref in person.get_primary_event_ref_list():
|
||||||
|
if event_ref:
|
||||||
|
event = db.get_event_from_handle(event_ref.ref)
|
||||||
|
if (event
|
||||||
|
and event.type.is_death_fallback()
|
||||||
|
and event_ref.role.is_primary()):
|
||||||
|
if format:
|
||||||
|
event.date.format = format
|
||||||
|
return event
|
||||||
|
return None
|
||||||
|
|
||||||
|
def get_event_ref(db, family, event_type):
|
||||||
|
"""
|
||||||
|
Return a reference to a primary family event of the given event type.
|
||||||
|
"""
|
||||||
|
from gen.lib import EventRoleType
|
||||||
|
for event_ref in family.get_event_ref_list():
|
||||||
|
event = db.get_event_from_handle(event_ref.ref)
|
||||||
|
if (event and event.get_type() == event_type and
|
||||||
|
(event_ref.get_role() == EventRoleType.FAMILY or
|
||||||
|
event_ref.get_role() == EventRoleType.PRIMARY)):
|
||||||
|
return event_ref
|
||||||
|
return None
|
||||||
|
|
||||||
|
def get_primary_event_ref_list(db, family):
|
||||||
|
"""
|
||||||
|
Return a reference to the primary events of the family.
|
||||||
|
"""
|
||||||
|
from gen.lib import EventRoleType
|
||||||
|
retval = []
|
||||||
|
for event_ref in family.get_event_ref_list():
|
||||||
|
event = db.get_event_from_handle(event_ref.ref)
|
||||||
|
if (event and
|
||||||
|
(event_ref.get_role() == EventRoleType.FAMILY or
|
||||||
|
event_ref.get_role() == EventRoleType.PRIMARY)):
|
||||||
|
retval.append(event_ref)
|
||||||
|
return retval
|
||||||
|
|
||||||
|
def get_marriage_or_fallback(db, family, format=None):
|
||||||
|
"""
|
||||||
|
Get a MARRIAGE event from a family, or fallback to an
|
||||||
|
alternative event type.
|
||||||
|
"""
|
||||||
|
from gen.lib import EventType, EventRoleType
|
||||||
|
marriage_ref = get_event_ref(db, family, EventType.MARRIAGE)
|
||||||
|
if marriage_ref: # regular marriage found
|
||||||
|
event = db.get_event_from_handle(marriage_ref.ref)
|
||||||
|
if event:
|
||||||
|
return event
|
||||||
|
# now search the event list for fallbacks
|
||||||
|
for event_ref in get_primary_event_ref_list(db, family):
|
||||||
|
if event_ref:
|
||||||
|
event = db.get_event_from_handle(event_ref.ref)
|
||||||
|
if (event
|
||||||
|
and event.type.is_marriage_fallback()
|
||||||
|
and (event_ref.role == EventRoleType.FAMILY or
|
||||||
|
event_ref.role == EventRoleType.PRIMARY)):
|
||||||
|
if format:
|
||||||
|
event.date.format = format
|
||||||
|
return event
|
||||||
|
return None
|
||||||
|
|
||||||
|
def get_divorce_or_fallback(db, family, format=None):
|
||||||
|
"""
|
||||||
|
Get a DIVORCE event from a family, or fallback to an
|
||||||
|
alternative event type.
|
||||||
|
"""
|
||||||
|
from gen.lib import EventType, EventRoleType
|
||||||
|
divorce_ref = get_event_ref(db, family, EventType.DIVORCE)
|
||||||
|
if divorce_ref: # regular marriage found
|
||||||
|
event = db.get_event_from_handle(divorce_ref.ref)
|
||||||
|
if event:
|
||||||
|
return event
|
||||||
|
# now search the event list for fallbacks
|
||||||
|
for event_ref in get_primary_event_ref_list(db, family):
|
||||||
|
if event_ref:
|
||||||
|
event = db.get_event_from_handle(event_ref.ref)
|
||||||
|
if (event
|
||||||
|
and event.type.is_divorce_fallback()
|
||||||
|
and (event_ref.role == EventRoleType.FAMILY or
|
||||||
|
event_ref.role == EventRoleType.PRIMARY)):
|
||||||
|
if format:
|
||||||
|
event.date.format = format
|
||||||
|
return event
|
||||||
|
return None
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Function to return the name of the main participant of an event
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
def get_participant_from_event(db, event_handle, all_=False):
|
||||||
|
"""
|
||||||
|
Obtain the first primary or family participant to an event we find in the
|
||||||
|
database. Note that an event can have more than one primary or
|
||||||
|
family participant, only one is returned, adding ellipses if there are
|
||||||
|
more. If the all_ parameter is true a comma-space separated string with
|
||||||
|
the names of all primary participants is returned and no ellipses is used.
|
||||||
|
"""
|
||||||
|
participant = ""
|
||||||
|
ellipses = False
|
||||||
|
result_list = list(db.find_backlink_handles(event_handle,
|
||||||
|
include_classes=['Person', 'Family']))
|
||||||
|
#obtain handles without duplicates
|
||||||
|
people = set([x[1] for x in result_list if x[0] == 'Person'])
|
||||||
|
families = set([x[1] for x in result_list if x[0] == 'Family'])
|
||||||
|
for personhandle in people:
|
||||||
|
person = db.get_person_from_handle(personhandle)
|
||||||
|
if not person:
|
||||||
|
continue
|
||||||
|
for event_ref in person.get_event_ref_list():
|
||||||
|
if event_handle == event_ref.ref and \
|
||||||
|
event_ref.get_role().is_primary():
|
||||||
|
if participant:
|
||||||
|
if all_:
|
||||||
|
participant += ', %s' % name_displayer.display(person)
|
||||||
|
else:
|
||||||
|
ellipses = True
|
||||||
|
else:
|
||||||
|
participant = name_displayer.display(person)
|
||||||
|
break
|
||||||
|
if ellipses:
|
||||||
|
break
|
||||||
|
if ellipses:
|
||||||
|
return _('%s, ...') % participant
|
||||||
|
|
||||||
|
for familyhandle in families:
|
||||||
|
family = db.get_family_from_handle(familyhandle)
|
||||||
|
for event_ref in family.get_event_ref_list():
|
||||||
|
if event_handle == event_ref.ref and \
|
||||||
|
event_ref.get_role().is_family():
|
||||||
|
if participant:
|
||||||
|
if all_:
|
||||||
|
participant += ', %s' % family_name(family, db)
|
||||||
|
else:
|
||||||
|
ellipses = True
|
||||||
|
else:
|
||||||
|
participant = family_name(family, db)
|
||||||
|
break
|
||||||
|
if ellipses:
|
||||||
|
break
|
||||||
|
|
||||||
|
if ellipses:
|
||||||
|
return _('%s, ...') % participant
|
||||||
|
else:
|
||||||
|
return participant
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Function to return a label to display the active object in the status bar
|
||||||
|
# and to describe bookmarked objects.
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
def navigation_label(db, nav_type, handle):
|
||||||
|
|
||||||
|
label = None
|
||||||
|
obj = None
|
||||||
|
if nav_type == 'Person':
|
||||||
|
obj = db.get_person_from_handle(handle)
|
||||||
|
if obj:
|
||||||
|
label = name_displayer.display(obj)
|
||||||
|
elif nav_type == 'Family':
|
||||||
|
obj = db.get_family_from_handle(handle)
|
||||||
|
if obj:
|
||||||
|
label = family_name(obj, db)
|
||||||
|
elif nav_type == 'Event':
|
||||||
|
obj = db.get_event_from_handle(handle)
|
||||||
|
if obj:
|
||||||
|
try:
|
||||||
|
who = get_participant_from_event(db, handle)
|
||||||
|
except:
|
||||||
|
# get_participants_from_event fails when called during a magic
|
||||||
|
# batch transaction because find_backlink_handles tries to
|
||||||
|
# access the reference_map_referenced_map which doesn't exist
|
||||||
|
# under those circumstances. Since setting the navigation_label
|
||||||
|
# is inessential, just accept this and go on.
|
||||||
|
who = ''
|
||||||
|
desc = obj.get_description()
|
||||||
|
label = obj.get_type()
|
||||||
|
if desc:
|
||||||
|
label = '%s - %s' % (label, desc)
|
||||||
|
if who:
|
||||||
|
label = '%s - %s' % (label, who)
|
||||||
|
elif nav_type == 'Place':
|
||||||
|
obj = db.get_place_from_handle(handle)
|
||||||
|
if obj:
|
||||||
|
label = obj.get_title()
|
||||||
|
elif nav_type == 'Source':
|
||||||
|
obj = db.get_source_from_handle(handle)
|
||||||
|
if obj:
|
||||||
|
label = obj.get_title()
|
||||||
|
elif nav_type == 'Citation':
|
||||||
|
obj = db.get_citation_from_handle(handle)
|
||||||
|
if obj:
|
||||||
|
label = obj.get_page()
|
||||||
|
src = db.get_source_from_handle(obj.get_reference_handle())
|
||||||
|
if src:
|
||||||
|
label = src.get_title() + " " + label
|
||||||
|
elif nav_type == 'Repository':
|
||||||
|
obj = db.get_repository_from_handle(handle)
|
||||||
|
if obj:
|
||||||
|
label = obj.get_name()
|
||||||
|
elif nav_type == 'Media' or nav_type == 'MediaObject':
|
||||||
|
obj = db.get_object_from_handle(handle)
|
||||||
|
if obj:
|
||||||
|
label = obj.get_description()
|
||||||
|
elif nav_type == 'Note':
|
||||||
|
obj = db.get_note_from_handle(handle)
|
||||||
|
if obj:
|
||||||
|
label = obj.get()
|
||||||
|
# When strings are cut, make sure they are unicode
|
||||||
|
#otherwise you may end of with cutting within an utf-8 sequence
|
||||||
|
label = unicode(label)
|
||||||
|
label = " ".join(label.split())
|
||||||
|
if len(label) > 40:
|
||||||
|
label = label[:40] + "..."
|
||||||
|
|
||||||
|
if label and obj:
|
||||||
|
label = '[%s] %s' % (obj.get_gramps_id(), label)
|
||||||
|
|
||||||
|
return (label, obj)
|
@ -1,144 +0,0 @@
|
|||||||
#
|
|
||||||
# Gramps - a GTK+/GNOME based genealogy program
|
|
||||||
#
|
|
||||||
# Copyright (C) 2000-2007 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
|
|
||||||
#
|
|
||||||
|
|
||||||
# $Id$
|
|
||||||
|
|
||||||
"""
|
|
||||||
Functional database interface for getting events, or fallback events.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def get_birth_or_fallback(db, person, format=None):
|
|
||||||
"""
|
|
||||||
Get BIRTH event from a person, or fallback to an event around
|
|
||||||
the time of birth.
|
|
||||||
"""
|
|
||||||
birth_ref = person.get_birth_ref()
|
|
||||||
if birth_ref: # regular birth found
|
|
||||||
event = db.get_event_from_handle(birth_ref.ref)
|
|
||||||
if event:
|
|
||||||
return event
|
|
||||||
# now search the event list for fallbacks
|
|
||||||
for event_ref in person.get_primary_event_ref_list():
|
|
||||||
if event_ref:
|
|
||||||
event = db.get_event_from_handle(event_ref.ref)
|
|
||||||
if (event
|
|
||||||
and event.type.is_birth_fallback()
|
|
||||||
and event_ref.role.is_primary()):
|
|
||||||
if format:
|
|
||||||
event.date.format = format
|
|
||||||
return event
|
|
||||||
return None
|
|
||||||
|
|
||||||
def get_death_or_fallback(db, person, format=None):
|
|
||||||
"""
|
|
||||||
Get a DEATH event from a person, or fallback to an
|
|
||||||
event around the time of death.
|
|
||||||
"""
|
|
||||||
death_ref = person.get_death_ref()
|
|
||||||
if death_ref: # regular death found
|
|
||||||
event = db.get_event_from_handle(death_ref.ref)
|
|
||||||
if event:
|
|
||||||
return event
|
|
||||||
# now search the event list for fallbacks
|
|
||||||
for event_ref in person.get_primary_event_ref_list():
|
|
||||||
if event_ref:
|
|
||||||
event = db.get_event_from_handle(event_ref.ref)
|
|
||||||
if (event
|
|
||||||
and event.type.is_death_fallback()
|
|
||||||
and event_ref.role.is_primary()):
|
|
||||||
if format:
|
|
||||||
event.date.format = format
|
|
||||||
return event
|
|
||||||
return None
|
|
||||||
|
|
||||||
def get_event_ref(db, family, event_type):
|
|
||||||
"""
|
|
||||||
Return a reference to a primary family event of the given event type.
|
|
||||||
"""
|
|
||||||
from gen.lib import EventRoleType
|
|
||||||
for event_ref in family.get_event_ref_list():
|
|
||||||
event = db.get_event_from_handle(event_ref.ref)
|
|
||||||
if (event and event.get_type() == event_type and
|
|
||||||
(event_ref.get_role() == EventRoleType.FAMILY or
|
|
||||||
event_ref.get_role() == EventRoleType.PRIMARY)):
|
|
||||||
return event_ref
|
|
||||||
return None
|
|
||||||
|
|
||||||
def get_primary_event_ref_list(db, family):
|
|
||||||
"""
|
|
||||||
Return a reference to the primary events of the family.
|
|
||||||
"""
|
|
||||||
from gen.lib import EventRoleType
|
|
||||||
retval = []
|
|
||||||
for event_ref in family.get_event_ref_list():
|
|
||||||
event = db.get_event_from_handle(event_ref.ref)
|
|
||||||
if (event and
|
|
||||||
(event_ref.get_role() == EventRoleType.FAMILY or
|
|
||||||
event_ref.get_role() == EventRoleType.PRIMARY)):
|
|
||||||
retval.append(event_ref)
|
|
||||||
return retval
|
|
||||||
|
|
||||||
def get_marriage_or_fallback(db, family, format=None):
|
|
||||||
"""
|
|
||||||
Get a MARRIAGE event from a family, or fallback to an
|
|
||||||
alternative event type.
|
|
||||||
"""
|
|
||||||
from gen.lib import EventType, EventRoleType
|
|
||||||
marriage_ref = get_event_ref(db, family, EventType.MARRIAGE)
|
|
||||||
if marriage_ref: # regular marriage found
|
|
||||||
event = db.get_event_from_handle(marriage_ref.ref)
|
|
||||||
if event:
|
|
||||||
return event
|
|
||||||
# now search the event list for fallbacks
|
|
||||||
for event_ref in get_primary_event_ref_list(db, family):
|
|
||||||
if event_ref:
|
|
||||||
event = db.get_event_from_handle(event_ref.ref)
|
|
||||||
if (event
|
|
||||||
and event.type.is_marriage_fallback()
|
|
||||||
and (event_ref.role == EventRoleType.FAMILY or
|
|
||||||
event_ref.role == EventRoleType.PRIMARY)):
|
|
||||||
if format:
|
|
||||||
event.date.format = format
|
|
||||||
return event
|
|
||||||
return None
|
|
||||||
|
|
||||||
def get_divorce_or_fallback(db, family, format=None):
|
|
||||||
"""
|
|
||||||
Get a DIVORCE event from a family, or fallback to an
|
|
||||||
alternative event type.
|
|
||||||
"""
|
|
||||||
from gen.lib import EventType, EventRoleType
|
|
||||||
divorce_ref = get_event_ref(db, family, EventType.DIVORCE)
|
|
||||||
if divorce_ref: # regular marriage found
|
|
||||||
event = db.get_event_from_handle(divorce_ref.ref)
|
|
||||||
if event:
|
|
||||||
return event
|
|
||||||
# now search the event list for fallbacks
|
|
||||||
for event_ref in get_primary_event_ref_list(db, family):
|
|
||||||
if event_ref:
|
|
||||||
event = db.get_event_from_handle(event_ref.ref)
|
|
||||||
if (event
|
|
||||||
and event.type.is_divorce_fallback()
|
|
||||||
and (event_ref.role == EventRoleType.FAMILY or
|
|
||||||
event_ref.role == EventRoleType.PRIMARY)):
|
|
||||||
if format:
|
|
||||||
event.date.format = format
|
|
||||||
return event
|
|
||||||
return None
|
|
@ -26,7 +26,7 @@ import unittest
|
|||||||
from test import test_util as tu
|
from test import test_util as tu
|
||||||
tu.path_append_parent()
|
tu.path_append_parent()
|
||||||
|
|
||||||
from gen.utils import Callback
|
from gen.utils.callback import Callback
|
||||||
|
|
||||||
try:
|
try:
|
||||||
log
|
log
|
||||||
|
@ -53,7 +53,7 @@ import gobject
|
|||||||
# GRAMPS modules
|
# GRAMPS modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import gen.utils
|
from gen.utils.callback import Callback
|
||||||
from gui.utils import process_pending_events
|
from gui.utils import process_pending_events
|
||||||
from gui.views.navigationview import NavigationView
|
from gui.views.navigationview import NavigationView
|
||||||
from gen.config import config
|
from gen.config import config
|
||||||
@ -61,7 +61,7 @@ from gen.display.name import displayer as name_displayer
|
|||||||
from gui.managedwindow import GrampsWindowManager
|
from gui.managedwindow import GrampsWindowManager
|
||||||
from gen.relationship import get_relationship_calculator
|
from gen.relationship import get_relationship_calculator
|
||||||
from gui.glade import Glade
|
from gui.glade import Glade
|
||||||
from Utils import navigation_label
|
from gen.utils.db import navigation_label
|
||||||
|
|
||||||
DISABLED = -1
|
DISABLED = -1
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ DISABLED = -1
|
|||||||
# History manager
|
# History manager
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class History(gen.utils.Callback):
|
class History(Callback):
|
||||||
""" History manages the objects of a certain type that have been viewed,
|
""" History manages the objects of a certain type that have been viewed,
|
||||||
with ability to go back, or forward.
|
with ability to go back, or forward.
|
||||||
When accessing an object, it should be pushed on the History.
|
When accessing an object, it should be pushed on the History.
|
||||||
@ -82,7 +82,7 @@ class History(gen.utils.Callback):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, dbstate, nav_type):
|
def __init__(self, dbstate, nav_type):
|
||||||
gen.utils.Callback.__init__(self)
|
Callback.__init__(self)
|
||||||
self.dbstate = dbstate
|
self.dbstate = dbstate
|
||||||
self.nav_type = nav_type
|
self.nav_type = nav_type
|
||||||
self.clear()
|
self.clear()
|
||||||
@ -351,7 +351,7 @@ class WarnHandler(RotateHandler):
|
|||||||
top.run()
|
top.run()
|
||||||
top.destroy()
|
top.destroy()
|
||||||
|
|
||||||
class DisplayState(gen.utils.Callback):
|
class DisplayState(Callback):
|
||||||
|
|
||||||
__signals__ = {
|
__signals__ = {
|
||||||
'filters-changed' : (str, ),
|
'filters-changed' : (str, ),
|
||||||
@ -380,7 +380,7 @@ class DisplayState(gen.utils.Callback):
|
|||||||
self.uimanager = uimanager
|
self.uimanager = uimanager
|
||||||
self.progress_monitor = progress_monitor
|
self.progress_monitor = progress_monitor
|
||||||
self.window = window
|
self.window = window
|
||||||
gen.utils.Callback.__init__(self)
|
Callback.__init__(self)
|
||||||
self.status = status
|
self.status = status
|
||||||
self.status_id = status.get_context_id('GRAMPS')
|
self.status_id = status.get_context_id('GRAMPS')
|
||||||
self.progress = progress
|
self.progress = progress
|
||||||
|
@ -38,7 +38,7 @@ from gen.ggettext import gettext as _
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gen.display.name import displayer as name_displayer
|
from gen.display.name import displayer as name_displayer
|
||||||
from gen.utils.name import family_name
|
from gen.utils.name import family_name
|
||||||
import Utils
|
from gen.utils.db import get_participant_from_event
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -112,7 +112,7 @@ class BackRefModel(gtk.ListStore):
|
|||||||
'part2': name}
|
'part2': name}
|
||||||
else:
|
else:
|
||||||
name = str(p.get_type())
|
name = str(p.get_type())
|
||||||
part = Utils.get_participant_from_event(self.db, ref[1])
|
part = get_participant_from_event(self.db, ref[1])
|
||||||
if part :
|
if part :
|
||||||
name = self.dispstr % {'part1': name,
|
name = self.dispstr % {'part1': name,
|
||||||
'part2': part}
|
'part2': part}
|
||||||
|
@ -37,7 +37,7 @@ import gen.datehandler
|
|||||||
from gen.display.name import displayer as name_displayer
|
from gen.display.name import displayer as name_displayer
|
||||||
from gen.utils.string import gender as gender_map
|
from gen.utils.string import gender as gender_map
|
||||||
import gen.lib
|
import gen.lib
|
||||||
from gen.utils import get_birth_or_fallback, get_death_or_fallback
|
from gen.utils.db import get_birth_or_fallback, get_death_or_fallback
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
@ -53,7 +53,7 @@ from displaytabs import (CitationEmbedList, NoteTab, GalleryTab,
|
|||||||
EventBackRefList, AttrEmbedList)
|
EventBackRefList, AttrEmbedList)
|
||||||
from gui.widgets import (MonitoredEntry, PrivacyButton,
|
from gui.widgets import (MonitoredEntry, PrivacyButton,
|
||||||
MonitoredDataType, MonitoredDate)
|
MonitoredDataType, MonitoredDate)
|
||||||
from Utils import get_participant_from_event
|
from gen.utils.db import get_participant_from_event
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
@ -62,7 +62,7 @@ import gobject
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gen.config import config
|
from gen.config import config
|
||||||
from gen.display.name import displayer as name_displayer
|
from gen.display.name import displayer as name_displayer
|
||||||
from gen.utils import get_marriage_or_fallback
|
from gen.utils.db import get_marriage_or_fallback
|
||||||
import gen.lib
|
import gen.lib
|
||||||
from gen.db import DbTxn
|
from gen.db import DbTxn
|
||||||
from gen.errors import WindowActiveError
|
from gen.errors import WindowActiveError
|
||||||
@ -80,7 +80,7 @@ from gui.widgets import (PrivacyButton, MonitoredEntry, MonitoredDataType,
|
|||||||
from gen.plug import CATEGORY_QR_FAMILY
|
from gen.plug import CATEGORY_QR_FAMILY
|
||||||
from gui.dialog import (ErrorDialog, RunDatabaseRepair, WarningDialog,
|
from gui.dialog import (ErrorDialog, RunDatabaseRepair, WarningDialog,
|
||||||
MessageHideDialog)
|
MessageHideDialog)
|
||||||
from gen.utils import get_birth_or_fallback, get_death_or_fallback
|
from gen.utils.db import get_birth_or_fallback, get_death_or_fallback
|
||||||
from gui.selectors import SelectorFactory
|
from gui.selectors import SelectorFactory
|
||||||
from gen.utils.id import create_id
|
from gen.utils.id import create_id
|
||||||
from gen.utils.name import preset_name, family_name
|
from gen.utils.name import preset_name, family_name
|
||||||
|
@ -52,7 +52,7 @@ import pango
|
|||||||
from gen.utils.file import media_path_full
|
from gen.utils.file import media_path_full
|
||||||
from gui.thumbnails import get_thumbnail_image
|
from gui.thumbnails import get_thumbnail_image
|
||||||
import gui.utils
|
import gui.utils
|
||||||
from gen.utils import get_birth_or_fallback
|
from gen.utils.db import get_birth_or_fallback
|
||||||
import gen.lib
|
import gen.lib
|
||||||
from gen.db import DbTxn
|
from gen.db import DbTxn
|
||||||
from gui import widgets
|
from gui import widgets
|
||||||
|
@ -34,7 +34,7 @@ import const
|
|||||||
from gui.display import display_help
|
from gui.display import display_help
|
||||||
from gui.managedwindow import ManagedWindow
|
from gui.managedwindow import ManagedWindow
|
||||||
import gen.datehandler
|
import gen.datehandler
|
||||||
import Utils
|
from gen.utils.db import get_participant_from_event
|
||||||
from gen.merge import MergeEventQuery
|
from gen.merge import MergeEventQuery
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -121,8 +121,8 @@ class MergeEvent(ManagedWindow):
|
|||||||
self.get_widget(widget_name).set_sensitive(False)
|
self.get_widget(widget_name).set_sensitive(False)
|
||||||
|
|
||||||
# Main window widgets that determine which handle survives
|
# Main window widgets that determine which handle survives
|
||||||
ppant1 = Utils.get_participant_from_event(database, handle1)
|
ppant1 = get_participant_from_event(database, handle1)
|
||||||
ppant2 = Utils.get_participant_from_event(database, handle2)
|
ppant2 = get_participant_from_event(database, handle2)
|
||||||
rbutton1 = self.get_widget("handle_btn1")
|
rbutton1 = self.get_widget("handle_btn1")
|
||||||
rbutton_label1 = self.get_widget("label_handle_btn1")
|
rbutton_label1 = self.get_widget("label_handle_btn1")
|
||||||
rbutton_label2 = self.get_widget("label_handle_btn2")
|
rbutton_label2 = self.get_widget("label_handle_btn2")
|
||||||
|
@ -42,7 +42,7 @@ import gtk
|
|||||||
# GRAMPS modules
|
# GRAMPS modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import gen.utils
|
from gen.utils.callback import Callback
|
||||||
from gen.plug import BasePluginManager, PluginRegister
|
from gen.plug import BasePluginManager, PluginRegister
|
||||||
from gen.constfunc import win
|
from gen.constfunc import win
|
||||||
from gen.config import config
|
from gen.config import config
|
||||||
@ -118,7 +118,7 @@ def base_reg_stock_icons(iconpaths, extraiconsize, items):
|
|||||||
# GuiPluginManager
|
# GuiPluginManager
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class GuiPluginManager(gen.utils.Callback):
|
class GuiPluginManager(Callback):
|
||||||
""" PluginManager is a Singleton which manages plugins.
|
""" PluginManager is a Singleton which manages plugins.
|
||||||
It is the gui implementation using a unique BasePluginmanager.
|
It is the gui implementation using a unique BasePluginmanager.
|
||||||
This class adds the possibility to hide plugins in the GUI via a config
|
This class adds the possibility to hide plugins in the GUI via a config
|
||||||
@ -141,7 +141,7 @@ class GuiPluginManager(gen.utils.Callback):
|
|||||||
raise Exception("This class is a singleton. "
|
raise Exception("This class is a singleton. "
|
||||||
"Use the get_instance() method")
|
"Use the get_instance() method")
|
||||||
|
|
||||||
gen.utils.Callback.__init__(self)
|
Callback.__init__(self)
|
||||||
self.basemgr = BasePluginManager.get_instance()
|
self.basemgr = BasePluginManager.get_instance()
|
||||||
self.__hidden_plugins = set(config.get('plugin.hiddenplugins'))
|
self.__hidden_plugins = set(config.get('plugin.hiddenplugins'))
|
||||||
self.__hidden_changed()
|
self.__hidden_changed()
|
||||||
|
@ -53,7 +53,7 @@ import gtk
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gui.display import display_help
|
from gui.display import display_help
|
||||||
from gui.listmodel import ListModel
|
from gui.listmodel import ListModel
|
||||||
import Utils
|
from gen.utils.db import navigation_label
|
||||||
import const
|
import const
|
||||||
from gen.ggettext import sgettext as _
|
from gen.ggettext import sgettext as _
|
||||||
|
|
||||||
@ -322,7 +322,7 @@ class PersonBookmarks(ListBookmarks) :
|
|||||||
goto_handle)
|
goto_handle)
|
||||||
|
|
||||||
def make_label(self, handle):
|
def make_label(self, handle):
|
||||||
return Utils.navigation_label(self.dbstate.db, 'Person', handle)
|
return navigation_label(self.dbstate.db, 'Person', handle)
|
||||||
|
|
||||||
def connect_signals(self):
|
def connect_signals(self):
|
||||||
self.dbstate.db.connect('person-delete', self.remove_handles)
|
self.dbstate.db.connect('person-delete', self.remove_handles)
|
||||||
@ -335,7 +335,7 @@ class FamilyBookmarks(ListBookmarks) :
|
|||||||
goto_handle)
|
goto_handle)
|
||||||
|
|
||||||
def make_label(self, handle):
|
def make_label(self, handle):
|
||||||
return Utils.navigation_label(self.dbstate.db, 'Family', handle)
|
return navigation_label(self.dbstate.db, 'Family', handle)
|
||||||
|
|
||||||
def connect_signals(self):
|
def connect_signals(self):
|
||||||
self.dbstate.db.connect('family-delete', self.remove_handles)
|
self.dbstate.db.connect('family-delete', self.remove_handles)
|
||||||
@ -348,7 +348,7 @@ class EventBookmarks(ListBookmarks) :
|
|||||||
goto_handle)
|
goto_handle)
|
||||||
|
|
||||||
def make_label(self, handle):
|
def make_label(self, handle):
|
||||||
return Utils.navigation_label(self.dbstate.db, 'Event', handle)
|
return navigation_label(self.dbstate.db, 'Event', handle)
|
||||||
|
|
||||||
def connect_signals(self):
|
def connect_signals(self):
|
||||||
self.dbstate.db.connect('event-delete', self.remove_handles)
|
self.dbstate.db.connect('event-delete', self.remove_handles)
|
||||||
@ -360,7 +360,7 @@ class SourceBookmarks(ListBookmarks) :
|
|||||||
goto_handle)
|
goto_handle)
|
||||||
|
|
||||||
def make_label(self, handle):
|
def make_label(self, handle):
|
||||||
return Utils.navigation_label(self.dbstate.db, 'Source', handle)
|
return navigation_label(self.dbstate.db, 'Source', handle)
|
||||||
|
|
||||||
def connect_signals(self):
|
def connect_signals(self):
|
||||||
self.dbstate.db.connect('source-delete', self.remove_handles)
|
self.dbstate.db.connect('source-delete', self.remove_handles)
|
||||||
@ -372,7 +372,7 @@ class CitationBookmarks(ListBookmarks) :
|
|||||||
goto_handle)
|
goto_handle)
|
||||||
|
|
||||||
def make_label(self, handle):
|
def make_label(self, handle):
|
||||||
return Utils.navigation_label(self.dbstate.db, 'Citation', handle)
|
return navigation_label(self.dbstate.db, 'Citation', handle)
|
||||||
|
|
||||||
def connect_signals(self):
|
def connect_signals(self):
|
||||||
self.dbstate.db.connect('citation-delete', self.remove_handles)
|
self.dbstate.db.connect('citation-delete', self.remove_handles)
|
||||||
@ -385,7 +385,7 @@ class MediaBookmarks(ListBookmarks) :
|
|||||||
goto_handle)
|
goto_handle)
|
||||||
|
|
||||||
def make_label(self, handle):
|
def make_label(self, handle):
|
||||||
return Utils.navigation_label(self.dbstate.db, 'Media', handle)
|
return navigation_label(self.dbstate.db, 'Media', handle)
|
||||||
|
|
||||||
def connect_signals(self):
|
def connect_signals(self):
|
||||||
self.dbstate.db.connect('media-delete', self.remove_handles)
|
self.dbstate.db.connect('media-delete', self.remove_handles)
|
||||||
@ -398,7 +398,7 @@ class RepoBookmarks(ListBookmarks) :
|
|||||||
goto_handle)
|
goto_handle)
|
||||||
|
|
||||||
def make_label(self, handle):
|
def make_label(self, handle):
|
||||||
return Utils.navigation_label(self.dbstate.db, 'Repository', handle)
|
return navigation_label(self.dbstate.db, 'Repository', handle)
|
||||||
|
|
||||||
def connect_signals(self):
|
def connect_signals(self):
|
||||||
self.dbstate.db.connect('repository-delete', self.remove_handles)
|
self.dbstate.db.connect('repository-delete', self.remove_handles)
|
||||||
@ -411,7 +411,7 @@ class PlaceBookmarks(ListBookmarks) :
|
|||||||
goto_handle)
|
goto_handle)
|
||||||
|
|
||||||
def make_label(self, handle):
|
def make_label(self, handle):
|
||||||
return Utils.navigation_label(self.dbstate.db, 'Place', handle)
|
return navigation_label(self.dbstate.db, 'Place', handle)
|
||||||
|
|
||||||
def connect_signals(self):
|
def connect_signals(self):
|
||||||
self.dbstate.db.connect('place-delete', self.remove_handles)
|
self.dbstate.db.connect('place-delete', self.remove_handles)
|
||||||
@ -424,7 +424,7 @@ class NoteBookmarks(ListBookmarks) :
|
|||||||
goto_handle)
|
goto_handle)
|
||||||
|
|
||||||
def make_label(self, handle):
|
def make_label(self, handle):
|
||||||
return Utils.navigation_label(self.dbstate.db, 'Note', handle)
|
return navigation_label(self.dbstate.db, 'Note', handle)
|
||||||
|
|
||||||
def connect_signals(self):
|
def connect_signals(self):
|
||||||
self.dbstate.db.connect('note-delete', self.remove_handles)
|
self.dbstate.db.connect('note-delete', self.remove_handles)
|
||||||
|
@ -48,7 +48,7 @@ import gtk
|
|||||||
#----------------------------------------------------------------
|
#----------------------------------------------------------------
|
||||||
from gui.views.pageview import PageView
|
from gui.views.pageview import PageView
|
||||||
from gen.ggettext import sgettext as _
|
from gen.ggettext import sgettext as _
|
||||||
from Utils import navigation_label
|
from gen.utils.db import navigation_label
|
||||||
from gen.constfunc import mod_key
|
from gen.constfunc import mod_key
|
||||||
|
|
||||||
DISABLED = -1
|
DISABLED = -1
|
||||||
|
@ -42,7 +42,7 @@ import gtk
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import gen.datehandler
|
import gen.datehandler
|
||||||
import gen.lib
|
import gen.lib
|
||||||
import Utils
|
from gen.utils.db import get_participant_from_event
|
||||||
from gen.config import config
|
from gen.config import config
|
||||||
from gui.views.treemodels.flatbasemodel import FlatBaseModel
|
from gui.views.treemodels.flatbasemodel import FlatBaseModel
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ class EventModel(FlatBaseModel):
|
|||||||
return data[COLUMN_DESCRIPTION]
|
return data[COLUMN_DESCRIPTION]
|
||||||
|
|
||||||
def column_participant(self,data):
|
def column_participant(self,data):
|
||||||
return Utils.get_participant_from_event(self.db, data[COLUMN_HANDLE])
|
return get_participant_from_event(self.db, data[COLUMN_HANDLE])
|
||||||
|
|
||||||
def column_place(self,data):
|
def column_place(self,data):
|
||||||
if data[COLUMN_PLACE]:
|
if data[COLUMN_PLACE]:
|
||||||
|
@ -143,7 +143,7 @@ class FamilyModel(FlatBaseModel):
|
|||||||
return unicode(gen.lib.FamilyRelType(data[5]))
|
return unicode(gen.lib.FamilyRelType(data[5]))
|
||||||
|
|
||||||
def column_marriage(self, data):
|
def column_marriage(self, data):
|
||||||
from gen.utils import get_marriage_or_fallback
|
from gen.utils.db import get_marriage_or_fallback
|
||||||
family = self.db.get_family_from_handle(data[0])
|
family = self.db.get_family_from_handle(data[0])
|
||||||
event = get_marriage_or_fallback(self.db, family, "<i>%s</i>")
|
event = get_marriage_or_fallback(self.db, family, "<i>%s</i>")
|
||||||
if event:
|
if event:
|
||||||
@ -157,7 +157,7 @@ class FamilyModel(FlatBaseModel):
|
|||||||
return u''
|
return u''
|
||||||
|
|
||||||
def sort_marriage(self, data):
|
def sort_marriage(self, data):
|
||||||
from gen.utils import get_marriage_or_fallback
|
from gen.utils.db import get_marriage_or_fallback
|
||||||
family = self.db.get_family_from_handle(data[0])
|
family = self.db.get_family_from_handle(data[0])
|
||||||
event = get_marriage_or_fallback(self.db, family)
|
event = get_marriage_or_fallback(self.db, family)
|
||||||
if event:
|
if event:
|
||||||
|
@ -48,7 +48,7 @@ from gen.plug.docgen import (FontStyle, ParagraphStyle, GraphicsStyle,
|
|||||||
from gen.sort import Sort
|
from gen.sort import Sort
|
||||||
from gen.display.name import displayer as name_displayer
|
from gen.display.name import displayer as name_displayer
|
||||||
from gen.config import config
|
from gen.config import config
|
||||||
from gen.utils import get_birth_or_fallback, get_death_or_fallback
|
from gen.utils.db import get_birth_or_fallback, get_death_or_fallback
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
from gui.listmodel import ListModel, NOSORT
|
from gui.listmodel import ListModel, NOSORT
|
||||||
from Utils import navigation_label
|
from gen.utils.db import navigation_label
|
||||||
from gen.plug import Gramplet
|
from gen.plug import Gramplet
|
||||||
from gen.ggettext import gettext as _
|
from gen.ggettext import gettext as _
|
||||||
import gtk
|
import gtk
|
||||||
|
@ -24,7 +24,7 @@ from gui.listmodel import ListModel, NOSORT
|
|||||||
from gen.plug import Gramplet
|
from gen.plug import Gramplet
|
||||||
from gen.ggettext import gettext as _
|
from gen.ggettext import gettext as _
|
||||||
from gen.display.name import displayer as name_displayer
|
from gen.display.name import displayer as name_displayer
|
||||||
from gen.utils import get_birth_or_fallback, get_death_or_fallback
|
from gen.utils.db import get_birth_or_fallback, get_death_or_fallback
|
||||||
import gen.datehandler
|
import gen.datehandler
|
||||||
from gen.errors import WindowActiveError
|
from gen.errors import WindowActiveError
|
||||||
import gtk
|
import gtk
|
||||||
|
@ -41,7 +41,7 @@ from gen.plug import Gramplet
|
|||||||
from gen.plug.report import utils as ReportUtils
|
from gen.plug.report import utils as ReportUtils
|
||||||
from gen.display.name import displayer as name_displayer
|
from gen.display.name import displayer as name_displayer
|
||||||
import gen.datehandler
|
import gen.datehandler
|
||||||
from gen.utils import get_birth_or_fallback, get_death_or_fallback
|
from gen.utils.db import get_birth_or_fallback, get_death_or_fallback
|
||||||
|
|
||||||
class DescendantGramplet(Gramplet):
|
class DescendantGramplet(Gramplet):
|
||||||
def init(self):
|
def init(self):
|
||||||
|
@ -25,7 +25,7 @@ from gen.plug import Gramplet
|
|||||||
from gen.ggettext import gettext as _
|
from gen.ggettext import gettext as _
|
||||||
from gen.display.name import displayer as name_displayer
|
from gen.display.name import displayer as name_displayer
|
||||||
import gen.datehandler
|
import gen.datehandler
|
||||||
from gen.utils import get_birth_or_fallback, get_marriage_or_fallback
|
from gen.utils.db import get_birth_or_fallback, get_marriage_or_fallback
|
||||||
from gen.errors import WindowActiveError
|
from gen.errors import WindowActiveError
|
||||||
import gtk
|
import gtk
|
||||||
from gen.config import config
|
from gen.config import config
|
||||||
|
@ -38,7 +38,7 @@ from gen.ggettext import ngettext
|
|||||||
from gen.display.name import displayer as name_displayer
|
from gen.display.name import displayer as name_displayer
|
||||||
import gen.datehandler
|
import gen.datehandler
|
||||||
import gen
|
import gen
|
||||||
from gen.utils import get_birth_or_fallback, get_death_or_fallback
|
from gen.utils.db import get_birth_or_fallback, get_death_or_fallback
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
@ -60,7 +60,7 @@ from gen.plug.report import MenuReportOptions
|
|||||||
from gen.plug.menu import (NumberOption, ColorOption, BooleanOption,
|
from gen.plug.menu import (NumberOption, ColorOption, BooleanOption,
|
||||||
EnumeratedListOption, PersonListOption,
|
EnumeratedListOption, PersonListOption,
|
||||||
SurnameColorOption)
|
SurnameColorOption)
|
||||||
from gen.utils import get_birth_or_fallback, get_death_or_fallback
|
from gen.utils.db import get_birth_or_fallback, get_death_or_fallback
|
||||||
from gen.display.name import displayer as name_displayer
|
from gen.display.name import displayer as name_displayer
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
|
@ -46,7 +46,7 @@ from gen.plug.report import Report
|
|||||||
from gen.plug.report import utils as ReportUtils
|
from gen.plug.report import utils as ReportUtils
|
||||||
from gen.plug.report import MenuReportOptions
|
from gen.plug.report import MenuReportOptions
|
||||||
import gen.datehandler
|
import gen.datehandler
|
||||||
from gen.utils import get_birth_or_fallback, get_death_or_fallback
|
from gen.utils.db import get_birth_or_fallback, get_death_or_fallback
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
@ -57,7 +57,7 @@ import gen.datehandler
|
|||||||
import gen.lib
|
import gen.lib
|
||||||
from gen.utils.file import media_path_full, find_file
|
from gen.utils.file import media_path_full, find_file
|
||||||
from gui.thumbnails import get_thumbnail_path
|
from gui.thumbnails import get_thumbnail_path
|
||||||
from gen.utils import get_birth_or_fallback, get_death_or_fallback
|
from gen.utils.db import get_birth_or_fallback, get_death_or_fallback
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
@ -40,7 +40,7 @@ from cgi import escape
|
|||||||
import gen.lib
|
import gen.lib
|
||||||
import gen.datehandler
|
import gen.datehandler
|
||||||
from gen.display.name import displayer as name_displayer
|
from gen.display.name import displayer as name_displayer
|
||||||
from gen.utils import get_birth_or_fallback, get_death_or_fallback, get_marriage_or_fallback
|
from gen.utils.db import get_birth_or_fallback, get_death_or_fallback, get_marriage_or_fallback
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
@ -40,7 +40,7 @@ Mary Smith was born on 3/28/1923.
|
|||||||
from gen.display.name import displayer as name_displayer
|
from gen.display.name import displayer as name_displayer
|
||||||
import gen.datehandler
|
import gen.datehandler
|
||||||
import gen.lib
|
import gen.lib
|
||||||
from gen.utils import get_birth_or_fallback, get_death_or_fallback
|
from gen.utils.db import get_birth_or_fallback, get_death_or_fallback
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
@ -53,7 +53,7 @@ from gen.plug.report import utils as ReportUtils
|
|||||||
from gen.plug.report import MenuReportOptions
|
from gen.plug.report import MenuReportOptions
|
||||||
import gen.datehandler
|
import gen.datehandler
|
||||||
from gen.sort import Sort
|
from gen.sort import Sort
|
||||||
from gen.utils 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, get_divorce_or_fallback)
|
get_marriage_or_fallback, get_divorce_or_fallback)
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ from gen.plug.report import Report
|
|||||||
from gen.plug.report import utils as ReportUtils
|
from gen.plug.report import utils as ReportUtils
|
||||||
from gen.plug.report import MenuReportOptions
|
from gen.plug.report import MenuReportOptions
|
||||||
import gen.datehandler
|
import gen.datehandler
|
||||||
from gen.utils import get_birth_or_fallback, get_death_or_fallback
|
from gen.utils.db import get_birth_or_fallback, get_death_or_fallback
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
@ -65,7 +65,6 @@ from gui.selectors.selectplace import SelectPlace
|
|||||||
from gui.filters.sidebar import EventSidebarFilter
|
from gui.filters.sidebar import EventSidebarFilter
|
||||||
from gui.views.navigationview import NavigationView
|
from gui.views.navigationview import NavigationView
|
||||||
from gui.views.bookmarks import EventBookmarks
|
from gui.views.bookmarks import EventBookmarks
|
||||||
from Utils import navigation_label
|
|
||||||
from maps.geography import GeoGraphyView
|
from maps.geography import GeoGraphyView
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
@ -65,7 +65,6 @@ from gui.selectors.selectplace import SelectPlace
|
|||||||
from gui.filters.sidebar import FamilySidebarFilter
|
from gui.filters.sidebar import FamilySidebarFilter
|
||||||
from gui.views.navigationview import NavigationView
|
from gui.views.navigationview import NavigationView
|
||||||
from gui.views.bookmarks import FamilyBookmarks
|
from gui.views.bookmarks import FamilyBookmarks
|
||||||
from Utils import navigation_label
|
|
||||||
from maps.geography import GeoGraphyView
|
from maps.geography import GeoGraphyView
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
@ -67,7 +67,6 @@ from gui.filters.sidebar import PersonSidebarFilter
|
|||||||
from gui.views.navigationview import NavigationView
|
from gui.views.navigationview import NavigationView
|
||||||
from gui.views.bookmarks import PersonBookmarks
|
from gui.views.bookmarks import PersonBookmarks
|
||||||
import constants
|
import constants
|
||||||
from Utils import navigation_label
|
|
||||||
from maps.geography import GeoGraphyView
|
from maps.geography import GeoGraphyView
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
@ -65,7 +65,6 @@ from gui.selectors.selectplace import SelectPlace
|
|||||||
from gui.filters.sidebar import PlaceSidebarFilter
|
from gui.filters.sidebar import PlaceSidebarFilter
|
||||||
from gui.views.navigationview import NavigationView
|
from gui.views.navigationview import NavigationView
|
||||||
from gui.views.bookmarks import PlaceBookmarks
|
from gui.views.bookmarks import PlaceBookmarks
|
||||||
from Utils import navigation_label
|
|
||||||
from maps.geography import GeoGraphyView
|
from maps.geography import GeoGraphyView
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
@ -64,7 +64,7 @@ from gen.errors import WindowActiveError
|
|||||||
from gui.views.bookmarks import PersonBookmarks
|
from gui.views.bookmarks import PersonBookmarks
|
||||||
import const
|
import const
|
||||||
from gen.utils.name import preset_name
|
from gen.utils.name import preset_name
|
||||||
from gen.utils import get_birth_or_fallback, get_death_or_fallback
|
from gen.utils.db import get_birth_or_fallback, get_death_or_fallback
|
||||||
from gui.listmodel import ListModel
|
from gui.listmodel import ListModel
|
||||||
from gui.managedwindow import ManagedWindow
|
from gui.managedwindow import ManagedWindow
|
||||||
from gui.glade import Glade
|
from gui.glade import Glade
|
||||||
|
@ -62,7 +62,7 @@ from gen.dbstate import DbState
|
|||||||
from gen.datehandler import displayer, parser
|
from gen.datehandler import displayer, parser
|
||||||
from gen.lib.date import Date as GDate, Today
|
from gen.lib.date import Date as GDate, Today
|
||||||
import gen.lib
|
import gen.lib
|
||||||
from gen.utils import get_birth_or_fallback, get_death_or_fallback
|
from gen.utils.db import get_birth_or_fallback, get_death_or_fallback
|
||||||
from gen.plug import BasePluginManager
|
from gen.plug import BasePluginManager
|
||||||
from cli.grampscli import CLIManager
|
from cli.grampscli import CLIManager
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user