Code guideline: move to relative import within gen module
svn: r20478
This commit is contained in:
parent
adac46441d
commit
47a612c36a
@ -29,7 +29,6 @@
|
||||
import cPickle
|
||||
import base64
|
||||
import time
|
||||
import gen
|
||||
import re
|
||||
from . import DbReadBase, DbWriteBase, DbTxn
|
||||
from . import (PERSON_KEY,
|
||||
@ -42,6 +41,7 @@ from . import (PERSON_KEY,
|
||||
REPOSITORY_KEY,
|
||||
NOTE_KEY)
|
||||
from ..utils.id import create_id
|
||||
from ..lib.researcher import Researcher
|
||||
from ..lib.mediaobj import MediaObject
|
||||
from ..lib.person import Person
|
||||
from ..lib.family import Family
|
||||
@ -509,7 +509,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
|
||||
return None
|
||||
|
||||
def get_researcher(self):
|
||||
obj = gen.lib.Researcher()
|
||||
obj = Researcher()
|
||||
return obj
|
||||
|
||||
def get_person_handles(self, sort_handles=False):
|
||||
|
@ -45,11 +45,11 @@ except ValueError:
|
||||
from test import test_util
|
||||
test_util.path_append_parent()
|
||||
|
||||
from gen.config import config
|
||||
import gen.datehandler
|
||||
from gen.datehandler import parser as _dp
|
||||
from gen.datehandler import displayer as _dd
|
||||
from gen.lib.date import Date, Span
|
||||
from ...config import config
|
||||
from ...datehandler import get_date_formats, set_format
|
||||
from ...datehandler import parser as _dp
|
||||
from ...datehandler import displayer as _dd
|
||||
from ...lib.date import Date, Span
|
||||
|
||||
gettext.textdomain("gramps")
|
||||
gettext.install("gramps",loc,unicode=1)
|
||||
@ -221,7 +221,7 @@ cal_str = [ "CAL_GREGORIAN", "CAL_JULIAN", "CAL_HEBREW", "CAL_FRENCH",
|
||||
mod_str = ["MOD_NONE", "MOD_BEFORE", "MOD_AFTER", "MOD_ABOUT", "MOD_RANGE",
|
||||
"MOD_SPAN", "MOD_TEXTONLY"]
|
||||
qua_str = ["QUAL_NONE", "QUAL_ESTIMATED", "QUAL_CALCULATED"]
|
||||
formats = gen.datehandler.get_date_formats()
|
||||
formats = get_date_formats()
|
||||
|
||||
class Eval(unittest.TestCase):
|
||||
def __init__(self, method_name, dateval, e1, e2, e3, format):
|
||||
@ -247,12 +247,12 @@ def suite3():
|
||||
suite = unittest.TestSuite()
|
||||
count = 1
|
||||
for testset in date_tests:
|
||||
for format in range( len( gen.datehandler.get_date_formats())):
|
||||
gen.datehandler.set_format(format)
|
||||
for format in range( len( get_date_formats())):
|
||||
set_format(format)
|
||||
for dateval in date_tests[testset]:
|
||||
if dateval.modifier != Date.MOD_TEXTONLY:
|
||||
dateval.text = ("Comment. Format: %s" %
|
||||
gen.datehandler.get_date_formats()[format])
|
||||
get_date_formats()[format])
|
||||
suite.addTest(
|
||||
Eval("testset '%s' test_eval%04d" % (testset, count),
|
||||
dateval,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -37,8 +37,8 @@ import libxslt
|
||||
|
||||
from libgrampsxml import GRAMPS_XML_VERSION
|
||||
from gen.const import ROOT_DIR, VERSION, USER_PLUGINS
|
||||
import gen.lib
|
||||
from gen.ggettext import sgettext as _
|
||||
from ...lib import Name, Surname
|
||||
from ...ggettext import sgettext as _
|
||||
|
||||
class CopiedDoc(object):
|
||||
"""Context manager that creates a deep copy of an libxml-xml document."""
|
||||
@ -1029,9 +1029,9 @@ class BirthCheck(BaseMergeCheck):
|
||||
</database>"""
|
||||
self.basedoc = libxml2.readDoc(self.base_str + base_str, '', None,
|
||||
libxml2.XML_PARSE_NONET)
|
||||
surname = gen.lib.Surname()
|
||||
surname = Surname()
|
||||
surname.set_surname(u"Person 0")
|
||||
name = gen.lib.Name()
|
||||
name = Name()
|
||||
name.add_surname(surname)
|
||||
self.expect_str = "person: i0000 ('i0000', 'I0000', 1, %s, [], " % str(
|
||||
name.serialize())
|
||||
|
@ -26,7 +26,7 @@ Contain and organize bibliographic information.
|
||||
"""
|
||||
import string
|
||||
import math
|
||||
import gen.lib
|
||||
from ...lib.citation import Citation as lib_Citation
|
||||
|
||||
class Citation(object):
|
||||
"""
|
||||
@ -213,7 +213,7 @@ class Bibliography(object):
|
||||
if ( self.mode & self.MODE_CONF ) == self.MODE_CONF:
|
||||
confidence = source_ref.get_confidence_level()
|
||||
if confidence is not None and confidence != \
|
||||
gen.lib.Citation.CONF_NORMAL:
|
||||
lib_Citation.CONF_NORMAL:
|
||||
return True
|
||||
if ( self.mode & self.MODE_NOTE ) == self.MODE_NOTE:
|
||||
if len(source_ref.get_note_list()) != 0:
|
||||
|
@ -41,9 +41,9 @@ from gen.ggettext import gettext as _
|
||||
# GRAMPS modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import gen.datehandler
|
||||
from gen.utils.file import media_path_full
|
||||
from gen.plug.docgen import IndexMark, INDEX_TYPE_ALP
|
||||
from ...datehandler import get_date
|
||||
from ...utils.file import media_path_full
|
||||
from ..docgen import IndexMark, INDEX_TYPE_ALP
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -190,12 +190,12 @@ def get_person_mark(db, person):
|
||||
birth_ref = person.get_birth_ref()
|
||||
if birth_ref:
|
||||
birthEvt = db.get_event_from_handle(birth_ref.ref)
|
||||
birth = gen.datehandler.get_date(birthEvt)
|
||||
birth = get_date(birthEvt)
|
||||
|
||||
death_ref = person.get_death_ref()
|
||||
if death_ref:
|
||||
deathEvt = db.get_event_from_handle(death_ref.ref)
|
||||
death = gen.datehandler.get_date(deathEvt)
|
||||
death = get_date(deathEvt)
|
||||
|
||||
if birth == death == " ":
|
||||
key = name
|
||||
@ -247,8 +247,8 @@ def get_person_filters(person, include_single=True):
|
||||
@param include_single: include a filter to include the single person
|
||||
@type person: boolean
|
||||
"""
|
||||
from gen.filters import GenericFilter, rules, CustomFilters
|
||||
from gen.display.name import displayer as name_displayer
|
||||
from ...filters import GenericFilter, rules, CustomFilters
|
||||
from ...display.name import displayer as name_displayer
|
||||
|
||||
if person:
|
||||
name = name_displayer.display(person)
|
||||
|
@ -35,12 +35,12 @@ import os
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
import gen.lib
|
||||
MALE = gen.lib.Person.MALE
|
||||
FEMALE = gen.lib.Person.FEMALE
|
||||
UNKNOWN = gen.lib.Person.UNKNOWN
|
||||
from gen.ggettext import sgettext as _
|
||||
from gen.plug import PluginRegister, BasePluginManager
|
||||
from lib import Person, ChildRefType, EventType, FamilyRelType
|
||||
MALE = Person.MALE
|
||||
FEMALE = Person.FEMALE
|
||||
UNKNOWN = Person.UNKNOWN
|
||||
from ggettext import sgettext as _
|
||||
from plug import PluginRegister, BasePluginManager
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -610,9 +610,9 @@ class RelationshipCalculator(object):
|
||||
ref.get_father_relation()) for ref in
|
||||
family.get_child_ref_list()
|
||||
if ref.ref == person.handle]
|
||||
if not birthmother and childrel[0][0] == gen.lib.ChildRefType.BIRTH:
|
||||
if not birthmother and childrel[0][0] == ChildRefType.BIRTH:
|
||||
birthmother = family.get_mother_handle()
|
||||
if not birthfather and childrel[0][1] == gen.lib.ChildRefType.BIRTH:
|
||||
if not birthfather and childrel[0][1] == ChildRefType.BIRTH:
|
||||
birthfather = family.get_father_handle()
|
||||
if birthmother and birthfather:
|
||||
break
|
||||
@ -631,11 +631,11 @@ class RelationshipCalculator(object):
|
||||
ref.get_father_relation()) for ref in
|
||||
family.get_child_ref_list()
|
||||
if ref.ref == person.handle]
|
||||
if not childrel[0][0] == gen.lib.ChildRefType.BIRTH \
|
||||
and not childrel[0][0] == gen.lib.ChildRefType.UNKNOWN :
|
||||
if not childrel[0][0] == ChildRefType.BIRTH \
|
||||
and not childrel[0][0] == ChildRefType.UNKNOWN :
|
||||
nb_parents.append(family.get_mother_handle())
|
||||
if not childrel[0][1] == gen.lib.ChildRefType.BIRTH \
|
||||
and not childrel[0][1] == gen.lib.ChildRefType.UNKNOWN :
|
||||
if not childrel[0][1] == ChildRefType.BIRTH \
|
||||
and not childrel[0][1] == ChildRefType.UNKNOWN :
|
||||
nb_parents.append(family.get_father_handle())
|
||||
#make every person appear only once:
|
||||
return list(set(nb_parents))
|
||||
@ -658,21 +658,21 @@ class RelationshipCalculator(object):
|
||||
ex = False
|
||||
for eventref in family.get_event_ref_list():
|
||||
event = db.get_event_from_handle(eventref.ref)
|
||||
if event and (event.get_type() == gen.lib.EventType.DIVORCE
|
||||
or event.get_type() == gen.lib.EventType.ANNULMENT):
|
||||
if event and (event.get_type() == EventType.DIVORCE
|
||||
or event.get_type() == EventType.ANNULMENT):
|
||||
ex = True
|
||||
break
|
||||
if family_rel == gen.lib.FamilyRelType.MARRIED:
|
||||
if family_rel == FamilyRelType.MARRIED:
|
||||
if ex:
|
||||
val.append(self.PARTNER_EX_MARRIED)
|
||||
else:
|
||||
val.append(self.PARTNER_MARRIED)
|
||||
elif family_rel == gen.lib.FamilyRelType.UNMARRIED:
|
||||
elif family_rel == FamilyRelType.UNMARRIED:
|
||||
if ex:
|
||||
val.append(self.PARTNER_EX_UNMARRIED)
|
||||
else:
|
||||
val.append(self.PARTNER_UNMARRIED)
|
||||
elif family_rel == gen.lib.FamilyRelType.CIVIL_UNION:
|
||||
elif family_rel == FamilyRelType.CIVIL_UNION:
|
||||
if ex:
|
||||
val.append(self.PARTNER_EX_CIVIL_UNION)
|
||||
else:
|
||||
@ -967,7 +967,7 @@ class RelationshipCalculator(object):
|
||||
self.REL_MOTHER_NOTBIRTH, childrel[0][0])]:
|
||||
if data[0] and data[0] not in parentstodo :
|
||||
persontodo = db.get_person_from_handle(data[0])
|
||||
if data[3] == gen.lib.ChildRefType.BIRTH :
|
||||
if data[3] == ChildRefType.BIRTH :
|
||||
addstr = data[1]
|
||||
elif not self.__only_birth :
|
||||
addstr = data[2]
|
||||
|
@ -28,16 +28,17 @@ Provide a simplified database access interface to the GRAMPS database.
|
||||
from __future__ import with_statement
|
||||
from types import NoneType
|
||||
|
||||
import gen.lib
|
||||
import gen.datehandler
|
||||
from gen.utils.string import gender as gender_map
|
||||
from gen.utils.db import get_birth_or_fallback, get_death_or_fallback
|
||||
from gen.plug.report.utils import place_name
|
||||
from ..lib import (Person, Family, Event, Source, Place, Citation,
|
||||
MediaObject, Repository, Note, Date)
|
||||
from ..datehandler import displayer
|
||||
from ..utils.string import gender as gender_map
|
||||
from ..utils.db import get_birth_or_fallback, get_death_or_fallback
|
||||
from ..plug.report.utils import place_name
|
||||
|
||||
from gen.display.name import displayer as name_displayer
|
||||
from gen.lib import EventType
|
||||
from gen.config import config
|
||||
from gen.ggettext import gettext as _
|
||||
from ..display.name import displayer as name_displayer
|
||||
from ..lib import EventType
|
||||
from ..config import config
|
||||
from ..ggettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -127,7 +128,7 @@ class SimpleAccess(object):
|
||||
"""
|
||||
if type(person) in [str, unicode]:
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
assert(isinstance(person, (gen.lib.Person, NoneType)))
|
||||
assert(isinstance(person, (Person, NoneType)))
|
||||
if person:
|
||||
return name_displayer.display(person)
|
||||
else:
|
||||
@ -144,7 +145,7 @@ class SimpleAccess(object):
|
||||
"""
|
||||
if type(person) in [str, unicode]:
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
assert(isinstance(person, (gen.lib.Person, NoneType)))
|
||||
assert(isinstance(person, (Person, NoneType)))
|
||||
if person:
|
||||
surname = person.get_primary_name().get_surname()
|
||||
return surname or config.get('preferences.no-surname-text')
|
||||
@ -162,7 +163,7 @@ class SimpleAccess(object):
|
||||
"""
|
||||
if type(person) in [str, unicode]:
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
assert(isinstance(person, (gen.lib.Person, NoneType)))
|
||||
assert(isinstance(person, (Person, NoneType)))
|
||||
if person:
|
||||
return person.get_primary_name().get_first_name()
|
||||
else:
|
||||
@ -193,7 +194,7 @@ class SimpleAccess(object):
|
||||
"""
|
||||
if type(person) in [str, unicode]:
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
assert(isinstance(person, (gen.lib.Person, NoneType)))
|
||||
assert(isinstance(person, (Person, NoneType)))
|
||||
if person:
|
||||
return gender_map[person.get_gender()]
|
||||
return u''
|
||||
@ -209,7 +210,7 @@ class SimpleAccess(object):
|
||||
@return: mother or father of the associated person
|
||||
@rtype: L{gen.lib.Person}
|
||||
"""
|
||||
assert(isinstance(person, (gen.lib.Person, NoneType)))
|
||||
assert(isinstance(person, (Person, NoneType)))
|
||||
|
||||
if person:
|
||||
parent_handle_list = person.get_parent_family_handle_list()
|
||||
@ -230,7 +231,7 @@ class SimpleAccess(object):
|
||||
@return: mother or father of the associated family
|
||||
@rtype: L{gen.lib.Family}
|
||||
"""
|
||||
assert(isinstance(family, (gen.lib.Family, NoneType)))
|
||||
assert(isinstance(family, (Family, NoneType)))
|
||||
|
||||
if family:
|
||||
handle = func(family)
|
||||
@ -249,7 +250,7 @@ class SimpleAccess(object):
|
||||
@return: Returns a string describing the date
|
||||
@rtype: unicode
|
||||
"""
|
||||
assert(isinstance(person, (gen.lib.Person, NoneType)))
|
||||
assert(isinstance(person, (Person, NoneType)))
|
||||
|
||||
if person:
|
||||
ref = func(person)
|
||||
@ -259,7 +260,7 @@ class SimpleAccess(object):
|
||||
event = self.dbase.get_event_from_handle(event_handle)
|
||||
date_obj = event.get_date_object()
|
||||
if date_obj:
|
||||
return gen.datehandler.displayer.display(date_obj)
|
||||
return displayer.display(date_obj)
|
||||
return u''
|
||||
|
||||
def __event_date_obj(self, person, func):
|
||||
@ -273,7 +274,7 @@ class SimpleAccess(object):
|
||||
@return: Returns the date
|
||||
@rtype: l{gen.lib.Date}
|
||||
"""
|
||||
assert(isinstance(person, (gen.lib.Person, NoneType)))
|
||||
assert(isinstance(person, (Person, NoneType)))
|
||||
|
||||
if person:
|
||||
ref = func(person)
|
||||
@ -285,8 +286,8 @@ class SimpleAccess(object):
|
||||
if date_obj:
|
||||
return date_obj
|
||||
else:
|
||||
return gen.lib.Date()
|
||||
return gen.lib.Date()
|
||||
return Date()
|
||||
return Date()
|
||||
|
||||
def __event_place(self, person, func):
|
||||
"""
|
||||
@ -299,7 +300,7 @@ class SimpleAccess(object):
|
||||
@return: Returns a string describing the place
|
||||
@rtype: unicode
|
||||
"""
|
||||
assert(isinstance(person, (gen.lib.Person, NoneType)))
|
||||
assert(isinstance(person, (Person, NoneType)))
|
||||
|
||||
if person:
|
||||
ref = func(person)
|
||||
@ -322,7 +323,7 @@ class SimpleAccess(object):
|
||||
"""
|
||||
if type(person) in [str, unicode]:
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
assert(isinstance(person, (gen.lib.Person, NoneType)))
|
||||
assert(isinstance(person, (Person, NoneType)))
|
||||
|
||||
if person:
|
||||
family_handle_list = person.get_family_handle_list()
|
||||
@ -350,7 +351,7 @@ class SimpleAccess(object):
|
||||
"""
|
||||
if type(person) in [str, unicode]:
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
assert(isinstance(person, (gen.lib.Person, NoneType)))
|
||||
assert(isinstance(person, (Person, NoneType)))
|
||||
|
||||
if person:
|
||||
family_handle_list = person.get_family_handle_list()
|
||||
@ -374,7 +375,7 @@ class SimpleAccess(object):
|
||||
"""
|
||||
if type(person) in [str, unicode]:
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
assert(isinstance(person, (gen.lib.Person, NoneType)))
|
||||
assert(isinstance(person, (Person, NoneType)))
|
||||
|
||||
if person:
|
||||
family_handle_list = person.get_family_handle_list()
|
||||
@ -406,7 +407,7 @@ class SimpleAccess(object):
|
||||
"""
|
||||
if type(person) in [str, unicode]:
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
assert(isinstance(person, (gen.lib.Person, NoneType)))
|
||||
assert(isinstance(person, (Person, NoneType)))
|
||||
|
||||
if person:
|
||||
family_handle_list = person.get_family_handle_list()
|
||||
@ -423,7 +424,7 @@ class SimpleAccess(object):
|
||||
if events:
|
||||
date_obj = events[0].get_date_object()
|
||||
if date_obj:
|
||||
return gen.datehandler.displayer.display(date_obj)
|
||||
return displayer.display(date_obj)
|
||||
return u''
|
||||
|
||||
def children(self, obj):
|
||||
@ -435,9 +436,9 @@ class SimpleAccess(object):
|
||||
@return: Returns a list of L{gen.lib.Person} objects representing the children
|
||||
@rtype: list
|
||||
"""
|
||||
assert(isinstance(obj, (gen.lib.Person, gen.lib.Family, NoneType)))
|
||||
assert(isinstance(obj, (Person, Family, NoneType)))
|
||||
|
||||
if isinstance(obj, gen.lib.Person):
|
||||
if isinstance(obj, Person):
|
||||
family_handle_list = obj.get_family_handle_list()
|
||||
if family_handle_list:
|
||||
family_id = family_handle_list[0]
|
||||
@ -445,7 +446,7 @@ class SimpleAccess(object):
|
||||
|
||||
return [ self.dbase.get_person_from_handle(hndl.ref)
|
||||
for hndl in family.get_child_ref_list() ]
|
||||
elif isinstance(obj, gen.lib.Family):
|
||||
elif isinstance(obj, Family):
|
||||
return [ self.dbase.get_person_from_handle(hndl.ref)
|
||||
for hndl in obj.get_child_ref_list() ]
|
||||
return []
|
||||
@ -461,10 +462,10 @@ class SimpleAccess(object):
|
||||
family
|
||||
@rtype: L{gen.lib.Person}
|
||||
"""
|
||||
if isinstance(obj, gen.lib.Person):
|
||||
return self.__parent(obj, gen.lib.Family.get_father_handle)
|
||||
elif isinstance(obj, gen.lib.Family):
|
||||
return self.__family_parent(obj, gen.lib.Family.get_father_handle)
|
||||
if isinstance(obj, Person):
|
||||
return self.__parent(obj, Family.get_father_handle)
|
||||
elif isinstance(obj, Family):
|
||||
return self.__family_parent(obj, Family.get_father_handle)
|
||||
else:
|
||||
return None
|
||||
|
||||
@ -479,10 +480,10 @@ class SimpleAccess(object):
|
||||
family
|
||||
@rtype: L{gen.lib.Person}
|
||||
"""
|
||||
if isinstance(obj, gen.lib.Person):
|
||||
return self.__parent(obj, gen.lib.Family.get_mother_handle)
|
||||
elif isinstance(obj, gen.lib.Family):
|
||||
return self.__family_parent(obj, gen.lib.Family.get_mother_handle)
|
||||
if isinstance(obj, Person):
|
||||
return self.__parent(obj, Family.get_mother_handle)
|
||||
elif isinstance(obj, Family):
|
||||
return self.__family_parent(obj, Family.get_mother_handle)
|
||||
else:
|
||||
return None
|
||||
|
||||
@ -497,7 +498,7 @@ class SimpleAccess(object):
|
||||
"""
|
||||
if type(person) in [str, unicode]:
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
return self.__event_date(person, gen.lib.Person.get_birth_ref)
|
||||
return self.__event_date(person, Person.get_birth_ref)
|
||||
|
||||
def birth_date_obj(self, person):
|
||||
"""
|
||||
@ -510,7 +511,7 @@ class SimpleAccess(object):
|
||||
"""
|
||||
if type(person) in [str, unicode]:
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
return self.__event_date_obj(person, gen.lib.Person.get_birth_ref)
|
||||
return self.__event_date_obj(person, Person.get_birth_ref)
|
||||
|
||||
|
||||
def birth_or_fallback(self, person, get_event=False):
|
||||
@ -530,7 +531,7 @@ class SimpleAccess(object):
|
||||
elif event:
|
||||
return event.date
|
||||
else:
|
||||
return gen.lib.Date()
|
||||
return Date()
|
||||
|
||||
def birth_place(self, person):
|
||||
"""
|
||||
@ -543,7 +544,7 @@ class SimpleAccess(object):
|
||||
"""
|
||||
if type(person) in [str, unicode]:
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
return self.__event_place(person, gen.lib.Person.get_birth_ref)
|
||||
return self.__event_place(person, Person.get_birth_ref)
|
||||
|
||||
def death_date(self, person):
|
||||
"""
|
||||
@ -556,7 +557,7 @@ class SimpleAccess(object):
|
||||
"""
|
||||
if type(person) in [str, unicode]:
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
return self.__event_date(person, gen.lib.Person.get_death_ref)
|
||||
return self.__event_date(person, Person.get_death_ref)
|
||||
|
||||
def death_date_obj(self, person):
|
||||
"""
|
||||
@ -569,7 +570,7 @@ class SimpleAccess(object):
|
||||
"""
|
||||
if type(person) in [str, unicode]:
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
return self.__event_date_obj(person, gen.lib.Person.get_death_ref)
|
||||
return self.__event_date_obj(person, Person.get_death_ref)
|
||||
|
||||
def death_or_fallback(self, person, get_event=False):
|
||||
"""
|
||||
@ -588,7 +589,7 @@ class SimpleAccess(object):
|
||||
elif event:
|
||||
return event.date
|
||||
else:
|
||||
return gen.lib.Date()
|
||||
return Date()
|
||||
|
||||
def death_place(self, person):
|
||||
"""
|
||||
@ -601,7 +602,7 @@ class SimpleAccess(object):
|
||||
"""
|
||||
if type(person) in [str, unicode]:
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
return self.__event_place(person, gen.lib.Person.get_death_ref)
|
||||
return self.__event_place(person, Person.get_death_ref)
|
||||
|
||||
def event_place(self, event):
|
||||
"""
|
||||
@ -612,7 +613,7 @@ class SimpleAccess(object):
|
||||
@return: Returns a string indicating the place of the event
|
||||
@rtype: unicode
|
||||
"""
|
||||
assert(isinstance(event, (gen.lib.Event, NoneType)))
|
||||
assert(isinstance(event, (Event, NoneType)))
|
||||
|
||||
if event:
|
||||
place_handle = event.get_place_handle()
|
||||
@ -630,7 +631,7 @@ class SimpleAccess(object):
|
||||
@rtype: unicode
|
||||
"""
|
||||
if date_obj:
|
||||
return gen.datehandler.displayer.display(date_obj)
|
||||
return displayer.display(date_obj)
|
||||
else:
|
||||
return u''
|
||||
|
||||
@ -643,10 +644,10 @@ class SimpleAccess(object):
|
||||
@return: Returns a string indicating the date of the event
|
||||
@rtype: unicode
|
||||
"""
|
||||
assert(isinstance(event, (gen.lib.Event, NoneType)))
|
||||
assert(isinstance(event, (Event, NoneType)))
|
||||
date_obj = event.get_date_object()
|
||||
if date_obj:
|
||||
return gen.datehandler.displayer.display(date_obj)
|
||||
return displayer.display(date_obj)
|
||||
else:
|
||||
return u''
|
||||
|
||||
@ -659,7 +660,7 @@ class SimpleAccess(object):
|
||||
@return: Returns a string indicating the date of the event
|
||||
@rtype: unicode
|
||||
"""
|
||||
assert(isinstance(event, (gen.lib.Event, NoneType)))
|
||||
assert(isinstance(event, (Event, NoneType)))
|
||||
if event:
|
||||
return event.get_date_object()
|
||||
|
||||
@ -672,7 +673,7 @@ class SimpleAccess(object):
|
||||
@return: Returns a string indicating the type of the event
|
||||
@rtype: unicode
|
||||
"""
|
||||
assert(isinstance(event, (gen.lib.Event, NoneType)))
|
||||
assert(isinstance(event, (Event, NoneType)))
|
||||
if event:
|
||||
return str(event.get_type())
|
||||
else:
|
||||
@ -691,7 +692,7 @@ class SimpleAccess(object):
|
||||
@return: list of events associated with the object
|
||||
@rtype: list
|
||||
"""
|
||||
assert(isinstance(obj, (gen.lib.Person, gen.lib.Family, NoneType)))
|
||||
assert(isinstance(obj, (Person, Family, NoneType)))
|
||||
assert(isinstance(restrict, list) or restrict is None)
|
||||
|
||||
if obj:
|
||||
@ -716,7 +717,7 @@ class SimpleAccess(object):
|
||||
@return: list of events associated with the object
|
||||
@rtype: list
|
||||
"""
|
||||
assert(isinstance(obj, (gen.lib.Person, gen.lib.Family, gen.lib.Event, NoneType)))
|
||||
assert(isinstance(obj, (Person, Family, Event, NoneType)))
|
||||
|
||||
if obj:
|
||||
handles = [ ref.ref for ref in obj.get_source_references() ]
|
||||
@ -736,7 +737,7 @@ class SimpleAccess(object):
|
||||
"""
|
||||
if type(person) in [str, unicode]:
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
assert(isinstance(person, (gen.lib.Person, NoneType)))
|
||||
assert(isinstance(person, (Person, NoneType)))
|
||||
|
||||
if person:
|
||||
return [ self.dbase.get_family_from_handle(handle)
|
||||
@ -755,7 +756,7 @@ class SimpleAccess(object):
|
||||
"""
|
||||
if type(person) in [str, unicode]:
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
assert(isinstance(person, (gen.lib.Person, NoneType)))
|
||||
assert(isinstance(person, (Person, NoneType)))
|
||||
|
||||
if person:
|
||||
return [ self.dbase.get_family_from_handle(handle)
|
||||
@ -842,7 +843,7 @@ class SimpleAccess(object):
|
||||
@return: title of the source
|
||||
@rtype: unicode
|
||||
"""
|
||||
assert(isinstance(source, (gen.lib.Source, NoneType)))
|
||||
assert(isinstance(source, (Source, NoneType)))
|
||||
if source:
|
||||
return source.get_title()
|
||||
return u''
|
||||
@ -856,7 +857,7 @@ class SimpleAccess(object):
|
||||
@return: title of the citation
|
||||
@rtype: unicode
|
||||
"""
|
||||
assert(isinstance(citation, (gen.lib.Citation, NoneType)))
|
||||
assert(isinstance(citation, (Citation, NoneType)))
|
||||
if citation:
|
||||
return citation.get_page()
|
||||
return u''
|
||||
@ -870,7 +871,7 @@ class SimpleAccess(object):
|
||||
@return: author of the source
|
||||
@rtype: unicode
|
||||
"""
|
||||
assert(isinstance(source, (gen.lib.Source, NoneType)))
|
||||
assert(isinstance(source, (Source, NoneType)))
|
||||
if source:
|
||||
return source.get_author()
|
||||
return u''
|
||||
@ -899,40 +900,40 @@ class SimpleAccess(object):
|
||||
obj = self.dbase.get_table_metadata(object_class)\
|
||||
[prop + "_func"](value)
|
||||
if obj:
|
||||
if isinstance(obj, gen.lib.Person):
|
||||
if isinstance(obj, Person):
|
||||
return "%s: %s [%s]" % (_(object_class),
|
||||
self.name(obj),
|
||||
self.gid(obj))
|
||||
elif isinstance(obj, gen.lib.Event):
|
||||
elif isinstance(obj, Event):
|
||||
return "%s: %s [%s]" % (_(object_class),
|
||||
self.event_type(obj),
|
||||
self.gid(obj))
|
||||
elif isinstance(obj, gen.lib.Family):
|
||||
elif isinstance(obj, Family):
|
||||
return "%s: %s/%s [%s]" % (_(object_class),
|
||||
self.name(self.mother(obj)),
|
||||
self.name(self.father(obj)),
|
||||
self.gid(obj))
|
||||
elif isinstance(obj, gen.lib.MediaObject):
|
||||
elif isinstance(obj, MediaObject):
|
||||
return "%s: %s [%s]" % (_(object_class),
|
||||
obj.desc,
|
||||
self.gid(obj))
|
||||
elif isinstance(obj, gen.lib.Source):
|
||||
elif isinstance(obj, Source):
|
||||
return "%s: %s [%s]" % (_(object_class),
|
||||
self.title(obj),
|
||||
self.gid(obj))
|
||||
elif isinstance(obj, gen.lib.Citation):
|
||||
elif isinstance(obj, Citation):
|
||||
return "%s: [%s]" % (_(object_class),
|
||||
self.gid(obj))
|
||||
elif isinstance(obj, gen.lib.Place):
|
||||
elif isinstance(obj, Place):
|
||||
return "%s: %s [%s]" % (_(object_class),
|
||||
place_name(self.dbase,
|
||||
obj.handle),
|
||||
self.gid(obj))
|
||||
elif isinstance(obj, gen.lib.Repository):
|
||||
elif isinstance(obj, Repository):
|
||||
return "%s: %s [%s]" % (_(object_class),
|
||||
obj.type,
|
||||
self.gid(obj))
|
||||
elif isinstance(obj, gen.lib.Note):
|
||||
elif isinstance(obj, Note):
|
||||
return "%s: %s [%s]" % (_(object_class),
|
||||
obj.type,
|
||||
self.gid(obj))
|
||||
@ -947,11 +948,11 @@ class SimpleAccess(object):
|
||||
"""
|
||||
Given a object, return a string describing the object.
|
||||
"""
|
||||
if isinstance(obj, gen.lib.Person):
|
||||
if isinstance(obj, Person):
|
||||
return self.name(obj)
|
||||
elif isinstance(obj, gen.lib.Event):
|
||||
elif isinstance(obj, Event):
|
||||
return self.event_type(obj)
|
||||
elif isinstance(obj, gen.lib.Family):
|
||||
elif isinstance(obj, Family):
|
||||
father = self.father(obj)
|
||||
mother = self.mother(obj)
|
||||
if father:
|
||||
@ -963,17 +964,17 @@ class SimpleAccess(object):
|
||||
else:
|
||||
mother_text = _("Unknown mother")
|
||||
return "%s and %s" % (mother_text, father_text)
|
||||
elif isinstance(obj, gen.lib.MediaObject):
|
||||
elif isinstance(obj, MediaObject):
|
||||
return obj.desc
|
||||
elif isinstance(obj, gen.lib.Citation):
|
||||
elif isinstance(obj, Citation):
|
||||
return obj.gramps_id
|
||||
elif isinstance(obj, gen.lib.Source):
|
||||
elif isinstance(obj, Source):
|
||||
return self.title(obj)
|
||||
elif isinstance(obj, gen.lib.Place):
|
||||
elif isinstance(obj, Place):
|
||||
return place_name(self.dbase, obj.handle)
|
||||
elif isinstance(obj, gen.lib.Repository):
|
||||
elif isinstance(obj, Repository):
|
||||
return obj.gramps_id
|
||||
elif isinstance(obj, gen.lib.Note):
|
||||
elif isinstance(obj, Note):
|
||||
return obj.gramps_id
|
||||
elif obj is None:
|
||||
return ""
|
||||
|
@ -28,9 +28,10 @@ Provide a simplified table creation interface
|
||||
|
||||
import cgi
|
||||
from gen.ggettext import sgettext as _
|
||||
import gen.lib
|
||||
from gen.config import config
|
||||
import gen.datehandler
|
||||
from ..lib import (Person, Family, Event, Source, Place, Citation,
|
||||
Repository, MediaObject, Note, Date, Span)
|
||||
from ..config import config
|
||||
from ..datehandler import displayer
|
||||
|
||||
class SimpleTable(object):
|
||||
"""
|
||||
@ -108,44 +109,44 @@ class SimpleTable(object):
|
||||
elif isinstance(item, (int, float, long)):
|
||||
retval.append(item)
|
||||
self.row_sort_val(col, item)
|
||||
elif isinstance(item, gen.lib.Person):
|
||||
elif isinstance(item, Person):
|
||||
retval.append(self.access.describe(item))
|
||||
if (self._link_col == col or link is None):
|
||||
link = ('Person', item.handle)
|
||||
elif isinstance(item, gen.lib.Family):
|
||||
elif isinstance(item, Family):
|
||||
retval.append(self.access.describe(item))
|
||||
if (self._link_col == col or link is None):
|
||||
link = ('Family', item.handle)
|
||||
elif isinstance(item, gen.lib.Citation):
|
||||
elif isinstance(item, Citation):
|
||||
retval.append(self.access.describe(item))
|
||||
if (self._link_col == col or link is None):
|
||||
link = ('Citation', item.handle)
|
||||
elif isinstance(item, gen.lib.Source):
|
||||
elif isinstance(item, Source):
|
||||
retval.append(self.access.describe(item))
|
||||
if (self._link_col == col or link is None):
|
||||
link = ('Source', item.handle)
|
||||
elif isinstance(item, gen.lib.Event):
|
||||
elif isinstance(item, Event):
|
||||
retval.append(self.access.describe(item))
|
||||
if (self._link_col == col or link is None):
|
||||
link = ('Event', item.handle)
|
||||
elif isinstance(item, gen.lib.MediaObject):
|
||||
elif isinstance(item, MediaObject):
|
||||
retval.append(self.access.describe(item))
|
||||
if (self._link_col == col or link is None):
|
||||
link = ('Media', item.handle)
|
||||
elif isinstance(item, gen.lib.Place):
|
||||
elif isinstance(item, Place):
|
||||
retval.append(self.access.describe(item))
|
||||
if (self._link_col == col or link is None):
|
||||
link = ('Place', item.handle)
|
||||
elif isinstance(item, gen.lib.Repository):
|
||||
elif isinstance(item, Repository):
|
||||
retval.append(self.access.describe(item))
|
||||
if (self._link_col == col or link is None):
|
||||
link = ('Repository', item.handle)
|
||||
elif isinstance(item, gen.lib.Note):
|
||||
elif isinstance(item, Note):
|
||||
retval.append(self.access.describe(item))
|
||||
if (self._link_col == col or link is None):
|
||||
link = ('Note', item.handle)
|
||||
elif isinstance(item, gen.lib.Date):
|
||||
text = gen.datehandler.displayer.display(item)
|
||||
elif isinstance(item, Date):
|
||||
text = displayer.display(item)
|
||||
retval.append(text)
|
||||
if item.get_valid():
|
||||
if item.format:
|
||||
@ -161,7 +162,7 @@ class SimpleTable(object):
|
||||
invalid_date_format % cgi.escape(text))
|
||||
if (self._link_col == col or link is None):
|
||||
link = ('Date', item)
|
||||
elif isinstance(item, gen.lib.Span):
|
||||
elif isinstance(item, Span):
|
||||
text = str(item)
|
||||
retval.append(text)
|
||||
self.row_sort_val(col, item)
|
||||
|
@ -31,8 +31,8 @@ Configuration based utilities
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gen.lib
|
||||
from gen.config import config
|
||||
from ..lib import Researcher
|
||||
from ..config import config
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -53,7 +53,7 @@ def get_researcher():
|
||||
phone = config.get('researcher.researcher-phone')
|
||||
email = config.get('researcher.researcher-email')
|
||||
|
||||
owner = gen.lib.Researcher()
|
||||
owner = Researcher()
|
||||
owner.set_name(name)
|
||||
owner.set_address(address)
|
||||
owner.set_locality(locality)
|
||||
|
@ -37,11 +37,11 @@ from cgi import escape
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gen.lib
|
||||
import gen.datehandler
|
||||
from gen.display.name import displayer as name_displayer
|
||||
from gen.utils.db import (get_birth_or_fallback, get_death_or_fallback,
|
||||
get_marriage_or_fallback)
|
||||
from ..lib import EventType
|
||||
from ..datehandler import get_date
|
||||
from ..display.name import displayer as name_displayer
|
||||
from .db import (get_birth_or_fallback, get_death_or_fallback,
|
||||
get_marriage_or_fallback)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -73,19 +73,19 @@ class FormattingHelper(object):
|
||||
|
||||
text = ""
|
||||
marriage = get_marriage_or_fallback(self.dbstate.db, family)
|
||||
if marriage and use_markup and marriage.get_type() != gen.lib.EventType.MARRIAGE:
|
||||
if marriage and use_markup and marriage.get_type() != EventType.MARRIAGE:
|
||||
mdate = "<i>%s %s</i>" % (marriage.get_type().get_abbreviation(),
|
||||
escape(gen.datehandler.get_date(marriage)))
|
||||
escape(get_date(marriage)))
|
||||
mplace = "<i>%s</i>" % escape(self.get_place_name(marriage.get_place_handle()))
|
||||
name = "<i>%s</i>" % str(marriage.get_type())
|
||||
elif marriage and use_markup:
|
||||
mdate = "%s %s" % (marriage.get_type().get_abbreviation(),
|
||||
escape(gen.datehandler.get_date(marriage)))
|
||||
escape(get_date(marriage)))
|
||||
mplace = escape(self.get_place_name(marriage.get_place_handle()))
|
||||
name = str(marriage.get_type())
|
||||
elif marriage:
|
||||
mdate = "%s %s" % (marriage.get_type().get_abbreviation(),
|
||||
gen.datehandler.get_date(marriage))
|
||||
get_date(marriage))
|
||||
mplace = self.get_place_name(marriage.get_place_handle())
|
||||
name = str(marriage.get_type())
|
||||
else:
|
||||
@ -149,31 +149,29 @@ class FormattingHelper(object):
|
||||
text = name
|
||||
if line_count >= 3:
|
||||
birth = get_birth_or_fallback(self.dbstate.db, person)
|
||||
if birth and use_markup and birth.get_type() != \
|
||||
gen.lib.EventType.BIRTH:
|
||||
bdate = "<i>%s</i>" % escape(gen.datehandler.get_date(birth))
|
||||
if birth and use_markup and birth.get_type() != EventType.BIRTH:
|
||||
bdate = "<i>%s</i>" % escape(get_date(birth))
|
||||
bplace = "<i>%s</i>" % escape(self.get_place_name(
|
||||
birth.get_place_handle()))
|
||||
elif birth and use_markup:
|
||||
bdate = escape(gen.datehandler.get_date(birth))
|
||||
bdate = escape(get_date(birth))
|
||||
bplace = escape(self.get_place_name(birth.get_place_handle()))
|
||||
elif birth:
|
||||
bdate = gen.datehandler.get_date(birth)
|
||||
bdate = get_date(birth)
|
||||
bplace = self.get_place_name(birth.get_place_handle())
|
||||
else:
|
||||
bdate = ""
|
||||
bplace = ""
|
||||
death = get_death_or_fallback(self.dbstate.db, person)
|
||||
if death and use_markup and death.get_type() != \
|
||||
gen.lib.EventType.DEATH:
|
||||
ddate = "<i>%s</i>" % escape(gen.datehandler.get_date(death))
|
||||
if death and use_markup and death.get_type() != EventType.DEATH:
|
||||
ddate = "<i>%s</i>" % escape(get_date(death))
|
||||
dplace = "<i>%s</i>" % escape(self.get_place_name(
|
||||
death.get_place_handle()))
|
||||
elif death and use_markup:
|
||||
ddate = escape(gen.datehandler.get_date(death))
|
||||
ddate = escape(get_date(death))
|
||||
dplace = escape(self.get_place_name(death.get_place_handle()))
|
||||
elif death:
|
||||
ddate = gen.datehandler.get_date(death)
|
||||
ddate = get_date(death)
|
||||
dplace = self.get_place_name(death.get_place_handle())
|
||||
else:
|
||||
ddate = ""
|
||||
|
@ -31,8 +31,8 @@ String mappings for constants
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gen.lib
|
||||
from gen.ggettext import sgettext as _
|
||||
from ..lib import Person, Citation, FamilyRelType
|
||||
from ..ggettext import sgettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -40,32 +40,32 @@ from gen.ggettext import sgettext as _
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
gender = {
|
||||
gen.lib.Person.MALE : _("male"),
|
||||
gen.lib.Person.FEMALE : _("female"),
|
||||
gen.lib.Person.UNKNOWN : _("gender|unknown"),
|
||||
Person.MALE : _("male"),
|
||||
Person.FEMALE : _("female"),
|
||||
Person.UNKNOWN : _("gender|unknown"),
|
||||
}
|
||||
|
||||
def format_gender( type):
|
||||
return gender.get(type[0], _("Invalid"))
|
||||
|
||||
confidence = {
|
||||
gen.lib.Citation.CONF_VERY_HIGH : _("Very High"),
|
||||
gen.lib.Citation.CONF_HIGH : _("High"),
|
||||
gen.lib.Citation.CONF_NORMAL : _("Normal"),
|
||||
gen.lib.Citation.CONF_LOW : _("Low"),
|
||||
gen.lib.Citation.CONF_VERY_LOW : _("Very Low"),
|
||||
Citation.CONF_VERY_HIGH : _("Very High"),
|
||||
Citation.CONF_HIGH : _("High"),
|
||||
Citation.CONF_NORMAL : _("Normal"),
|
||||
Citation.CONF_LOW : _("Low"),
|
||||
Citation.CONF_VERY_LOW : _("Very Low"),
|
||||
}
|
||||
|
||||
family_rel_descriptions = {
|
||||
gen.lib.FamilyRelType.MARRIED : _("A legal or common-law relationship "
|
||||
FamilyRelType.MARRIED : _("A legal or common-law relationship "
|
||||
"between a husband and wife"),
|
||||
gen.lib.FamilyRelType.UNMARRIED : _("No legal or common-law relationship "
|
||||
FamilyRelType.UNMARRIED : _("No legal or common-law relationship "
|
||||
"between man and woman"),
|
||||
gen.lib.FamilyRelType.CIVIL_UNION : _("An established relationship between "
|
||||
FamilyRelType.CIVIL_UNION : _("An established relationship between "
|
||||
"members of the same sex"),
|
||||
gen.lib.FamilyRelType.UNKNOWN : _("Unknown relationship between a man "
|
||||
FamilyRelType.UNKNOWN : _("Unknown relationship between a man "
|
||||
"and woman"),
|
||||
gen.lib.FamilyRelType.CUSTOM : _("An unspecified relationship between "
|
||||
FamilyRelType.CUSTOM : _("An unspecified relationship between "
|
||||
"a man and woman"),
|
||||
}
|
||||
|
||||
|
@ -38,10 +38,14 @@ import time
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gen.lib
|
||||
from gen.utils.id import create_id
|
||||
from gen.const import IMAGE_DIR
|
||||
from gen.ggettext import sgettext as _
|
||||
from ..lib import (Person, Surname, Name, NameType, Family, FamilyRelType,
|
||||
Event, EventType, Source, Place, Citation,
|
||||
Repository, RepositoryType, MediaObject, Note, NoteType,
|
||||
StyledText, StyledTextTag, StyledTextTagType, Tag,
|
||||
ChildRef, ChildRefType)
|
||||
from id import create_id
|
||||
from ..const import IMAGE_DIR
|
||||
from ..ggettext import sgettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -86,19 +90,19 @@ def make_unknown(class_arg, explanation, class_func, commit_func, transaction,
|
||||
"""
|
||||
retval = []
|
||||
obj = class_func(class_arg)
|
||||
if isinstance(obj, gen.lib.Person):
|
||||
surname = gen.lib.Surname()
|
||||
if isinstance(obj, Person):
|
||||
surname = Surname()
|
||||
surname.set_surname('Unknown')
|
||||
name = gen.lib.Name()
|
||||
name = Name()
|
||||
name.add_surname(surname)
|
||||
name.set_type(gen.lib.NameType.UNKNOWN)
|
||||
name.set_type(NameType.UNKNOWN)
|
||||
obj.set_primary_name(name)
|
||||
elif isinstance(obj, gen.lib.Family):
|
||||
obj.set_relationship(gen.lib.FamilyRelType.UNKNOWN)
|
||||
elif isinstance(obj, Family):
|
||||
obj.set_relationship(FamilyRelType.UNKNOWN)
|
||||
handle = obj.handle
|
||||
if getattr(argv['db'].transaction, 'no_magic', False):
|
||||
backlinks = argv['db'].find_backlink_handles(
|
||||
handle, [gen.lib.Person.__name__])
|
||||
handle, [Person.__name__])
|
||||
for dummy, person_handle in backlinks:
|
||||
person = argv['db'].get_person_from_handle(person_handle)
|
||||
add_personref_to_family(obj, person)
|
||||
@ -106,16 +110,16 @@ def make_unknown(class_arg, explanation, class_func, commit_func, transaction,
|
||||
for person in argv['db'].iter_people():
|
||||
if person._has_handle_reference('Family', handle):
|
||||
add_personref_to_family(obj, person)
|
||||
elif isinstance(obj, gen.lib.Event):
|
||||
elif isinstance(obj, Event):
|
||||
if 'type' in argv:
|
||||
obj.set_type(argv['type'])
|
||||
else:
|
||||
obj.set_type(gen.lib.EventType.UNKNOWN)
|
||||
elif isinstance(obj, gen.lib.Place):
|
||||
obj.set_type(EventType.UNKNOWN)
|
||||
elif isinstance(obj, Place):
|
||||
obj.set_title(_('Unknown'))
|
||||
elif isinstance(obj, gen.lib.Source):
|
||||
elif isinstance(obj, Source):
|
||||
obj.set_title(_('Unknown'))
|
||||
elif isinstance(obj, gen.lib.Citation):
|
||||
elif isinstance(obj, Citation):
|
||||
#TODO create a new source for every citation?
|
||||
obj2 = argv['source_class_func'](argv['source_class_arg'])
|
||||
obj2.set_title(_('Unknown'))
|
||||
@ -123,23 +127,23 @@ def make_unknown(class_arg, explanation, class_func, commit_func, transaction,
|
||||
argv['source_commit_func'](obj2, transaction, time.time())
|
||||
retval.append(obj2)
|
||||
obj.set_reference_handle(obj2.handle)
|
||||
elif isinstance(obj, gen.lib.Repository):
|
||||
elif isinstance(obj, Repository):
|
||||
obj.set_name(_('Unknown'))
|
||||
obj.set_type(gen.lib.RepositoryType.UNKNOWN)
|
||||
elif isinstance(obj, gen.lib.MediaObject):
|
||||
obj.set_type(RepositoryType.UNKNOWN)
|
||||
elif isinstance(obj, MediaObject):
|
||||
obj.set_path(os.path.join(IMAGE_DIR, "image-missing.png"))
|
||||
obj.set_mime_type('image/png')
|
||||
obj.set_description(_('Unknown'))
|
||||
elif isinstance(obj, gen.lib.Note):
|
||||
obj.set_type(gen.lib.NoteType.UNKNOWN);
|
||||
elif isinstance(obj, Note):
|
||||
obj.set_type(NoteType.UNKNOWN);
|
||||
text = _('Unknown, created to replace a missing note object.')
|
||||
link_start = text.index(',') + 2
|
||||
link_end = len(text) - 1
|
||||
tag = gen.lib.StyledTextTag(gen.lib.StyledTextTagType.LINK,
|
||||
tag = StyledTextTag(StyledTextTagType.LINK,
|
||||
'gramps://Note/handle/%s' % explanation,
|
||||
[(link_start, link_end)])
|
||||
obj.set_styledtext(gen.lib.StyledText(text, [tag]))
|
||||
elif isinstance(obj, gen.lib.Tag):
|
||||
obj.set_styledtext(StyledText(text, [tag]))
|
||||
elif isinstance(obj, Tag):
|
||||
if not hasattr(make_unknown, 'count'):
|
||||
make_unknown.count = 1 #primitive static variable
|
||||
obj.set_name(_("Unknown, was missing %(time)s (%(count)d)") % {
|
||||
@ -161,7 +165,7 @@ def create_explanation_note(dbase):
|
||||
those objects of type "Unknown" need a explanatory note. This funcion
|
||||
provides such a note for import methods.
|
||||
"""
|
||||
note = gen.lib.Note( _('Objects referenced by this note '
|
||||
note = Note( _('Objects referenced by this note '
|
||||
'were missing in a file imported on %s.') %
|
||||
time.strftime('%x %X', time.localtime()))
|
||||
note.set_handle(create_id())
|
||||
@ -177,18 +181,18 @@ def add_personref_to_family(family, person):
|
||||
handle = family.handle
|
||||
person_handle = person.handle
|
||||
if handle in person.get_family_handle_list():
|
||||
if ((person.get_gender() == gen.lib.Person.FEMALE) and
|
||||
if ((person.get_gender() == Person.FEMALE) and
|
||||
(family.get_mother_handle() is None)):
|
||||
family.set_mother_handle(person_handle)
|
||||
else:
|
||||
# This includes cases of gen.lib.Person.UNKNOWN
|
||||
# This includes cases of Person.UNKNOWN
|
||||
if family.get_father_handle() is None:
|
||||
family.set_father_handle(person_handle)
|
||||
else:
|
||||
family.set_mother_handle(person_handle)
|
||||
if handle in person.get_parent_family_handle_list():
|
||||
childref = gen.lib.ChildRef()
|
||||
childref = ChildRef()
|
||||
childref.set_reference_handle(person_handle)
|
||||
childref.set_mother_relation(gen.lib.ChildRefType.UNKNOWN)
|
||||
childref.set_father_relation(gen.lib.ChildRefType.UNKNOWN)
|
||||
childref.set_mother_relation(ChildRefType.UNKNOWN)
|
||||
childref.set_father_relation(ChildRefType.UNKNOWN)
|
||||
family.add_child_ref(childref)
|
||||
|
Loading…
Reference in New Issue
Block a user