[r22062]GrampsLocale: Fix execption

'Foo has no attribute _Foo__get_type'
From moving the set_locale function to the superclass. One can get
carried away with enforcing private attributes...

svn: r22063
This commit is contained in:
John Ralls 2013-04-21 18:02:47 +00:00
parent f405ef9f3a
commit f9e8c90b7d
4 changed files with 16 additions and 15 deletions

View File

@ -65,8 +65,8 @@ class Report(object):
language = None language = None
locale = GrampsLocale(lang=language) locale = GrampsLocale(lang=language)
self._ = locale.translation.gettext self._ = locale.translation.gettext
self.__get_date = locale.get_date self._get_date = locale.get_date
self.__get_type = locale.get_type self._get_type = locale.get_type
return locale return locale
def write_report(self): def write_report(self):

View File

@ -946,6 +946,7 @@ class GrampsLocale(object):
:returns: The name as text in the proper language. :returns: The name as text in the proper language.
:rtype: unicode :rtype: unicode
""" """
from gramps.gen.lib.grampstype import GrampsType
return GrampsType.xml_str(name) return GrampsType.xml_str(name)
def format(self, format, val, grouping=False, monetary=False): def format(self, format, val, grouping=False, monetary=False):

View File

@ -326,7 +326,7 @@ class DetAncestorReport(Report):
self.doc.end_paragraph() self.doc.end_paragraph()
first = False first = False
self.doc.start_paragraph('DAR-MoreDetails') self.doc.start_paragraph('DAR-MoreDetails')
atype = self.__get_type(alt_name.get_type()) atype = self._get_type(alt_name.get_type())
self.doc.write_text_citation( self.doc.write_text_citation(
self._('%(name_kind)s: %(name)s%(endnotes)s') % { self._('%(name_kind)s: %(name)s%(endnotes)s') % {
'name_kind' : self._(atype), 'name_kind' : self._(atype),
@ -366,7 +366,7 @@ class DetAncestorReport(Report):
self.doc.write_text(self._('Address: ')) self.doc.write_text(self._('Address: '))
if self.fulldate: if self.fulldate:
date = self.__get_date(addr.get_date_object()) date = self._get_date(addr.get_date_object())
else: else:
date = addr.get_date_object().get_year() date = addr.get_date_object().get_year()
@ -387,7 +387,7 @@ class DetAncestorReport(Report):
for attr in attrs: for attr in attrs:
self.doc.start_paragraph('DAR-MoreDetails') self.doc.start_paragraph('DAR-MoreDetails')
attrName = self.__get_type(attr.get_type()) attrName = self._get_type(attr.get_type())
text = self._("%(type)s: %(value)s%(endnotes)s") % { text = self._("%(type)s: %(value)s%(endnotes)s") % {
'type' : self._(attrName), 'type' : self._(attrName),
'value' : attr.get_value(), 'value' : attr.get_value(),
@ -402,7 +402,7 @@ class DetAncestorReport(Report):
event = self.database.get_event_from_handle(event_ref.ref) event = self.database.get_event_from_handle(event_ref.ref)
if self.fulldate: if self.fulldate:
date = self.__get_date(event.get_date_object()) date = self._get_date(event.get_date_object())
else: else:
date = event.get_date_object().get_year() date = event.get_date_object().get_year()
@ -413,7 +413,7 @@ class DetAncestorReport(Report):
place = '' place = ''
self.doc.start_paragraph('DAR-MoreDetails') self.doc.start_paragraph('DAR-MoreDetails')
evtName = self.__get_type(event.get_type()) evtName = self._get_type(event.get_type())
if date and place: if date and place:
text += self._('%(date)s, %(place)s') % { text += self._('%(date)s, %(place)s') % {
'date' : date, 'place' : place } 'date' : date, 'place' : place }
@ -445,7 +445,7 @@ class DetAncestorReport(Report):
for attr in attr_list: for attr in attr_list:
if text: if text:
text += "; " text += "; "
attrName = self.__get_type(attr.get_type()) attrName = self._get_type(attr.get_type())
text += self._("%(type)s: %(value)s%(endnotes)s") % { text += self._("%(type)s: %(value)s%(endnotes)s") % {
'type' : self._(attrName), 'type' : self._(attrName),
'value' : attr.get_value(), 'value' : attr.get_value(),

View File

@ -418,7 +418,7 @@ class DetDescendantReport(Report):
event = self.database.get_event_from_handle(event_ref.ref) event = self.database.get_event_from_handle(event_ref.ref)
if self.fulldate: if self.fulldate:
date = self.__get_date(event.get_date_object()) date = self._get_date(event.get_date_object())
else: else:
date = event.get_date_object().get_year() date = event.get_date_object().get_year()
@ -429,7 +429,7 @@ class DetDescendantReport(Report):
place = '' place = ''
self.doc.start_paragraph('DDR-MoreDetails') self.doc.start_paragraph('DDR-MoreDetails')
event_name = self.__get_type(event.get_type()) event_name = self._get_type(event.get_type())
if date and place: if date and place:
text += self._('%(date)s, %(place)s') % { text += self._('%(date)s, %(place)s') % {
'date' : date, 'place' : place } 'date' : date, 'place' : place }
@ -461,7 +461,7 @@ class DetDescendantReport(Report):
for attr in attr_list: for attr in attr_list:
if text: if text:
text += "; " text += "; "
attrName = self.__get_type(attr.get_type()) attrName = self._get_type(attr.get_type())
text += self._("%(type)s: %(value)s%(endnotes)s") % { text += self._("%(type)s: %(value)s%(endnotes)s") % {
'type' : self._(attrName), 'type' : self._(attrName),
'value' : attr.get_value(), 'value' : attr.get_value(),
@ -708,7 +708,7 @@ class DetDescendantReport(Report):
for attr in attrs: for attr in attrs:
self.doc.start_paragraph('DDR-MoreDetails') self.doc.start_paragraph('DDR-MoreDetails')
attrName = self.__get_type(attr.get_type()) attrName = self._get_type(attr.get_type())
text = self._("%(type)s: %(value)s%(endnotes)s") % { text = self._("%(type)s: %(value)s%(endnotes)s") % {
'type' : self._(attrName), 'type' : self._(attrName),
'value' : attr.get_value(), 'value' : attr.get_value(),
@ -787,7 +787,7 @@ class DetDescendantReport(Report):
self.doc.end_paragraph() self.doc.end_paragraph()
first = False first = False
self.doc.start_paragraph('DDR-MoreDetails') self.doc.start_paragraph('DDR-MoreDetails')
atype = self.__get_type(alt_name.get_type()) atype = self._get_type(alt_name.get_type())
aname = alt_name.get_regular_name() aname = alt_name.get_regular_name()
self.doc.write_text_citation(self._('%(name_kind)s: %(name)s%(endnotes)s') % { self.doc.write_text_citation(self._('%(name_kind)s: %(name)s%(endnotes)s') % {
'name_kind' : self._(atype), 'name_kind' : self._(atype),
@ -820,7 +820,7 @@ class DetDescendantReport(Report):
text = ReportUtils.get_address_str(addr) text = ReportUtils.get_address_str(addr)
if self.fulldate: if self.fulldate:
date = self.__get_date(addr.get_date_object()) date = self._get_date(addr.get_date_object())
else: else:
date = addr.get_date_object().get_year() date = addr.get_date_object().get_year()
@ -842,7 +842,7 @@ class DetDescendantReport(Report):
for attr in attrs: for attr in attrs:
self.doc.start_paragraph('DDR-MoreDetails') self.doc.start_paragraph('DDR-MoreDetails')
attrName = self.__get_type(attr.get_type()) attrName = self._get_type(attr.get_type())
text = self._("%(type)s: %(value)s%(endnotes)s") % { text = self._("%(type)s: %(value)s%(endnotes)s") % {
'type' : self._(attrName), 'type' : self._(attrName),
'value' : attr.get_value(), 'value' : attr.get_value(),