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:
@ -74,7 +74,7 @@ log = logging.getLogger(".WebPage")
|
||||
# GRAMPS module
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import gen.lib
|
||||
from gen.lib import UrlType, EventType, Person, date, ChildRefType, FamilyRelType
|
||||
import const
|
||||
from GrampsCfg import get_researcher
|
||||
import Sort
|
||||
@ -88,7 +88,7 @@ import Utils
|
||||
import ThumbNails
|
||||
import ImgManip
|
||||
import Mime
|
||||
from Utils import probably_alive
|
||||
from Utils import probably_alive, xml_lang
|
||||
from QuestionDialog import ErrorDialog, WarningDialog
|
||||
from BasicUtils import name_displayer as _nd
|
||||
from DateHandler import displayer as _dd
|
||||
@ -351,10 +351,10 @@ class BasePage:
|
||||
of.write('</p>\n')
|
||||
of.write('\t</div>\n')
|
||||
|
||||
value = _dp.parse(time.strftime('%b %d %Y'))
|
||||
value = _dd.display(value)
|
||||
msg = _('Generated by <a href="http://gramps-project.org">'
|
||||
'GRAMPS</a> on %(date)s') % {'date' : value}
|
||||
value = _dd.display(date.Today())
|
||||
msg = _('Generated by <a href="%(homepage)s">'
|
||||
'GRAMPS</a> on %(date)s') % {'date' : value,
|
||||
'homepage' : const.URL_HOMEPAGE}
|
||||
|
||||
# optional "link-home" feature; see bug report #2736
|
||||
if self.report.options['linkhome']:
|
||||
@ -370,7 +370,7 @@ class BasePage:
|
||||
text = ''
|
||||
if copy_nr == 0:
|
||||
if self.author:
|
||||
year = time.localtime()[0]
|
||||
year = gen.lib.date.Today().get_year()
|
||||
text = '© %(year)d %(person)s' % {
|
||||
'person' : self.author,
|
||||
'year' : year}
|
||||
@ -397,7 +397,7 @@ class BasePage:
|
||||
of.write('<!DOCTYPE html PUBLIC ')
|
||||
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')
|
||||
xmllang = Utils.xml_lang()
|
||||
xmllang = xml_lang()
|
||||
of.write('<html xmlns="http://www.w3.org/1999/xhtml" '
|
||||
'xml:lang="%s" lang="%s">\n' % (xmllang, xmllang))
|
||||
|
||||
@ -633,11 +633,11 @@ class BasePage:
|
||||
descr = url.get_description()
|
||||
if not descr:
|
||||
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))
|
||||
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))
|
||||
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))
|
||||
else:
|
||||
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">')
|
||||
birth = ReportUtils.get_birth_or_fallback(db, person)
|
||||
if birth:
|
||||
if birth.get_type() == gen.lib.EventType.BIRTH:
|
||||
if birth.get_type() == EventType.BIRTH:
|
||||
of.write(_dd.display(birth.get_date_object()))
|
||||
else:
|
||||
of.write('<em>')
|
||||
@ -871,7 +871,7 @@ class IndividualListPage(BasePage):
|
||||
of.write('\t\t\t<td class="ColumnDeath">')
|
||||
death = ReportUtils.get_death_or_fallback(db, person)
|
||||
if death:
|
||||
if death.get_type() == gen.lib.EventType.DEATH:
|
||||
if death.get_type() == EventType.DEATH:
|
||||
of.write(_dd.display(death.get_date_object()))
|
||||
else:
|
||||
of.write('<em>')
|
||||
@ -988,7 +988,7 @@ class SurnamePage(BasePage):
|
||||
of.write('\t\t\t<td class="ColumnBirth">')
|
||||
birth = ReportUtils.get_birth_or_fallback(db, person)
|
||||
if birth:
|
||||
if birth.get_type() == gen.lib.EventType.BIRTH:
|
||||
if birth.get_type() == EventType.BIRTH:
|
||||
of.write(_dd.display(birth.get_date_object()))
|
||||
else:
|
||||
of.write('<em>')
|
||||
@ -1001,7 +1001,7 @@ class SurnamePage(BasePage):
|
||||
of.write('\t\t\t<td class="ColumnDeath">')
|
||||
death = ReportUtils.get_death_or_fallback(db, person)
|
||||
if death:
|
||||
if death.get_type() == gen.lib.EventType.DEATH:
|
||||
if death.get_type() == EventType.DEATH:
|
||||
of.write(_dd.display(death.get_date_object()))
|
||||
else:
|
||||
of.write('<em>')
|
||||
@ -1862,9 +1862,9 @@ class IndividualPage(BasePage):
|
||||
"""
|
||||
|
||||
gender_map = {
|
||||
gen.lib.Person.MALE : _('male'),
|
||||
gen.lib.Person.FEMALE : _('female'),
|
||||
gen.lib.Person.UNKNOWN : _('unknown'),
|
||||
Person.MALE : _('male'),
|
||||
Person.FEMALE : _('female'),
|
||||
Person.UNKNOWN : _('unknown'),
|
||||
}
|
||||
|
||||
def __init__(self, report, title, person, ind_list, place_list, src_list):
|
||||
@ -1939,9 +1939,9 @@ class IndividualPage(BasePage):
|
||||
top = center - _HEIGHT/2
|
||||
xoff = _XOFFSET+col*(_WIDTH+_HGAP)
|
||||
sex = person.gender
|
||||
if sex == gen.lib.Person.MALE:
|
||||
if sex == Person.MALE:
|
||||
divclass = "male"
|
||||
elif sex == gen.lib.Person.FEMALE:
|
||||
elif sex == Person.FEMALE:
|
||||
divclass = "female"
|
||||
else:
|
||||
divclass = "unknown"
|
||||
@ -2215,7 +2215,7 @@ class IndividualPage(BasePage):
|
||||
birth_date = birth_event.get_date_object()
|
||||
|
||||
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_date = None
|
||||
if death_ref:
|
||||
@ -2390,7 +2390,7 @@ class IndividualPage(BasePage):
|
||||
self.person_link(of, url, _nd.display(person), gid)
|
||||
else:
|
||||
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('</td>\n')
|
||||
|
||||
@ -2617,10 +2617,10 @@ class IndividualPage(BasePage):
|
||||
gender = self.person.get_gender()
|
||||
reltype = family.get_relationship()
|
||||
|
||||
if reltype == gen.lib.FamilyRelType.MARRIED:
|
||||
if gender == gen.lib.Person.FEMALE:
|
||||
if reltype == FamilyRelType.MARRIED:
|
||||
if gender == Person.FEMALE:
|
||||
relstr = _("Husband")
|
||||
elif gender == gen.lib.Person.MALE:
|
||||
elif gender == Person.MALE:
|
||||
relstr = _("Wife")
|
||||
else:
|
||||
relstr = _("Partner")
|
||||
@ -3602,7 +3602,7 @@ def _get_prefix_suffix_name(sex, name):
|
||||
prefix = name.get_surname_prefix()
|
||||
if prefix:
|
||||
first = prefix + " " + first
|
||||
if sex == gen.lib.Person.FEMALE:
|
||||
if sex == Person.FEMALE:
|
||||
return first
|
||||
else:
|
||||
suffix = name.get_suffix()
|
||||
|
Reference in New Issue
Block a user