Cleaned up gramps import section to have smaller memory footprint by specifying exactly what to import instead just everything.
svn: r12411
This commit is contained in:
parent
4d49eab84f
commit
2aea2184e7
@ -42,7 +42,7 @@ from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT
|
|||||||
from gen.plug.menu import BooleanOption, StringOption, NumberOption, \
|
from gen.plug.menu import BooleanOption, StringOption, NumberOption, \
|
||||||
EnumeratedListOption, FilterOption, PersonOption
|
EnumeratedListOption, FilterOption, PersonOption
|
||||||
import GrampsLocale
|
import GrampsLocale
|
||||||
import gen.lib
|
from gen.lib import NameType, EventType, Name, Date, Person
|
||||||
from Utils import probably_alive, ProgressMeter
|
from Utils import probably_alive, ProgressMeter
|
||||||
|
|
||||||
import libholiday
|
import libholiday
|
||||||
@ -89,18 +89,18 @@ class CalendarReport(Report):
|
|||||||
married_name = None
|
married_name = None
|
||||||
names = [primary_name] + person.get_alternate_names()
|
names = [primary_name] + person.get_alternate_names()
|
||||||
for name in names:
|
for name in names:
|
||||||
if int(name.get_type()) == gen.lib.NameType.MARRIED:
|
if int(name.get_type()) == NameType.MARRIED:
|
||||||
married_name = name
|
married_name = name
|
||||||
break # use first
|
break # use first
|
||||||
# Now, decide which to use:
|
# Now, decide which to use:
|
||||||
if maiden_name is not None:
|
if maiden_name is not None:
|
||||||
if married_name is not None:
|
if married_name is not None:
|
||||||
name = gen.lib.Name(married_name)
|
name = Name(married_name)
|
||||||
else:
|
else:
|
||||||
name = gen.lib.Name(primary_name)
|
name = Name(primary_name)
|
||||||
name.set_surname(maiden_name)
|
name.set_surname(maiden_name)
|
||||||
else:
|
else:
|
||||||
name = gen.lib.Name(primary_name)
|
name = Name(primary_name)
|
||||||
name.set_display_as(self.name_format)
|
name.set_display_as(self.name_format)
|
||||||
return _nd.display_name(name)
|
return _nd.display_name(name)
|
||||||
|
|
||||||
@ -211,13 +211,13 @@ class CalendarReport(Report):
|
|||||||
month = birth_date.get_month()
|
month = birth_date.get_month()
|
||||||
day = birth_date.get_day()
|
day = birth_date.get_day()
|
||||||
|
|
||||||
prob_alive_date = gen.lib.Date(self.year, month, day)
|
prob_alive_date = Date(self.year, month, day)
|
||||||
|
|
||||||
nyears = self.year - year
|
nyears = self.year - year
|
||||||
# add some things to handle maiden name:
|
# add some things to handle maiden name:
|
||||||
father_lastname = None # husband, actually
|
father_lastname = None # husband, actually
|
||||||
if self.maiden_name in ['spouse_first', 'spouse_last']: # get husband's last name:
|
if self.maiden_name in ['spouse_first', 'spouse_last']: # get husband's last name:
|
||||||
if person.get_gender() == gen.lib.Person.FEMALE:
|
if person.get_gender() == Person.FEMALE:
|
||||||
family_list = person.get_family_handle_list()
|
family_list = person.get_family_handle_list()
|
||||||
if len(family_list) > 0:
|
if len(family_list) > 0:
|
||||||
if self.maiden_name == 'spouse_first':
|
if self.maiden_name == 'spouse_first':
|
||||||
@ -278,12 +278,12 @@ class CalendarReport(Report):
|
|||||||
are_married = None
|
are_married = None
|
||||||
for event_ref in fam.get_event_ref_list():
|
for event_ref in fam.get_event_ref_list():
|
||||||
event = self.database.get_event_from_handle(event_ref.ref)
|
event = self.database.get_event_from_handle(event_ref.ref)
|
||||||
if event.type in [gen.lib.EventType.MARRIAGE,
|
if event.type in [EventType.MARRIAGE,
|
||||||
gen.lib.EventType.MARR_ALT]:
|
EventType.MARR_ALT]:
|
||||||
are_married = event
|
are_married = event
|
||||||
elif event.type in [gen.lib.EventType.DIVORCE,
|
elif event.type in [EventType.DIVORCE,
|
||||||
gen.lib.EventType.ANNULMENT,
|
EventType.ANNULMENT,
|
||||||
gen.lib.EventType.DIV_FILING]:
|
EventType.DIV_FILING]:
|
||||||
are_married = None
|
are_married = None
|
||||||
if are_married is not None:
|
if are_married is not None:
|
||||||
for event_ref in fam.get_event_ref_list():
|
for event_ref in fam.get_event_ref_list():
|
||||||
@ -306,7 +306,7 @@ class CalendarReport(Report):
|
|||||||
'person' : short_name,
|
'person' : short_name,
|
||||||
'nyears' : nyears})
|
'nyears' : nyears})
|
||||||
|
|
||||||
prob_alive_date = gen.lib.Date(self.year, month, day)
|
prob_alive_date = Date(self.year, month, day)
|
||||||
alive1 = probably_alive(person, self.database, \
|
alive1 = probably_alive(person, self.database, \
|
||||||
prob_alive_date)
|
prob_alive_date)
|
||||||
alive2 = probably_alive(spouse, self.database, \
|
alive2 = probably_alive(spouse, self.database, \
|
||||||
|
@ -74,7 +74,7 @@ log = logging.getLogger(".WebPage")
|
|||||||
# GRAMPS module
|
# GRAMPS module
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
import gen.lib
|
from gen.lib import UrlType, EventType, Person, date, ChildRefType, FamilyRelType
|
||||||
import const
|
import const
|
||||||
from GrampsCfg import get_researcher
|
from GrampsCfg import get_researcher
|
||||||
import Sort
|
import Sort
|
||||||
@ -88,7 +88,7 @@ import Utils
|
|||||||
import ThumbNails
|
import ThumbNails
|
||||||
import ImgManip
|
import ImgManip
|
||||||
import Mime
|
import Mime
|
||||||
from Utils import probably_alive
|
from Utils import probably_alive, xml_lang
|
||||||
from QuestionDialog import ErrorDialog, WarningDialog
|
from QuestionDialog import ErrorDialog, WarningDialog
|
||||||
from BasicUtils import name_displayer as _nd
|
from BasicUtils import name_displayer as _nd
|
||||||
from DateHandler import displayer as _dd
|
from DateHandler import displayer as _dd
|
||||||
@ -351,10 +351,10 @@ class BasePage:
|
|||||||
of.write('</p>\n')
|
of.write('</p>\n')
|
||||||
of.write('\t</div>\n')
|
of.write('\t</div>\n')
|
||||||
|
|
||||||
value = _dp.parse(time.strftime('%b %d %Y'))
|
value = _dd.display(date.Today())
|
||||||
value = _dd.display(value)
|
msg = _('Generated by <a href="%(homepage)s">'
|
||||||
msg = _('Generated by <a href="http://gramps-project.org">'
|
'GRAMPS</a> on %(date)s') % {'date' : value,
|
||||||
'GRAMPS</a> on %(date)s') % {'date' : value}
|
'homepage' : const.URL_HOMEPAGE}
|
||||||
|
|
||||||
# optional "link-home" feature; see bug report #2736
|
# optional "link-home" feature; see bug report #2736
|
||||||
if self.report.options['linkhome']:
|
if self.report.options['linkhome']:
|
||||||
@ -370,7 +370,7 @@ class BasePage:
|
|||||||
text = ''
|
text = ''
|
||||||
if copy_nr == 0:
|
if copy_nr == 0:
|
||||||
if self.author:
|
if self.author:
|
||||||
year = time.localtime()[0]
|
year = gen.lib.date.Today().get_year()
|
||||||
text = '© %(year)d %(person)s' % {
|
text = '© %(year)d %(person)s' % {
|
||||||
'person' : self.author,
|
'person' : self.author,
|
||||||
'year' : year}
|
'year' : year}
|
||||||
@ -397,7 +397,7 @@ class BasePage:
|
|||||||
of.write('<!DOCTYPE html PUBLIC ')
|
of.write('<!DOCTYPE html PUBLIC ')
|
||||||
of.write('\t"-//W3C//DTD XHTML 1.0 Strict//EN" ')
|
of.write('\t"-//W3C//DTD XHTML 1.0 Strict//EN" ')
|
||||||
of.write('\t\t"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n')
|
of.write('\t\t"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n')
|
||||||
xmllang = Utils.xml_lang()
|
xmllang = xml_lang()
|
||||||
of.write('<html xmlns="http://www.w3.org/1999/xhtml" '
|
of.write('<html xmlns="http://www.w3.org/1999/xhtml" '
|
||||||
'xml:lang="%s" lang="%s">\n' % (xmllang, xmllang))
|
'xml:lang="%s" lang="%s">\n' % (xmllang, xmllang))
|
||||||
|
|
||||||
@ -633,11 +633,11 @@ class BasePage:
|
|||||||
descr = url.get_description()
|
descr = url.get_description()
|
||||||
if not descr:
|
if not descr:
|
||||||
descr = uri
|
descr = uri
|
||||||
if url.get_type() == gen.lib.UrlType.EMAIL and not uri.startswith("mailto:"):
|
if url.get_type() == UrlType.EMAIL and not uri.startswith("mailto:"):
|
||||||
of.write('\t\t\t<li><a href="mailto:%s">%s</a>' % (uri, descr))
|
of.write('\t\t\t<li><a href="mailto:%s">%s</a>' % (uri, descr))
|
||||||
elif url.get_type() == gen.lib.UrlType.WEB_HOME and not uri.startswith("http://"):
|
elif url.get_type() == UrlType.WEB_HOME and not uri.startswith("http://"):
|
||||||
of.write('\t\t\t<li><a href="http://%s">%s</a>' % (uri, descr))
|
of.write('\t\t\t<li><a href="http://%s">%s</a>' % (uri, descr))
|
||||||
elif url.get_type() == gen.lib.UrlType.WEB_FTP and not uri.startswith("ftp://"):
|
elif url.get_type() == UrlType.WEB_FTP and not uri.startswith("ftp://"):
|
||||||
of.write('\t\t\t<li><a href="ftp://%s">%s</a>' % (uri, descr))
|
of.write('\t\t\t<li><a href="ftp://%s">%s</a>' % (uri, descr))
|
||||||
else:
|
else:
|
||||||
of.write('\t\t\t<li><a href="%s">%s</a>' % (uri, descr))
|
of.write('\t\t\t<li><a href="%s">%s</a>' % (uri, descr))
|
||||||
@ -858,7 +858,7 @@ class IndividualListPage(BasePage):
|
|||||||
of.write('\t\t\t<td class="ColumnBirth">')
|
of.write('\t\t\t<td class="ColumnBirth">')
|
||||||
birth = ReportUtils.get_birth_or_fallback(db, person)
|
birth = ReportUtils.get_birth_or_fallback(db, person)
|
||||||
if birth:
|
if birth:
|
||||||
if birth.get_type() == gen.lib.EventType.BIRTH:
|
if birth.get_type() == EventType.BIRTH:
|
||||||
of.write(_dd.display(birth.get_date_object()))
|
of.write(_dd.display(birth.get_date_object()))
|
||||||
else:
|
else:
|
||||||
of.write('<em>')
|
of.write('<em>')
|
||||||
@ -871,7 +871,7 @@ class IndividualListPage(BasePage):
|
|||||||
of.write('\t\t\t<td class="ColumnDeath">')
|
of.write('\t\t\t<td class="ColumnDeath">')
|
||||||
death = ReportUtils.get_death_or_fallback(db, person)
|
death = ReportUtils.get_death_or_fallback(db, person)
|
||||||
if death:
|
if death:
|
||||||
if death.get_type() == gen.lib.EventType.DEATH:
|
if death.get_type() == EventType.DEATH:
|
||||||
of.write(_dd.display(death.get_date_object()))
|
of.write(_dd.display(death.get_date_object()))
|
||||||
else:
|
else:
|
||||||
of.write('<em>')
|
of.write('<em>')
|
||||||
@ -988,7 +988,7 @@ class SurnamePage(BasePage):
|
|||||||
of.write('\t\t\t<td class="ColumnBirth">')
|
of.write('\t\t\t<td class="ColumnBirth">')
|
||||||
birth = ReportUtils.get_birth_or_fallback(db, person)
|
birth = ReportUtils.get_birth_or_fallback(db, person)
|
||||||
if birth:
|
if birth:
|
||||||
if birth.get_type() == gen.lib.EventType.BIRTH:
|
if birth.get_type() == EventType.BIRTH:
|
||||||
of.write(_dd.display(birth.get_date_object()))
|
of.write(_dd.display(birth.get_date_object()))
|
||||||
else:
|
else:
|
||||||
of.write('<em>')
|
of.write('<em>')
|
||||||
@ -1001,7 +1001,7 @@ class SurnamePage(BasePage):
|
|||||||
of.write('\t\t\t<td class="ColumnDeath">')
|
of.write('\t\t\t<td class="ColumnDeath">')
|
||||||
death = ReportUtils.get_death_or_fallback(db, person)
|
death = ReportUtils.get_death_or_fallback(db, person)
|
||||||
if death:
|
if death:
|
||||||
if death.get_type() == gen.lib.EventType.DEATH:
|
if death.get_type() == EventType.DEATH:
|
||||||
of.write(_dd.display(death.get_date_object()))
|
of.write(_dd.display(death.get_date_object()))
|
||||||
else:
|
else:
|
||||||
of.write('<em>')
|
of.write('<em>')
|
||||||
@ -1862,9 +1862,9 @@ class IndividualPage(BasePage):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
gender_map = {
|
gender_map = {
|
||||||
gen.lib.Person.MALE : _('male'),
|
Person.MALE : _('male'),
|
||||||
gen.lib.Person.FEMALE : _('female'),
|
Person.FEMALE : _('female'),
|
||||||
gen.lib.Person.UNKNOWN : _('unknown'),
|
Person.UNKNOWN : _('unknown'),
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, report, title, person, ind_list, place_list, src_list):
|
def __init__(self, report, title, person, ind_list, place_list, src_list):
|
||||||
@ -1939,9 +1939,9 @@ class IndividualPage(BasePage):
|
|||||||
top = center - _HEIGHT/2
|
top = center - _HEIGHT/2
|
||||||
xoff = _XOFFSET+col*(_WIDTH+_HGAP)
|
xoff = _XOFFSET+col*(_WIDTH+_HGAP)
|
||||||
sex = person.gender
|
sex = person.gender
|
||||||
if sex == gen.lib.Person.MALE:
|
if sex == Person.MALE:
|
||||||
divclass = "male"
|
divclass = "male"
|
||||||
elif sex == gen.lib.Person.FEMALE:
|
elif sex == Person.FEMALE:
|
||||||
divclass = "female"
|
divclass = "female"
|
||||||
else:
|
else:
|
||||||
divclass = "unknown"
|
divclass = "unknown"
|
||||||
@ -2215,7 +2215,7 @@ class IndividualPage(BasePage):
|
|||||||
birth_date = birth_event.get_date_object()
|
birth_date = birth_event.get_date_object()
|
||||||
|
|
||||||
if (birth_date is not None and birth_date.is_valid()):
|
if (birth_date is not None and birth_date.is_valid()):
|
||||||
alive = probably_alive(self.person, self.report.database, gen.lib.date.Today())
|
alive = probably_alive(self.person, self.report.database, date.Today())
|
||||||
death_ref = self.person.get_death_ref()
|
death_ref = self.person.get_death_ref()
|
||||||
death_date = None
|
death_date = None
|
||||||
if death_ref:
|
if death_ref:
|
||||||
@ -2390,7 +2390,7 @@ class IndividualPage(BasePage):
|
|||||||
self.person_link(of, url, _nd.display(person), gid)
|
self.person_link(of, url, _nd.display(person), gid)
|
||||||
else:
|
else:
|
||||||
of.write(_nd.display(person))
|
of.write(_nd.display(person))
|
||||||
if rel and rel != gen.lib.ChildRefType(gen.lib.ChildRefType.BIRTH):
|
if rel and rel != ChildRefType(ChildRefType.BIRTH):
|
||||||
of.write(' (%s)' % str(rel))
|
of.write(' (%s)' % str(rel))
|
||||||
of.write('</td>\n')
|
of.write('</td>\n')
|
||||||
|
|
||||||
@ -2617,10 +2617,10 @@ class IndividualPage(BasePage):
|
|||||||
gender = self.person.get_gender()
|
gender = self.person.get_gender()
|
||||||
reltype = family.get_relationship()
|
reltype = family.get_relationship()
|
||||||
|
|
||||||
if reltype == gen.lib.FamilyRelType.MARRIED:
|
if reltype == FamilyRelType.MARRIED:
|
||||||
if gender == gen.lib.Person.FEMALE:
|
if gender == Person.FEMALE:
|
||||||
relstr = _("Husband")
|
relstr = _("Husband")
|
||||||
elif gender == gen.lib.Person.MALE:
|
elif gender == Person.MALE:
|
||||||
relstr = _("Wife")
|
relstr = _("Wife")
|
||||||
else:
|
else:
|
||||||
relstr = _("Partner")
|
relstr = _("Partner")
|
||||||
@ -3602,7 +3602,7 @@ def _get_prefix_suffix_name(sex, name):
|
|||||||
prefix = name.get_surname_prefix()
|
prefix = name.get_surname_prefix()
|
||||||
if prefix:
|
if prefix:
|
||||||
first = prefix + " " + first
|
first = prefix + " " + first
|
||||||
if sex == gen.lib.Person.FEMALE:
|
if sex == Person.FEMALE:
|
||||||
return first
|
return first
|
||||||
else:
|
else:
|
||||||
suffix = name.get_suffix()
|
suffix = name.get_suffix()
|
||||||
|
Loading…
Reference in New Issue
Block a user