Commit d353ec89 authored by steve9000's avatar steve9000

Use newsytle classes where possible.

parent 2d8ab7c6
......@@ -37,7 +37,7 @@ import paths
# Local Functions
#
################################################################################
class Entry:
class Entry(object):
states = _("Ignored:Non CVS:::Error::Newly added:Modified:<b>Conflict</b>:Removed:Missing").split(":")
assert len(states)==tree.STATE_MAX
def __str__(self):
......@@ -174,7 +174,7 @@ def _lookup_cvs_files(dirs, files):
"The pattern was '%s'\n" \
"The error was '%s'") % (",".join(ignored), e))
else:
class dummy:
class dummy(object):
def match(*args): return None
ignore_re = dummy()
......@@ -377,7 +377,7 @@ class CvsView(melddoc.MeldDoc, gnomeglade.Component):
addCol(_("Tag"), COL_TAG)
addCol(_("Options"), COL_OPTIONS)
class ConsoleStream:
class ConsoleStream(object):
def __init__(this, textview):
this.textview = textview
b = textview.get_buffer()
......
......@@ -64,7 +64,7 @@ class IncrementalSequenceMatcher(difflib.SequenceMatcher):
# Differ
#
################################################################################
class Differ:
class Differ(object):
"""Utility class to hold diff2 or diff3 chunks"""
reversemap = {
"replace":"replace",
......
......@@ -365,7 +365,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
yield _("[%s] Scanning %s") % (self.label_text, roots[0][prefixlen:])
differences = [0]
if not self.button_ignore_case.get_active():
class accum:
class accum(object):
def __init__(self, parent, roots):
self.items = []
self.n = parent.num_panes
......@@ -379,7 +379,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
return [ tuple(repeat(i,self.n)) for i in uniq(self.items) ]
else:
canonicalize = lambda x : x.lower()
class accum:
class accum(object):
def __init__(self, parent, roots):
self.items = {} # map canonical names to realnames
self.bad = []
......
......@@ -146,13 +146,13 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
self.queue_draw()
def _get_texts(self):
class FakeText:
class FakeText(object):
def __init__(self, buf):
self.buf = buf
def __getslice__(self, lo, hi):
b = self.buf
return b.get_text(b.get_iter_at_line(lo), b.get_iter_at_line(hi), 0).split("\n")[:-1]
class FakeTextArray:
class FakeTextArray(object):
def __init__(self, bufs):
self.texts = map(FakeText, bufs)
def __getitem__(self, i):
......@@ -447,7 +447,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
text = [],
pane = i)
tasks.append(task)
except IOError, e:
except (IOError, LookupError), e:
buffers[i].set_text("\n")
misc.run_dialog(
_("Could not open '%s' for reading.\n\nThe error was:\n%s") % (f, str(e)),
......@@ -561,26 +561,25 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
starts = [b.get_iter_at_line(l) for b,l in zip(bufs, (c[1],c[3])) ]
for b, t, s, l in zip(bufs, tags, starts, (c[2],c[4])):
b.apply_tag(t, s, b.get_iter_at_line(l))
#text1 = "\n".join(lines[1] [c[1]:c[2]])
#textn = "\n".join(lines[i*2][c[3]:c[4]])
text1 = "\n".join( self._get_texts()[1 ][c[1]:c[2]] )
textn = "\n".join( self._get_texts()[i*2][c[3]:c[4]] )
matcher = difflib.SequenceMatcher(None, text1, textn)
#print "<<<\n%s\n---\n%s\n>>>" % (text1, textn)
tags = [b.get_tag_table().lookup("inline line") for b in bufs]
back = (0,0)
for o in matcher.get_opcodes():
if o[0] == "equal":
if (o[2]-o[1] < 3) or (o[4]-o[3] < 3):
back = o[4]-o[3], o[2]-o[1]
continue
for i in range(2):
s,e = starts[i].copy(), starts[i].copy()
s.forward_chars( o[1+2*i] - back[i] )
e.forward_chars( o[2+2*i] )
bufs[i].apply_tag(tags[i], s, e)
if 0:
text1 = "\n".join( self._get_texts()[1 ][c[1]:c[2]] )
textn = "\n".join( self._get_texts()[i*2][c[3]:c[4]] )
matcher = difflib.SequenceMatcher(None, text1, textn)
#print "<<<\n%s\n---\n%s\n>>>" % (text1, textn)
tags = [b.get_tag_table().lookup("inline line") for b in bufs]
back = (0,0)
yield 1
for o in matcher.get_opcodes():
if o[0] == "equal":
if (o[2]-o[1] < 3) or (o[4]-o[3] < 3):
back = o[4]-o[3], o[2]-o[1]
continue
for i in range(2):
s,e = starts[i].copy(), starts[i].copy()
s.forward_chars( o[1+2*i] - back[i] )
e.forward_chars( o[2+2*i] )
bufs[i].apply_tag(tags[i], s, e)
back = (0,0)
yield 1
yield 1
def save_file(self, pane, saveas=0):
......@@ -1072,7 +1071,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
#
################################################################################
class MeldBufferData:
class MeldBufferData(object):
__slots__ = ("modified", "writable", "filename", "encoding", "newlines")
def __init__(self, filename=None):
self.modified = 0
......@@ -1086,7 +1085,7 @@ class MeldBufferData:
# BufferInsertionAction
#
################################################################################
class BufferInsertionAction:
class BufferInsertionAction(object):
"""A helper to undo/redo text insertion into a text buffer"""
def __init__(self, buffer, offset, text):
self.buffer = buffer
......@@ -1104,7 +1103,7 @@ class BufferInsertionAction:
# BufferDeletionAction
#
################################################################################
class BufferDeletionAction:
class BufferDeletionAction(object):
"""A helper to undo/redo text deletion from a text buffer"""
def __init__(self, buffer, offset, text):
self.buffer = buffer
......@@ -1121,7 +1120,7 @@ class BufferDeletionAction:
# BufferModifiedAction
#
################################################################################
class BufferModifiedAction:
class BufferModifiedAction(object):
"""A helper set modified flag on a text buffer"""
def __init__(self, buffer, app):
self.buffer, self.app = buffer, app
......
......@@ -24,7 +24,7 @@ import gnome
import gnome.ui
import gettext
class Base:
class Base(object):
"""Base class for all glade objects.
This class handles loading the xml glade file and connects
......
......@@ -301,7 +301,7 @@ class PreferencesDialog(gnomeglade.Component):
#
################################################################################
class MeldStatusBar:
class MeldStatusBar(object):
def __init__(self, appbar):
self.appbar = appbar
......@@ -741,7 +741,7 @@ class MeldApp(gnomeglade.GnomeApp):
index = self.notebook.get_current_page()
if index >= 0:
return self.notebook.get_nth_page(index).get_data("pyobject")
class DummyDoc:
class DummyDoc(object):
def __getattr__(self, a): return lambda *x: None
return DummyDoc()
......@@ -785,7 +785,7 @@ Written by Stephen Kennedy <steve9000@users.sf.net>""") % version
#
################################################################################
def main():
class Unbuffered:
class Unbuffered(object):
def __init__(self, file):
self.file = file
def write(self, arg):
......
......@@ -63,7 +63,7 @@ def run_dialog( text, parent=None, messagetype=gtk.MESSAGE_WARNING, buttonstype=
d.destroy()
return ret
class struct:
class struct(object):
"""Similar to a dictionary except that members may be accessed as s.member.
Usage:
......@@ -143,7 +143,7 @@ def read_pipe_iter(command, errorstream, yield_interval=0.1, workdir=None):
When all the data is read, the entire string is yeilded.
If 'workdir' is specified the command is run from that directory.
"""
class sentinel:
class sentinel(object):
def __del__(self):
if self.pipe:
errorstream.write("killing '%s' with pid '%i'\n" % (command[0], self.pipe.pid) )
......
......@@ -61,7 +61,7 @@ FLOAT = "float"
##
class Preferences:
class Preferences(object):
"""Persistent preferences object.
Example:
......
......@@ -20,7 +20,7 @@
from __future__ import generators
import traceback
class SchedulerBase:
class SchedulerBase(object):
"""Base class with common functionality for schedulers.
Derived classes should implement the 'get_current_task' method.
......
......@@ -33,7 +33,7 @@ def on_undo_button_pressed():
import gobject
class GroupAction:
class GroupAction(object):
"""A group action combines several actions into one logical action.
"""
def __init__(self, seq):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment