rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
server_version = "Python-urllib/%s" % __version__ self.addheaders = [('User-agent', server_version)]
self.addheaders = [('User-agent', self.version)]
def __init__(self, proxies=None, **x509): if proxies is None: proxies = getproxies() assert hasattr(proxies, 'has_key'), "proxies must be a mapping" self.proxies = proxies self.key_file = x509.get('key_file') self.cert_file = x509.get('cert_file') server_version = "Python-urllib/%s" % __version__ self.addheaders = [('User-agent', server_version)] self.__tempfiles = [] self.__unlink = os.unlink # See cleanup() self.tempcache = None # Undocumented feature: if you assign {} to tempcache, # it is used to cache files retrieved with # self.retrieve(). This is not enabled by default # since it does not work for changing documents (and I # haven't got the logic to check expiration headers # yet). self.ftpcache = ftpcache # Undocumented feature: you can use a different # ftp cache by assigning to the .ftpcache member; # in case you want logically independent URL openers # XXX This is not threadsafe. Bah.
ba3113807dc63e827463d641c1b4511b064d3c88 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ba3113807dc63e827463d641c1b4511b064d3c88/urllib.py
"""Converts self to a int, truncating if necessary."""
"""Converts self to an int, truncating if necessary."""
def __int__(self): """Converts self to a int, truncating if necessary.""" if self._is_special: if self._isnan(): context = getcontext() return context._raise_error(InvalidContext) elif self._isinfinity(): raise OverflowError, "Cannot convert infinity to long" if self._exp >= 0: s = ''.join(map(str, self._int)) + '0'*self._exp else: s = ''.join(map(str, self._int))[:self._exp] if s == '': s = '0' sign = '-'*self._sign return int(sign + s)
46b0802ccd9a9c47b27a285526fbb2a8bee5b8cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/46b0802ccd9a9c47b27a285526fbb2a8bee5b8cb/decimal.py
def __init__(self, flist=None, filename=None, key=None, root=None): currentTheme=idleConf.CurrentTheme() self.flist = flist root = root or flist.root self.root = root self.menubar = Menu(root) self.top = top = self.Toplevel(root, menu=self.menubar) if flist: self.vars = flist.vars #self.top.instanceDict makes flist.inversedict avalable to #configDialog.py so it can access all EditorWindow instaces self.top.instanceDict=flist.inversedict self.recentFilesPath=os.path.join(idleConf.GetUserCfgDir(), 'recent-files.lst') self.vbar = vbar = Scrollbar(top, name='vbar') self.text_frame = text_frame = Frame(top) self.text = text = Text(text_frame, name='text', padx=5, wrap='none', foreground=idleConf.GetHighlight(currentTheme, 'normal',fgBg='fg'), background=idleConf.GetHighlight(currentTheme, 'normal',fgBg='bg'), highlightcolor=idleConf.GetHighlight(currentTheme, 'hilite',fgBg='fg'), highlightbackground=idleConf.GetHighlight(currentTheme, 'hilite',fgBg='bg'), insertbackground=idleConf.GetHighlight(currentTheme, 'cursor',fgBg='fg'), width=idleConf.GetOption('main','EditorWindow','width'), height=idleConf.GetOption('main','EditorWindow','height') )
5e65ce671c3d3113035dd7783b79d395c9d71b3d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5e65ce671c3d3113035dd7783b79d395c9d71b3d/EditorWindow.py
def __init__(self, flist=None, filename=None, key=None, root=None): currentTheme=idleConf.CurrentTheme() self.flist = flist root = root or flist.root self.root = root self.menubar = Menu(root) self.top = top = self.Toplevel(root, menu=self.menubar) if flist: self.vars = flist.vars #self.top.instanceDict makes flist.inversedict avalable to #configDialog.py so it can access all EditorWindow instaces self.top.instanceDict=flist.inversedict self.recentFilesPath=os.path.join(idleConf.GetUserCfgDir(), 'recent-files.lst') self.vbar = vbar = Scrollbar(top, name='vbar') self.text_frame = text_frame = Frame(top) self.text = text = Text(text_frame, name='text', padx=5, wrap='none', foreground=idleConf.GetHighlight(currentTheme, 'normal',fgBg='fg'), background=idleConf.GetHighlight(currentTheme, 'normal',fgBg='bg'), highlightcolor=idleConf.GetHighlight(currentTheme, 'hilite',fgBg='fg'), highlightbackground=idleConf.GetHighlight(currentTheme, 'hilite',fgBg='bg'), insertbackground=idleConf.GetHighlight(currentTheme, 'cursor',fgBg='fg'), width=idleConf.GetOption('main','EditorWindow','width'), height=idleConf.GetOption('main','EditorWindow','height') )
5e65ce671c3d3113035dd7783b79d395c9d71b3d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5e65ce671c3d3113035dd7783b79d395c9d71b3d/EditorWindow.py
def addcolorizer(self): if self.color: return ##print "Add colorizer" self.per.removefilter(self.undo) self.color = self.ColorDelegator() self.per.insertfilter(self.color) self.per.insertfilter(self.undo)
5e65ce671c3d3113035dd7783b79d395c9d71b3d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5e65ce671c3d3113035dd7783b79d395c9d71b3d/EditorWindow.py
def rmcolorizer(self): if not self.color: return ##print "Remove colorizer" self.per.removefilter(self.undo) self.per.removefilter(self.color) self.color = None self.per.insertfilter(self.undo)
5e65ce671c3d3113035dd7783b79d395c9d71b3d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5e65ce671c3d3113035dd7783b79d395c9d71b3d/EditorWindow.py
def apply_bindings(self, keydefs=None): if keydefs is None: keydefs = self.Bindings.default_keydefs text = self.text text.keydefs = keydefs for event, keylist in keydefs.items(): ##print>>sys.__stderr__, "event, list: ", event, keylist if keylist: apply(text.event_add, (event,) + tuple(keylist))
5e65ce671c3d3113035dd7783b79d395c9d71b3d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5e65ce671c3d3113035dd7783b79d395c9d71b3d/EditorWindow.py
def fill_menus(self, defs=None, keydefs=None): """Add appropriate entries to the menus and submenus
5e65ce671c3d3113035dd7783b79d395c9d71b3d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5e65ce671c3d3113035dd7783b79d395c9d71b3d/EditorWindow.py
def fill_menus(self, defs=None, keydefs=None): """Add appropriate entries to the menus and submenus
5e65ce671c3d3113035dd7783b79d395c9d71b3d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5e65ce671c3d3113035dd7783b79d395c9d71b3d/EditorWindow.py
def command(text=text, event=event): text.event_generate(event)
5e65ce671c3d3113035dd7783b79d395c9d71b3d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5e65ce671c3d3113035dd7783b79d395c9d71b3d/EditorWindow.py
import poll if map is None: map = socket_map if timeout is not None: timeout = int(timeout*1000) if map: l = [] for fd, obj in map.items(): flags = 0 if obj.readable(): flags = poll.POLLIN if obj.writable(): flags = flags | poll.POLLOUT if flags: l.append((fd, flags)) r = poll.poll(l, timeout) for fd, flags in r: obj = map.get(fd) if obj is None: continue readwrite(obj, flags) def poll3(timeout=0.0, map=None):
def poll2(timeout=0.0, map=None): import poll if map is None: map = socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) if map: l = [] for fd, obj in map.items(): flags = 0 if obj.readable(): flags = poll.POLLIN if obj.writable(): flags = flags | poll.POLLOUT if flags: l.append((fd, flags)) r = poll.poll(l, timeout) for fd, flags in r: obj = map.get(fd) if obj is None: continue readwrite(obj, flags)
6c2871e707b88cede6a18e72c6c55721da9b610f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6c2871e707b88cede6a18e72c6c55721da9b610f/asyncore.py
if use_poll: if hasattr(select, 'poll'): poll_fun = poll3 else: poll_fun = poll2
if use_poll and hasattr(select, 'poll'): poll_fun = poll2
def loop(timeout=30.0, use_poll=0, map=None): if map is None: map = socket_map if use_poll: if hasattr(select, 'poll'): poll_fun = poll3 else: poll_fun = poll2 else: poll_fun = poll while map: poll_fun(timeout, map)
6c2871e707b88cede6a18e72c6c55721da9b610f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6c2871e707b88cede6a18e72c6c55721da9b610f/asyncore.py
self.pos = self.pos + length return self.fp.read(length)
data = self.fp.read(length) self.pos = self.fp.tell() return data
def read(self, length = None): if self.pos >= self.stop: return '' remaining = self.stop - self.pos if length is None or length < 0: length = remaining elif length > remaining: length = remaining self.fp.seek(self.pos) self.pos = self.pos + length return self.fp.read(length)
7333c4cafcbb0c0ea5ad7bed9f5f77c16a844e34 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7333c4cafcbb0c0ea5ad7bed9f5f77c16a844e34/mailbox.py
if len(data) < length: length = len(data) self.pos = self.pos + length
self.pos = self.fp.tell()
def readline(self, length = None): if self.pos >= self.stop: return '' if length is None: length = self.stop - self.pos self.fp.seek(self.pos) data = self.fp.readline(length) if len(data) < length: length = len(data) self.pos = self.pos + length return data
7333c4cafcbb0c0ea5ad7bed9f5f77c16a844e34 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7333c4cafcbb0c0ea5ad7bed9f5f77c16a844e34/mailbox.py
pass
del self.fp
def close(self): pass
7333c4cafcbb0c0ea5ad7bed9f5f77c16a844e34 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7333c4cafcbb0c0ea5ad7bed9f5f77c16a844e34/mailbox.py
_safechars = string.letters + string.digits + '!@%_-+=:,./'
_safechars = string.ascii_letters + string.digits + '!@%_-+=:,./'
def makepipeline(infile, steps, outfile): # Build a list with for each command: # [input filename or '', command string, kind, output filename or ''] list = [] for cmd, kind in steps: list.append(['', cmd, kind, '']) # # Make sure there is at least one step # if not list: list.append(['', 'cat', '--', '']) # # Take care of the input and output ends # [cmd, kind] = list[0][1:3] if kind[0] == 'f' and not infile: list.insert(0, ['', 'cat', '--', '']) list[0][0] = infile # [cmd, kind] = list[-1][1:3] if kind[1] == 'f' and not outfile: list.append(['', 'cat', '--', '']) list[-1][-1] = outfile # # Invent temporary files to connect stages that need files # garbage = [] for i in range(1, len(list)): lkind = list[i-1][2] rkind = list[i][2] if lkind[1] == 'f' or rkind[0] == 'f': temp = tempfile.mktemp() garbage.append(temp) list[i-1][-1] = list[i][0] = temp # for item in list: [inf, cmd, kind, outf] = item if kind[1] == 'f': cmd = 'OUT=' + quote(outf) + '; ' + cmd if kind[0] == 'f': cmd = 'IN=' + quote(inf) + '; ' + cmd if kind[0] == '-' and inf: cmd = cmd + ' <' + quote(inf) if kind[1] == '-' and outf: cmd = cmd + ' >' + quote(outf) item[1] = cmd # cmdlist = list[0][1] for item in list[1:]: [cmd, kind] = item[1:3] if item[0] == '': if 'f' in kind: cmd = '{ ' + cmd + '; }' cmdlist = cmdlist + ' |\n' + cmd else: cmdlist = cmdlist + '\n' + cmd # if garbage: rmcmd = 'rm -f' for file in garbage: rmcmd = rmcmd + ' ' + quote(file) trapcmd = 'trap ' + quote(rmcmd + '; exit') + ' 1 2 3 13 14 15' cmdlist = trapcmd + '\n' + cmdlist + '\n' + rmcmd # return cmdlist
0f715d2aa119d0391dd50919c04bfaa8a4452cf0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0f715d2aa119d0391dd50919c04bfaa8a4452cf0/pipes.py
referenced = C() a = C()
referenced = A() a = A()
def callback(*args): pass
55cf434735380ce51034c64722cf422457f891e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/55cf434735380ce51034c64722cf422457f891e0/test_weakref.py
a = C() a.wrc = weakref.ref(referenced, callback)
a = A() weakref.ref(referenced, callback)
def callback(*args): pass
55cf434735380ce51034c64722cf422457f891e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/55cf434735380ce51034c64722cf422457f891e0/test_weakref.py
text = text[:75] + ' ...'
textlines = text.splitlines() for i, line in enumerate(textlines): if len(line) > 79: textlines[i] = line[:75] + ' ...' text = '\n'.join(textlines)
def showtip(self, text, parenleft, parenright): """Show the calltip, bind events which will close it and reposition it. """ # truncate overly long calltip if len(text) >= 79: text = text[:75] + ' ...' self.text = text if self.tipwindow or not self.text: return
0b48303f28fa4846c713240c57501d5fa70436c7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0b48303f28fa4846c713240c57501d5fa70436c7/CallTipWindow.py
self.d.DragWindow(where, screenbounds)
self.w.DragWindow(where, screenbounds)
def _update(self, value): maxval = self.maxval if maxval == 0: # XXXX Quick fix. Should probably display an unknown duration value = 0 maxval = 1 if maxval > 32767: value = int(value/(maxval/32767.0)) maxval = 32767 progbar = self.d.GetDialogItemAsControl(3) progbar.SetControlMaximum(maxval) progbar.SetControlValue(value) # Test for cancel button ready, ev = Evt.WaitNextEvent( Events.mDownMask, 1 ) if ready : what,msg,when,where,mod = ev part = Win.FindWindow(where)[0] if Dlg.IsDialogEvent(ev): ds = Dlg.DialogSelect(ev) if ds[0] and ds[1] == self.d and ds[-1] == 1: self.w.HideWindow() self.w = None self.d = None raise KeyboardInterrupt, ev else: if part == 4: # inDrag self.d.DragWindow(where, screenbounds) else: MacOS.HandleEvent(ev)
8d2f3d66ee681a7d9a18fb854d0ecd1816edb78b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8d2f3d66ee681a7d9a18fb854d0ecd1816edb78b/EasyDialogs.py
print >>sys.stderr, name, "exists:", os.path.exists(name)
def expect(got_this, expect_this): if test_support.verbose: print '%s =?= %s ...' % (`got_this`, `expect_this`), if got_this != expect_this: if test_support.verbose: print 'no' raise test_support.TestFailed, 'got %s, but expected %s' %\ (str(got_this), str(expect_this)) else: if test_support.verbose: print 'yes'
198c1d8b5981e8e58a229827ac5c344fcd004b54 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/198c1d8b5981e8e58a229827ac5c344fcd004b54/test_largefile.py
unsigned int uiValue;
Py_UCS4 value;
typedef struct
bc30b117643a3bffb39ba3e93bba1beb493d1f37 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bc30b117643a3bffb39ba3e93bba1beb493d1f37/GenUCNHash.py
return rv + '\n'
rv = rv + "\n" sys.stdout.write(rv) return rv
def readline(self): import EasyDialogs # A trick to make the input dialog box a bit more palatable if hasattr(sys.stdout, '_buf'): prompt = sys.stdout._buf else: prompt = "" if not prompt: prompt = "Stdin input:" sys.stdout.flush() rv = EasyDialogs.AskString(prompt) if rv is None: return "" return rv + '\n'
226275f780c878f836542a1c1916688f581f34ec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/226275f780c878f836542a1c1916688f581f34ec/PyConsole.py
def test_remove(self): d = deque('abcdefghcij') d.remove('c') self.assertEqual(d, deque('abdefghcij')) d.remove('c') self.assertEqual(d, deque('abdefghij')) self.assertRaises(ValueError, d.remove, 'c') self.assertEqual(d, deque('abdefghij'))
c448a91ee855ee9c24ecf3e66410e04ae3c6ce98 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c448a91ee855ee9c24ecf3e66410e04ae3c6ce98/test_deque.py
locale.getlocale(locale.LC_TIME),
locale.getlocale(locale.LC_TIME)[0],
def test_lang(self): # Make sure lang is set self.failUnless(self.LT_ins.lang in (locale.getdefaultlocale()[0], locale.getlocale(locale.LC_TIME), ''), "Setting of lang failed")
d1deac06e78fd8fb79018f712dbd70047b5a7fa9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d1deac06e78fd8fb79018f712dbd70047b5a7fa9/test_strptime.py
def poll (timeout=0.0, map=None):
def poll(timeout=0.0, map=None):
def poll (timeout=0.0, map=None): if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.iteritems(): if obj.readable(): r.append(fd) if obj.writable(): w.append(fd) try: r, w, e = select.select(r, w, e, timeout) except select.error, err: if err[0] != EINTR: raise for fd in r: obj = map.get(fd) if obj is None: continue read(obj) for fd in w: obj = map.get(fd) if obj is None: continue write(obj)
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
for fd, obj in map.iteritems():
for fd, obj in map.items():
def poll (timeout=0.0, map=None): if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.iteritems(): if obj.readable(): r.append(fd) if obj.writable(): w.append(fd) try: r, w, e = select.select(r, w, e, timeout) except select.error, err: if err[0] != EINTR: raise for fd in r: obj = map.get(fd) if obj is None: continue read(obj) for fd in w: obj = map.get(fd) if obj is None: continue write(obj)
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def poll2 (timeout=0.0, map=None):
def poll2(timeout=0.0, map=None):
def poll2 (timeout=0.0, map=None): import poll if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) if map: l = [] for fd, obj in map.iteritems(): flags = 0 if obj.readable(): flags = poll.POLLIN if obj.writable(): flags = flags | poll.POLLOUT if flags: l.append ((fd, flags)) r = poll.poll (l, timeout) for fd, flags in r: obj = map.get(fd) if obj is None: continue readwrite(obj, flags)
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
map=socket_map
map = socket_map
def poll2 (timeout=0.0, map=None): import poll if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) if map: l = [] for fd, obj in map.iteritems(): flags = 0 if obj.readable(): flags = poll.POLLIN if obj.writable(): flags = flags | poll.POLLOUT if flags: l.append ((fd, flags)) r = poll.poll (l, timeout) for fd, flags in r: obj = map.get(fd) if obj is None: continue readwrite(obj, flags)
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
for fd, obj in map.iteritems():
for fd, obj in map.items():
def poll2 (timeout=0.0, map=None): import poll if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) if map: l = [] for fd, obj in map.iteritems(): flags = 0 if obj.readable(): flags = poll.POLLIN if obj.writable(): flags = flags | poll.POLLOUT if flags: l.append ((fd, flags)) r = poll.poll (l, timeout) for fd, flags in r: obj = map.get(fd) if obj is None: continue readwrite(obj, flags)
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
l.append ((fd, flags)) r = poll.poll (l, timeout)
l.append((fd, flags)) r = poll.poll(l, timeout)
def poll2 (timeout=0.0, map=None): import poll if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) if map: l = [] for fd, obj in map.iteritems(): flags = 0 if obj.readable(): flags = poll.POLLIN if obj.writable(): flags = flags | poll.POLLOUT if flags: l.append ((fd, flags)) r = poll.poll (l, timeout) for fd, flags in r: obj = map.get(fd) if obj is None: continue readwrite(obj, flags)
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def poll3 (timeout=0.0, map=None):
def poll3(timeout=0.0, map=None):
def poll3 (timeout=0.0, map=None): # Use the poll() support added to the select module in Python 2.0 if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) pollster = select.poll() if map: for fd, obj in map.iteritems(): flags = 0 if obj.readable(): flags = select.POLLIN if obj.writable(): flags = flags | select.POLLOUT if flags: pollster.register(fd, flags) try: r = pollster.poll (timeout) except select.error, err: if err[0] != EINTR: raise r = [] for fd, flags in r: obj = map.get(fd) if obj is None: continue readwrite(obj, flags)
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
map=socket_map
map = socket_map
def poll3 (timeout=0.0, map=None): # Use the poll() support added to the select module in Python 2.0 if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) pollster = select.poll() if map: for fd, obj in map.iteritems(): flags = 0 if obj.readable(): flags = select.POLLIN if obj.writable(): flags = flags | select.POLLOUT if flags: pollster.register(fd, flags) try: r = pollster.poll (timeout) except select.error, err: if err[0] != EINTR: raise r = [] for fd, flags in r: obj = map.get(fd) if obj is None: continue readwrite(obj, flags)
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
for fd, obj in map.iteritems():
for fd, obj in map.items():
def poll3 (timeout=0.0, map=None): # Use the poll() support added to the select module in Python 2.0 if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) pollster = select.poll() if map: for fd, obj in map.iteritems(): flags = 0 if obj.readable(): flags = select.POLLIN if obj.writable(): flags = flags | select.POLLOUT if flags: pollster.register(fd, flags) try: r = pollster.poll (timeout) except select.error, err: if err[0] != EINTR: raise r = [] for fd, flags in r: obj = map.get(fd) if obj is None: continue readwrite(obj, flags)
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
r = pollster.poll (timeout)
r = pollster.poll(timeout)
def poll3 (timeout=0.0, map=None): # Use the poll() support added to the select module in Python 2.0 if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) pollster = select.poll() if map: for fd, obj in map.iteritems(): flags = 0 if obj.readable(): flags = select.POLLIN if obj.writable(): flags = flags | select.POLLOUT if flags: pollster.register(fd, flags) try: r = pollster.poll (timeout) except select.error, err: if err[0] != EINTR: raise r = [] for fd, flags in r: obj = map.get(fd) if obj is None: continue readwrite(obj, flags)
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def loop (timeout=30.0, use_poll=0, map=None):
def loop(timeout=30.0, use_poll=0, map=None):
def loop (timeout=30.0, use_poll=0, map=None): if map is None: map = socket_map if use_poll: if hasattr (select, 'poll'): poll_fun = poll3 else: poll_fun = poll2 else: poll_fun = poll while map: poll_fun (timeout, map)
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
if hasattr (select, 'poll'):
if hasattr(select, 'poll'):
def loop (timeout=30.0, use_poll=0, map=None): if map is None: map = socket_map if use_poll: if hasattr (select, 'poll'): poll_fun = poll3 else: poll_fun = poll2 else: poll_fun = poll while map: poll_fun (timeout, map)
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
poll_fun (timeout, map)
poll_fun(timeout, map)
def loop (timeout=30.0, use_poll=0, map=None): if map is None: map = socket_map if use_poll: if hasattr (select, 'poll'): poll_fun = poll3 else: poll_fun = poll2 else: poll_fun = poll while map: poll_fun (timeout, map)
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def __init__ (self, sock=None, map=None):
def __init__(self, sock=None, map=None):
def __init__ (self, sock=None, map=None): if sock: self.set_socket (sock, map) # I think it should inherit this anyway self.socket.setblocking (0) self.connected = 1 # XXX Does the constructor require that the socket passed # be connected? try: self.addr = sock.getpeername() except socket.error: # The addr isn't crucial pass else: self.socket = None
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
self.set_socket (sock, map)
self.set_socket(sock, map)
def __init__ (self, sock=None, map=None): if sock: self.set_socket (sock, map) # I think it should inherit this anyway self.socket.setblocking (0) self.connected = 1 # XXX Does the constructor require that the socket passed # be connected? try: self.addr = sock.getpeername() except socket.error: # The addr isn't crucial pass else: self.socket = None
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
self.socket.setblocking (0)
self.socket.setblocking(0)
def __init__ (self, sock=None, map=None): if sock: self.set_socket (sock, map) # I think it should inherit this anyway self.socket.setblocking (0) self.connected = 1 # XXX Does the constructor require that the socket passed # be connected? try: self.addr = sock.getpeername() except socket.error: # The addr isn't crucial pass else: self.socket = None
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def __repr__ (self):
def __repr__(self):
def __repr__ (self): status = [self.__class__.__module__+"."+self.__class__.__name__] if self.accepting and self.addr: status.append ('listening') elif self.connected: status.append ('connected') if self.addr is not None: try: status.append ('%s:%d' % self.addr) except TypeError: status.append (repr(self.addr)) return '<%s at %#x>' % (' '.join (status), id (self))
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
status.append ('listening')
status.append('listening')
def __repr__ (self): status = [self.__class__.__module__+"."+self.__class__.__name__] if self.accepting and self.addr: status.append ('listening') elif self.connected: status.append ('connected') if self.addr is not None: try: status.append ('%s:%d' % self.addr) except TypeError: status.append (repr(self.addr)) return '<%s at %#x>' % (' '.join (status), id (self))
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
status.append ('connected')
status.append('connected')
def __repr__ (self): status = [self.__class__.__module__+"."+self.__class__.__name__] if self.accepting and self.addr: status.append ('listening') elif self.connected: status.append ('connected') if self.addr is not None: try: status.append ('%s:%d' % self.addr) except TypeError: status.append (repr(self.addr)) return '<%s at %#x>' % (' '.join (status), id (self))
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
status.append ('%s:%d' % self.addr)
status.append('%s:%d' % self.addr)
def __repr__ (self): status = [self.__class__.__module__+"."+self.__class__.__name__] if self.accepting and self.addr: status.append ('listening') elif self.connected: status.append ('connected') if self.addr is not None: try: status.append ('%s:%d' % self.addr) except TypeError: status.append (repr(self.addr)) return '<%s at %#x>' % (' '.join (status), id (self))
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
status.append (repr(self.addr)) return '<%s at % def add_channel (self, map=None):
status.append(repr(self.addr)) return '<%s at % def add_channel(self, map=None):
def __repr__ (self): status = [self.__class__.__module__+"."+self.__class__.__name__] if self.accepting and self.addr: status.append ('listening') elif self.connected: status.append ('connected') if self.addr is not None: try: status.append ('%s:%d' % self.addr) except TypeError: status.append (repr(self.addr)) return '<%s at %#x>' % (' '.join (status), id (self))
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
map=socket_map
map = socket_map
def add_channel (self, map=None): #self.log_info ('adding channel %s' % self) if map is None: map=socket_map map [self._fileno] = self
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def del_channel (self, map=None):
def del_channel(self, map=None):
def del_channel (self, map=None): fd = self._fileno if map is None: map=socket_map if map.has_key (fd): #self.log_info ('closing channel %d:%s' % (fd, self)) del map [fd]
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
map=socket_map if map.has_key (fd):
map = socket_map if map.has_key(fd):
def del_channel (self, map=None): fd = self._fileno if map is None: map=socket_map if map.has_key (fd): #self.log_info ('closing channel %d:%s' % (fd, self)) del map [fd]
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def create_socket (self, family, type):
def create_socket(self, family, type):
def create_socket (self, family, type): self.family_and_type = family, type self.socket = socket.socket (family, type) self.socket.setblocking(0) self._fileno = self.socket.fileno() self.add_channel()
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
self.socket = socket.socket (family, type)
self.socket = socket.socket(family, type)
def create_socket (self, family, type): self.family_and_type = family, type self.socket = socket.socket (family, type) self.socket.setblocking(0) self._fileno = self.socket.fileno() self.add_channel()
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def set_socket (self, sock, map=None):
def set_socket(self, sock, map=None):
def set_socket (self, sock, map=None): self.socket = sock
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
self.add_channel (map) def set_reuse_addr (self):
self.add_channel(map) def set_reuse_addr(self):
def set_socket (self, sock, map=None): self.socket = sock
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
self.socket.setsockopt (
self.socket.setsockopt(
def set_reuse_addr (self): # try to re-use a server port if possible try: self.socket.setsockopt ( socket.SOL_SOCKET, socket.SO_REUSEADDR, self.socket.getsockopt (socket.SOL_SOCKET, socket.SO_REUSEADDR) | 1 ) except socket.error: pass
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
self.socket.getsockopt (socket.SOL_SOCKET, socket.SO_REUSEADDR) | 1
self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) | 1
def set_reuse_addr (self): # try to re-use a server port if possible try: self.socket.setsockopt ( socket.SOL_SOCKET, socket.SO_REUSEADDR, self.socket.getsockopt (socket.SOL_SOCKET, socket.SO_REUSEADDR) | 1 ) except socket.error: pass
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def readable (self):
def readable(self):
def readable (self): return True
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def writable (self):
def writable(self):
def writable (self): return not self.accepting
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def writable (self):
def writable(self):
def writable (self): return True
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def listen (self, num):
def listen(self, num):
def listen (self, num): self.accepting = 1 if os.name == 'nt' and num > 5: num = 1 return self.socket.listen (num)
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
return self.socket.listen (num) def bind (self, addr):
return self.socket.listen(num) def bind(self, addr):
def listen (self, num): self.accepting = 1 if os.name == 'nt' and num > 5: num = 1 return self.socket.listen (num)
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
return self.socket.bind (addr) def connect (self, address):
return self.socket.bind(addr) def connect(self, address):
def bind (self, addr): self.addr = addr return self.socket.bind (addr)
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def accept (self):
def accept(self):
def accept (self): # XXX can return either an address pair or None try: conn, addr = self.socket.accept() return conn, addr except socket.error, why: if why[0] == EWOULDBLOCK: pass else: raise socket.error, why
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def send (self, data): try: result = self.socket.send (data)
def send(self, data): try: result = self.socket.send(data)
def send (self, data): try: result = self.socket.send (data) return result except socket.error, why: if why[0] == EWOULDBLOCK: return 0 else: raise socket.error, why return 0
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def recv (self, buffer_size): try: data = self.socket.recv (buffer_size)
def recv(self, buffer_size): try: data = self.socket.recv(buffer_size)
def recv (self, buffer_size): try: data = self.socket.recv (buffer_size) if not data: # a closed connection is indicated by signaling # a read condition, and having recv() return 0. self.handle_close() return '' else: return data except socket.error, why: # winsock sometimes throws ENOTCONN if why[0] in [ECONNRESET, ENOTCONN, ESHUTDOWN]: self.handle_close() return '' else: raise socket.error, why
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def close (self):
def close(self):
def close (self): self.del_channel() self.socket.close()
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def __getattr__ (self, attr): return getattr (self.socket, attr)
def __getattr__(self, attr): return getattr(self.socket, attr)
def __getattr__ (self, attr): return getattr (self.socket, attr)
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def log (self, message): sys.stderr.write ('log: %s\n' % str(message)) def log_info (self, message, type='info'):
def log(self, message): sys.stderr.write('log: %s\n' % str(message)) def log_info(self, message, type='info'):
def log (self, message): sys.stderr.write ('log: %s\n' % str(message))
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def handle_read_event (self):
def handle_read_event(self):
def handle_read_event (self): if self.accepting: # for an accepting socket, getting a read implies # that we are connected if not self.connected: self.connected = 1 self.handle_accept() elif not self.connected: self.handle_connect() self.connected = 1 self.handle_read() else: self.handle_read()
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def handle_write_event (self):
def handle_write_event(self):
def handle_write_event (self): # getting a write implies that we are connected if not self.connected: self.handle_connect() self.connected = 1 self.handle_write()
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def handle_expt_event (self):
def handle_expt_event(self):
def handle_expt_event (self): self.handle_expt()
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def handle_error (self):
def handle_error(self):
def handle_error (self): nil, t, v, tbinfo = compact_traceback()
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
self_repr = repr (self)
self_repr = repr(self)
def handle_error (self): nil, t, v, tbinfo = compact_traceback()
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
self_repr = '<__repr__ (self) failed for object at %0x>' % id(self) self.log_info (
self_repr = '<__repr__(self) failed for object at %0x>' % id(self) self.log_info(
def handle_error (self): nil, t, v, tbinfo = compact_traceback()
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def handle_expt (self): self.log_info ('unhandled exception', 'warning') def handle_read (self): self.log_info ('unhandled read event', 'warning') def handle_write (self): self.log_info ('unhandled write event', 'warning') def handle_connect (self): self.log_info ('unhandled connect event', 'warning') def handle_accept (self): self.log_info ('unhandled accept event', 'warning') def handle_close (self): self.log_info ('unhandled close event', 'warning')
def handle_expt(self): self.log_info('unhandled exception', 'warning') def handle_read(self): self.log_info('unhandled read event', 'warning') def handle_write(self): self.log_info('unhandled write event', 'warning') def handle_connect(self): self.log_info('unhandled connect event', 'warning') def handle_accept(self): self.log_info('unhandled accept event', 'warning') def handle_close(self): self.log_info('unhandled close event', 'warning')
def handle_expt (self): self.log_info ('unhandled exception', 'warning')
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
class dispatcher_with_send (dispatcher): def __init__ (self, sock=None): dispatcher.__init__ (self, sock)
class dispatcher_with_send(dispatcher): def __init__(self, sock=None): dispatcher.__init__(self, sock)
def handle_close (self): self.log_info ('unhandled close event', 'warning') self.close()
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def initiate_send (self):
def initiate_send(self):
def initiate_send (self): num_sent = 0 num_sent = dispatcher.send (self, self.out_buffer[:512]) self.out_buffer = self.out_buffer[num_sent:]
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
num_sent = dispatcher.send (self, self.out_buffer[:512])
num_sent = dispatcher.send(self, self.out_buffer[:512])
def initiate_send (self): num_sent = 0 num_sent = dispatcher.send (self, self.out_buffer[:512]) self.out_buffer = self.out_buffer[num_sent:]
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def handle_write (self):
def handle_write(self):
def handle_write (self): self.initiate_send()
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def writable (self):
def writable(self):
def writable (self): return (not self.connected) or len(self.out_buffer)
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def send (self, data):
def send(self, data):
def send (self, data): if self.debug: self.log_info ('sending %s' % repr(data)) self.out_buffer = self.out_buffer + data self.initiate_send()
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
self.log_info ('sending %s' % repr(data))
self.log_info('sending %s' % repr(data))
def send (self, data): if self.debug: self.log_info ('sending %s' % repr(data)) self.out_buffer = self.out_buffer + data self.initiate_send()
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def compact_traceback ():
def compact_traceback():
def compact_traceback (): t,v,tb = sys.exc_info() tbinfo = [] while 1: tbinfo.append (( tb.tb_frame.f_code.co_filename, tb.tb_frame.f_code.co_name, str(tb.tb_lineno) )) tb = tb.tb_next if not tb: break # just to be safe del tb file, function, line = tbinfo[-1] info = '[' + '] ['.join(map(lambda x: '|'.join(x), tbinfo)) + ']' return (file, function, line), t, v, info
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
tbinfo.append ((
tbinfo.append((
def compact_traceback (): t,v,tb = sys.exc_info() tbinfo = [] while 1: tbinfo.append (( tb.tb_frame.f_code.co_filename, tb.tb_frame.f_code.co_name, str(tb.tb_lineno) )) tb = tb.tb_next if not tb: break # just to be safe del tb file, function, line = tbinfo[-1] info = '[' + '] ['.join(map(lambda x: '|'.join(x), tbinfo)) + ']' return (file, function, line), t, v, info
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def close_all (map=None):
def close_all(map=None):
def close_all (map=None): if map is None: map=socket_map for x in map.values(): x.socket.close() map.clear()
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
map=socket_map
map = socket_map
def close_all (map=None): if map is None: map=socket_map for x in map.values(): x.socket.close() map.clear()
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def __init__ (self, fd):
def __init__(self, fd):
def __init__ (self, fd): self.fd = fd
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def recv (self, *args):
def recv(self, *args):
def recv (self, *args): return os.read(self.fd, *args)
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def send (self, *args):
def send(self, *args):
def send (self, *args): return os.write(self.fd, *args)
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
def close (self): return os.close (self.fd) def fileno (self):
def close(self): return os.close(self.fd) def fileno(self):
def close (self): return os.close (self.fd)
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
class file_dispatcher (dispatcher): def __init__ (self, fd): dispatcher.__init__ (self)
class file_dispatcher(dispatcher): def __init__(self, fd): dispatcher.__init__(self)
def fileno (self): return self.fd
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
flags = fcntl.fcntl (fd, fcntl.F_GETFL, 0)
flags = fcntl.fcntl(fd, fcntl.F_GETFL, 0)
def __init__ (self, fd): dispatcher.__init__ (self) self.connected = 1 # set it to non-blocking mode flags = fcntl.fcntl (fd, fcntl.F_GETFL, 0) flags = flags | os.O_NONBLOCK fcntl.fcntl (fd, fcntl.F_SETFL, flags) self.set_file (fd)
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
fcntl.fcntl (fd, fcntl.F_SETFL, flags) self.set_file (fd) def set_file (self, fd):
fcntl.fcntl(fd, fcntl.F_SETFL, flags) self.set_file(fd) def set_file(self, fd):
def __init__ (self, fd): dispatcher.__init__ (self) self.connected = 1 # set it to non-blocking mode flags = fcntl.fcntl (fd, fcntl.F_GETFL, 0) flags = flags | os.O_NONBLOCK fcntl.fcntl (fd, fcntl.F_SETFL, flags) self.set_file (fd)
d560ace3a76d1fa162fa40ec90a158d4d3540036 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d560ace3a76d1fa162fa40ec90a158d4d3540036/asyncore.py
print '\tnew IMAP4 connection, tag=%s' % self.tagpre
_mesg('new IMAP4 connection, tag=%s' % self.tagpre)
def __init__(self, host = '', port = IMAP4_PORT): self.host = host self.port = port self.debug = Debug self.state = 'LOGOUT' self.literal = None # A literal argument to a command self.tagged_commands = {} # Tagged commands awaiting response self.untagged_responses = {} # {typ: [data, ...], ...} self.continuation_response = '' # Last continuation response self.tagnum = 0
26367a001ddaca576aba1a3f31a7c035c53199e8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/26367a001ddaca576aba1a3f31a7c035c53199e8/imaplib.py
print '\tCAPABILITIES: %s' % `self.capabilities`
_mesg('CAPABILITIES: %s' % `self.capabilities`)
def __init__(self, host = '', port = IMAP4_PORT): self.host = host self.port = port self.debug = Debug self.state = 'LOGOUT' self.literal = None # A literal argument to a command self.tagged_commands = {} # Tagged commands awaiting response self.untagged_responses = {} # {typ: [data, ...], ...} self.continuation_response = '' # Last continuation response self.tagnum = 0
26367a001ddaca576aba1a3f31a7c035c53199e8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/26367a001ddaca576aba1a3f31a7c035c53199e8/imaplib.py
def __getattr__(self, attr): """Allow UPPERCASE variants of all following IMAP4 commands.""" if Commands.has_key(attr): return eval("self.%s" % string.lower(attr)) raise AttributeError("Unknown IMAP4 command: '%s'" % attr)
def recent(self): """Return most recent 'RECENT' responses if any exist, else prompt server for an update using the 'NOOP' command. (typ, [data]) = <instance>.recent() 'data' is None if no new messages, else list of RECENT responses, most recent last. """ name = 'RECENT' typ, dat = self._untagged_response('OK', [None], name) if dat[-1]: return typ, dat typ, dat = self.noop() return self._untagged_response(typ, dat, name) def response(self, code): """Return data for response 'code' if received, or None. Old value for response 'code' is cleared. (code, [data]) = <instance>.response(code) """ return self._untagged_response(code, [None], string.upper(code)) def socket(self): """Return socket instance used to connect to IMAP4 server. socket = <instance>.socket() """ return self.sock
def __getattr__(self, attr): """Allow UPPERCASE variants of all following IMAP4 commands.""" if Commands.has_key(attr): return eval("self.%s" % string.lower(attr)) raise AttributeError("Unknown IMAP4 command: '%s'" % attr)
26367a001ddaca576aba1a3f31a7c035c53199e8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/26367a001ddaca576aba1a3f31a7c035c53199e8/imaplib.py
raise self.error(dat)
raise self.error(dat[-1])
def authenticate(self, mechanism, authobject): """Authenticate command - requires response processing.
26367a001ddaca576aba1a3f31a7c035c53199e8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/26367a001ddaca576aba1a3f31a7c035c53199e8/imaplib.py
try: typ, dat = self._simple_command('CLOSE') except EOFError: typ, dat = None, [None]
typ, dat = self._simple_command('CLOSE')
def close(self): """Close currently selected mailbox.
26367a001ddaca576aba1a3f31a7c035c53199e8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/26367a001ddaca576aba1a3f31a7c035c53199e8/imaplib.py
return self._untagged_response(typ, name)
return self._untagged_response(typ, dat, name)
def expunge(self): """Permanently remove deleted items from selected mailbox.
26367a001ddaca576aba1a3f31a7c035c53199e8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/26367a001ddaca576aba1a3f31a7c035c53199e8/imaplib.py
return self._untagged_response(typ, name)
return self._untagged_response(typ, dat, name)
def fetch(self, message_set, message_parts): """Fetch (parts of) messages.
26367a001ddaca576aba1a3f31a7c035c53199e8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/26367a001ddaca576aba1a3f31a7c035c53199e8/imaplib.py
return self._untagged_response(typ, name)
return self._untagged_response(typ, dat, name)
def list(self, directory='""', pattern='*'): """List mailbox names in directory matching pattern.
26367a001ddaca576aba1a3f31a7c035c53199e8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/26367a001ddaca576aba1a3f31a7c035c53199e8/imaplib.py