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 and text for each person / marriage
""" """
def __init__(self, dbase): def __init__(self, dbase):
__gui = GUIConnect() _gui = GUIConnect()
#calculate the printed lines for each box #calculate the printed lines for each box
#display_repl = [] #Not used in this report #display_repl = [] #Not used in this report
#str = "" #str = ""
#if self.get_val('miss_val'): #if self.get_val('miss_val'):
# str = "_____" # 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_father = None
self.__blank_mother = None self.__blank_mother = None
self.__blank_father = \ 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.__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.center_use = _gui.get_val("center_uses")
self.disp_father = __gui.get_val("father_disp") self.disp_father = _gui.get_val("father_disp")
self.disp_mother = __gui.get_val("mother_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.__blank_marriage = \
self.__calc_l.calc_lines(None, None, self.disp_marr) self.__calc_l.calc_lines(None, None, self.disp_marr)
@@ -227,8 +227,8 @@ class MakeAncestorTree(AscendPerson):
if index[LVL_GEN] > self.max_generation: if index[LVL_GEN] > self.max_generation:
self.max_generation = index[LVL_GEN] self.max_generation = index[LVL_GEN]
myself.text = self.calc_items.calc_person( myself.text = self.calc_items.calc_person(index,
index, indi_handle, fams_handle) indi_handle, fams_handle)
myself.add_mark(self.database, myself.add_mark(self.database,
self.database.get_person_from_handle(indi_handle)) self.database.get_person_from_handle(indi_handle))
@@ -286,7 +286,8 @@ class MakeAncestorTree(AscendPerson):
for box in self.canvas.boxes: for box in self.canvas.boxes:
if "fam" in box.boxstr: if "fam" in box.boxstr:
box.level = box.level + \ 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: else:
box.level = box.level + \ box.level = box.level + \
(self.y_index(box.level[LVL_GEN], box.level[LVL_INDX]),) (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) 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: for box in self.canvas.boxes:
box.level = (box.level[0], box.level[1], box.level[2]-move) box.level = (box.level[0], box.level[1], box.level[2]-move)
move = 0 move = 0
line.start = [] line.start = []
r = -1 # if len(mykids)%2 == 1 else 0 rrr = -1 # if len(mykids)%2 == 1 else 0
for kid in mykids: for kid in mykids:
r += 1 rrr += 1
me = self.add_person((1, 1, move+r), kid, self.center_family) mee = self.add_person((1, 1, move+rrr), kid, self.center_family)
line.add_from(me) line.add_from(mee)
#me.level = (0, 1, level - (len(mykids)//2)+r ) #mee.level = (0, 1, level - (len(mykids)//2)+rrr)
def start(self, person_id): def start(self, person_id):
""" go ahead and make it happen """ """ go ahead and make it happen """
center = self.database.get_person_from_gramps_id(person_id) center = self.database.get_person_from_gramps_id(person_id)
if center is None: if center is None:
raise ReportError(_("Person %s is not in the Database") raise ReportError(
% person_id) _("Person %s is not in the Database") % person_id)
center_h = center.get_handle() center_h = center.get_handle()
#Step 1. Get the people #Step 1. Get the people
@@ -448,7 +450,7 @@ class MakeReport:
return self.max_generations return self.max_generations
def start(self): def start(self):
__gui = GUIConnect() ## __gui = GUIConnect()
# 1. # 1.
#set the sizes for each box and get the max_generations. #set the sizes for each box and get the max_generations.
self.father_ht = 0.0 self.father_ht = 0.0
@@ -490,8 +492,8 @@ class GUIConnect:
def set__opts(self, options, locale, name_displayer): def set__opts(self, options, locale, name_displayer):
""" Set only once as we are BORG. """ """ Set only once as we are BORG. """
self.__opts = options self.__opts = options
self._locale = locale self.locale = locale
self._nd = name_displayer self.n_d = name_displayer
def get_val(self, val): def get_val(self, val):
""" Get a GUI value. """ """ Get a GUI value. """
@@ -506,9 +508,9 @@ class GUIConnect:
GUI options """ GUI options """
title_type = self.get_val('report_title') title_type = self.get_val('report_title')
if title_type: if title_type:
return TitleA(doc, self._locale, self._nd) return TitleA(doc, self.locale, self.n_d)
else: else:
return TitleN(doc, self._locale) return TitleN(doc, self.locale)
def inc_marr(self): def inc_marr(self):
return self.get_val("inc_marr") return self.get_val("inc_marr")
@@ -531,6 +533,7 @@ class GUIConnect:
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class AncestorTree(Report): class AncestorTree(Report):
""" AncestorTree Report """
def __init__(self, database, options, user): def __init__(self, database, options, user):
""" """
@@ -599,7 +602,7 @@ class AncestorTree(Report):
_('Making the Tree...'), 4) as step: _('Making the Tree...'), 4) as step:
#make the tree onto the canvas #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') self.max_generations = self.connect.get_val('maxgen')
tree = MakeAncestorTree(database, self.canvas) tree = MakeAncestorTree(database, self.canvas)
tree.start(self.connect.get_val('pid')) tree.start(self.connect.get_val('pid'))
@@ -610,8 +613,7 @@ class AncestorTree(Report):
#Title #Title
title = self.connect.title_class(self.doc) title = self.connect.title_class(self.doc)
center = self.database.get_person_from_gramps_id( center = self.database.get_person_from_gramps_id(
self.connect.get_val('pid') self.connect.get_val('pid'))
)
title.calc_title(center) title.calc_title(center)
self.canvas.add_title(title) self.canvas.add_title(title)
@@ -639,7 +641,8 @@ class AncestorTree(Report):
scale_report = self.connect.get_val("scale_tree") scale_report = self.connect.get_val("scale_tree")
scale = self.canvas.scale_report(one_page, scale = self.canvas.scale_report(one_page,
scale_report != 0, scale_report == 2) scale_report != 0,
scale_report == 2)
step() step()
@@ -783,8 +786,10 @@ class AncestorTreeOptions(MenuReportOptions):
stdoptions.add_private_data_option(menu, category_name) stdoptions.add_private_data_option(menu, category_name)
siblings = BooleanOption(_('Include siblings of the center person'), False) siblings = BooleanOption(
siblings.set_help(_("Whether to only display the center person or all " _('Include siblings of the center person'), False)
siblings.set_help(
_("Whether to only display the center person or all "
"of his/her siblings too")) "of his/her siblings too"))
menu.add_option(category_name, "inc_siblings", siblings) menu.add_option(category_name, "inc_siblings", siblings)
@@ -803,7 +808,8 @@ class AncestorTreeOptions(MenuReportOptions):
self.__fillout_vals() self.__fillout_vals()
compress = BooleanOption(_('Compress tree'), True) 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")) "aside for people that are unknown"))
menu.add_option(category_name, "compress_tree", compress) menu.add_option(category_name, "compress_tree", compress)
@@ -856,21 +862,20 @@ class AncestorTreeOptions(MenuReportOptions):
#category_name = _("Secondary") #category_name = _("Secondary")
dispMom = TextOption(_("Mother\nDisplay Format"), disp_mom = TextOption(_("Mother\nDisplay Format"),
["$n", ["$n",
"%s $b" %_BORN, "%s $b" %_BORN,
"%s $m" %_MARR, "%s $m" %_MARR,
"-{%s $d}" %_DIED] "-{%s $d}" %_DIED])
) disp_mom.set_help(_("Display format for the mothers box."))
dispMom.set_help(_("Display format for the mothers box.")) menu.add_option(category_name, "mother_disp", disp_mom)
menu.add_option(category_name, "mother_disp", dispMom)
centerDisp = EnumeratedListOption(_("Center person uses\n" center_disp = EnumeratedListOption(_("Center person uses\n"
"which format"), 0) "which format"), 0)
centerDisp.add_item(0, _("Use Fathers Display format")) center_disp.add_item(0, _("Use Fathers Display format"))
centerDisp.add_item(1, _("Use Mothers display format")) center_disp.add_item(1, _("Use Mothers display format"))
centerDisp.set_help(_("Which Display format to use the center person")) center_disp.set_help(_("Which Display format to use the center person"))
menu.add_option(category_name, "center_uses", centerDisp) menu.add_option(category_name, "center_uses", center_disp)
incmarr = BooleanOption(_('Include Marriage box'), False) incmarr = BooleanOption(_('Include Marriage box'), False)
incmarr.set_help( incmarr.set_help(
@@ -895,7 +900,8 @@ class AncestorTreeOptions(MenuReportOptions):
self.scale.connect('value-changed', self.__check_blank) self.scale.connect('value-changed', self.__check_blank)
if "BKI" not in self.name.split(","): 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" "\n"
"Note: Overrides options in the 'Paper Option' tab" "Note: Overrides options in the 'Paper Option' tab"
), ),
@@ -923,7 +929,8 @@ class AncestorTreeOptions(MenuReportOptions):
self.box_Y_sf = NumberOption(_("inter-box scale factor"), self.box_Y_sf = NumberOption(_("inter-box scale factor"),
1.00, 0.10, 2.00, 0.01) 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) menu.add_option(category_name, "box_Yscale", self.box_Y_sf)
self.box_shadow_sf = NumberOption(_("box shadow scale factor"), 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 " item_list.append([1, _("One Generation of empty boxes "
"for unknown ancestors")]) "for unknown ancestors")])
item_list.extend([itr, str(itr) + item_list.extend(
[itr, str(itr) +
_(" Generations of empty boxes for unknown ancestors")] _(" 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) self.fillout.set_items(item_list)
if old_val+2 > len(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 else: # No person_list2: Just one family
if len(names) == 1: if len(names) == 1:
title = self._("Descendant Chart for %(person)s") % { title = self._(
'person': names[0]} "Descendant Chart for %(person)s") % {'person': names[0]}
else: # Should be two items in names list else: # Should be two items in names list
title = self._("Descendant Chart for %(father)s and " title = self._("Descendant Chart for %(father)s and "
"%(mother)s") % { "%(mother)s") % {
@@ -304,8 +304,7 @@ class TitleDFN(DescendantTitleBase):
def calc_title(self, family_id): def calc_title(self, family_id):
"""Calculate the title of the report""" """Calculate the title of the report"""
self.text = self.descendant_print( self.text = self.descendant_print(self.get_parents(family_id))
self.get_parents(family_id) )
self.set_box_height_width() self.set_box_height_width()
class TitleF(DescendantTitleBase): class TitleF(DescendantTitleBase):
@@ -321,10 +320,11 @@ class TitleF(DescendantTitleBase):
names = self._get_names(parents, self._nd) names = self._get_names(parents, self._nd)
if len(parents) == 1: if len(parents) == 1:
title = self._("Family Chart for %(person)s") % { title = self._(
'person': names[0] } "Family Chart for %(person)s") % {'person': names[0]}
elif len(parents) == 2: 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]} 'father1': names[0], 'mother1': names[1]}
#else: #else:
# title = str(tmp) + " " + str(len(tmp)) # title = str(tmp) + " " + str(len(tmp))
@@ -349,8 +349,8 @@ class TitleC(DescendantTitleBase):
# translators: needed for Arabic, ignore otherwise # translators: needed for Arabic, ignore otherwise
cousin_names = self._(', ').join(self._get_names(kids, self._nd)) cousin_names = self._(', ').join(self._get_names(kids, self._nd))
self.text = self._("Cousin Chart for %(names)s") % { self.text = self._(
'names' : cousin_names} "Cousin Chart for %(names)s") % {'names' : cousin_names}
self.set_box_height_width() self.set_box_height_width()
@@ -424,7 +424,8 @@ class RecurseDown:
if box.level[1] == 0 and self.__last_direct[level]: if box.level[1] == 0 and self.__last_direct[level]:
#ok, a new direct descendant. #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] # self.__last_direct[level].text[0]
if box.father != self.__last_direct[level].father and \ if box.father != self.__last_direct[level].father and \
box.father != self.__last_direct[level]: box.father != self.__last_direct[level]:
@@ -496,10 +497,14 @@ class RecurseDown:
or we reach the max number of spouses or we reach the max number of spouses
that we want to deal with""" that we want to deal with"""
if not person_handle: return if not person_handle:
if x_level > self.max_generations: return return
if s_level > 0 and s_level == self.max_spouses: return if x_level > self.max_generations:
if person_handle in self.families_seen: return return
if s_level > 0 and s_level == self.max_spouses:
return
if person_handle in self.families_seen:
return
myself = None myself = None
person = self.database.get_person_from_handle(person_handle) person = self.database.get_person_from_handle(person_handle)
@@ -534,7 +539,8 @@ class RecurseDown:
spouse_handle not in self.families_seen): spouse_handle not in self.families_seen):
def _spouse_box(who): def _spouse_box(who):
return self.add_person_box((x_level, s_level+1), return self.add_person_box((x_level, s_level+1),
spouse_handle, family_handle, who) spouse_handle,
family_handle, who)
if s_level > 0: if s_level > 0:
spouse = _spouse_box(father) spouse = _spouse_box(father)
elif self.inlc_marr: elif self.inlc_marr:
@@ -1605,7 +1611,8 @@ class DescendTreeOptions(MenuReportOptions):
self.scale.connect('value-changed', self.__check_blank) self.scale.connect('value-changed', self.__check_blank)
if "BKI" not in self.name.split(","): 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" "\n"
"Note: Overrides options in the 'Paper Option' tab" "Note: Overrides options in the 'Paper Option' tab"
), ),