x = None
try:
p = os.popen('${PAGER-more}', 'w')
- x = SaveLines().init(p)
+ x = SaveLines(p)
get_alt_textfile(selector, host, port, x.writeln)
except IOError, msg:
print 'IOError:', msg
f = open_savefile()
if not f:
return
- x = SaveLines().init(f)
+ x = SaveLines(f)
try:
get_alt_textfile(selector, host, port, x.writeln)
print 'Done.'
f = open_savefile()
if not f:
return
- x = SaveWithProgress().init(f)
+ x = SaveWithProgress(f)
get_alt_binary(selector, host, port, x.write, 8*1024)
x.close()
# Class used to save lines, appending a newline to each line
class SaveLines:
- def init(self, f):
+ def __init__(self, f):
self.f = f
- return self
def writeln(self, line):
self.f.write(line + '\n')
def close(self):
# Class used to save data while showing progress
class SaveWithProgress:
- def init(self, f):
+ def __init__(self, f):
self.f = f
- return self
def write(self, data):
sys.stdout.write('#')
sys.stdout.flush()
# Global variables
-class struct(): pass # Class to define featureless structures
+class struct: pass # Class to define featureless structures
G = struct() # oHlds writable global variables
mainloop.register(win)
mainloop.mainloop()
-def lpdispatch(type, win, detail):
+def lpdispatch(event):
+ type, win, detail = event
if type == WE_CLOSE or type == WE_CHAR and detail in ('q', 'Q'):
mainloop.unregister(win)
elif type == WE_DRAW:
save_stdout = sys.stdout
save_stderr = sys.stderr
try:
- sys.stdin = sys.stdout = sys.stderr = IOWindow().init(win)
+ sys.stdin = sys.stdout = sys.stderr = IOWindow(win)
win.busy = 1
try:
exec(command, win.globals)
#
class IOWindow:
#
- def init(self, win):
+ def __init__(self, win):
self.win = win
- return self
#
def readline(self, *unused_args):
n = len(inputwindows)