# Initialize a queue object with a given maximum size
# (If maxsize is <= 0, the maximum size is infinite)
- def init(self, maxsize):
- import thread
+ def __init__(self, maxsize):
self._init(maxsize)
self.mutex = thread.allocate_lock()
self.esema = thread.allocate_lock()
self.esema.acquire_lock()
self.fsema = thread.allocate_lock()
- return self
# Get an approximation of the queue size (not reliable!)
def qsize(self):
_write_long(f, lomant)
class Chunk:
- def init(self, file):
+ def __init__(self, file):
self.file = file
self.chunkname = self.file.read(4)
if len(self.chunkname) < 4:
self.chunksize = _read_long(self.file)
self.size_read = 0
self.offset = self.file.tell()
- return self
def rewind(self):
self.file.seek(self.offset, 0)
# These variables are available to the user though appropriate
# methods of this class:
# _file -- the open file with methods read(), close(), and seek()
- # set through the init() ir initfp() method
+ # set through the __init__() method
# _nchannels -- the number of audio channels
# available through the getnchannels() method
# _nframes -- the number of audio frames
#DEBUG: SGI's soundfiler has a bug. There should
# be no need to check for EOF here.
try:
- chunk = Chunk().init(self._file)
+ chunk = Chunk(self._file)
except EOFError:
if formlength == 8:
print 'Warning: FORM chunk size too large'
else:
params[3] = 24
self._decomp.SetParams(params)
- return self
- def init(self, filename):
- return self.initfp(builtin.open(filename, 'r'))
+ def __init__(self, f):
+ if type(f) == type(''):
+ f = builtin.open(f, 'r')
+ # else, assume it is an open file object already
+ self.initfp(f)
def __del__(self):
if self._file:
# These variables are user settable through appropriate methods
# of this class:
# _file -- the open file with methods write(), close(), tell(), seek()
- # set through the init() or initfp() method
+ # set through the __init__() method
# _comptype -- the AIFF-C compression type ('NONE' in AIFF)
# set through the setcomptype() or setparams() method
# _compname -- the human-readable AIFF-C compression type
# _datalength -- the size of the audio samples written to the header
# _datawritten -- the size of the audio samples actually written
- def init(self, filename):
- self = self.initfp(builtin.open(filename, 'w'))
+ def __init__(self, f):
+ if type(f) == type(''):
+ f = builtin.open(f, 'w')
+ # else, assume it is an open file object already
+ self.initfp(f)
if filename[-5:] == '.aiff':
self._aifc = 0
else:
self._aifc = 1
- return self
def initfp(self, file):
self._file = file
self._markers = []
self._marklength = 0
self._aifc = 1 # AIFF-C is default
- return self
def __del__(self):
if self._file:
_write_long(self._file, pos)
_write_string(self._file, name)
-def open(filename, mode):
+def open(f, mode):
if mode == 'r':
- return Aifc_read().init(filename)
+ return Aifc_read(f)
elif mode == 'w':
- return Aifc_write().init(filename)
+ return Aifc_write(f)
else:
raise Error, 'mode must be \'r\' or \'w\''
-def openfp(filep, mode):
- if mode == 'r':
- return Aifc_read().initfp(filep)
- elif mode == 'w':
- return Aifc_write().initfp(filep)
- else:
- raise Error, 'mode must be \'r\' or \'w\''
+openfp = open # B/W compatibility
def __init__(self):
self.breaks = {}
-
- def init(self): # BW compat only
- return self
def reset(self):
self.botframe = None
self.prompt = PROMPT
self.identchars = IDENTCHARS
self.lastcmd = ''
-
- def init(self): # BW compat only
- return self
def cmdloop(self):
stop = None
if args[1:]:
apply(self.login, args[1:])
- # Old init method (explicitly called by caller)
- def init(self, *args):
- if args:
- apply(self.connect, args)
-
# Connect to host. Arguments:
# - host: hostname to connect to (default previous host)
# - port: port to connect to (default previous port)
self.welcome = self.getresp()
# Get the welcome message from the server
- # (this is read and squirreled away by init())
+ # (this is read and squirreled away by connect())
def getwelcome(self):
if self.debugging: print '*welcome*', `self.welcome`
return self.welcome
forms = {}
for name in altforms.keys():
altobj, altlist = altforms[name]
- obj = _newobj().init()
+ obj = _newobj()
obj.make(altobj)
list = []
for altobj in altlist:
- nobj = _newobj().init()
+ nobj = _newobj()
nobj.make(altobj)
list.append(nobj)
forms[name] = obj, list
# Internal class: a convient place to store object info fields
#
class _newobj:
- def init(self):
- return self
def add(self, name, value):
self.__dict__[name] = value
def make(self, dict):
file.seek(pos)
def _parse_object(file):
- obj = _newobj().init()
+ obj = _newobj()
while 1:
pos = file.tell()
datum = _parse_1_line(file)
elif len(arg) == 2:
self.player = cd.open(arg[0], arg[1])
else:
- raise Error, 'bad init call'
+ raise Error, 'bad __init__ call'
self.list = []
self.callbacks = [(None, None)] * 8
self.parser = cd.createparser()
table = {}
-t = pipes.Template().init()
+t = pipes.Template()
t.append('fromppm $IN $OUT', 'ff')
table['ppm'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
t.append('fromppm $IN $OUT', 'ff')
table['pnm'] = t
table['pgm'] = t
table['pbm'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('fromgif $IN $OUT', 'ff')
table['gif'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('tifftopnm', '--')
t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
t.append('fromppm $IN $OUT', 'ff')
table['tiff'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('rasttopnm', '--')
t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
t.append('fromppm $IN $OUT', 'ff')
table['rast'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('djpeg', '--')
t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
t.append('fromppm $IN $OUT', 'ff')
table['jpeg'] = t
-uncompress = pipes.Template().init()
+uncompress = pipes.Template()
uncompress.append('uncompress', '--')
if event[0] <> WE_TIMER:
mainloop.dispatch(event)
-q = sched.scheduler().init(time.millitimer, delayfunc)
+q = sched.scheduler(time.millitimer, delayfunc)
# Export functions enter, enterabs and cancel just like a scheduler
#
class BaseWindow:
- def init(self, title):
+ def __init__(self, title):
self.win = stdwin.open(title)
self.win.dispatch = self.dispatch
mainloop.register(self.win)
- return self
# def reopen(self):
# title = self.win.gettitle()
# Pass the window's drawing object, and left, top, right
# coordinates of the drawing space as arguments.
#
- def init(self, d, left, top, right):
+ def __init__(self, d, left, top, right):
self.d = d # Drawing object
self.left = left # Left margin
self.right = right # Right margin
self.justify = 1
self.setfont('') # Default font
self._reset() # Prepare for new line
- return self
#
# Reset for start of fresh line.
#
w.change((0, 0), (1000, 1000))
elif type == WE_DRAW:
width, height = winsize
- f = formatter().init(w.begindrawing(), 0, 0, width)
+ f = formatter(w.begindrawing(), 0, 0, width)
f.center = center
f.justify = justify
if not center:
#
class Dialog:
#
- def init(self, title):
+ def __init__(self, title):
self.window = stdwin.open(title)
self.window.dispatch = self.dispatch
register(self.window)
- return self
#
def close(self):
unregister(self.window)
class TextWindow(basewin.BaseWindow):
- def init(self, title, contents):
+ def __init__(self, title, contents):
self.contents = contents
self.linecount = countlines(self.contents)
#
width = WIDTH*stdwin.textwidth('0')
height = lh*min(MAXHEIGHT, self.linecount)
stdwin.setdefwinsize(width, height)
- self = basewin.BaseWindow.init(self, title)
+ basewin.BaseWindow.__init__(self, title)
#
self.win.setdocsize(0, self.bottom)
self.initeditor()
- return self
def initeditor(self):
r = (self.leftmargin, self.top), (self.rightmargin, self.bottom)
class SourceWindow(TextWindow):
- def init(self, filename):
+ def __init__(self, filename):
self.filename = filename
f = open(self.filename, 'r')
contents = f.read()
f.close()
- return TextWindow.init(self, self.filename, contents)
+ TextWindow.__init__(self, self.filename, contents)
# ------------------------------ testing ------------------------------
def test():
import mainloop
- sw = SourceWindow().init(TESTFILE)
+ sw = SourceWindow(TESTFILE)
mainloop.mainloop()
class Wdb(bdb.Bdb, basewin.BaseWindow): # Window debugger
- def init(self):
+ def __init__(self):
self.sourcewindows = {}
self.framewindows = {}
- self = bdb.Bdb.init(self)
+ bdb.Bdb.__init__(self)
width = WIDTH*stdwin.textwidth('0')
height = HEIGHT*stdwin.lineheight()
stdwin.setdefwinsize(width, height)
- self = basewin.BaseWindow.init(self, '--Stack--')
+ basewin.BaseWindow.__init__(self, '--Stack--')
self.closed = 0
- return self
def reset(self):
if self.closed: raise RuntimeError, 'already closed'
if not self.sourcewindows.has_key(fn):
import wdbsrcwin
try:
- self.sourcewindows[fn] = \
- wdbsrcwin.DebuggerSourceWindow(). \
- init(self, fn)
+ self.sourcewindows[fn] = wdbsrcwin. \
+ DebuggerSourceWindow(self, fn)
except IOError:
stdwin.fleep()
return
else:
import wdbframewin
self.framewindows[name] = \
- wdbframewin.FrameWindow().init(self, \
+ wdbframewin.FrameWindow(self, \
self.curframe, \
self.curframe.f_locals, name)
do_f = do_frame
else:
import wdbframewin
self.framewindows[name] = \
- wdbframewin.FrameWindow().init(self, \
+ wdbframewin.FrameWindow(self, \
self.curframe, \
self.curframe.f_globals, name)
do_g = do_globalframe
# Simplified interface
def run(statement):
- x = Wdb().init()
+ x = Wdb()
try: x.run(statement)
finally: x.close()
def runctx(statement, globals, locals):
- x = Wdb().init()
+ x = Wdb()
try: x.runctx(statement, globals, locals)
finally: x.close()
def runcall(*args):
- x = Wdb().init()
- try: apply(Pdb().init().runcall, args)
+ x = Wdb()
+ try: apply(x.runcall, args)
finally: x.close()
# Post-Mortem interface
def post_mortem(traceback):
- p = Pdb().init()
- p.reset()
- p.interaction(None, traceback)
+ x = Wdb()
+ x.reset()
+ x.interaction(None, traceback)
def pm():
import sys
class FrameWindow(basewin.BaseWindow):
- def init(self, debugger, frame, dict, name):
+ def __init__(self, debugger, frame, dict, name):
self.debugger = debugger
self.frame = frame # Not used except for identity tests
self.dict = dict
width = WIDTH*stdwin.textwidth('0')
height = nl*stdwin.lineheight()
stdwin.setdefwinsize(width, height)
- self = basewin.BaseWindow.init(self, '--Frame ' + name + '--')
+ basewin.BaseWindow.__init__(
+ self, '--Frame ' + name + '--')
# XXX Should use current function name
self.initeditor()
self.displaylist = ['>>>', '', '-'*WIDTH]
self.refreshframe()
- return self
def initeditor(self):
r = (stdwin.textwidth('>>> '), 0), (30000, stdwin.lineheight())
self.debugger.framewindows[name].popup()
else:
self.debugger.framewindows[name] = \
- FrameWindow().init(self.debugger,
+ FrameWindow(self.debugger,
self.frame, value.__dict__,
name)
return
class DebuggerSourceWindow(srcwin.SourceWindow):
- def init(self, debugger, filename):
+ def __init__(self, debugger, filename):
self.debugger = debugger
self.curlineno = 0
self.focus = 0
- return srcwin.SourceWindow.init(self, filename)
+ srcwin.SourceWindow.__init__(self, filename)
def close(self):
del self.debugger.sourcewindows[self.filename]
class Message(rfc822.Message):
- def init(self, fp):
- self = rfc822.Message.init(self, fp)
+ def __init__(self, fp):
+ rfc822.Message.__init__(self, fp)
self.encodingheader = \
self.getheader('content-transfer-encoding')
self.typeheader = \
self.getheader('content-type')
self.parsetype()
self.parseplist()
- return self
def parsetype(self):
str = self.typeheader
# Suggested use:
#
# real_fp = open(...)
-# fp = MultiFile().init(real_fp)
+# fp = MultiFile(real_fp)
#
# "read some lines from fp"
# fp.push(separator)
class MultiFile:
#
- def init(self, fp):
+ def __init__(self, fp):
self.fp = fp
self.stack = [] # Grows down
self.level = 0
self.last = 0
self.start = self.fp.tell()
self.posstack = [] # Grows down
- return self
#
def tell(self):
if self.level > 0:
#
# Create a new mutex -- initially unlocked
#
- def init(self):
+ def __init__(self):
self.locked = 0
self.queue = []
- return self
#
# Test the locked bit of the mutex
#
# Example:
#
# >>> from nntplib import NNTP
-# >>> s = NNTP().init('charon')
+# >>> s = NNTP('charon')
# >>> resp, count, first, last, name = s.group('nlnet.misc')
# >>> print 'Group', name, 'has', count, 'articles, range', first, 'to', last
# Group nlnet.misc has 525 articles, range 6960 to 7485
# - host: hostname to connect to
# - port: port to connect to (default the standard NNTP port)
- def init(self, host, *args):
+ def __init__(self, host, *args):
if len(args) > 1: raise TypeError, 'too many args'
if args: port = args[0]
else: port = NNTP_PORT
self.file = self.sock.makefile('r')
self.debugging = 0
self.welcome = self.getresp()
- return self
# Get the welcome message from the server
- # (this is read and squirreled away by init()).
+ # (this is read and squirreled away by __init__()).
# If the response code is 200, posting is allowed;
# if it 201, posting is not allowed
bdb.Bdb.__init__(self)
cmd.Cmd.__init__(self)
self.prompt = '(Pdb) '
-
- def init(self): # BW compat only
- return self
def reset(self):
bdb.Bdb.reset(self)
# -----------
#
# To create a template:
-# t = Template().init()
+# t = Template()
#
# To add a conversion step to a template:
# t.append(command, kind)
class Template:
- # Template().init() returns a fresh pipeline template
- def init(self):
+ # Template() returns a fresh pipeline template
+ def __init__(self):
self.debugging = 0
self.reset()
- return self
# t.__repr__() implements `t`
def __repr__(self):
# t.clone() returns a new pipeline template with identical
# initial state as the current one
def clone(self):
- t = Template().init()
+ t = Template()
t.steps = self.steps[:]
t.debugging = self.debugging
return t
def test():
import os
print 'Testing...'
- t = Template().init()
+ t = Template()
t.append('togif $IN $OUT', 'ff')
t.append('giftoppm', '--')
t.append('ppmtogif >$OUT', '-f')
forms = {}
for name in altforms.keys():
altobj, altlist = altforms[name]
- obj = _newobj().init()
+ obj = _newobj()
obj.make(altobj)
list = []
for altobj in altlist:
- nobj = _newobj().init()
+ nobj = _newobj()
nobj.make(altobj)
list.append(nobj)
forms[name] = obj, list
# Internal class: a convient place to store object info fields
#
class _newobj:
- def init(self):
- return self
def add(self, name, value):
self.__dict__[name] = value
def make(self, dict):
file.seek(pos)
def _parse_object(file):
- obj = _newobj().init()
+ obj = _newobj()
while 1:
pos = file.tell()
datum = _parse_1_line(file)
elif len(arg) == 2:
self.player = cd.open(arg[0], arg[1])
else:
- raise Error, 'bad init call'
+ raise Error, 'bad __init__ call'
self.list = []
self.callbacks = [(None, None)] * 8
self.parser = cd.createparser()
table = {}
-t = pipes.Template().init()
+t = pipes.Template()
t.append('fromppm $IN $OUT', 'ff')
table['ppm'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
t.append('fromppm $IN $OUT', 'ff')
table['pnm'] = t
table['pgm'] = t
table['pbm'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('fromgif $IN $OUT', 'ff')
table['gif'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('tifftopnm', '--')
t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
t.append('fromppm $IN $OUT', 'ff')
table['tiff'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('rasttopnm', '--')
t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
t.append('fromppm $IN $OUT', 'ff')
table['rast'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('djpeg', '--')
t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
t.append('fromppm $IN $OUT', 'ff')
table['jpeg'] = t
-uncompress = pipes.Template().init()
+uncompress = pipes.Template()
uncompress.append('uncompress', '--')
class Profile:
- def init(self):
+ def __init__(self):
self.timings = {}
self.debug = None
self.call_level = 0
self.profile_func = None
self.profiling = 0
- return self
def profile(self, funcname):
if not self.profile_func:
return d
class Stats:
- def init(self, file):
+ def __init__(self, file):
f = open(file, 'r')
self.stats = marshal.load(f)
f.close()
self.stats_list = None
- return self
def print_stats(self):
print_title()
# simplified user interface
def run(statement, *args):
- prof = Profile().init()
+ prof = Profile()
try:
prof.run(statement)
except SystemExit:
# test command with debugging
def debug():
- prof = Profile().init()
+ prof = Profile()
prof.debug = 1
try:
prof.run('import x; x.main()')
from regex_syntax import *
class Prog:
- def init(self, pat):
+ def __init__(self, pat):
save_syntax = regex.set_syntax(RE_SYNTAX_AWK)
try:
self.prog = regex.compile(pat)
finally:
xxx = regex.set_syntax(save_syntax)
- return self
def match(self, *args):
if len(args) == 2:
str, offset = args
return regs[:i]
def compile(pat):
- return Prog().init(pat)
+ return Prog(pat)
cache_pat = None
cache_prog = None
import string
class Repr:
- def init(self):
+ def __init__(self):
self.maxlevel = 6
self.maxtuple = 6
self.maxlist = 6
self.maxstring = 30
self.maxlong = 40
self.maxother = 20
- return self
def repr(self, x):
return self.repr1(x, self.maxlevel)
def repr1(self, x, level):
s = s[:i] + '...' + s[len(s)-j:]
return s
-aRepr = Repr().init()
+aRepr = Repr()
repr = aRepr.repr
# fp = open(file, 'r')
# (or use any other legal way of getting an open file object, e.g. use
# sys.stdin or call os.popen()).
-# Then pass the open file object to the init() method of Message:
-# m = Message().init(fp)
+# Then pass the open file object to the Message() constructor:
+# m = Message(fp)
#
# To get the text of a particular header there are several methods:
# str = m.getheader(name)
# Initialize the class instance and read the headers.
- def init(self, fp):
+ def __init__(self, fp):
self.fp = fp
#
try:
self.startofbody = self.fp.tell()
except IOError:
self.startofbody = None
- #
- return self
# Rewind the file to the start of the body (if seekable).
#
# Initialize a new instance, passing the time and delay functions
#
- def init(self, timefunc, delayfunc):
+ def __init__(self, timefunc, delayfunc):
self.queue = []
self.timefunc = timefunc
self.delayfunc = delayfunc
- return self
#
# Enter a new event in the queue at an absolute time.
# Returns an ID for the event which can be used
if event[0] <> WE_TIMER:
mainloop.dispatch(event)
-q = sched.scheduler().init(time.millitimer, delayfunc)
+q = sched.scheduler(time.millitimer, delayfunc)
# Export functions enter, enterabs and cancel just like a scheduler
#
class BaseWindow:
- def init(self, title):
+ def __init__(self, title):
self.win = stdwin.open(title)
self.win.dispatch = self.dispatch
mainloop.register(self.win)
- return self
# def reopen(self):
# title = self.win.gettitle()
# Pass the window's drawing object, and left, top, right
# coordinates of the drawing space as arguments.
#
- def init(self, d, left, top, right):
+ def __init__(self, d, left, top, right):
self.d = d # Drawing object
self.left = left # Left margin
self.right = right # Right margin
self.justify = 1
self.setfont('') # Default font
self._reset() # Prepare for new line
- return self
#
# Reset for start of fresh line.
#
w.change((0, 0), (1000, 1000))
elif type == WE_DRAW:
width, height = winsize
- f = formatter().init(w.begindrawing(), 0, 0, width)
+ f = formatter(w.begindrawing(), 0, 0, width)
f.center = center
f.justify = justify
if not center:
#
class Dialog:
#
- def init(self, title):
+ def __init__(self, title):
self.window = stdwin.open(title)
self.window.dispatch = self.dispatch
register(self.window)
- return self
#
def close(self):
unregister(self.window)
class TextWindow(basewin.BaseWindow):
- def init(self, title, contents):
+ def __init__(self, title, contents):
self.contents = contents
self.linecount = countlines(self.contents)
#
width = WIDTH*stdwin.textwidth('0')
height = lh*min(MAXHEIGHT, self.linecount)
stdwin.setdefwinsize(width, height)
- self = basewin.BaseWindow.init(self, title)
+ basewin.BaseWindow.__init__(self, title)
#
self.win.setdocsize(0, self.bottom)
self.initeditor()
- return self
def initeditor(self):
r = (self.leftmargin, self.top), (self.rightmargin, self.bottom)
class SourceWindow(TextWindow):
- def init(self, filename):
+ def __init__(self, filename):
self.filename = filename
f = open(self.filename, 'r')
contents = f.read()
f.close()
- return TextWindow.init(self, self.filename, contents)
+ TextWindow.__init__(self, self.filename, contents)
# ------------------------------ testing ------------------------------
def test():
import mainloop
- sw = SourceWindow().init(TESTFILE)
+ sw = SourceWindow(TESTFILE)
mainloop.mainloop()
class Wdb(bdb.Bdb, basewin.BaseWindow): # Window debugger
- def init(self):
+ def __init__(self):
self.sourcewindows = {}
self.framewindows = {}
- self = bdb.Bdb.init(self)
+ bdb.Bdb.__init__(self)
width = WIDTH*stdwin.textwidth('0')
height = HEIGHT*stdwin.lineheight()
stdwin.setdefwinsize(width, height)
- self = basewin.BaseWindow.init(self, '--Stack--')
+ basewin.BaseWindow.__init__(self, '--Stack--')
self.closed = 0
- return self
def reset(self):
if self.closed: raise RuntimeError, 'already closed'
if not self.sourcewindows.has_key(fn):
import wdbsrcwin
try:
- self.sourcewindows[fn] = \
- wdbsrcwin.DebuggerSourceWindow(). \
- init(self, fn)
+ self.sourcewindows[fn] = wdbsrcwin. \
+ DebuggerSourceWindow(self, fn)
except IOError:
stdwin.fleep()
return
else:
import wdbframewin
self.framewindows[name] = \
- wdbframewin.FrameWindow().init(self, \
+ wdbframewin.FrameWindow(self, \
self.curframe, \
self.curframe.f_locals, name)
do_f = do_frame
else:
import wdbframewin
self.framewindows[name] = \
- wdbframewin.FrameWindow().init(self, \
+ wdbframewin.FrameWindow(self, \
self.curframe, \
self.curframe.f_globals, name)
do_g = do_globalframe
# Simplified interface
def run(statement):
- x = Wdb().init()
+ x = Wdb()
try: x.run(statement)
finally: x.close()
def runctx(statement, globals, locals):
- x = Wdb().init()
+ x = Wdb()
try: x.runctx(statement, globals, locals)
finally: x.close()
def runcall(*args):
- x = Wdb().init()
- try: apply(Pdb().init().runcall, args)
+ x = Wdb()
+ try: apply(x.runcall, args)
finally: x.close()
# Post-Mortem interface
def post_mortem(traceback):
- p = Pdb().init()
- p.reset()
- p.interaction(None, traceback)
+ x = Wdb()
+ x.reset()
+ x.interaction(None, traceback)
def pm():
import sys
class FrameWindow(basewin.BaseWindow):
- def init(self, debugger, frame, dict, name):
+ def __init__(self, debugger, frame, dict, name):
self.debugger = debugger
self.frame = frame # Not used except for identity tests
self.dict = dict
width = WIDTH*stdwin.textwidth('0')
height = nl*stdwin.lineheight()
stdwin.setdefwinsize(width, height)
- self = basewin.BaseWindow.init(self, '--Frame ' + name + '--')
+ basewin.BaseWindow.__init__(
+ self, '--Frame ' + name + '--')
# XXX Should use current function name
self.initeditor()
self.displaylist = ['>>>', '', '-'*WIDTH]
self.refreshframe()
- return self
def initeditor(self):
r = (stdwin.textwidth('>>> '), 0), (30000, stdwin.lineheight())
self.debugger.framewindows[name].popup()
else:
self.debugger.framewindows[name] = \
- FrameWindow().init(self.debugger,
+ FrameWindow(self.debugger,
self.frame, value.__dict__,
name)
return
class DebuggerSourceWindow(srcwin.SourceWindow):
- def init(self, debugger, filename):
+ def __init__(self, debugger, filename):
self.debugger = debugger
self.curlineno = 0
self.focus = 0
- return srcwin.SourceWindow.init(self, filename)
+ srcwin.SourceWindow.__init__(self, filename)
def close(self):
del self.debugger.sourcewindows[self.filename]
break
else:
self._info = ''
- return self
- def init(self, filename):
- import builtin
- return self.initfp(builtin.open(filename, 'r'))
+ def __init__(self, f):
+ if type(f) == type(''):
+ import builtin
+ f = builtin.open(f, 'r')
+ self.initfp(f)
def __del__(self):
if self._file:
self._file = None
class Au_write:
- def init(self, filename):
- import builtin
- return self.initfp(builtin.open(filename, 'w'))
+ def __init__(self, f):
+ if type(f) == type(''):
+ import builtin
+ f = builtin.open(f, 'w')
+ self.initfp(f)
def initfp(self, file):
self._file = file
self._datalength = 0
self._info = ''
self._comptype = 'ULAW' # default is U-law
- return self
def __del__(self):
if self._file:
self._datalength = self._datawritten
self._file.seek(0, 2)
-def open(filename, mode):
+def open(f, mode):
if mode == 'r':
- return Au_read().init(filename)
+ return Au_read(f)
elif mode == 'w':
- return Au_write().init(filename)
+ return Au_write(f)
else:
raise Error, "mode must be 'r' or 'w'"
-def openfp(filep, mode):
- if mode == 'r':
- return Au_read().initfp(filep)
- elif mode == 'w':
- return Au_write().initfp(filep)
- else:
- raise Error, "mode must be 'r' or 'w'"
+openfp = open
# Class substituted for sys.stdout, to compare it with the given file
class Compare:
- def init(self, filename):
+ def __init__(self, filename):
self.fp = open(filename, 'r')
- return self
def write(self, data):
expected = self.fp.read(len(data))
if data <> expected:
filename = findfile('testall.out')
real_stdout = sys.stdout
try:
- sys.stdout = Compare().init(filename)
+ sys.stdout = Compare(filename)
import testall
finally:
sys.stdout = real_stdout
table = {}
-t = pipes.Template().init()
+t = pipes.Template()
t.append('sox -t au - -t aiff -r 8000 -', '--')
table['au'] = t
# XXX files sampled at 5.5k or 7.333k; however this means that files
# XXX sampled at 11k are unnecessarily expanded.
# XXX Similar comments apply to some other file types.
-t = pipes.Template().init()
+t = pipes.Template()
t.append('sox -t hcom - -t aiff -r 22050 -', '--')
table['hcom'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('sox -t voc - -t aiff -r 11025 -', '--')
table['voc'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('sox -t wav - -t aiff -', '--')
table['wav'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('sox -t 8svx - -t aiff -r 16000 -', '--')
table['8svx'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('sox -t sndt - -t aiff -r 16000 -', '--')
table['sndt'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('sox -t sndr - -t aiff -r 16000 -', '--')
table['sndr'] = t
-uncompress = pipes.Template().init()
+uncompress = pipes.Template()
uncompress.append('uncompress', '--')
# Without arguments, initialize from current time.
# With arguments (x, y, z), initialize from them.
#
- def init(self, *xyz):
+ def __init__(self, *xyz):
if not xyz:
# Initialize from current time
import time
# Initialize from arguments (x, y, z)
x, y, z = xyz
self.seed(x, y, z)
- return self
#
# Set the seed from (x, y, z).
# These must be integers in the range [0, 256).
# Initialize from the current time
#
-_inst = whrandom().init()
+_inst = whrandom()
seed = _inst.seed
random = _inst.random
uniform = _inst.uniform