bugged stringlengths 4 228k | fixed stringlengths 0 96.3M | __index_level_0__ int64 0 481k |
|---|---|---|
def set_link_objects (self, objects): """Set the list of object files (or analogues) to be included in every link to 'objects'. This does not affect any standard object files that the linker may include by default (such as system libraries). """ self.objects = copy (objects) | def set_link_objects (self, objects): """Set the list of object files (or analogues) to be included in every link to 'objects'. This does not affect any standard object files that the linker may include by default (such as system libraries). """ self.objects = copy (objects) | 10,000 |
def parse(self, source): import saxutils source = saxutils.prepare_input_source(source) | def parse(self, source): from . import saxutils source = saxutils.prepare_input_source(source) | 10,001 |
def test_exc(formatstr, args, exception, excmsg): try: testformat(formatstr, args) except exception, exc: if str(exc) == excmsg: if verbose: print "yes" else: if verbose: print 'no' print 'Unexpected ', exception, ':', repr(str(exc)) except: if verbose: print 'no' print 'Unexpected exception' raise | def test_exc(formatstr, args, exception, excmsg): try: testformat(formatstr, args) except exception, exc: if str(exc) == excmsg: if verbose: print "yes" else: if verbose: print 'no' print 'Unexpected ', exception, ':', repr(str(exc)) except: if verbose: print 'no' print 'Unexpected exception' raise | 10,002 |
def poll2(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.items(): flags = 0 if obj.readable(): flags = select.P... | def poll2(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.items(): flags = select.POLLERR | select.POLLHUP | sel... | 10,003 |
def poll2(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.items(): flags = 0 if obj.readable(): flags = select.P... | def poll2(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.items(): flags = 0 if obj.readable(): flags = select.P... | 10,004 |
def getinfo(self): return (self.format, self.width, self.height, self.packfactor,\ self.c0bits, self.c1bits, self.c2bits, self.offset, \ self.chrompack) | def getinfo(self): return (self.format, self.width, self.height, self.packfactor,\ self.c0bits, self.c1bits, self.c2bits, self.offset, \ self.chrompack) | 10,005 |
def rewind(self): self.fp.seek(0) x = self.initfp(self.fp, self.filename) | def reopen(self): self.fp.seek(0) x = self.initfp(self.fp, self.filename) | 10,006 |
def getnextframedata(self, (size, chromsize)): if self.hascache: self.position() self.frameno = self.frameno + 1 data = self.fp.read(size) if len(data) <> size: raise EOFError if chromsize: chromdata = self.fp.read(chromsize) if len(chromdata) <> chromsize: raise EOFError else: chromdata = None # return data, chromdata | def getnextframedata(self, size, chromsize): if self.hascache: self.position() self.frameno = self.frameno + 1 data = self.fp.read(size) if len(data) <> size: raise EOFError if chromsize: chromdata = self.fp.read(chromsize) if len(chromdata) <> chromsize: raise EOFError else: chromdata = None # return data, chromdata | 10,007 |
def skipnextframedata(self, (size, chromsize)): if self.hascache: self.frameno = self.frameno + 1 return # Note that this won't raise EOFError for a partial frame. try: self.fp.seek(size + chromsize, 1) # Relative seek except: # Assume it's a pipe -- read the data to discard it dummy = self.fp.read(size + chromsize) | def skipnextframedata(self, size, chromsize): if self.hascache: self.frameno = self.frameno + 1 return # Note that this won't raise EOFError for a partial frame. try: self.fp.seek(size + chromsize, 1) # Relative seek except: # Assume it's a pipe -- read the data to discard it dummy = self.fp.read(size + chromsize) | 10,008 |
def showframe(self, (data, chromdata)): w, h, pf = self.width, self.height, self.packfactor if not self.colormapinited: self.initcolormap() factor = self.magnify if pf: factor = factor * pf if chromdata and not self.skipchrom: cp = self.chrompack cw = (w+cp-1)/cp ch = (h+cp-1)/cp gl.rectzoom(factor*cp, factor*cp) gl.pi... | def showframe(self, data, chromdata): w, h, pf = self.width, self.height, self.packfactor if not self.colormapinited: self.initcolormap() factor = self.magnify if pf: factor = factor * pf if chromdata and not self.skipchrom: cp = self.chrompack cw = (w+cp-1)/cp ch = (h+cp-1)/cp gl.rectzoom(factor*cp, factor*cp) gl.pixm... | 10,009 |
def initcolormap(self): self.colormapinited = 1 if self.format == 'rgb': gl.RGBmode() gl.gconfig() return gl.cmode() gl.gconfig() self.skipchrom = 0 sys.stderr.write('Initializing color map...') self.initcmap() sys.stderr.write(' Done.\n') if self.offset == 0: gl.color(0x800) gl.clear() self.mask = 0x7ff else: self.mas... | def initcolormap(self): self.colormapinited = 1 if self.format == 'rgb': gl.RGBmode() gl.gconfig() return gl.cmode() gl.gconfig() self.skipchrom = 0 if not self.quiet: sys.stderr.write('Initializing color map...') self.initcmap() sys.stderr.write(' Done.\n') if self.offset == 0: gl.color(0x800) gl.clear() self.mask = 0... | 10,010 |
def initcolormap(self): self.colormapinited = 1 if self.format == 'rgb': gl.RGBmode() gl.gconfig() return gl.cmode() gl.gconfig() self.skipchrom = 0 sys.stderr.write('Initializing color map...') self.initcmap() sys.stderr.write(' Done.\n') if self.offset == 0: gl.color(0x800) gl.clear() self.mask = 0x7ff else: self.mas... | def initcolormap(self): self.colormapinited = 1 if self.format == 'rgb': gl.RGBmode() gl.gconfig() return gl.cmode() gl.gconfig() self.skipchrom = 0 sys.stderr.write('Initializing color map...') self.initcmap() if not self.quiet: sys.stderr.write(' Done.\n') if self.offset == 0: gl.color(0x800) gl.clear() self.mask = 0... | 10,011 |
def writeheader(self): self.headerwritten = 1 if self.format == 'rgb': self.packfactor = 0 elif self.packfactor == 0: self.packfactor = 1 self.fp.write('CMIF video 3.0\n') if self.format == 'rgb': data = ('rgb', 0) elif self.format == 'grey': data = ('grey', 0) else: data = (self.format, (self.c0bits, self.c1bits, \ se... | def writeheader(self): self.headerwritten = 1 if self.format == 'rgb': self.packfactor = 0 elif self.packfactor == 0: self.packfactor = 1 self.fp.write('CMIF video 3.0\n') if self.format == 'rgb': data = ('rgb', 0) elif self.format == 'grey': data = ('grey', self.c0bits) else: data = (self.format, (self.c0bits, self.c1... | 10,012 |
def __init__(self, switchboard, parent=None): # non-gui ivars self.__sb = switchboard self.__hexp = BooleanVar() self.__uwtyping = BooleanVar() # create the gui self.__frame = Frame(parent, relief=GROOVE, borderwidth=2) self.__frame.pack(side=RIGHT) # Red self.__xl = Label(self.__frame, text='Red:') self.__xl.grid(row=... | def __init__(self, switchboard, parent=None): # non-gui ivars self.__sb = switchboard self.__hexp = BooleanVar() self.__uwtyping = BooleanVar() # create the gui self.__frame = Frame(parent, relief=GROOVE, borderwidth=2) self.__frame.pack(side=RIGHT) # Red self.__xl = Label(self.__frame, text='Red:') self.__xl.grid(row=... | 10,013 |
def __normalize(self, event=None): ew = event.widget contents = ew.get() if contents == '': contents = '0' # figure out what the contents value is in the current base try: if self.__hexp.get(): v = string.atoi(contents, 16) else: v = string.atoi(contents) except ValueError: v = None # if value is not legal, delete the ... | def __normalize(self, event=None): ew = event.widget contents = ew.get() if contents == '': contents = '0' # figure out what the contents value is in the current base try: if self.__hexp.get(): v = string.atoi(contents, 16) else: v = string.atoi(contents) except ValueError: v =... | 10,014 |
def __normalize(self, event=None): ew = event.widget contents = ew.get() if contents == '': contents = '0' # figure out what the contents value is in the current base try: if self.__hexp.get(): v = string.atoi(contents, 16) else: v = string.atoi(contents) except ValueError: v = None # if value is not legal, delete the ... | def __normalize(self, event=None): ew = event.widget contents = ew.get() if contents == '': contents = '0' # figure out what the contents value is in the current base try: if self.__hexp.get(): v = string.atoi(contents, 16) else: v = string.atoi(contents) except ValueError: v = None # if value is not legal, delete the ... | 10,015 |
def add(self, message): """Add message and return assigned key.""" tmp_file = self._create_tmp() try: self._dump_message(message, tmp_file) finally: _sync_close(tmp_file) if isinstance(message, MaildirMessage): subdir = message.get_subdir() suffix = self.colon + message.get_info() if suffix == self.colon: suffix = '' e... | def add(self, message): """Add message and return assigned key.""" tmp_file = self._create_tmp() try: self._dump_message(message, tmp_file) finally: _sync_close(tmp_file) if isinstance(message, MaildirMessage): subdir = message.get_subdir() suffix = self.colon + message.get_info() if suffix == self.colon: suffix = '' e... | 10,016 |
def _create_tmp(self): """Create a file in the tmp subdirectory and open and return it.""" now = time.time() hostname = socket.gethostname() if '/' in hostname: hostname = hostname.replace('/', r'\057') if ':' in hostname: hostname = hostname.replace(':', r'\072') uniq = "%s.M%sP%sQ%s.%s" % (int(now), int(now % 1 * 1e6... | def _create_tmp(self): """Create a file in the tmp subdirectory and open and return it.""" now = time.time() hostname = socket.gethostname() if '/' in hostname: hostname = hostname.replace('/', r'\057') if ':' in hostname: hostname = hostname.replace(':', r'\072') uniq = "%s.M%sP%sQ%s.%s" % (int(now), int(now % 1 * 1e6... | 10,017 |
def _create_tmp(self): """Create a file in the tmp subdirectory and open and return it.""" now = time.time() hostname = socket.gethostname() if '/' in hostname: hostname = hostname.replace('/', r'\057') if ':' in hostname: hostname = hostname.replace(':', r'\072') uniq = "%s.M%sP%sQ%s.%s" % (int(now), int(now % 1 * 1e6... | def _create_tmp(self): """Create a file in the tmp subdirectory and open and return it.""" now = time.time() hostname = socket.gethostname() if '/' in hostname: hostname = hostname.replace('/', r'\057') if ':' in hostname: hostname = hostname.replace(':', r'\072') uniq = "%s.M%sP%sQ%s.%s" % (int(now), int(now % 1 * 1e6... | 10,018 |
def pickle(ob_type, pickle_function, constructor_ob = None): dispatch_table[ob_type] = pickle_function if constructor_ob is not None: constructor(constructor_ob) | def pickle(ob_type, pickle_function, constructor_ob=None): if type(ob_type) is _ClassType: raise TypeError("copy_reg is not intended for use with classes") if not callable(pickle_function): raise TypeError("reduction functions must be callable") dispatch_table[ob_type] = pickle_function if constructor_ob is not None:... | 10,019 |
def pickle_complex(c): return complex, (c.real, c.imag) | defpickle_complex(c):returncomplex,(c.real,c.imag) | 10,020 |
def read(self, size=-1): | def read(self, size=-1): | 10,021 |
def read(self, size=-1): | def read(self, size=-1): | 10,022 |
def readline(self, size=None): | def readline(self, size=None): | 10,023 |
def readlines(self, sizehint=0): | def readlines(self, sizehint=0): | 10,024 |
def __str__(self): return self.x | def __str__(self): return self.x | 10,025 |
def startElementNS(self, name, qname, attrs): self._cont_handler.startElement(name, attrs) | def startElementNS(self, name, qname, attrs): self._cont_handler.startElement(name, attrs) | 10,026 |
def askdirectory (**options): "Ask for a directory, and return the file name" return Directory(**options).show() | def askdirectory (**options): "Ask for a directory, and return the file name" return Directory(**options).show() | 10,027 |
def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scrip... | def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scrip... | 10,028 |
def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scrip... | def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scrip... | 10,029 |
def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scrip... | def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scrip... | 10,030 |
def main(): if os.name == 'mac': import macfs fss, ok = macfs.GetDirectory('Directory to zap pyc files in') if not ok: sys.exit(0) dir = fss.as_pathname() zappyc(dir) else: if not sys.argv[1:]: print 'Usage: zappyc dir ...' sys.exit(1) for dir in sys.argv[1:]: zappyc(dir) | def main(): if not sys.argv[1:]: if os.name == 'mac': import macfs fss, ok = macfs.GetDirectory('Directory to zap pyc files in') if not ok: sys.exit(0) dir = fss.as_pathname() zappyc(dir) else: print 'Usage: zappyc dir ...' sys.exit(1) for dir in sys.argv[1:]: zappyc(dir) | 10,031 |
def main(): if os.name == 'mac': import macfs fss, ok = macfs.GetDirectory('Directory to zap pyc files in') if not ok: sys.exit(0) dir = fss.as_pathname() zappyc(dir) else: if not sys.argv[1:]: print 'Usage: zappyc dir ...' sys.exit(1) for dir in sys.argv[1:]: zappyc(dir) | def main(): if os.name == 'mac': import macfs fss, ok = macfs.GetDirectory('Directory to zap pyc files in') if not ok: sys.exit(0) dir = fss.as_pathname() zappyc(dir) else: if not sys.argv[1:]: print 'Usage: zappyc dir ...' sys.exit(1) for dir in sys.argv[1:]: zappyc(dir) | 10,032 |
def doc(thing, title='Python Library Documentation: '): """Display text documentation, given an object or a path to an object.""" suffix, name = '', None if type(thing) is type(''): try: object = locate(thing) except ErrorDuringImport, value: print value return if not object: print 'no Python documentation found for %s... | def doc(thing, title='Python Library Documentation: %s'): """Display text documentation, given an object or a path to an object.""" suffix, name = '', None if type(thing) is type(''): try: object = locate(thing) except ErrorDuringImport, value: print value return if not object: print 'no Python documentation found for ... | 10,033 |
def doc(thing, title='Python Library Documentation: '): """Display text documentation, given an object or a path to an object.""" suffix, name = '', None if type(thing) is type(''): try: object = locate(thing) except ErrorDuringImport, value: print value return if not object: print 'no Python documentation found for %s... | def doc(thing, title='Python Library Documentation: '): """Display text documentation, given an object or a path to an object.""" suffix, name = '', None if type(thing) is type(''): try: object = locate(thing) except ErrorDuringImport, value: print value return if not object: print 'no Python documentation found for %s... | 10,034 |
def run(self, key, callback, completer=None): key = lower(key) self.quit = 0 seen = {} | def run(self, callback, key=None, completer=None): if key: key = lower(key) self.quit = 0 seen = {} | 10,035 |
def run(self, key, callback, completer=None): key = lower(key) self.quit = 0 seen = {} | def run(self, key, callback, completer=None): key = lower(key) self.quit = 0 seen = {} | 10,036 |
def run(self, key, callback, completer=None): key = lower(key) self.quit = 0 seen = {} | def run(self, key, callback, completer=None): key = lower(key) self.quit = 0 seen = {} | 10,037 |
def run(self, key, callback, completer=None): key = lower(key) self.quit = 0 seen = {} | def run(self, key, callback, completer=None): key = lower(key) self.quit = 0 seen = {} | 10,038 |
def callback(path, modname, desc): if modname[-9:] == '.__init__': modname = modname[:-9] + ' (package)' print modname, desc and '- ' + desc | def callback(path, modname, desc): if modname[-9:] == '.__init__': modname = modname[:-9] + ' (package)' print modname, desc and '- ' + desc | 10,039 |
def serve(port, callback=None, finalizer=None): import BaseHTTPServer, SocketServer, mimetools, select # Patch up mimetools.Message so it doesn't break if rfc822 is reloaded. class Message(mimetools.Message): def __init__(self, fp, seekable=1): Message = self.__class__ Message.__bases__[0].__bases__[0].__init__(self, ... | def serve(port, callback=None, completer=None): import BaseHTTPServer, SocketServer, mimetools, select # Patch up mimetools.Message so it doesn't break if rfc822 is reloaded. class Message(mimetools.Message): def __init__(self, fp, seekable=1): Message = self.__class__ Message.__bases__[0].__bases__[0].__init__(self, ... | 10,040 |
def server_activate(self): self.base.server_activate(self) if self.callback: self.callback(self) | def server_activate(self): self.base.server_activate(self) if self.callback: self.callback(self) | 10,041 |
def interact(scriptname): if PPC_ONLY: return 'pwpc' d = Dlg.GetNewDialog(DLG_ID, -1) if not d: print "Can't get DLOG resource with id =", DLG_ID return d.SetDialogDefaultItem(OK_BUTTON) d.SetDialogCancelItem(CANCEL_BUTTON) Dlg.ParamText(scriptname, "", "", "") radiogroup = radio(d, GENFAT_BUTTON, GENPPC_BUTTON, GEN68... | def interact(scriptname): if PPC_ONLY: return 'pwpc', 1 d = Dlg.GetNewDialog(DLG_ID, -1) if not d: print "Can't get DLOG resource with id =", DLG_ID return d.SetDialogDefaultItem(OK_BUTTON) d.SetDialogCancelItem(CANCEL_BUTTON) Dlg.ParamText(scriptname, "", "", "") radiogroup = radio(d, GENFAT_BUTTON, GENPPC_BUTTON, GE... | 10,042 |
def interact(scriptname): if PPC_ONLY: return 'pwpc' d = Dlg.GetNewDialog(DLG_ID, -1) if not d: print "Can't get DLOG resource with id =", DLG_ID return d.SetDialogDefaultItem(OK_BUTTON) d.SetDialogCancelItem(CANCEL_BUTTON) Dlg.ParamText(scriptname, "", "", "") radiogroup = radio(d, GENFAT_BUTTON, GENPPC_BUTTON, GEN68... | def interact(scriptname): if PPC_ONLY: return 'pwpc' d = Dlg.GetNewDialog(DLG_ID, -1) if not d: raise "Can't get DLOG resource with id =", DLG_ID d.SetDialogDefaultItem(OK_BUTTON) d.SetDialogCancelItem(CANCEL_BUTTON) Dlg.ParamText(scriptname, "", "", "") radiogroup = radio(d, GENFAT_BUTTON, GENPPC_BUTTON, GEN68K_BUTTO... | 10,043 |
>>> def f(): | >>> def f(): | 10,044 |
>>> def f(): | >>> def f(): | 10,045 |
>>> def f(): | >>> def f(): | 10,046 |
>>> def f(): | >>> def f(): | 10,047 |
>>> def f(): | >>> def f(): | 10,048 |
>>> def f(): | >>> def f(): | 10,049 |
>>> def f(): | >>> def f(): | 10,050 |
>>> def f(): | >>> def f(): | 10,051 |
>>> def f(): | >>> def f(): | 10,052 |
... def f(i): | ... def f(i): | 10,053 |
def test_gopher(self): import warnings warnings.filterwarnings("ignore", "the gopherlib module is deprecated", DeprecationWarning, "urllib2$") urls = [ # Thanks to Fred for finding these! 'gopher://gopher.lib.ncsu.edu/11/library/stacks/Alex', 'gopher://gopher.vt.edu:10010/10/33', ] self._test_urls(urls, self._extra_han... | def test_gopher(self): import warnings warnings.filterwarnings("ignore", "the gopherlib module is deprecated", DeprecationWarning, "urllib2$") urls = [ # Thanks to Fred for finding these! 'gopher://gopher.lib.ncsu.edu./11/library/stacks/Alex', 'gopher://gopher.vt.edu.:10010/10/33', ] self._test_urls(urls, self._extra_h... | 10,054 |
def _test_urls(self, urls, handlers): import socket import time import logging debug = logging.getLogger("test_urllib2").debug | def _test_urls(self, urls, handlers): import socket import time import logging debug = logging.getLogger("test_urllib2").debug | 10,055 |
def _extra_handlers(self): handlers = [] | def_extra_handlers(self):handlers=[] | 10,056 |
def whichmodule(cls, clsname): """Figure out the module in which a class occurs. Search sys.modules for the module. Cache in classmap. Return a module name. If the class cannot be found, return __main__. """ if classmap.has_key(cls): return classmap[cls] import sys for name, module in sys.modules.items(): if name != ... | def whichmodule(cls, clsname): """Figure out the module in which a class occurs. Search sys.modules for the module. Cache in classmap. Return a module name. If the class cannot be found, return __main__. """ if classmap.has_key(cls): return classmap[cls] for name, module in sys.modules.items(): if name != '__main__' ... | 10,057 |
def load_inst(self): k = self.marker() args = tuple(self.stack[k+1:]) del self.stack[k:] module = self.readline()[:-1] name = self.readline()[:-1] klass = self.find_class(module, name) instantiated = 0 if (not args and type(klass) is ClassType and not hasattr(klass, "__getinitargs__")): try: value = _EmptyClass() value... | def load_inst(self): k = self.marker() args = tuple(self.stack[k+1:]) del self.stack[k:] module = self.readline()[:-1] name = self.readline()[:-1] klass = self.find_class(module, name) instantiated = 0 if (not args and type(klass) is ClassType and not hasattr(klass, "__getinitargs__")): try: value = _EmptyClass() value... | 10,058 |
_s = ("def %s(self, *args): return self._sock.%s(*args)\n\n" "%s.__doc__ = _realsocket.%s.__doc__\n") | _s = ("def %s(self, *args): return self._sock.%s(*args)\n\n" "%s.__doc__ = _realsocket.%s.__doc__\n") | 10,059 |
def test_basic(self): f = StringIO.StringIO('\xed\x95\x9c\n\xea\xb8\x80') ef = codecs.EncodedFile(f, 'utf-16', 'utf-8') self.assertEquals(ef.read(), '\xff\xfe\\\xd5\n\x00\x00\xae') | def test_basic(self): f = StringIO.StringIO('\xed\x95\x9c\n\xea\xb8\x80') ef = codecs.EncodedFile(f, 'utf-16', 'utf-8') self.assertEquals(ef.read(), '\xff\xfe\\\xd5\n\x00\x00\xae') | 10,060 |
def subn(self, repl, source, count=0): """subn(repl, string[, count=0]) -> tuple | def subn(self, repl, source, count=0): """subn(repl, string[, count=0]) -> tuple | 10,061 |
def subn(self, repl, source, count=0): """subn(repl, string[, count=0]) -> tuple | def subn(self, repl, source, count=0): """subn(repl, string[, count=0]) -> tuple | 10,062 |
def smart_backspace_event(self, event): text = self.text first, last = self.editwin.get_selection_indices() if first and last: text.delete(first, last) text.mark_set("insert", first) return "break" # Delete whitespace left, until hitting a real char or closest # preceding virtual tab stop. chars = text.get("insert line... | def smart_backspace_event(self, event): text = self.text first, last = self.editwin.get_selection_indices() if first and last: text.delete(first, last) text.mark_set("insert", first) return "break" # Delete whitespace left, until hitting a real char or closest # preceding virtual tab stop. chars = text.get("insert line... | 10,063 |
def classifyws(s, tabwidth): raw = effective = 0 for ch in s: if ch == ' ': raw = raw + 1 effective = effective + 1 elif ch == '\t': raw = raw + 1 effective = (int(effective / tabwidth) + 1) * tabwidth else: break return raw, effective | def classifyws(s, tabwidth): raw = effective = 0 for ch in s: if ch == ' ': raw = raw + 1 effective = effective + 1 elif ch == '\t': raw = raw + 1 effective = (effective // tabwidth + 1) * tabwidth else: break return raw, effective | 10,064 |
def __init__(self): self.preffilepath = ":Python:PythonIDE preferences" Wapplication.Application.__init__(self, 'Pide') from Carbon import AE from Carbon import AppleEvents AE.AEInstallEventHandler(AppleEvents.kCoreEventClass, AppleEvents.kAEOpenApplication, self.ignoreevent) AE.AEInstallEventHandler(AppleEvents.kCore... | def __init__(self): self.preffilepath = os.path.join("Python", "PythonIDE preferences") Wapplication.Application.__init__(self, 'Pide') from Carbon import AE from Carbon import AppleEvents AE.AEInstallEventHandler(AppleEvents.kCoreEventClass, AppleEvents.kAEOpenApplication, self.ignoreevent) AE.AEInstallEventHandler(A... | 10,065 |
def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (o... | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, leakdebug=0): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look... | 10,066 |
def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (o... | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (o... | 10,067 |
def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (o... | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (o... | 10,068 |
def startElementNS(self, name, tagName , attrs): uri, localname = name if uri: # When using namespaces, the reader may or may not # provide us with the original name. If not, create # *a* valid tagName from the current context. if tagName is None: prefix = self._current_context[uri] if prefix: tagName = prefix + ":" + ... | def startElementNS(self, name, tagName , attrs): uri, localname = name if uri: # When using namespaces, the reader may or may not # provide us with the original name. If not, create # *a* valid tagName from the current context. if tagName is None: prefix = self._current_context[uri] if prefix: tagName = prefix + ":" + ... | 10,069 |
def add_ui(db): x = y = 50 w = 370 h = 300 title = "[ProductName] Setup" # see "Dialog Style Bits" modal = 3 # visible | modal modeless = 1 # visible track_disk_space = 32 add_data(db, 'ActionText', uisample.ActionText) add_data(db, 'UIText', uisample.UIText) # Bitmaps if not os.path.exists(srcdir+r"\PC\pytho... | def add_ui(db): x = y = 50 w = 370 h = 300 title = "[ProductName] Setup" # see "Dialog Style Bits" modal = 3 # visible | modal modeless = 1 # visible track_disk_space = 32 add_data(db, 'ActionText', uisample.ActionText) add_data(db, 'UIText', uisample.UIText) # Bitmaps if not os.path.exists(srcdir+r"\PC\pytho... | 10,070 |
def add_cookie_header(self, request): """Add correct Cookie: header to request (urllib2.Request object). | def add_cookie_header(self, request): """Add correct Cookie: header to request (urllib2.Request object). | 10,071 |
def set_cookie_if_ok(self, cookie, request): """Set a cookie if policy says it's OK to do so.""" self._cookies_lock.acquire() self._policy._now = self._now = int(time.time()) | def set_cookie_if_ok(self, cookie, request): """Set a cookie if policy says it's OK to do so.""" self._cookies_lock.acquire() self._policy._now = self._now = int(time.time()) | 10,072 |
def extract_cookies(self, response, request): """Extract cookies from response, where allowable given the request.""" _debug("extract_cookies: %s", response.info()) self._cookies_lock.acquire() self._policy._now = self._now = int(time.time()) | def extract_cookies(self, response, request): """Extract cookies from response, where allowable given the request.""" _debug("extract_cookies: %s", response.info()) self._cookies_lock.acquire() self._policy._now = self._now = int(time.time()) | 10,073 |
def clear_session_cookies(self): """Discard all session cookies. | def clear_session_cookies(self): """Discard all session cookies. | 10,074 |
def clear_expired_cookies(self): """Discard all expired cookies. | def clear_expired_cookies(self): """Discard all expired cookies. | 10,075 |
def revert(self, filename=None, ignore_discard=False, ignore_expires=False): """Clear all cookies and reload cookies from a saved file. | def revert(self, filename=None, ignore_discard=False, ignore_expires=False): """Clear all cookies and reload cookies from a saved file. | 10,076 |
def revert(self, filename=None, ignore_discard=False, ignore_expires=False): """Clear all cookies and reload cookies from a saved file. | def revert(self, filename=None, ignore_discard=False, ignore_expires=False): """Clear all cookies and reload cookies from a saved file. | 10,077 |
def acquire(self, blocking=1): me = currentThread() if self.__owner is me: self.__count = self.__count + 1 if __debug__: self._note("%s.acquire(%s): recursive success", self, blocking) return 1 rc = self.__block.acquire(blocking) if rc: self.__owner = me self.__count = 1 if __debug__: self._note("%s.acquire(%s): initia... | def acquire(self, blocking=1): me = currentThread() if self.__owner is me: self.__count = self.__count + 1 if __debug__: self._note("%s.acquire(%s): recursive success", self, blocking) return 1 rc = self.__block.acquire(blocking) if rc: self.__owner = me self.__count = 1 if __debug__: self._note("%s.acquire(%s): initia... | 10,078 |
def __init__(self, filename, etype, evalue): self.filename = filename self.etype = etype self.evalue = evalue if type(etype) is types.ClassType: etype = etype.__name__ self.args = '%s: %s' % (etype, evalue) | def __init__(self, filename, (type, value, tb)): self.filename = filename self.etype = etype self.evalue = evalue if type(etype) is types.ClassType: etype = etype.__name__ self.args = '%s: %s' % (etype, evalue) | 10,079 |
def __init__(self, filename, etype, evalue): self.filename = filename self.etype = etype self.evalue = evalue if type(etype) is types.ClassType: etype = etype.__name__ self.args = '%s: %s' % (etype, evalue) | def __init__(self, filename, etype, evalue): self.filename = filename self.etype = etype self.evalue = evalue if type(etype) is types.ClassType: etype = etype.__name__ self.args = '%s: %s' % (etype, evalue) | 10,080 |
def importfile(path): """Import a Python source file or compiled file given its path.""" magic = imp.get_magic() file = open(path, 'r') if file.read(len(magic)) == magic: kind = imp.PY_COMPILED else: kind = imp.PY_SOURCE file.close() filename = os.path.basename(path) name, ext = os.path.splitext(filename) file = open(p... | def importfile(path): """Import a Python source file or compiled file given its path.""" magic = imp.get_magic() file = open(path, 'r') if file.read(len(magic)) == magic: kind = imp.PY_COMPILED else: kind = imp.PY_SOURCE file.close() filename = os.path.basename(path) name, ext = os.path.splitext(filename) file = open(p... | 10,081 |
def ispackage(path): """Guess whether a path refers to a package directory.""" if os.path.isdir(path): init = os.path.join(path, '__init__.py') initc = os.path.join(path, '__init__.pyc') if os.path.isfile(init) or os.path.isfile(initc): return 1 | def ispackage(path): """Guess whether a path refers to a package directory.""" if os.path.isdir(path): for ext in ['.py', '.pyc', '.pyo']: if os.path.isfile(os.path.join(path, '__init__' + ext)): return 1 | 10,082 |
def document(self, object, *args): """Generate documentation for an object.""" args = (object,) + args if inspect.ismodule(object): return apply(self.docmodule, args) if inspect.isclass(object): return apply(self.docclass, args) if inspect.isroutine(object): return apply(self.docroutine, args) raise TypeError, "don't k... | def document(self, object, name=None, *args): """Generate documentation for an object.""" args = (object,) + args if inspect.ismodule(object): return apply(self.docmodule, args) if inspect.isclass(object): return apply(self.docclass, args) if inspect.isroutine(object): return apply(self.docroutine, args) raise TypeErro... | 10,083 |
def document(self, object, *args): """Generate documentation for an object.""" args = (object,) + args if inspect.ismodule(object): return apply(self.docmodule, args) if inspect.isclass(object): return apply(self.docclass, args) if inspect.isroutine(object): return apply(self.docroutine, args) raise TypeError, "don't k... | def document(self, object, *args): """Generate documentation for an object.""" args = (object, name) + args if inspect.ismodule(object): return apply(self.docmodule, args) if inspect.isclass(object): return apply(self.docclass, args) if inspect.isroutine(object): return apply(self.docroutine, args) raise TypeError, "do... | 10,084 |
def document(self, object, *args): """Generate documentation for an object.""" args = (object,) + args if inspect.ismodule(object): return apply(self.docmodule, args) if inspect.isclass(object): return apply(self.docclass, args) if inspect.isroutine(object): return apply(self.docroutine, args) raise TypeError, "don't k... | def document(self, object, *args): """Generate documentation for an object.""" args = (object,) + args if inspect.ismodule(object): return apply(self.docmodule, args) if inspect.isclass(object): return apply(self.docclass, args) if inspect.isroutine(object): return apply(self.docroutine, args) raise TypeError, "don't k... | 10,085 |
def __init__(self): Repr.__init__(self) self.maxlist = self.maxtuple = self.maxdict = 10 self.maxstring = self.maxother = 50 | def __init__(self): Repr.__init__(self) self.maxlist = self.maxtuple = self.maxdict = 10 self.maxstring = self.maxother = 50 | 10,086 |
def repr(self, object): result = Repr.repr(self, object) return result | def repr(self, object): result = Repr.repr(self, object) return result | 10,087 |
def repr_instance(self, x, level): try: return cram(stripid(repr(x)), self.maxstring) except: return self.escape('<%s instance>' % x.__class__.__name__) | def repr_instance(self, x, level): try: return self.escape(cram(stripid(repr(x)), self.maxstring)) except: return self.escape('<%s instance>' % x.__class__.__name__) | 10,088 |
def multicolumn(self, list, format, cols=4): """Format a list of items into a multi-column list.""" result = '' rows = (len(list)+cols-1)/cols | defmulticolumn(self,list,format,cols=4):"""Formatalistofitemsintoamulti-columnlist."""result=''rows=(len(list)+cols-1)/cols | 10,089 |
def heading(self, title, fgcol, bgcol, extras=''): """Format a page heading.""" return """ | def heading(self, title, fgcol, bgcol, extras=''): """Format a page heading.""" return """ | 10,090 |
def modpkglink(self, (name, path, ispackage, shadowed)): """Make a link for a module or package to display in an index.""" if shadowed: return '<font color="#909090">%s</font>' % name if path: url = '%s.%s.html' % (path, name) else: url = '%s.html' % name if ispackage: text = '<strong>%s</strong> (package)' % name... | def modpkglink(self, (name, path, ispackage, shadowed)): """Make a link for a module or package to display in an index.""" if shadowed: return '<font color="#909090">%s</font>' % name if path: url = '%s.%s.html' % (path, name) else: url = '%s.html' % name if ispackage: text = '<strong>%s</strong> (package)' % name... | 10,091 |
def doctree(self, tree, modname, classes={}, parent=None): """Produce HTML for a class tree as given by inspect.getclasstree().""" result = '' for entry in tree: if type(entry) is type(()): c, bases = entry result = result + '<dt><font face="helvetica, arial"><small>' result = result + self.classlink(c, modname, classe... | def formattree(self, tree, modname, classes={}, parent=None): """Produce HTML for a class tree as given by inspect.getclasstree().""" result = '' for entry in tree: if type(entry) is type(()): c, bases = entry result = result + '<dt><font face="helvetica, arial"><small>' result = result + self.classlink(c, modname, cla... | 10,092 |
def doctree(self, tree, modname, classes={}, parent=None): """Produce HTML for a class tree as given by inspect.getclasstree().""" result = '' for entry in tree: if type(entry) is type(()): c, bases = entry result = result + '<dt><font face="helvetica, arial"><small>' result = result + self.classlink(c, modname, classe... | def doctree(self, tree, modname, classes={}, parent=None): """Produce HTML for a class tree as given by inspect.getclasstree().""" result = '' for entry in tree: if type(entry) is type(()): c, bases = entry result = result + '<dt><font face="helvetica, arial"><small>' result = result + self.classlink(c, modname, classe... | 10,093 |
def docmodule(self, object): """Produce HTML documentation for a module object.""" name = object.__name__ parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.... | def docmodule(self, object, name=None): """Produce HTML documentation for a module object.""" name = object.__name__ parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + par... | 10,094 |
def docmodule(self, object): """Produce HTML documentation for a module object.""" name = object.__name__ parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.... | def docmodule(self, object): """Produce HTML documentation for a module object.""" name = object.__name__ parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.... | 10,095 |
def docmodule(self, object): """Produce HTML documentation for a module object.""" name = object.__name__ parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.... | def docmodule(self, object): """Produce HTML documentation for a module object.""" name = object.__name__ parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.... | 10,096 |
def docmodule(self, object): """Produce HTML documentation for a module object.""" name = object.__name__ parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.... | def docmodule(self, object): """Produce HTML documentation for a module object.""" name = object.__name__ parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.... | 10,097 |
def docmodule(self, object): """Produce HTML documentation for a module object.""" name = object.__name__ parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.... | def docmodule(self, object): """Produce HTML documentation for a module object.""" name = object.__name__ parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.... | 10,098 |
def docmodule(self, object): """Produce HTML documentation for a module object.""" name = object.__name__ parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.... | def docmodule(self, object): """Produce HTML documentation for a module object.""" name = object.__name__ parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.... | 10,099 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.