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()
@ -681,7 +684,7 @@ class AncestorTree(Report):
#lets finally make some pages!!!
#####################
pages = self.canvas.page_count(incblank)
with self._user.progress( _('Ancestor Tree'),
with self._user.progress(_('Ancestor Tree'),
_('Printing the Tree...'), pages) as step:
for page in self.canvas.page_iter_gen(incblank):
@ -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,16 +808,17 @@ 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)
#better to 'Show siblings of\nthe center person
#Spouse_disp = EnumeratedListOption(_("Show spouses of\nthe center "
# "person"), 0)
#Spouse_disp.add_item( 0, _("No. Do not show Spouses"))
#Spouse_disp.add_item( 1, _("Yes, and use the Main Display Format"))
#Spouse_disp.add_item( 2, _("Yes, and use the Secondary "
#Spouse_disp.add_item(0, _("No. Do not show Spouses"))
#Spouse_disp.add_item(1, _("Yes, and use the Main Display Format"))
#Spouse_disp.add_item(2, _("Yes, and use the Secondary "
# "Display Format"))
#Spouse_disp.set_help(_("Show spouses of the center person?"))
#menu.add_option(category_name, "Spouse_disp", Spouse_disp)
@ -849,28 +855,27 @@ class AncestorTreeOptions(MenuReportOptions):
#Will add when libsubstkeyword supports it.
#missing = EnumeratedListOption(_("Replace missing\nplaces\\dates \
# with"), 0)
#missing.add_item( 0, _("Does not display anything"))
#missing.add_item( 1, _("Displays '_____'"))
#missing.add_item(0, _("Does not display anything"))
#missing.add_item(1, _("Displays '_____'"))
#missing.set_help(_("What will print when information is not known"))
#menu.add_option(category_name, "miss_val", missing)
#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

@ -88,7 +88,7 @@ class PersonBox(DescendantBoxBase):
Calculates information about the box that will print on a page
"""
def __init__(self, level, boldable = 0):
def __init__(self, level, boldable=0):
DescendantBoxBase.__init__(self, "CG2-box")
self.level = level
@ -130,13 +130,13 @@ class PlaceHolderBox(BoxBase):
#------------------------------------------------------------------------
class DescendantTitleBase(TitleBox):
def __init__(self, dbase, doc, locale, name_displayer,
boxstr = "CG2-Title"):
boxstr="CG2-Title"):
self._nd = name_displayer
TitleBox.__init__(self, doc, boxstr)
self.database = dbase
self._ = locale.translation.sgettext
def descendant_print(self, person_list, person_list2 = []):
def descendant_print(self, person_list, person_list2=[]):
""" calculate the Descendant title
Person_list will always be passed
If in the Family reports and there are two families, person_list2
@ -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,11 +320,12 @@ 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") % {
'father1': names[0], 'mother1': names[1] }
title = self._(
"Family Chart for %(father1)s and %(mother1)s") % {
'father1': names[0], 'mother1': names[1]}
#else:
# title = str(tmp) + " " + str(len(tmp))
self.text = title
@ -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,17 +497,21 @@ 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)
family_handles = person.get_family_handle_list()
if s_level == 0:
val = family_handles[0] if family_handles else None
myself = self.add_person_box( (x_level, s_level),
myself = self.add_person_box((x_level, s_level),
person_handle, val, father)
marr = None
@ -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:
@ -709,7 +715,7 @@ class MakePersonTree(RecurseDown):
#######################
#now it will ONLY be my fathers parents
if family2:
self.add_family( 0, family2, None )
self.add_family(0, family2, None)
else:
self.bold_now = 2
self.recurse(center1_h, 0, 0, None)
@ -818,7 +824,7 @@ class MakeFamilyTree(RecurseDown):
if not show:
self.families_seen.add(father1_h)
family2_l = self.add_family( 0, family2, None )
family2_l = self.add_family(0, family2, None)
elif father1:
#######################
@ -879,7 +885,7 @@ class MakeFamilyTree(RecurseDown):
#######################
#don't do my parents family.
self.families_seen = set([family1_h] )
self.families_seen = set([family1_h])
##If mom has no other children from other marriages. remove her
if self.max_spouses == 0 and not self.has_children(mother1_h):
self.families_seen.add(mother1_h)
@ -903,7 +909,7 @@ class MakeFamilyTree(RecurseDown):
#my mothers parents!
#######################
if family2:
family2_l = self.add_family( 0, family2, None )
family2_l = self.add_family(0, family2, None)
family2_line = family2_l[1] if self.inlc_marr else family2_l[0]
family2_line = family2_line.line_to
@ -1595,9 +1601,9 @@ class DescendTreeOptions(MenuReportOptions):
category_name = _("Size")
self.scale = EnumeratedListOption(_("Scale tree to fit"), 0)
self.scale.add_item( 0, _("Do not scale tree"))
self.scale.add_item( 1, _("Scale tree to fit page width only"))
self.scale.add_item( 2, _("Scale tree to fit the size of the page"))
self.scale.add_item(0, _("Do not scale tree"))
self.scale.add_item(1, _("Scale tree to fit page width only"))
self.scale.add_item(2, _("Scale tree to fit the size of the page"))
self.scale.set_help(
_("Whether to scale the tree to fit a specific paper size")
)
@ -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"
),
@ -1646,8 +1653,8 @@ class DescendTreeOptions(MenuReportOptions):
category_name = _("Include")
self.title = EnumeratedListOption(_("Report Title"), 0)
self.title.add_item( 0, _("Do not include a title"))
self.title.add_item( 1, _("Descendant Chart for [selected person(s)]"))
self.title.add_item(0, _("Do not include a title"))
self.title.add_item(1, _("Descendant Chart for [selected person(s)]"))
if self.name.split(",")[0] != _RPT_NAME:
self.title.add_item(2,
_("Family Chart for [names of chosen family]"))
@ -1678,7 +1685,7 @@ class DescendTreeOptions(MenuReportOptions):
)
menu.add_option(category_name, "inc_note", self.usenote)
self.notedisp = TextOption(_("Note"),[])
self.notedisp = TextOption(_("Note"), [])
self.notedisp.set_help(_("Add a note"
"\n\n$T inserts today's date"))
menu.add_option(category_name, "note_disp", self.notedisp)
@ -1686,7 +1693,7 @@ class DescendTreeOptions(MenuReportOptions):
locals = NoteType(0)
notelocal = EnumeratedListOption(_("Note Location"), 2)
for num, text in locals.note_locals():
notelocal.add_item( num, text )
notelocal.add_item(num, text)
notelocal.set_help(_("Where to place the note."))
menu.add_option(category_name, "note_place", notelocal)
@ -1697,20 +1704,20 @@ class DescendTreeOptions(MenuReportOptions):
else:
value = True
off = value and (self.scale.get_value() != 2)
self.__blank.set_available( off )
self.__blank.set_available(off)
def __Title_enum(self):
item_list = [
[0, _("Do not include a title") ],
[1, _("Descendant Chart for [selected person(s)]") ],
[0, _("Do not include a title")],
[1, _("Descendant Chart for [selected person(s)]")],
]
if self.name.split(",")[0] != _RPT_NAME:
item_list.append(
[2, _("Family Chart for [names of chosen family]") ]
[2, _("Family Chart for [names of chosen family]")]
)
if self.showparents.get_value():
item_list.append(
[3, _("Cousin Chart for [names of children]") ]
[3, _("Cousin Chart for [names of children]")]
)
self.title.set_items(item_list)