# -*- Mode: Python; tab-width: 4 -*-
-# Id: asynchat.py,v 2.26 2000/09/07 22:29:26 rushing Exp
+# Id: asynchat.py,v 2.26 2000/09/07 22:29:26 rushing Exp
# Author: Sam Rushing <rushing@nightmare.com>
# ======================================================================
else:
self.write(BINSTRING + s + object)
else:
- if unicode:
+ if unicode:
object = object.replace(u"\\", u"\\u005c")
object = object.replace(u"\n", u"\\u000a")
object = object.encode('raw-unicode-escape')
self.write(self.put(memo_len))
memo[d] = (memo_len, object)
dispatch[StringType] = save_string
-
+
def save_tuple(self, object):
write = self.write
return inst.fromchild, inst.tochild
__all__.extend(["Popen3", "Popen4"])
-
+
def _test():
cmd = "cat"
teststr = "ab cd\n"
initial_slashes = path.startswith('/')
# POSIX allows one or two initial slashes, but treats three or more
# as single slash.
- if (initial_slashes and
+ if (initial_slashes and
path.startswith('//') and not path.startswith('///')):
initial_slashes = 2
comps = path.split('/')
def _indent(ws, _expandtabs=string.expandtabs):
return len(_expandtabs(ws, TABWIDTH))
-
EMPTYSTRING = ''
-\f
+
def usage(code, msg=''):
print >> sys.stderr, __doc__ % globals()
if msg:
sys.exit(code)
-\f
+
class SMTPChannel(asynchat.async_chat):
COMMAND = 0
DATA = 1
self.push('354 End data with <CR><LF>.<CR><LF>')
-\f
+
class SMTPServer(asyncore.dispatcher):
def __init__(self, localaddr, remoteaddr):
self._localaddr = localaddr
"""
raise UnimplementedError
-\f
+
class DebuggingServer(SMTPServer):
# Do something with the gathered message
def process_message(self, peer, mailfrom, rcpttos, data):
print '------------ END MESSAGE ------------'
-\f
+
class PureProxy(SMTPServer):
def process_message(self, peer, mailfrom, rcpttos, data):
lines = data.split('\n')
return refused
-\f
+
class MailmanProxy(PureProxy):
def process_message(self, peer, mailfrom, rcpttos, data):
from cStringIO import StringIO
# since we don't expect a large number of recipients.
for rcpt, listname, command in listnames:
rcpttos.remove(rcpt)
- # If there's any non-list destined recipients left,
+ # If there's any non-list destined recipients left,
print >> DEBUGSTREAM, 'forwarding recips:', ' '.join(rcpttos)
if rcpttos:
refused = self._deliver(mailfrom, rcpttos, data)
msg.Enqueue(mlist, torequest=1)
-\f
+
class Options:
setuid = 1
classname = 'PureProxy'
return options
-\f
+
if __name__ == '__main__':
options = parseargs()
# Become nobody
parameters in the output will match the order of parameters in the
input.
"""
-
+
if hasattr(query,"items"):
# mapping objects
query = query.items()
class Error(Exception):
pass
-_browsers = {} # Dictionary of available browser controllers
-_tryorder = [] # Preference order of available browsers
+_browsers = {} # Dictionary of available browser controllers
+_tryorder = [] # Preference order of available browsers
def register(name, klass, instance=None):
"""Register a browser connector and, optionally, connection."""
# User gave us a command line, don't mess with it.
return browser
else:
- # User gave us a browser name.
+ # User gave us a browser name.
command = _browsers[browser.lower()]
if command[1] is None:
return command[0]()
def open(url, new=0, autoraise=1):
get().open(url, new, autoraise)
-def open_new(url): # Marked deprecated. May be removed in 2.1.
+def open_new(url): # Marked deprecated. May be removed in 2.1.
get().open(url, 1)
#
# support the user's platform.
#
-#
+#
# Platform support for Unix
#
def open(self, url, new=0, autoraise=1):
os.system(self.command % url)
- def open_new(self, url): # Deprecated. May be removed in 2.1.
+ def open_new(self, url): # Deprecated. May be removed in 2.1.
self.open(url)
# Easy cases first -- register console browsers if we have them.