Commit c8fb8fb7 authored by Stephen Kennedy's avatar Stephen Kennedy

Fix pychecker warnings.

parent e9fb1e52
......@@ -16,7 +16,6 @@
from __future__ import generators
import difflib
import misc
def _null_or_space(s):
return len(s.strip()) == 0
......@@ -78,7 +77,7 @@ class Differ(object):
# Internally, diffs are stored from text1 -> text0 and text1 -> text2.
self.num_sequences = len(sequences)
self.seqlength = [0,0,0]
for i,s in misc.enumerate(sequences):
for i,s in enumerate(sequences):
self.seqlength[i] = len(s)
if len(sequences)==0 or len(sequences)==1:
......@@ -302,19 +301,20 @@ class Differ(object):
self.diffs = diffs
self.num_sequences = len(sequences)
self.seqlength = [0,0,0]
for i,s in misc.enumerate(sequences):
for i,s in enumerate(sequences):
self.seqlength[i] = len(s)
yield 1
def main():
t0 = open("test/lao").readlines()
tc = open("test/tzu").readlines()
t1 = open("test/tao").readlines()
thread0 = IncrementalSequenceMatcher(None, tc, t0).get_difference_opcodes()
thread1 = IncrementalSequenceMatcher(None, tc, t1).get_difference_opcodes()
texts = (t0,tc,t1)
pass
# t0 = open("test/lao").readlines()
# tc = open("test/tzu").readlines()
# t1 = open("test/tao").readlines()
#
# thread0 = IncrementalSequenceMatcher(None, tc, t0).get_difference_opcodes()
# thread1 = IncrementalSequenceMatcher(None, tc, t1).get_difference_opcodes()
#
# texts = (t0,tc,t1)
if __name__=="__main__":
if __name__=="__main__":
main()
......@@ -17,8 +17,6 @@
from __future__ import generators
import paths
import diffutil
import errno
import gnomeglade
import gobject
import gtk
......@@ -29,7 +27,6 @@ import os
import shutil
import melddoc
import tree
import filecmp
import re
import stat
import time
......@@ -248,7 +245,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
if r.active:
try:
self.regexes.append( re.compile(r.value+"(?m)") )
except re.error, e:
except re.error:
misc.run_dialog(
text=_("Error converting pattern '%s' to regular expression") % r.value )
......@@ -264,14 +261,14 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
continue
try:
cregex = re.compile(regex)
except re.error, e:
misc.run_dialog( _("Error converting pattern '%s' to regular expression") % pattern, self )
except re.error:
misc.run_dialog( _("Error converting pattern '%s' to regular expression") % f.value, self )
else:
func = lambda x, r=cregex : r.match(x) == None
self.name_filters_available.append( TypeFilter(f.name, f.active, func) )
self.name_filters = []
tips = gtk.Tooltips()
for i,f in misc.enumerate(self.name_filters_available):
for i,f in enumerate(self.name_filters_available):
icon = gtk.Image()
icon.set_from_stock(gtk.STOCK_FIND, gtk.ICON_SIZE_LARGE_TOOLBAR)
toggle = gtk.ToggleToolButton()
......@@ -316,20 +313,20 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
def file_deleted(self, path, pane):
# is file still extant in other pane?
iter = self.model.get_iter(path)
files = self.model.value_paths(iter)
is_present = [ os.path.exists( file ) for file in files ]
it = self.model.get_iter(path)
files = self.model.value_paths(it)
is_present = [ os.path.exists(f) for f in files ]
if 1 in is_present:
self._update_item_state(iter)
self._update_item_state(it)
else: # nope its gone
self.model.remove(iter)
self.model.remove(it)
self._update_diffmaps()
def file_created(self, path, pane):
iter = self.model.get_iter(path)
while iter and self.model.get_path(iter) != (0,):
self._update_item_state( iter )
iter = self.model.iter_parent(iter)
it = self.model.get_iter(path)
while it and self.model.get_path(it) != (0,):
self._update_item_state( it )
it = self.model.iter_parent(it)
self._update_diffmaps()
def on_fileentry_activate(self, entry):
......@@ -340,7 +337,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
self.set_num_panes(len(locations))
locations = [os.path.abspath(l or ".") for l in locations]
self.model.clear()
for pane, loc in misc.enumerate(locations):
for pane, loc in enumerate(locations):
self.fileentry[pane].set_filename(loc)
child = self.model.add_entries(None, locations)
self._update_item_state(child)
......@@ -351,12 +348,12 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
def recursively_update( self, path ):
"""Recursively update from tree path 'path'.
"""
iter = self.model.get_iter( path )
child = self.model.iter_children( iter )
it = self.model.get_iter( path )
child = self.model.iter_children( it )
while child:
self.model.remove(child)
child = self.model.iter_children( iter )
self._update_item_state(iter)
child = self.model.iter_children( it )
self._update_item_state(it)
self.scheduler.add_task( self._search_recursively_iter( path ).next )
def _search_recursively_iter(self, rootpath):
......@@ -368,8 +365,8 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
while len(todo):
todo.sort() # depth first
path = todo.pop(0)
iter = self.model.get_iter( path )
roots = self.model.value_paths( iter )
it = self.model.get_iter( path )
roots = self.model.value_paths( it )
yield _("[%s] Scanning %s") % (self.label_text, roots[0][prefixlen:])
differences = [0]
if not self.button_ignore_case.get_active():
......@@ -422,12 +419,12 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
return [ fixup(k, self.items[k]) for k in keys ]
accumdirs = accum(self, roots)
accumfiles = accum(self, roots)
for pane, root in misc.enumerate(roots):
for pane, root in enumerate(roots):
if os.path.isdir( root ):
try:
entries = os.listdir( root )
except OSError, err:
self.model.add_error( iter, err.strerror, pane )
self.model.add_error( it, err.strerror, pane )
differences = [1]
else:
for f in self.name_filters:
......@@ -463,13 +460,13 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
# then directories and files
if len(alldirs) + len(allfiles) != 0:
def add_entry(names):
child = self.model.add_entries( iter, [join(r,n) for r,n in zip(roots, names) ] )
child = self.model.add_entries( it, [join(r,n) for r,n in zip(roots, names) ] )
differences[0] |= self._update_item_state(child)
return child
map(lambda x : todo.append( self.model.get_path(add_entry(x))), alldirs )
map(add_entry, allfiles)
else: # directory is empty, add a placeholder
self.model.add_empty(iter)
self.model.add_empty(it)
if differences[0]:
start = path[:]
while len(start) and not self.treeview[0].row_expanded(start):
......@@ -481,12 +478,12 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
yield _("[%s] Done") % self.label_text
self.filter_hide_current.set_sensitive(True)
def launch_comparison(self, iter, pane, force=1):
"""Launch comparison at 'iter'.
def launch_comparison(self, it, pane, force=1):
"""Launch comparison at 'it'.
If it is a file we launch a diff.
If it is a folder we recursively open diffs for each non equal file.
"""
paths = filter(os.path.exists, self.model.value_paths(iter))
paths = filter(os.path.exists, self.model.value_paths(it))
self.emit("create-diff", paths)
def launch_comparisons_on_selected(self):
......@@ -509,12 +506,12 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
paths.reverse()
model = self.model
for path in paths: #filter(lambda x: x.name!=None, sel):
iter = model.get_iter(path)
name = model.value_path(iter, src_pane)
it = model.get_iter(path)
name = model.value_path(it, src_pane)
if name == None:
continue
src = model.value_path(iter, src_pane)
dst = model.value_path(iter, dst_pane)
src = model.value_path(it, src_pane)
dst = model.value_path(it, dst_pane)
try:
if os.path.isfile(src):
dstdir = os.path.dirname( dst )
......@@ -542,8 +539,8 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
paths = self._get_selected_paths(pane)
paths.reverse()
for path in paths:
iter = self.model.get_iter(path)
name = self.model.value_path(iter, pane)
it = self.model.get_iter(path)
name = self.model.value_path(it, pane)
try:
if os.path.isfile(name):
os.remove(name)
......@@ -578,9 +575,9 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
if abs(int(deltat)) < 5 * units:
return msg(int(deltat)) % int(deltat)
deltat /= units
file = self.model.value_path( self.model.get_iter(paths[0]), pane )
fname = self.model.value_path( self.model.get_iter(paths[0]), pane )
try:
stat = os.stat(file)
stat = os.stat(fname)
except OSError:
self.emit("status-changed", "" )
else:
......@@ -613,12 +610,12 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
return event.keyval in (gtk.keysyms.Left, gtk.keysyms.Right) #handled
def on_treeview_row_activated(self, view, path, column):
iter = self.model.get_iter(path)
it = self.model.get_iter(path)
files = []
for i in range(self.num_panes):
file = self.model.value_path( iter, i )
if os.path.exists(file):
files.append(file)
fname = self.model.value_path( it, i )
if os.path.exists(fname):
files.append(fname)
else:
files.append(None)
if files.count(None) != self.num_panes:
......@@ -635,7 +632,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
else:
view.expand_row(path,0)
def on_treeview_row_expanded(self, view, iter, path):
def on_treeview_row_expanded(self, view, it, path):
self._do_to_others(view, self.treeview, "expand_row", (path,0) )
self._update_diffmaps()
......@@ -718,7 +715,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
assert pane != None
selected_paths = []
self.treeview[pane].get_selection().selected_foreach(
lambda store, path, iter: selected_paths.append( path ) )
lambda store, path, it: selected_paths.append( path ) )
return selected_paths
#
......@@ -749,17 +746,17 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
ret.append( files )
return ret
def _update_item_state(self, iter):
"""Update the state of the item at 'iter'
def _update_item_state(self, it):
"""Update the state of the item at 'it'
"""
files = self.model.value_paths(iter)
files = self.model.value_paths(it)
def mtime(f):
try:
return os.stat(f).st_mtime
except OSError:
return 0
# find the newest file, checking also that they differ
mod_times = [ mtime( file ) for file in files[:self.num_panes] ]
mod_times = [ mtime(f) for f in files[:self.num_panes] ]
newest_index = mod_times.index( max(mod_times) )
if mod_times.count( max(mod_times) ) == len(mod_times):
newest_index = -1 # all same
......@@ -779,20 +776,20 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
if mod_times[j]:
isdir = os.path.isdir( files[j] )
if all_same == 1:
self.model.set_state(iter, j, tree.STATE_NORMAL, isdir)
self.model.set_state(it, j, tree.STATE_NORMAL, isdir)
different = 0
elif all_same == 2:
self.model.set_state(iter, j, tree.STATE_NOCHANGE, isdir)
self.model.set_state(it, j, tree.STATE_NOCHANGE, isdir)
different = 0
elif all_present_same:
self.model.set_state(iter, j, tree.STATE_NEW, isdir)
self.model.set_state(it, j, tree.STATE_NEW, isdir)
else:
self.model.set_state(iter, j, tree.STATE_MODIFIED, isdir)
self.model.set_value(iter,
self.model.set_state(it, j, tree.STATE_MODIFIED, isdir)
self.model.set_value(it,
self.model.column_index(COL_EMBLEM, j),
j == newest_index and pixbuf_newer or None)
else:
self.model.set_state(iter, j, tree.STATE_MISSING)
self.model.set_state(it, j, tree.STATE_MISSING)
return different
def on_treeview_button_press_event(self, treeview, event):
......@@ -811,6 +808,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
treeview.set_cursor( path, col, 0)
self.popup_menu.popup_in_pane( self.treeview.index(treeview) )
return event.state==0
return 0
def set_num_panes(self, n):
if n != self.num_panes and n in (1,2,3):
......@@ -855,13 +853,13 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
todo = [root]
model = self.model
while len(todo):
iter = todo.pop(0)
#print model.value_path(iter, treeindex), model.get_state(iter, treeindex)
yield model.get_state(iter, treeindex)
path = model.get_path(iter)
it = todo.pop(0)
#print model.value_path(it, treeindex), model.get_state(it, treeindex)
yield model.get_state(it, treeindex)
path = model.get_path(it)
if treeview.row_expanded(path):
children = []
child = model.iter_children(iter)
child = model.iter_children(it)
while child:
children.append(child)
child = model.iter_next(child)
......@@ -940,6 +938,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
upper = adj.upper - adj.page_size
adj.set_value( max( min(upper, val), 0) )
return 1
return 0
def on_file_changed(self, changed_filename):
"""When a file has changed, try to find it in our tree
......
......@@ -20,8 +20,6 @@ import codecs
import math
import os
import re
import sys
import tempfile
import difflib
import struct
......@@ -187,7 +185,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
if r.active:
try:
self.regexes.append( (re.compile(r.value+"(?m)"), r.value) )
except re.error, e:
except re.error:
pass
def _disconnect_buffer_handlers(self):
......@@ -211,11 +209,11 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
def _update_cursor_status(self, buf):
def update():
iter = buf.get_iter_at_mark( buf.get_insert() )
it = buf.get_iter_at_mark( buf.get_insert() )
# Abbreviation for insert,overwrite so that it will fit in the status bar
insert_overwrite = _("INS,OVR").split(",")[ self.textview_overwrite ]
# Abbreviation for line, column so that it will fit in the status bar
line_column = _("Ln %i, Col %i") % (iter.get_line()+1, iter.get_line_offset()+1)
line_column = _("Ln %i, Col %i") % (it.get_line()+1, it.get_line_offset()+1)
status = "%s : %s" % ( insert_overwrite, line_column )
self.emit("status-changed", status )
raise StopIteration; yield 0
......@@ -235,8 +233,8 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
if self.num_panes > 1:
buffers = [t.get_buffer() for t in self.textview[:self.num_panes] ]
pane = buffers.index(buffer)
range = self.linediffer.change_sequence( pane, startline, sizechange, self._get_texts())
for iter in self._update_highlighting( range[0], range[1] ):
change_range = self.linediffer.change_sequence( pane, startline, sizechange, self._get_texts())
for it in self._update_highlighting( change_range[0], change_range[1] ):
pass
self.queue_draw()
self._update_cursor_status(buffer)
......@@ -272,19 +270,19 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
for c,r in self.regexes:
txt = c.sub(killit,txt)
except AssertionError:
if self.warned_bad_comparison == False:
if not self.warned_bad_comparison:
misc.run_dialog(_("Regular expression '%s' changed the number of lines in the file. " \
"Comparison will be incorrect. See the user manual for more details.") % r)
self.warned_bad_comparison = True
return txt
def after_text_insert_text(self, buffer, iter, newtext, textlen):
def after_text_insert_text(self, buffer, it, newtext, textlen):
lines_added = newtext.count("\n")
starting_at = iter.get_line() - lines_added
starting_at = it.get_line() - lines_added
self._after_text_modified(buffer, starting_at, lines_added)
def after_text_delete_range(self, buffer, iter0, iter1):
starting_at = iter0.get_line()
def after_text_delete_range(self, buffer, it0, it1):
starting_at = it0.get_line()
assert self.deleted_lines_pending != -1
self._after_text_modified(buffer, starting_at, -self.deleted_lines_pending)
self.deleted_lines_pending = -1
......@@ -405,17 +403,17 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
def on_text_end_user_action(self, *buffer):
self.undosequence.end_group()
def on_text_insert_text(self, buffer, iter, text, textlen):
def on_text_insert_text(self, buffer, it, text, textlen):
if not self.undosequence_busy:
self.undosequence.begin_group()
pane = self.textview.index( buffer.textview )
if self.bufferdata[pane].modified != 1:
self.undosequence.add_action( BufferModifiedAction(buffer, self) )
self.undosequence.add_action( BufferInsertionAction(buffer, iter.get_offset(), text) )
self.undosequence.add_action( BufferInsertionAction(buffer, it.get_offset(), text) )
self.undosequence.end_group()
def on_text_delete_range(self, buffer, iter0, iter1):
text = buffer.get_text(iter0, iter1, 0)
def on_text_delete_range(self, buffer, it0, it1):
text = buffer.get_text(it0, it1, 0)
pane = self.textview.index(buffer.textview)
assert self.deleted_lines_pending == -1
self.deleted_lines_pending = text.count("\n")
......@@ -423,7 +421,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
self.undosequence.begin_group()
if self.bufferdata[pane].modified != 1:
self.undosequence.add_action( BufferModifiedAction(buffer, self) )
self.undosequence.add_action( BufferDeletionAction(buffer, iter0.get_offset(), text) )
self.undosequence.add_action( BufferDeletionAction(buffer, it0.get_offset(), text) )
self.undosequence.end_group()
#
......@@ -491,6 +489,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
pane = self.textview.index(textview)
self.popup_menu.popup_in_pane( pane )
return 1
return 0
def on_textview_toggle_overwrite(self, view):
self.textview_overwrite = not self.textview_overwrite
......@@ -524,10 +523,10 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
if match == None and wrap:
match = pattern.search(text, 0)
if match:
iter = buf.get_iter_at_offset( match.start() )
buf.place_cursor( iter )
iter.forward_chars( match.end() - match.start() )
buf.move_mark( buf.get_selection_bound(), iter )
it = buf.get_iter_at_offset( match.start() )
buf.place_cursor( it )
it.forward_chars( match.end() - match.start() )
buf.move_mark( buf.get_selection_bound(), it )
view.scroll_to_mark( buf.get_insert(), 0)
elif regex:
misc.run_dialog( _("The regular expression '%s' was not found.") % tofind_utf8, self, messagetype=gtk.MESSAGE_INFO)
......@@ -560,7 +559,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
"""Set num panes to len(files) and load each file given.
If an element is None, the text of a pane is left as is.
"""
for i,f in misc.enumerate(files):
for i,f in enumerate(files):
if f:
b = self.textview[i].get_buffer()
b.delete( b.get_start_iter(), b.get_end_iter() )
......@@ -581,7 +580,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
yield _("[%s] Opening files") % self.label_text
panetext = ["\n"] * self.num_panes
tasks = []
for i,f in misc.enumerate(files):
for i,f in enumerate(files):
if f:
try:
task = misc.struct(filename = f,
......@@ -679,7 +678,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
tag = table.lookup(tagname)
b.remove_tag(tag, b.get_start_iter(), b.get_end_iter() )
for chunk in self.linediffer.all_changes(self._get_texts()):
for i,c in misc.enumerate(chunk):
for i,c in enumerate(chunk):
if c and c[0] == "replace":
bufs = buffers[1], buffers[i*2]
#tags = [b.get_tag_table().lookup("replace line") for b in bufs]
......@@ -713,7 +712,6 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
return
if not hasattr(textview, "meldgc"):
self._setup_gcs(textview)
gctext = textview.get_style().text_gc[0]
visible = textview.get_visible_rect()
pane = self.textview.index(textview)
start_line = self._pixel_to_line(pane, visible.y)
......@@ -751,8 +749,8 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
parent=self.widget.get_toplevel(),
action=gtk.FILE_CHOOSER_ACTION_SAVE,
buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK) )
response = ilenamedialog.run()
fname = None
response = dialog.run()
filename = None
if response == gtk.RESPONSE_OK:
filename = dialog.get_filename()
dialog.destroy()
......@@ -765,6 +763,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
if response == gtk.RESPONSE_NO:
return None
return filename
return None
def _save_text_to_filename(self, filename, text):
try:
......@@ -807,7 +806,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
if bufdata.encoding and self.prefs.save_encoding==0:
try:
text = text.encode(bufdata.encoding)
except UnicodeEncodeError, e:
except UnicodeEncodeError:
if misc.run_dialog(
_("'%s' contains characters not encodable with '%s'\nWould you like to save as UTF-8?") % (bufdata.filename, bufdata.encoding),
self, gtk.MESSAGE_ERROR, gtk.BUTTONS_YES_NO) != gtk.RESPONSE_YES:
......@@ -920,7 +919,6 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
if not self._sync_hscroll_lock:
self._sync_hscroll_lock = 1
adjs = map( lambda x: x.get_hadjustment(), self.scrolledwindow)
master = adjs.index(adjustment)
adjs.remove(adjustment)
val = adjustment.get_value()
for a in adjs:
......@@ -995,7 +993,6 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
scaleit = lambda x,s=hperline,o=size_of_arrow: x*s+o
x0 = 4
x1 = area.get_allocation().width - 2*x0
madj = self.scrolledwindow[textindex].get_vadjustment()
window = area.window
window.clear()
......@@ -1023,6 +1020,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
upper = adj.upper - adj.page_size
adj.set_value( max( min(upper, val), 0) )
return 1
return 0
def _get_line_count(self, index):
"""Return the number of lines in the buffer of textview 'text'"""
......@@ -1046,8 +1044,8 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
self.recompute_label()
def _line_to_pixel(self, pane, line ):
iter = self.textview[pane].get_buffer().get_iter_at_line(line)
return self.textview[pane].get_iter_location( iter ).y
it = self.textview[pane].get_buffer().get_iter_at_line(line)
return self.textview[pane].get_iter_location( it ).y
def _pixel_to_line(self, pane, pixel ):
return self.textview[pane].get_line_at_y( pixel )[0].get_line()
......@@ -1264,6 +1262,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
return 1
elif event.button == 2:
self.linkmap_drag_coord = event.x
return 0
def on_linkmap_motion_notify_event(self, area, event):
return
......@@ -1312,6 +1311,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
b1.insert_with_tags_by_name(b1.get_iter_at_line(chunk[2]), t0, "edited line")
self.on_text_end_user_action()
return 1
return 0
def on_linkmap_drag_begin(self, *args):
print args
......
......@@ -407,7 +407,6 @@
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
<property name="fixed_height_mode">True</property>
<property name="hover_selection">False</property>
<property name="hover_expand">False</property>
<signal name="row_expanded" handler="on_treeview_row_expanded" last_modification_time="Sun, 03 Nov 2002 16:03:11 GMT"/>
......@@ -446,7 +445,6 @@
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
<property name="fixed_height_mode">True</property>
<property name="hover_selection">False</property>
<property name="hover_expand">False</property>
<signal name="row_expanded" handler="on_treeview_row_expanded" last_modification_time="Sun, 03 Nov 2002 16:03:29 GMT"/>
......@@ -668,7 +666,6 @@
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
<property name="fixed_height_mode">True</property>
<property name="hover_selection">False</property>
<property name="hover_expand">False</property>
<signal name="row_expanded" handler="on_treeview_row_expanded" last_modification_time="Sun, 03 Nov 2002 16:03:29 GMT"/>
......
......@@ -75,7 +75,7 @@ class Base(object):
"""
for item in widgetnames:
setattr(self,item, [])
list = getattr(self,item)
lst = getattr(self,item)
i = 0
while 1:
key = "%s%i"%(item,i)
......@@ -83,7 +83,7 @@ class Base(object):
val = getattr(self, key)
except AttributeError:
break
list.append(val)
lst.append(val)
i += 1
......@@ -107,7 +107,7 @@ class GtkApp(Base):
"""
gtk.main()
def quit(*args):
def quit(self, *args):
"""Signal the gtk main loop to quit.
"""
gtk.main_quit()
......
......@@ -17,9 +17,18 @@
### Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# i18n support
# pychecker
#
import sys
if "--pychecker" in sys.argv:
sys.argv.remove("--pychecker")
import os
os.environ['PYCHECKER'] = "--no-argsused --no-classattr --stdlib"
#'--blacklist=gettext,locale,pygtk,gtk,gtk.keysyms,popen2,random,difflib,filecmp,tempfile'
import pychecker.checker
#
# i18n support
#
sys.path += [ #LIBDIR#
]
import paths
......
......@@ -28,7 +28,6 @@ import paths
import prefs
import gnomeglade
import misc
import melddoc
import filediff
import vcview
import dirdiff
......@@ -113,8 +112,8 @@ class ListWidget(gnomeglade.Component):
rentext = gtk.CellRendererText()
rentext.set_property("editable", 1)
def change_text(ren, row, text):
iter = model.get_iter( (int(row),))
model.set_value( iter, colnum, text)
it = model.get_iter( (int(row),))
model.set_value( it, colnum, text)
self._update_filter_string()
rentext.connect("edited", change_text)
column = gtk.TreeViewColumn(label)
......@@ -125,8 +124,8 @@ class ListWidget(gnomeglade.Component):
model = view.get_model()
rentoggle = gtk.CellRendererToggle()
def change_toggle(ren, row):
iter = model.get_iter( (int(row),))
model.set_value( iter, colnum, not ren.get_active() )
it = model.get_iter( (int(row),))
model.set_value( it, colnum, not ren.get_active() )
self._update_filter_string()
rentoggle.connect("toggled", change_toggle)
column = gtk.TreeViewColumn(label)
......@@ -142,14 +141,14 @@ class ListWidget(gnomeglade.Component):
self._update_filter_model()
def on_item_new_clicked(self, button):
model = self.treeview.get_model()
iter = model.append()
model.set_value(iter, 0, "label")
model.set_value(iter, 2, "pattern")
it = model.append()
model.set_value(it, 0, "label")
model.set_value(it, 2, "pattern")
self._update_filter_string()
def _get_selected(self):
selected = []
self.treeview.get_selection().selected_foreach(
lambda store, path, iter: selected.append( path ) )
lambda store, path, it: selected.append( path ) )
return selected
def on_item_delete_clicked(self, button):
model = self.treeview.get_model()
......@@ -161,22 +160,22 @@ class ListWidget(gnomeglade.Component):
for s in self._get_selected():
if s[0] > 0: # XXX need model.swap
old = model.get_iter(s[0])
iter = model.insert( s[0]-1 )
it = model.insert( s[0]-1 )
for i in range(3):
model.set_value(iter, i, model.get_value(old, i) )
model.set_value(it, i, model.get_value(old, i) )
model.remove(old)
self.treeview.get_selection().select_iter(iter)
self.treeview.get_selection().select_iter(it)
self._update_filter_string()
def on_item_down_clicked(self, button):
model = self.treeview.get_model()
for s in self._get_selected():
if s[0] < len(model)-1: # XXX need model.swap
old = model.get_iter(s[0])
iter = model.insert( s[0]+2 )
it = model.insert( s[0]+2 )