From 5326703ef0559191430b99b16fbec8292525ec27 Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Wed, 7 Nov 2012 20:48:56 +0000 Subject: [PATCH] python 3: use division from the future svn: r20636 --- gramps/plugins/docgen/gtkprint.py | 2 +- gramps/plugins/drawreport/ancestortree.py | 1 + gramps/plugins/drawreport/descendtree.py | 1 + gramps/plugins/drawreport/statisticschart.py | 1 + gramps/plugins/drawreport/timeline.py | 1 + gramps/plugins/lib/libcairodoc.py | 1 + gramps/plugins/tool/verify.py | 5 ++- gramps/plugins/view/pedigreeview.py | 40 ++++++++++---------- gramps/plugins/webreport/narrativeweb.py | 2 +- 9 files changed, 30 insertions(+), 24 deletions(-) diff --git a/gramps/plugins/docgen/gtkprint.py b/gramps/plugins/docgen/gtkprint.py index fa813b5fd..c53a5aaa9 100644 --- a/gramps/plugins/docgen/gtkprint.py +++ b/gramps/plugins/docgen/gtkprint.py @@ -23,7 +23,7 @@ """Printing interface based on Gtk.Print* classes. """ - +from __future__ import division #------------------------------------------------------------------------ # # Python modules diff --git a/gramps/plugins/drawreport/ancestortree.py b/gramps/plugins/drawreport/ancestortree.py index 04172b459..ca297a263 100644 --- a/gramps/plugins/drawreport/ancestortree.py +++ b/gramps/plugins/drawreport/ancestortree.py @@ -24,6 +24,7 @@ """Reports/Graphical Reports/Ancestor Tree""" +from __future__ import division #------------------------------------------------------------------------ # # python modules diff --git a/gramps/plugins/drawreport/descendtree.py b/gramps/plugins/drawreport/descendtree.py index e76d48962..696803898 100644 --- a/gramps/plugins/drawreport/descendtree.py +++ b/gramps/plugins/drawreport/descendtree.py @@ -27,6 +27,7 @@ Reports/Graphical Reports/Familial Tree Reports/Graphical Reports/Personal Tree """ +from __future__ import division #------------------------------------------------------------------------ # diff --git a/gramps/plugins/drawreport/statisticschart.py b/gramps/plugins/drawreport/statisticschart.py index da2643bc0..0d448fda3 100644 --- a/gramps/plugins/drawreport/statisticschart.py +++ b/gramps/plugins/drawreport/statisticschart.py @@ -27,6 +27,7 @@ """Reports/Graphical Reports/Statistics Report""" +from __future__ import division #------------------------------------------------------------------------ # # python modules diff --git a/gramps/plugins/drawreport/timeline.py b/gramps/plugins/drawreport/timeline.py index 0d11a96af..4148b5b42 100644 --- a/gramps/plugins/drawreport/timeline.py +++ b/gramps/plugins/drawreport/timeline.py @@ -27,6 +27,7 @@ Timeline Chart """ +from __future__ import division #------------------------------------------------------------------------ # # python modules diff --git a/gramps/plugins/lib/libcairodoc.py b/gramps/plugins/lib/libcairodoc.py index 66c6ed246..9327ca6ba 100644 --- a/gramps/plugins/lib/libcairodoc.py +++ b/gramps/plugins/lib/libcairodoc.py @@ -30,6 +30,7 @@ """Report output generator based on Cairo. """ +from __future__ import division #------------------------------------------------------------------------ # # Python modules diff --git a/gramps/plugins/tool/verify.py b/gramps/plugins/tool/verify.py index c97684770..51548b11b 100644 --- a/gramps/plugins/tool/verify.py +++ b/gramps/plugins/tool/verify.py @@ -28,6 +28,7 @@ A plugin to verify the data against user-adjusted tests. This is the research tool, not the low-level data ingerity check. """ +from __future__ import division #------------------------------------------------------------------------ # # standard python modules @@ -942,7 +943,7 @@ class OldAge(PersonRule): return (self.old_age,self.est) def broken(self): - age_at_death = get_age_at_death(self.db,self.obj,self.est) + age_at_death = get_age_at_death(self.db, self.obj, self.est) return (age_at_death/365 > self.old_age) def get_message(self): @@ -1000,7 +1001,7 @@ class OldUnmarried(PersonRule): def broken(self): age_at_death = get_age_at_death(self.db,self.obj,self.est) n_spouses = len(self.obj.get_family_handle_list()) - return (age_at_death/365>self.old_unm and n_spouses==0) + return (age_at_death/365 > self.old_unm and n_spouses==0) def get_message(self): return _("Old and unmarried") diff --git a/gramps/plugins/view/pedigreeview.py b/gramps/plugins/view/pedigreeview.py index e3fcc36a1..1b94e2773 100644 --- a/gramps/plugins/view/pedigreeview.py +++ b/gramps/plugins/view/pedigreeview.py @@ -29,7 +29,7 @@ # Python modules # #------------------------------------------------------------------------- -from __future__ import unicode_literals +from __future__ import unicode_literals, division from gramps.gen.ggettext import sgettext as _ from gramps.gen.ggettext import ngettext @@ -903,15 +903,15 @@ class PedigreeView(NavigationView): offset = i + 1 - (2**level) if self.tree_style == 0: - _delta = (2**size) / (2**level) + _delta = (2**size) // (2**level) else: - _delta = (2**size) / (2**level) * 2 + _delta = (2**size) // (2**level) * 2 x_pos = (1 + _width) * level + 1 - y_pos = _delta / 2 + offset * _delta - 1 + y_pos = _delta // 2 + offset * _delta - 1 if self.tree_style == 0 and level == size - 1: - y_pos = _delta / 2 + offset * _delta + y_pos = _delta // 2 + offset * _delta height = _height = 1 else: try: @@ -926,22 +926,22 @@ class PedigreeView(NavigationView): pbw = None if not lst[i] and ( (self.tree_style in [0, 2] and self.show_unknown_people and - lst[((i+1)/2)-1]) or self.tree_style == 1): + lst[((i+1) // 2) - 1]) or self.tree_style == 1): # # No person -> show empty box # pbw = PersonBoxWidgetCairo(self, self.format_helper, self.dbstate, None, False, 0, None) - if i > 0 and lst[((i+1)/2)-1]: + if i > 0 and lst[((i+1) // 2) - 1]: fam_h = None - fam = lst[((i+1)/2)-1][2] + fam = lst[((i+1) // 2) - 1][2] if fam: fam_h = fam.get_handle() if not self.dbstate.db.readonly: pbw.connect("button-press-event", self.cb_missing_parent_button_press, - lst[((i+1)/2)-1][0].get_handle(), fam_h) + lst[((i+1) // 2) - 1][0].get_handle(), fam_h) pbw.force_mouse_over = True elif lst[i]: @@ -950,7 +950,7 @@ class PedigreeView(NavigationView): # image = False if self.show_images and height > 1 and ( - i < ((2**size-1)/2) or self.tree_style == 2): + i < ((2**size-1) // 2) or self.tree_style == 2): image = True pbw = PersonBoxWidgetCairo(self, self.format_helper, @@ -1015,10 +1015,10 @@ class PedigreeView(NavigationView): self.attach_widget(table_widget, line, xmax, x_pos, x_pos+width, y_pos, y_pos+height) - elif self.tree_style in [0, 2] and lst[((i+1)/2)-1]: + elif self.tree_style in [0, 2] and lst[((i+1) // 2) - 1]: # combined for father and mother - x_pos = (1 + _width)*level - y_pos = offset * _delta - (_delta / 2) - 1 + x_pos = (1 + _width) * level + y_pos = offset * _delta - (_delta // 2) - 1 width = 1 height = _delta + 3 @@ -1033,7 +1033,7 @@ class PedigreeView(NavigationView): if lst[i - 1]: mrela = lst[i-1][1] - line = LineWidget(lst[((i+1)/2)-1][4], + line = LineWidget(lst[((i+1) // 2) - 1][4], last_pbw, frela, pbw, mrela, self.tree_direction) @@ -1043,14 +1043,14 @@ class PedigreeView(NavigationView): line.add_events(Gdk.EventMask.BUTTON_PRESS_MASK) line.connect("button-press-event", self.cb_relation_button_press, - lst[((i+1)/2)-1][2].get_handle()) + lst[((i+1) // 2) - 1][2].get_handle()) # Required for tooltip and mouse-over line.add_events(Gdk.EventMask.ENTER_NOTIFY_MASK) # Required for tooltip and mouse-over line.add_events(Gdk.EventMask.LEAVE_NOTIFY_MASK) line.set_tooltip_text( self.format_helper.format_relation( - lst[((i+1)/2)-1][2], 11)) + lst[((i+1) // 2) - 1][2], 11)) self.attach_widget(table_widget, line, xmax, x_pos, x_pos+width, y_pos, y_pos+height) @@ -1072,7 +1072,7 @@ class PedigreeView(NavigationView): label.set_alignment(0.1, 0.5) if self.tree_style in [0, 2]: x_pos = (1 + _width) * (level + 1) + 1 - y_pos = _delta / 2 + offset * _delta -1 + _height / 2 + y_pos = _delta // 2 + offset * _delta -1 + _height // 2 width = 1 height = 1 if self.tree_style == 0 and level < 2 and size > 4: @@ -1114,7 +1114,7 @@ class PedigreeView(NavigationView): else: button.set_sensitive(False) - ymid = int(math.floor(ymax/2)) + ymid = ymax // 2 self.attach_widget(table_widget, button, xmax, 0, 1, ymid, ymid +1) @@ -1127,7 +1127,7 @@ class PedigreeView(NavigationView): else: button.set_sensitive(False) - ymid = int(math.floor(ymax/4)) + ymid = ymax // 4 self.attach_widget(table_widget, button, xmax, xmax, xmax+1, ymid-1, ymid+2) @@ -1140,7 +1140,7 @@ class PedigreeView(NavigationView): else: button.set_sensitive(False) - ymid = int(math.floor(ymax/4*3)) + ymid = ymax // 4 * 3 self.attach_widget(table_widget, button, xmax, xmax, xmax+1, ymid-1, ymid+2) diff --git a/gramps/plugins/webreport/narrativeweb.py b/gramps/plugins/webreport/narrativeweb.py index 9aad8d0b3..4cec8e723 100644 --- a/gramps/plugins/webreport/narrativeweb.py +++ b/gramps/plugins/webreport/narrativeweb.py @@ -38,7 +38,7 @@ Narrative Web Page generator. #------------------------------------------------ # python modules #------------------------------------------------ -from __future__ import print_function +from __future__ import print_function, division from functools import partial import gc