increase pylint score of two more reports, to above 9.00

This commit is contained in:
Paul Franklin
2016-06-10 14:15:34 -07:00
parent c52b806702
commit cf8a6390ca
2 changed files with 176 additions and 162 deletions

View File

@@ -142,28 +142,28 @@ class CalcItems:
and text for each person / marriage
"""
def __init__(self, dbase):
__gui = GUIConnect()
_gui = GUIConnect()
#calculate the printed lines for each box
#display_repl = [] #Not used in this report
#str = ""
#if self.get_val('miss_val'):
# str = "_____"
self.__calc_l = CalcLines(dbase, [], __gui._locale, __gui._nd)
self.__calc_l = CalcLines(dbase, [], _gui.locale, _gui.n_d)
self.__blank_father = None
self.__blank_mother = None
self.__blank_father = \
self.__calc_l.calc_lines( None, None, __gui.get_val("father_disp"))
self.__calc_l.calc_lines(None, None, _gui.get_val("father_disp"))
self.__blank_mother = \
self.__calc_l.calc_lines( None, None, __gui.get_val("mother_disp"))
self.__calc_l.calc_lines(None, None, _gui.get_val("mother_disp"))
self.center_use = __gui.get_val("center_uses")
self.disp_father = __gui.get_val("father_disp")
self.disp_mother = __gui.get_val("mother_disp")
self.center_use = _gui.get_val("center_uses")
self.disp_father = _gui.get_val("father_disp")
self.disp_mother = _gui.get_val("mother_disp")
self.disp_marr = [__gui.get_val("marr_disp")]
self.disp_marr = [_gui.get_val("marr_disp")]
self.__blank_marriage = \
self.__calc_l.calc_lines(None, None, self.disp_marr)
@@ -227,8 +227,8 @@ class MakeAncestorTree(AscendPerson):
if index[LVL_GEN] > self.max_generation:
self.max_generation = index[LVL_GEN]
myself.text = self.calc_items.calc_person(
index, indi_handle, fams_handle)
myself.text = self.calc_items.calc_person(index,
indi_handle, fams_handle)
myself.add_mark(self.database,
self.database.get_person_from_handle(indi_handle))
@@ -286,7 +286,8 @@ class MakeAncestorTree(AscendPerson):
for box in self.canvas.boxes:
if "fam" in box.boxstr:
box.level = box.level + \
(self.y_index(box.level[LVL_GEN]-1, int(box.level[LVL_INDX]/2)),)
(self.y_index(box.level[LVL_GEN]-1,
int(box.level[LVL_INDX]/2)),)
else:
box.level = box.level + \
(self.y_index(box.level[LVL_GEN], box.level[LVL_INDX]),)
@@ -331,27 +332,28 @@ class MakeAncestorTree(AscendPerson):
move = level - (len(mykids)//2) + ((len(mykids)+1)%2)
if move < 0: # more kids than parents. ran off the page. Move them all down
if move < 0:
# more kids than parents. ran off the page. Move them all down
for box in self.canvas.boxes:
box.level = (box.level[0], box.level[1], box.level[2]-move)
move = 0
line.start = []
r = -1 # if len(mykids)%2 == 1 else 0
rrr = -1 # if len(mykids)%2 == 1 else 0
for kid in mykids:
r += 1
me = self.add_person((1, 1, move+r), kid, self.center_family)
line.add_from(me)
#me.level = (0, 1, level - (len(mykids)//2)+r )
rrr += 1
mee = self.add_person((1, 1, move+rrr), kid, self.center_family)
line.add_from(mee)
#mee.level = (0, 1, level - (len(mykids)//2)+rrr)
def start(self, person_id):
""" go ahead and make it happen """
center = self.database.get_person_from_gramps_id(person_id)
if center is None:
raise ReportError(_("Person %s is not in the Database")
% person_id)
raise ReportError(
_("Person %s is not in the Database") % person_id)
center_h = center.get_handle()
#Step 1. Get the people
@@ -448,7 +450,7 @@ class MakeReport:
return self.max_generations
def start(self):
__gui = GUIConnect()
## __gui = GUIConnect()
# 1.
#set the sizes for each box and get the max_generations.
self.father_ht = 0.0
@@ -490,8 +492,8 @@ class GUIConnect:
def set__opts(self, options, locale, name_displayer):
""" Set only once as we are BORG. """
self.__opts = options
self._locale = locale
self._nd = name_displayer
self.locale = locale
self.n_d = name_displayer
def get_val(self, val):
""" Get a GUI value. """
@@ -506,9 +508,9 @@ class GUIConnect:
GUI options """
title_type = self.get_val('report_title')
if title_type:
return TitleA(doc, self._locale, self._nd)
return TitleA(doc, self.locale, self.n_d)
else:
return TitleN(doc, self._locale)
return TitleN(doc, self.locale)
def inc_marr(self):
return self.get_val("inc_marr")
@@ -531,6 +533,7 @@ class GUIConnect:
#
#------------------------------------------------------------------------
class AncestorTree(Report):
""" AncestorTree Report """
def __init__(self, database, options, user):
"""
@@ -599,7 +602,7 @@ class AncestorTree(Report):
_('Making the Tree...'), 4) as step:
#make the tree onto the canvas
inlc_marr = self.connect.get_val("inc_marr")
## inlc_marr = self.connect.get_val("inc_marr")
self.max_generations = self.connect.get_val('maxgen')
tree = MakeAncestorTree(database, self.canvas)
tree.start(self.connect.get_val('pid'))
@@ -610,8 +613,7 @@ class AncestorTree(Report):
#Title
title = self.connect.title_class(self.doc)
center = self.database.get_person_from_gramps_id(
self.connect.get_val('pid')
)
self.connect.get_val('pid'))
title.calc_title(center)
self.canvas.add_title(title)
@@ -639,7 +641,8 @@ class AncestorTree(Report):
scale_report = self.connect.get_val("scale_tree")
scale = self.canvas.scale_report(one_page,
scale_report != 0, scale_report == 2)
scale_report != 0,
scale_report == 2)
step()
@@ -783,8 +786,10 @@ class AncestorTreeOptions(MenuReportOptions):
stdoptions.add_private_data_option(menu, category_name)
siblings = BooleanOption(_('Include siblings of the center person'), False)
siblings.set_help(_("Whether to only display the center person or all "
siblings = BooleanOption(
_('Include siblings of the center person'), False)
siblings.set_help(
_("Whether to only display the center person or all "
"of his/her siblings too"))
menu.add_option(category_name, "inc_siblings", siblings)
@@ -803,7 +808,8 @@ class AncestorTreeOptions(MenuReportOptions):
self.__fillout_vals()
compress = BooleanOption(_('Compress tree'), True)
compress.set_help(_("Whether to remove any extra blank spaces set "
compress.set_help(
_("Whether to remove any extra blank spaces set "
"aside for people that are unknown"))
menu.add_option(category_name, "compress_tree", compress)
@@ -856,21 +862,20 @@ class AncestorTreeOptions(MenuReportOptions):
#category_name = _("Secondary")
dispMom = TextOption(_("Mother\nDisplay Format"),
disp_mom = TextOption(_("Mother\nDisplay Format"),
["$n",
"%s $b" %_BORN,
"%s $m" %_MARR,
"-{%s $d}" %_DIED]
)
dispMom.set_help(_("Display format for the mothers box."))
menu.add_option(category_name, "mother_disp", dispMom)
"-{%s $d}" %_DIED])
disp_mom.set_help(_("Display format for the mothers box."))
menu.add_option(category_name, "mother_disp", disp_mom)
centerDisp = EnumeratedListOption(_("Center person uses\n"
center_disp = EnumeratedListOption(_("Center person uses\n"
"which format"), 0)
centerDisp.add_item(0, _("Use Fathers Display format"))
centerDisp.add_item(1, _("Use Mothers display format"))
centerDisp.set_help(_("Which Display format to use the center person"))
menu.add_option(category_name, "center_uses", centerDisp)
center_disp.add_item(0, _("Use Fathers Display format"))
center_disp.add_item(1, _("Use Mothers display format"))
center_disp.set_help(_("Which Display format to use the center person"))
menu.add_option(category_name, "center_uses", center_disp)
incmarr = BooleanOption(_('Include Marriage box'), False)
incmarr.set_help(
@@ -895,7 +900,8 @@ class AncestorTreeOptions(MenuReportOptions):
self.scale.connect('value-changed', self.__check_blank)
if "BKI" not in self.name.split(","):
self.__onepage = BooleanOption(_("Resize Page to Fit Tree size\n"
self.__onepage = BooleanOption(
_("Resize Page to Fit Tree size\n"
"\n"
"Note: Overrides options in the 'Paper Option' tab"
),
@@ -923,7 +929,8 @@ class AncestorTreeOptions(MenuReportOptions):
self.box_Y_sf = NumberOption(_("inter-box scale factor"),
1.00, 0.10, 2.00, 0.01)
self.box_Y_sf.set_help(_("Make the inter-box spacing bigger or smaller"))
self.box_Y_sf.set_help(
_("Make the inter-box spacing bigger or smaller"))
menu.add_option(category_name, "box_Yscale", self.box_Y_sf)
self.box_shadow_sf = NumberOption(_("box shadow scale factor"),
@@ -995,10 +1002,10 @@ class AncestorTreeOptions(MenuReportOptions):
item_list.append([1, _("One Generation of empty boxes "
"for unknown ancestors")])
item_list.extend([itr, str(itr) +
item_list.extend(
[itr, str(itr) +
_(" Generations of empty boxes for unknown ancestors")]
for itr in range(2, max_gen)
)
for itr in range(2, max_gen))
self.fillout.set_items(item_list)
if old_val+2 > len(item_list):

View File

@@ -176,8 +176,8 @@ class DescendantTitleBase(TitleBox):
}
else: # No person_list2: Just one family
if len(names) == 1:
title = self._("Descendant Chart for %(person)s") % {
'person': names[0]}
title = self._(
"Descendant Chart for %(person)s") % {'person': names[0]}
else: # Should be two items in names list
title = self._("Descendant Chart for %(father)s and "
"%(mother)s") % {
@@ -304,8 +304,7 @@ class TitleDFN(DescendantTitleBase):
def calc_title(self, family_id):
"""Calculate the title of the report"""
self.text = self.descendant_print(
self.get_parents(family_id) )
self.text = self.descendant_print(self.get_parents(family_id))
self.set_box_height_width()
class TitleF(DescendantTitleBase):
@@ -321,10 +320,11 @@ class TitleF(DescendantTitleBase):
names = self._get_names(parents, self._nd)
if len(parents) == 1:
title = self._("Family Chart for %(person)s") % {
'person': names[0] }
title = self._(
"Family Chart for %(person)s") % {'person': names[0]}
elif len(parents) == 2:
title = self._("Family Chart for %(father1)s and %(mother1)s") % {
title = self._(
"Family Chart for %(father1)s and %(mother1)s") % {
'father1': names[0], 'mother1': names[1]}
#else:
# title = str(tmp) + " " + str(len(tmp))
@@ -349,8 +349,8 @@ class TitleC(DescendantTitleBase):
# translators: needed for Arabic, ignore otherwise
cousin_names = self._(', ').join(self._get_names(kids, self._nd))
self.text = self._("Cousin Chart for %(names)s") % {
'names' : cousin_names}
self.text = self._(
"Cousin Chart for %(names)s") % {'names' : cousin_names}
self.set_box_height_width()
@@ -424,7 +424,8 @@ class RecurseDown:
if box.level[1] == 0 and self.__last_direct[level]:
#ok, a new direct descendant.
#print level, box.father is not None, self.__last_direct[level].father is not None, box.text[0], \
#print level, box.father is not None, \
# self.__last_direct[level].father is not None, box.text[0], \
# self.__last_direct[level].text[0]
if box.father != self.__last_direct[level].father and \
box.father != self.__last_direct[level]:
@@ -496,10 +497,14 @@ class RecurseDown:
or we reach the max number of spouses
that we want to deal with"""
if not person_handle: return
if x_level > self.max_generations: return
if s_level > 0 and s_level == self.max_spouses: return
if person_handle in self.families_seen: return
if not person_handle:
return
if x_level > self.max_generations:
return
if s_level > 0 and s_level == self.max_spouses:
return
if person_handle in self.families_seen:
return
myself = None
person = self.database.get_person_from_handle(person_handle)
@@ -534,7 +539,8 @@ class RecurseDown:
spouse_handle not in self.families_seen):
def _spouse_box(who):
return self.add_person_box((x_level, s_level+1),
spouse_handle, family_handle, who)
spouse_handle,
family_handle, who)
if s_level > 0:
spouse = _spouse_box(father)
elif self.inlc_marr:
@@ -1605,7 +1611,8 @@ class DescendTreeOptions(MenuReportOptions):
self.scale.connect('value-changed', self.__check_blank)
if "BKI" not in self.name.split(","):
self.__onepage = BooleanOption(_("Resize Page to Fit Tree size\n"
self.__onepage = BooleanOption(
_("Resize Page to Fit Tree size\n"
"\n"
"Note: Overrides options in the 'Paper Option' tab"
),