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, \
|
||||
EnumeratedListOption, FilterOption, PersonOption
|
||||
import GrampsLocale
|
||||
import gen.lib
|
||||
from gen.lib import NameType, EventType, Name, Date, Person
|
||||
from Utils import probably_alive, ProgressMeter
|
||||
|
||||
import libholiday
|
||||
@ -89,18 +89,18 @@ class CalendarReport(Report):
|
||||
married_name = None
|
||||
names = [primary_name] + person.get_alternate_names()
|
||||
for name in names:
|
||||
if int(name.get_type()) == gen.lib.NameType.MARRIED:
|
||||
if int(name.get_type()) == NameType.MARRIED:
|
||||
married_name = name
|
||||
break # use first
|
||||
# Now, decide which to use:
|
||||
if maiden_name is not None:
|
||||
if married_name is not None:
|
||||
name = gen.lib.Name(married_name)
|
||||
name = Name(married_name)
|
||||
else:
|
||||
name = gen.lib.Name(primary_name)
|
||||
name = Name(primary_name)
|
||||
name.set_surname(maiden_name)
|
||||
else:
|
||||
name = gen.lib.Name(primary_name)
|
||||
name = Name(primary_name)
|
||||
name.set_display_as(self.name_format)
|
||||
return _nd.display_name(name)
|
||||
|
||||
@ -211,13 +211,13 @@ class CalendarReport(Report):
|
||||
month = birth_date.get_month()
|
||||
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
|
||||
# add some things to handle maiden name:
|
||||
father_lastname = None # husband, actually
|
||||
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()
|
||||
if len(family_list) > 0:
|
||||
if self.maiden_name == 'spouse_first':
|
||||
@ -278,12 +278,12 @@ class CalendarReport(Report):
|
||||
are_married = None
|
||||
for event_ref in fam.get_event_ref_list():
|
||||
event = self.database.get_event_from_handle(event_ref.ref)
|
||||
if event.type in [gen.lib.EventType.MARRIAGE,
|
||||
gen.lib.EventType.MARR_ALT]:
|
||||
if event.type in [EventType.MARRIAGE,
|
||||
EventType.MARR_ALT]:
|
||||
are_married = event
|
||||
elif event.type in [gen.lib.EventType.DIVORCE,
|
||||
gen.lib.EventType.ANNULMENT,
|
||||
gen.lib.EventType.DIV_FILING]:
|
||||
elif event.type in [EventType.DIVORCE,
|
||||
EventType.ANNULMENT,
|
||||
EventType.DIV_FILING]:
|
||||
are_married = None
|
||||
if are_married is not None:
|
||||
for event_ref in fam.get_event_ref_list():
|
||||
@ -306,7 +306,7 @@ class CalendarReport(Report):
|
||||
'person' : short_name,
|
||||
'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, \
|
||||
prob_alive_date)
|
||||
alive2 = probably_alive(spouse, self.database, \
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user