Commit 146965ab authored by Tim Peters's avatar Tim Peters

Whitespace standardization.

parent 538f05c9
...@@ -702,7 +702,7 @@ class Aifc_write: ...@@ -702,7 +702,7 @@ class Aifc_write:
if len(self._markers) == 0: if len(self._markers) == 0:
return None return None
return self._markers return self._markers
def tell(self): def tell(self):
return self._nframeswritten return self._nframeswritten
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
Instead of Instead of
import dbm import dbm
d = dbm.open(file, 'w', 0666) d = dbm.open(file, 'w', 0666)
use use
import anydbm import anydbm
d = anydbm.open(file, 'w') d = anydbm.open(file, 'w')
The returned object is a dbhash, gdbm, dbm or dumbdbm object, The returned object is a dbhash, gdbm, dbm or dumbdbm object,
dependent on the type of database being opened (determined by whichdb dependent on the type of database being opened (determined by whichdb
...@@ -19,14 +19,14 @@ order). ...@@ -19,14 +19,14 @@ order).
It has the following interface (key and data are strings): It has the following interface (key and data are strings):
d[key] = data # store data at key (may override data at d[key] = data # store data at key (may override data at
# existing key) # existing key)
data = d[key] # retrieve data at key (raise KeyError if no data = d[key] # retrieve data at key (raise KeyError if no
# such key) # such key)
del d[key] # delete data stored at key (raises KeyError del d[key] # delete data stored at key (raises KeyError
# if no such key) # if no such key)
flag = d.has_key(key) # true if the key exists flag = d.has_key(key) # true if the key exists
list = d.keys() # return a list of all existing keys (slow!) list = d.keys() # return a list of all existing keys (slow!)
Future versions may change the order in which implementations are Future versions may change the order in which implementations are
tested for existence, add interfaces to other dbm-like tested for existence, add interfaces to other dbm-like
...@@ -43,44 +43,44 @@ only if it doesn't exist; and 'n' always creates a new database. ...@@ -43,44 +43,44 @@ only if it doesn't exist; and 'n' always creates a new database.
""" """
try: try:
class error(Exception): class error(Exception):
pass pass
except: except:
error = "anydbm.error" error = "anydbm.error"
_names = ['dbhash', 'gdbm', 'dbm', 'dumbdbm'] _names = ['dbhash', 'gdbm', 'dbm', 'dumbdbm']
_errors = [error] _errors = [error]
_defaultmod = None _defaultmod = None
for _name in _names: for _name in _names:
try: try:
_mod = __import__(_name) _mod = __import__(_name)
except ImportError: except ImportError:
continue continue
if not _defaultmod: if not _defaultmod:
_defaultmod = _mod _defaultmod = _mod
_errors.append(_mod.error) _errors.append(_mod.error)
if not _defaultmod: if not _defaultmod:
raise ImportError, "no dbm clone found; tried %s" % _names raise ImportError, "no dbm clone found; tried %s" % _names
error = tuple(_errors) error = tuple(_errors)
def open(file, flag = 'r', mode = 0666): def open(file, flag = 'r', mode = 0666):
# guess the type of an existing database # guess the type of an existing database
from whichdb import whichdb from whichdb import whichdb
result=whichdb(file) result=whichdb(file)
if result is None: if result is None:
# db doesn't exist # db doesn't exist
if 'c' in flag or 'n' in flag: if 'c' in flag or 'n' in flag:
# file doesn't exist and the new # file doesn't exist and the new
# flag was used so use default type # flag was used so use default type
mod = _defaultmod mod = _defaultmod
else: else:
raise error, "need 'c' or 'n' flag to open new db" raise error, "need 'c' or 'n' flag to open new db"
elif result == "": elif result == "":
# db type cannot be determined # db type cannot be determined
raise error, "db type could not be determined" raise error, "db type could not be determined"
else: else:
mod = __import__(result) mod = __import__(result)
return mod.open(file, flag, mode) return mod.open(file, flag, mode)
This diff is collapsed.
# -*- Mode: Python -*- # -*- Mode: Python -*-
# Id: asyncore.py,v 2.51 2000/09/07 22:29:26 rushing Exp # Id: asyncore.py,v 2.51 2000/09/07 22:29:26 rushing Exp
# Author: Sam Rushing <rushing@nightmare.com> # Author: Sam Rushing <rushing@nightmare.com>
# ====================================================================== # ======================================================================
# Copyright 1996 by Sam Rushing # Copyright 1996 by Sam Rushing
# #
# All Rights Reserved # All Rights Reserved
# #
# Permission to use, copy, modify, and distribute this software and # Permission to use, copy, modify, and distribute this software and
# its documentation for any purpose and without fee is hereby # its documentation for any purpose and without fee is hereby
# granted, provided that the above copyright notice appear in all # granted, provided that the above copyright notice appear in all
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# Rushing not be used in advertising or publicity pertaining to # Rushing not be used in advertising or publicity pertaining to
# distribution of the software without specific, written prior # distribution of the software without specific, written prior
# permission. # permission.
# #
# SAM RUSHING DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, # SAM RUSHING DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
# NO EVENT SHALL SAM RUSHING BE LIABLE FOR ANY SPECIAL, INDIRECT OR # NO EVENT SHALL SAM RUSHING BE LIABLE FOR ANY SPECIAL, INDIRECT OR
...@@ -28,22 +28,22 @@ ...@@ -28,22 +28,22 @@
"""Basic infrastructure for asynchronous socket service clients and servers. """Basic infrastructure for asynchronous socket service clients and servers.
There are only two ways to have a program on a single processor do "more There are only two ways to have a program on a single processor do "more
than one thing at a time". Multi-threaded programming is the simplest and than one thing at a time". Multi-threaded programming is the simplest and
most popular way to do it, but there is another very different technique, most popular way to do it, but there is another very different technique,
that lets you have nearly all the advantages of multi-threading, without that lets you have nearly all the advantages of multi-threading, without
actually using multiple threads. it's really only practical if your program actually using multiple threads. it's really only practical if your program
is largely I/O bound. If your program is CPU bound, then pre-emptive is largely I/O bound. If your program is CPU bound, then pre-emptive
scheduled threads are probably what you really need. Network servers are scheduled threads are probably what you really need. Network servers are
rarely CPU-bound, however. rarely CPU-bound, however.
If your operating system supports the select() system call in its I/O If your operating system supports the select() system call in its I/O
library (and nearly all do), then you can use it to juggle multiple library (and nearly all do), then you can use it to juggle multiple
communication channels at once; doing other work while your I/O is taking communication channels at once; doing other work while your I/O is taking
place in the "background." Although this strategy can seem strange and place in the "background." Although this strategy can seem strange and
complex, especially at first, it is in many ways easier to understand and complex, especially at first, it is in many ways easier to understand and
control than multi-threaded programming. The module documented here solves control than multi-threaded programming. The module documented here solves
many of the difficult problems for you, making the task of building many of the difficult problems for you, making the task of building
sophisticated high-performance network servers and clients a snap. sophisticated high-performance network servers and clients a snap.
""" """
import exceptions import exceptions
...@@ -191,7 +191,7 @@ class dispatcher: ...@@ -191,7 +191,7 @@ class dispatcher:
ar = repr(self.addr) ar = repr(self.addr)
except: except:
ar = 'no self.addr!' ar = 'no self.addr!'
return '<__repr__ (self) failed for object at %x (addr=%s)>' % (id(self),ar) return '<__repr__ (self) failed for object at %x (addr=%s)>' % (id(self),ar)
def add_channel (self, map=None): def add_channel (self, map=None):
...@@ -324,7 +324,7 @@ class dispatcher: ...@@ -324,7 +324,7 @@ class dispatcher:
# log and log_info maybe overriden to provide more sophisitcated # log and log_info maybe overriden to provide more sophisitcated
# logging and warning methods. In general, log is for 'hit' logging # logging and warning methods. In general, log is for 'hit' logging
# and 'log_info' is for informational, warning and error logging. # and 'log_info' is for informational, warning and error logging.
def log (self, message): def log (self, message):
sys.stderr.write ('log: %s\n' % str(message)) sys.stderr.write ('log: %s\n' % str(message))
...@@ -433,7 +433,7 @@ def compact_traceback (): ...@@ -433,7 +433,7 @@ def compact_traceback ():
while 1: while 1:
tbinfo.append (( tbinfo.append ((
tb.tb_frame.f_code.co_filename, tb.tb_frame.f_code.co_filename,
tb.tb_frame.f_code.co_name, tb.tb_frame.f_code.co_name,
str(tb.tb_lineno) str(tb.tb_lineno)
)) ))
tb = tb.tb_next tb = tb.tb_next
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
atexit.py - allow programmer to define multiple exit functions to be executed atexit.py - allow programmer to define multiple exit functions to be executed
upon normal program termination. upon normal program termination.
One public function, register, is defined. One public function, register, is defined.
""" """
_exithandlers = [] _exithandlers = []
...@@ -12,7 +12,7 @@ def _run_exitfuncs(): ...@@ -12,7 +12,7 @@ def _run_exitfuncs():
_exithandlers is traversed in reverse order so functions are executed _exithandlers is traversed in reverse order so functions are executed
last in, first out. last in, first out.
""" """
while _exithandlers: while _exithandlers:
func, targs, kargs = _exithandlers[-1] func, targs, kargs = _exithandlers[-1]
apply(func, targs, kargs) apply(func, targs, kargs)
...@@ -51,4 +51,3 @@ if __name__ == "__main__": ...@@ -51,4 +51,3 @@ if __name__ == "__main__":
register(x2, 12) register(x2, 12)
register(x3, 5, "bar") register(x3, 5, "bar")
register(x3, "no kwd args") register(x3, "no kwd args")
This diff is collapsed.
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