From 5db0763970f35461ec0d66dedb356c0070cf088f Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sun, 21 Apr 2013 17:49:08 +0000 Subject: [PATCH] GrampsLocale: Fix 'Foo has no attribute _Foo__get_type' execption From moving the set_locale function to the superclass. One can get carried away with enforcing private attributes... svn: r22062 --- gramps/gen/plug/report/_reportbase.py | 4 ++-- gramps/gen/utils/grampslocale.py | 1 + gramps/plugins/textreport/detancestralreport.py | 12 ++++++------ gramps/plugins/textreport/detdescendantreport.py | 14 +++++++------- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/gramps/gen/plug/report/_reportbase.py b/gramps/gen/plug/report/_reportbase.py index 769690913..478809209 100644 --- a/gramps/gen/plug/report/_reportbase.py +++ b/gramps/gen/plug/report/_reportbase.py @@ -65,8 +65,8 @@ class Report(object): language = None locale = GrampsLocale(lang=language) self._ = locale.translation.gettext - self.__get_date = locale.get_date - self.__get_type = locale.get_type + self._get_date = locale.get_date + self._get_type = locale.get_type return locale def write_report(self): diff --git a/gramps/gen/utils/grampslocale.py b/gramps/gen/utils/grampslocale.py index 3e997b691..606e941ba 100644 --- a/gramps/gen/utils/grampslocale.py +++ b/gramps/gen/utils/grampslocale.py @@ -946,6 +946,7 @@ class GrampsLocale(object): :returns: The name as text in the proper language. :rtype: unicode """ + from gramps.gen.lib.grampstype import GrampsType return GrampsType.xml_str(name) def format(self, format, val, grouping=False, monetary=False): diff --git a/gramps/plugins/textreport/detancestralreport.py b/gramps/plugins/textreport/detancestralreport.py index 7b5da7e4f..d56056831 100644 --- a/gramps/plugins/textreport/detancestralreport.py +++ b/gramps/plugins/textreport/detancestralreport.py @@ -326,7 +326,7 @@ class DetAncestorReport(Report): self.doc.end_paragraph() first = False 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._('%(name_kind)s: %(name)s%(endnotes)s') % { 'name_kind' : self._(atype), @@ -366,7 +366,7 @@ class DetAncestorReport(Report): self.doc.write_text(self._('Address: ')) if self.fulldate: - date = self.__get_date(addr.get_date_object()) + date = self._get_date(addr.get_date_object()) else: date = addr.get_date_object().get_year() @@ -387,7 +387,7 @@ class DetAncestorReport(Report): for attr in attrs: 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") % { 'type' : self._(attrName), 'value' : attr.get_value(), @@ -402,7 +402,7 @@ class DetAncestorReport(Report): event = self.database.get_event_from_handle(event_ref.ref) if self.fulldate: - date = self.__get_date(event.get_date_object()) + date = self._get_date(event.get_date_object()) else: date = event.get_date_object().get_year() @@ -413,7 +413,7 @@ class DetAncestorReport(Report): place = '' self.doc.start_paragraph('DAR-MoreDetails') - evtName = self.__get_type(event.get_type()) + evtName = self._get_type(event.get_type()) if date and place: text += self._('%(date)s, %(place)s') % { 'date' : date, 'place' : place } @@ -445,7 +445,7 @@ class DetAncestorReport(Report): for attr in attr_list: if text: text += "; " - attrName = self.__get_type(attr.get_type()) + attrName = self._get_type(attr.get_type()) text += self._("%(type)s: %(value)s%(endnotes)s") % { 'type' : self._(attrName), 'value' : attr.get_value(), diff --git a/gramps/plugins/textreport/detdescendantreport.py b/gramps/plugins/textreport/detdescendantreport.py index e935e0086..d58c94828 100644 --- a/gramps/plugins/textreport/detdescendantreport.py +++ b/gramps/plugins/textreport/detdescendantreport.py @@ -418,7 +418,7 @@ class DetDescendantReport(Report): event = self.database.get_event_from_handle(event_ref.ref) if self.fulldate: - date = self.__get_date(event.get_date_object()) + date = self._get_date(event.get_date_object()) else: date = event.get_date_object().get_year() @@ -429,7 +429,7 @@ class DetDescendantReport(Report): place = '' 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: text += self._('%(date)s, %(place)s') % { 'date' : date, 'place' : place } @@ -461,7 +461,7 @@ class DetDescendantReport(Report): for attr in attr_list: if text: text += "; " - attrName = self.__get_type(attr.get_type()) + attrName = self._get_type(attr.get_type()) text += self._("%(type)s: %(value)s%(endnotes)s") % { 'type' : self._(attrName), 'value' : attr.get_value(), @@ -708,7 +708,7 @@ class DetDescendantReport(Report): for attr in attrs: 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") % { 'type' : self._(attrName), 'value' : attr.get_value(), @@ -787,7 +787,7 @@ class DetDescendantReport(Report): self.doc.end_paragraph() first = False 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() self.doc.write_text_citation(self._('%(name_kind)s: %(name)s%(endnotes)s') % { 'name_kind' : self._(atype), @@ -820,7 +820,7 @@ class DetDescendantReport(Report): text = ReportUtils.get_address_str(addr) if self.fulldate: - date = self.__get_date(addr.get_date_object()) + date = self._get_date(addr.get_date_object()) else: date = addr.get_date_object().get_year() @@ -842,7 +842,7 @@ class DetDescendantReport(Report): for attr in attrs: 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") % { 'type' : self._(attrName), 'value' : attr.get_value(),