Tweaks to use inplace arithmetic

svn: r13191
This commit is contained in:
Gerald Britton
2009-09-10 18:49:48 +00:00
parent d5e48cda06
commit 941fff23ae
31 changed files with 56 additions and 60 deletions

View File

@ -281,7 +281,7 @@ class Bookmarks :
self.namemodel.remove(the_iter) self.namemodel.remove(the_iter)
self.modified = True self.modified = True
if row > 0: if row > 0:
row = row - 1 row -= 1
self.namemodel.select_row(row) self.namemodel.select_row(row)
def up_clicked(self, obj): def up_clicked(self, obj):

View File

@ -524,10 +524,10 @@ class GeoView(HtmlView):
modulo = intvl - ( intvl % 10 ) modulo = intvl - ( intvl % 10 )
if modulo == 0: if modulo == 0:
modulo = 10 modulo = 10
self.minyear = ( self.minyear - ( self.minyear % 10 ) ) self.minyear -= self.minyear % 10
self.maxyear = ( self.maxyear - ( self.maxyear % 10 ) ) self.maxyear -= self.maxyear % 10
self.yearint = (self.maxyear-self.minyear)/self.maxgen self.yearint = (self.maxyear-self.minyear)/self.maxgen
self.yearint = ( self.yearint - ( self.yearint % modulo ) ) self.yearint -= self.yearint % modulo
if self.yearint == 0: if self.yearint == 0:
self.yearint = 10 self.yearint = 10
self.mapview.write("<script>\n") self.mapview.write("<script>\n")
@ -929,13 +929,13 @@ class GeoView(HtmlView):
if tfc > self.maxyear: if tfc > self.maxyear:
self.maxyear = tfc self.maxyear = tfc
if tfa < 0.0: if tfa < 0.0:
tfa = tfa - 0.00000001 tfa -= 0.00000001
else: else:
tfa = tfa + 0.00000001 tfa += 0.00000001
if tfb < 0.0: if tfb < 0.0:
tfb = tfb - 0.00000001 tfb -= 0.00000001
else: else:
tfb = tfb + 0.00000001 tfb += 0.00000001
if self.minlat == 0.0: if self.minlat == 0.0:
self.minlat = tfa self.minlat = tfa
if tfa < self.minlat: if tfa < self.minlat:

View File

@ -810,7 +810,7 @@ class GuiGramplet(object):
else: else:
markup = text[i+2:i+stop].upper() # close tag markup = text[i+2:i+stop].upper() # close tag
markup_pos[markup][-1].append(r) markup_pos[markup][-1].append(r)
i = i + stop + 1 i += stop + 1
elif text[i] == "<": elif text[i] == "<":
# start of start tag # start of start tag
stop = text[i:].find(">") stop = text[i:].find(">")
@ -821,7 +821,7 @@ class GuiGramplet(object):
else: else:
markup, attr = parse_tag_attr(text[i+1:i+stop]) markup, attr = parse_tag_attr(text[i+1:i+stop])
markup_pos[markup].append([r, attr]) markup_pos[markup].append([r, attr])
i = i + stop + 1 i += stop + 1
elif text[i] == "\\": elif text[i] == "\\":
retval += text[i+1] retval += text[i+1]
r += 1 r += 1

View File

@ -494,7 +494,7 @@ class EditRule(ManagedWindow.ManagedWindow):
tlist.append(t) tlist.append(t)
table.attach(l, 1, 2, pos, pos+1, gtk.FILL, 0, 5, 5) table.attach(l, 1, 2, pos, pos+1, gtk.FILL, 0, 5, 5)
table.attach(t, 2, 3, pos, pos+1, gtk.EXPAND|gtk.FILL, 0, 5, 5) table.attach(t, 2, 3, pos, pos+1, gtk.EXPAND|gtk.FILL, 0, 5, 5)
pos = pos + 1 pos += 1
self.notebook.append_page(table, gtk.Label(class_obj.name)) self.notebook.append_page(table, gtk.Label(class_obj.name))
self.class2page[class_obj] = self.page_num self.class2page[class_obj] = self.page_num
self.page_num = self.page_num + 1 self.page_num = self.page_num + 1

View File

@ -89,10 +89,7 @@ def __convert_structure_to_float(sign, degs, mins=0, secs=0.0) :
v += float(mins) / 60. v += float(mins) / 60.
if secs is not None: if secs is not None:
v += secs / 3600. v += secs / 3600.
if sign == "-": return -v if sign == "-" else v
v = v * -1.
return v
def __convert_using_float_repr(stringValue): def __convert_using_float_repr(stringValue):
""" helper function that tries to convert the string using the float """ helper function that tries to convert the string using the float

View File

@ -465,7 +465,7 @@ class ToolManagedWindowBase(ManagedWindow.ManagedWindow):
else: else:
table.attach(widget, 2, 3, row, row+1, table.attach(widget, 2, 3, row, row+1,
yoptions=gtk.SHRINK) yoptions=gtk.SHRINK)
row = row + 1 row += 1
self.notebook.show_all() self.notebook.show_all()
#------------------------------------------------------------------------ #------------------------------------------------------------------------

View File

@ -169,7 +169,7 @@ class RecentFiles(object):
xml_file.write('<RecentFiles>\n') xml_file.write('<RecentFiles>\n')
index = 0 index = 0
for item in self.gramps_recent_files: for item in self.gramps_recent_files:
index = index + 1 index += 1
if index > MAX_GRAMPS_ITEMS: if index > MAX_GRAMPS_ITEMS:
break break
xml_file.write(' <RecentItem>\n') xml_file.write(' <RecentItem>\n')

View File

@ -87,11 +87,11 @@ class Citation(object):
number_of_letters = int(math.log(float(ref_count), float(letter_count)))+1 number_of_letters = int(math.log(float(ref_count), float(letter_count)))+1
# Exclude index for number_of_letters-1 # Exclude index for number_of_letters-1
for n in range(1, number_of_letters-1): for n in range(1, number_of_letters-1):
ref_count = ref_count - pow(letter_count, n) ref_count -= pow(letter_count, n)
# Adjust number_of_letters for new index # Adjust number_of_letters for new index
number_of_letters = int(math.log(float(ref_count), float(letter_count))) +1 number_of_letters = int(math.log(float(ref_count), float(letter_count))) +1
for n in range(1, number_of_letters): for n in range(1, number_of_letters):
x_ref_count = x_ref_count - pow(letter_count, n) x_ref_count -= pow(letter_count, n)
for letter in range(1, number_of_letters): for letter in range(1, number_of_letters):
index = x_ref_count / pow(letter_count, letter) % letter_count index = x_ref_count / pow(letter_count, letter) % letter_count
key += string.ascii_lowercase[ index ] key += string.ascii_lowercase[ index ]

View File

@ -70,7 +70,7 @@ class _DrawFormatComboBox(gtk.ComboBox):
self.store.append(row=[name]) self.store.append(row=[name])
if plugin.get_extension() == active: if plugin.get_extension() == active:
active_index = index active_index = index
index = index + 1 index += 1
self.set_active(active_index) self.set_active(active_index)
def get_active_plugin(self): def get_active_plugin(self):

View File

@ -871,7 +871,7 @@ class GraphvizFormatComboBox(gtk.ComboBox):
self.store.append(row=[name]) self.store.append(row=[name])
if item['type'] == active: if item['type'] == active:
active_index = index active_index = index
index = index + 1 index += 1
self.set_active(active_index) self.set_active(active_index)
def get_label(self): def get_label(self):

View File

@ -370,7 +370,7 @@ class ReportDialog(ManagedWindow.ManagedWindow):
else: else:
table.attach(widget, 2, 3, row, row+1, table.attach(widget, 2, 3, row, row+1,
yoptions=gtk.SHRINK) yoptions=gtk.SHRINK)
row = row + 1 row += 1
def setup_main_options(self): def setup_main_options(self):
if "" in self.frames: if "" in self.frames:

View File

@ -1533,7 +1533,7 @@ def draw_wedge(doc, style, centerx, centery, radius, start_angle,
x = centerx + cos(angle) * short_radius x = centerx + cos(angle) * short_radius
y = centery + sin(angle) * short_radius y = centery + sin(angle) * short_radius
p.append((x, y)) p.append((x, y))
angle = angle - radiansdelta angle -= radiansdelta
doc.draw_path(style, p) doc.draw_path(style, p)
delta = (eangle - sangle) / 2.0 delta = (eangle - sangle) / 2.0

View File

@ -122,7 +122,7 @@ class StyleListDisplay(object):
if style == "default": if style == "default":
continue continue
self.list.add([style]) self.list.add([style])
index = index + 1 index += 1
def on_add_clicked(self, obj): def on_add_clicked(self, obj):
"""Called with the ADD button is clicked. Invokes the StyleEditor to """Called with the ADD button is clicked. Invokes the StyleEditor to

View File

@ -71,7 +71,7 @@ class _TextFormatComboBox(gtk.ComboBox):
self.store.append(row=[name]) self.store.append(row=[name])
if plugin.get_extension() == active: if plugin.get_extension() == active:
active_index = index active_index = index
index = index + 1 index += 1
self.set_active(active_index) self.set_active(active_index)
def get_active_plugin(self): def get_active_plugin(self):

View File

@ -296,10 +296,10 @@ class TextBufDoc(BaseDoc, TextDoc):
self.in_cell = 1 self.in_cell = 1
self.cellnum = self.cellnum + span self.cellnum = self.cellnum + span
span = span - 1 span -= 1
while span: while span:
self.cell_widths[self.cellnum-span] = 0 self.cell_widths[self.cellnum-span] = 0
span = span - 1 span -= 1
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# #

View File

@ -561,7 +561,7 @@ class Span(object):
diff = 0 diff = 0
while eDate >> date2 and diff > -60: while eDate >> date2 and diff > -60:
diff -= 1 diff -= 1
eDate = eDate - (0, 0, abs(diff)) eDate -= (0, 0, abs(diff))
if diff == -60: if diff == -60:
return (-1, -1, -1) return (-1, -1, -1)
if self.negative: if self.negative:

View File

@ -1078,7 +1078,7 @@ class _BookFormatComboBox(gtk.ComboBox):
self.store.append(row=[name]) self.store.append(row=[name])
if plugin.get_extension() == active: if plugin.get_extension() == active:
active_index = index active_index = index
index = index + 1 index += 1
self.set_active(active_index) self.set_active(active_index)
def get_active_plugin(self): def get_active_plugin(self):

View File

@ -317,12 +317,12 @@ class AsciiDoc(BaseDoc,TextDoc):
def start_cell(self,style_name,span=1): def start_cell(self,style_name,span=1):
self.in_cell = 1 self.in_cell = 1
self.cellnum = self.cellnum + span self.cellnum = self.cellnum + span
span = span - 1 span -= 1
while span: while span:
self.cell_widths[self.cellnum] += \ self.cell_widths[self.cellnum] += \
self.cell_widths[self.cellnum-span] self.cell_widths[self.cellnum-span]
self.cell_widths[self.cellnum-span] = 0 self.cell_widths[self.cellnum-span] = 0
span = span - 1 span -= 1
#-------------------------------------------------------------------- #--------------------------------------------------------------------

View File

@ -103,11 +103,11 @@ class RTFDoc(BaseDoc,TextDoc):
if fgcolor not in self.color_map: if fgcolor not in self.color_map:
self.color_map[fgcolor] = index self.color_map[fgcolor] = index
self.f.write('\\red%d\\green%d\\blue%d;' % fgcolor) self.f.write('\\red%d\\green%d\\blue%d;' % fgcolor)
index = index + 1 index += 1
if bgcolor not in self.color_map: if bgcolor not in self.color_map:
self.f.write('\\red%d\\green%d\\blue%d;' % bgcolor) self.f.write('\\red%d\\green%d\\blue%d;' % bgcolor)
self.color_map[bgcolor] = index self.color_map[bgcolor] = index
index = index + 1 index += 1
self.f.write('}\n') self.f.write('}\n')
self.f.write('\\kerning0\\cf0\\viewkind1') self.f.write('\\kerning0\\cf0\\viewkind1')
self.f.write('\\paperw%d' % twips(self.paper.get_size().get_width())) self.f.write('\\paperw%d' % twips(self.paper.get_size().get_width()))

View File

@ -254,7 +254,7 @@ class SvgDrawDoc(BaseDoc, DrawDoc):
p = style_sheet.get_paragraph_style(para_name) p = style_sheet.get_paragraph_style(para_name)
font = p.get_font() font = p.get_font()
width = self.string_width(font, text) / 72 width = self.string_width(font, text) / 72
x = x - width x -= width
self.draw_text(style, text, x, y) self.draw_text(style, text, x, y)
def units(val): def units(val):

View File

@ -183,7 +183,7 @@ class FanChart(Report):
style_sheet = self.doc.get_style_sheet() style_sheet = self.doc.get_style_sheet()
fontsize = pt2cm(style_sheet.get_paragraph_style('FC-Title').get_font().get_size()) fontsize = pt2cm(style_sheet.get_paragraph_style('FC-Title').get_font().get_size())
# y is vertical distance to center of circle, move center down 1 fontsize # y is vertical distance to center of circle, move center down 1 fontsize
y = y + fontsize y += fontsize
# min_XY is the diamter of the circle, subtract two fontsize # min_XY is the diamter of the circle, subtract two fontsize
# so we dont draw outside bottom of the paper # so we dont draw outside bottom of the paper
min_xy = min(min_xy,y-2*fontsize) min_xy = min(min_xy,y-2*fontsize)

View File

@ -591,9 +591,9 @@ class StatisticsChart(Report):
# output data... # output data...
radius = middle - 2*margin radius = middle - 2*margin
yoffset = yoffset + margin + radius yoffset += margin + radius
ReportUtils.draw_pie_chart(self.doc, middle_w, yoffset, radius, chart_data, -90) ReportUtils.draw_pie_chart(self.doc, middle_w, yoffset, radius, chart_data, -90)
yoffset = yoffset + radius + 2*margin yoffset += radius + 2*margin
if middle == middle_h: # Landscape if middle == middle_h: # Landscape
legendx = 1.0 legendx = 1.0
yoffset = margin yoffset = margin

View File

@ -395,7 +395,7 @@ class FanChartWidget(gtk.Widget):
self.angle[generation][selected] = [current, current + slice, self.angle[generation][selected] = [current, current + slice,
male,state] male,state]
self.shrink_parents(generation + 1, selected, current) self.shrink_parents(generation + 1, selected, current)
current = current + slice current += slice
start,stop,male,state = self.angle[generation][selected+1] start,stop,male,state = self.angle[generation][selected+1]
if state in [self.NORMAL, self.EXPANDED]: if state in [self.NORMAL, self.EXPANDED]:
slice = (stop - start) / 2.0 slice = (stop - start) / 2.0

View File

@ -85,7 +85,7 @@ class StatsGramplet(Gramplet):
photo = database.get_object_from_handle(photo_id) photo = database.get_object_from_handle(photo_id)
fullname = media_path_full(database, photo.get_path()) fullname = media_path_full(database, photo.get_path())
try: try:
bytes = bytes + posixpath.getsize(fullname) bytes += posixpath.getsize(fullname)
except: except:
notfound.append(photo.get_path()) notfound.append(photo.get_path())

View File

@ -193,7 +193,7 @@ def _get_mem_text(mems, i):
if i <= 0: if i <= 0:
return '' return ''
i = i - 1 i -= 1
recno = mems[i][0] recno = mems[i][0]
text = mems[i][1].decode('cp850') text = mems[i][1].decode('cp850')
if recno != 0: if recno != 0:

View File

@ -393,7 +393,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
going sideways in a branch as the nieces/newphews going downward going sideways in a branch as the nieces/newphews going downward
from your brother/sisters. This used to be called "kozijn" from your brother/sisters. This used to be called "kozijn"
""" """
removed = removed - 1 removed -= 1
if removed > len(_removed_level)-1: if removed > len(_removed_level)-1:
return "verre %s%sneef (kozijn, %d graden)" % (inlaw, step, return "verre %s%sneef (kozijn, %d graden)" % (inlaw, step,
removed) removed)
@ -408,7 +408,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
going sideways in a branch as the nieces/newphews going downward going sideways in a branch as the nieces/newphews going downward
from your brother/sisters. This used to be called "kozijn" from your brother/sisters. This used to be called "kozijn"
""" """
removed = removed - 1 removed -= 1
if removed > len(_removed_level)-1: if removed > len(_removed_level)-1:
return "verre %s%snicht (kozijn, %d graden)" % (inlaw, step, return "verre %s%snicht (kozijn, %d graden)" % (inlaw, step,
removed) removed)

View File

@ -172,7 +172,7 @@ class DetAncestorReport(Report):
mark = IndexMark(text, INDEX_TYPE_TOC, 2) mark = IndexMark(text, INDEX_TYPE_TOC, 2)
self.doc.write_text(text, mark) self.doc.write_text(text, mark)
self.doc.end_paragraph() self.doc.end_paragraph()
generation = generation + 1 generation += 1
if self.childref: if self.childref:
self.prev_gen_handles = self.gen_handles.copy() self.prev_gen_handles = self.gen_handles.copy()
self.gen_handles.clear() self.gen_handles.clear()

View File

@ -419,7 +419,7 @@ class FamilyGroup(Report):
else: else:
spouse_id = family.get_father_handle() spouse_id = family.get_father_handle()
if spouse_id: if spouse_id:
spouse_count = spouse_count + 1 spouse_count += 1
self.doc.start_row() self.doc.start_row()
if spouse_count != 0 or self.missingInfo or death is not None or birth is not None: if spouse_count != 0 or self.missingInfo or death is not None or birth is not None:
@ -462,7 +462,7 @@ class FamilyGroup(Report):
index = 0 index = 0
for family_handle in person.get_family_handle_list(): for family_handle in person.get_family_handle_list():
m = None m = None
index = index + 1 index += 1
family = self.database.get_family_from_handle(family_handle) family = self.database.get_family_from_handle(family_handle)
for event_ref in family.get_event_ref_list(): for event_ref in family.get_event_ref_list():
@ -562,7 +562,7 @@ class FamilyGroup(Report):
index = 1 index = 1
for child_ref in family.get_child_ref_list(): for child_ref in family.get_child_ref_list():
self.dump_child(index,child_ref.ref) self.dump_child(index,child_ref.ref)
index = index + 1 index += 1
self.doc.end_table() self.doc.end_table()
if self.recursive: if self.recursive:

View File

@ -111,32 +111,32 @@ class SummaryReport(Report):
# Count people with media. # Count people with media.
length = len(person.get_media_list()) length = len(person.get_media_list())
if length > 0: if length > 0:
with_media = with_media + 1 with_media += 1
# Count people with incomplete names. # Count people with incomplete names.
name = person.get_primary_name() name = person.get_primary_name()
if name.get_first_name() == "" or name.get_surname() == "": if name.get_first_name() == "" or name.get_surname() == "":
incomp_names = incomp_names + 1 incomp_names += 1
# Count people without families. # Count people without families.
if (not person.get_main_parents_family_handle()) and \ if (not person.get_main_parents_family_handle()) and \
(not len(person.get_family_handle_list())): (not len(person.get_family_handle_list())):
disconnected = disconnected + 1 disconnected += 1
# Count missing birthdays. # Count missing birthdays.
birth_ref = person.get_birth_ref() birth_ref = person.get_birth_ref()
if birth_ref: if birth_ref:
birth = self.__db.get_event_from_handle(birth_ref.ref) birth = self.__db.get_event_from_handle(birth_ref.ref)
if not DateHandler.get_date(birth): if not DateHandler.get_date(birth):
missing_bday = missing_bday + 1 missing_bday += 1
else: else:
missing_bday = missing_bday + 1 missing_bday += 1
# Count genders. # Count genders.
if person.get_gender() == gen.lib.Person.FEMALE: if person.get_gender() == gen.lib.Person.FEMALE:
females = females + 1 females += 1
elif person.get_gender() == gen.lib.Person.MALE: elif person.get_gender() == gen.lib.Person.MALE:
males = males + 1 males += 1
else: else:
unknowns += 1 unknowns += 1
@ -212,9 +212,8 @@ class SummaryReport(Report):
for media_id in self.__db.get_media_object_handles(): for media_id in self.__db.get_media_object_handles():
media = self.__db.get_object_from_handle(media_id) media = self.__db.get_object_from_handle(media_id)
try: try:
size_in_bytes = size_in_bytes + posixpath.getsize( size_in_bytes += posixpath.getsize(
media_path_full(self.__db, media_path_full(self.__db, media.get_path()))
media.get_path()))
except: except:
notfound.append(media.get_path()) notfound.append(media.get_path())

View File

@ -275,9 +275,9 @@ class DisplayChart(ManagedWindow.ManagedWindow):
column.set_sort_column_id(model_index) column.set_sort_column_id(model_index)
self.eventlist.append_column(column) self.eventlist.append_column(column)
# This one numbers the tree columns: increment on new column # This one numbers the tree columns: increment on new column
tree_index = tree_index + 1 tree_index += 1
# This one numbers the model columns: always increment # This one numbers the model columns: always increment
model_index = model_index + 1 model_index += 1
model = gtk.ListStore(*mylist) model = gtk.ListStore(*mylist)
self.eventlist.set_model(model) self.eventlist.set_model(model)

View File

@ -220,9 +220,9 @@ class Tooltip(gtk.Window):
if ((y + h + widget.allocation.height + Tooltip.BORDER_WIDTH) > if ((y + h + widget.allocation.height + Tooltip.BORDER_WIDTH) >
monitor.y + monitor.height): monitor.y + monitor.height):
y = y - h - Tooltip.BORDER_WIDTH y -= h + Tooltip.BORDER_WIDTH
else: else:
y = y + widget.allocation.height + Tooltip.BORDER_WIDTH y += widget.allocation.height + Tooltip.BORDER_WIDTH
return x, y return x, y