bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def redirect_internal(self, url, fp, errcode, errmsg, headers, data): if 'location' in headers: newurl = headers['location'] elif 'uri' in headers: newurl = headers['uri'] else: return void = fp.read() fp.close() # In case the server sent a relative URL, join with original: newurl = basejoin(self.type + ":" + url, newu...
def redirect_internal(self, url, fp, errcode, errmsg, headers, data): if 'location' in headers: newurl = headers['location'] elif 'uri' in headers: newurl = headers['uri'] else: return void = fp.read() fp.close() # In case the server sent a relative URL, join with original: newurl = basejoin(self.type + ":" + url, newu...
10,200
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,201
def _remote(self, url, action, autoraise): autoraise = int(bool(autoraise)) # always 0/1 raise_opt = self.raise_opts and self.raise_opts[autoraise] or '' cmd = "%s %s %s '%s' >/dev/null 2>&1" % (self.name, raise_opt, self.remote_cmd, action) if remote_background: cmd += ' &' rc = os.system(cmd) if rc: # bad return stat...
def _remote(self, url, action, autoraise): autoraise = int(bool(autoraise)) # always 0/1 raise_opt = self.raise_opts and self.raise_opts[autoraise] or '' cmd = "%s %s %s '%s' >/dev/null 2>&1" % (self.name, raise_opt, self.remote_cmd, action) if self.remote_background: cmd += ' &' rc = os.system(cmd) if rc: # bad return...
10,202
def open(self, url, new=0, autoraise=1): if new: ok = self._remote("LOADNEW " + url) else: ok = self._remote("LOAD " + url) return ok
def open(self, url, new=0, autoraise=1): if new: ok = self._remote("LOADNEW " + url) else: ok = self._remote("LOAD " + url) return ok
10,203
def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m
def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m
10,204
def timeit(self, number=default_number): """Time 'number' executions of the main statement.
def timeit(self, number=default_number): """Time 'number' executions of the main statement.
10,205
def getenvironment(self): if self.path: file = self.path dir = os.path.dirname(file) # check if we're part of a package modname = "" while os.path.exists(os.path.join(dir, "__init__.py")): dir, dirname = os.path.split(dir) modname = modname + dirname + '.' subname = _filename_as_modname(self.title) if modname: if subna...
def getenvironment(self): if self.path: file = self.path dir = os.path.dirname(file) # check if we're part of a package modname = "" while os.path.exists(os.path.join(dir, "__init__.py")): dir, dirname = os.path.split(dir) modname = dirname + '.' + modname subname = _filename_as_modname(self.title) if modname: if subna...
10,206
def getenvironment(self): if self.path: file = self.path dir = os.path.dirname(file) # check if we're part of a package modname = "" while os.path.exists(os.path.join(dir, "__init__.py")): dir, dirname = os.path.split(dir) modname = modname + dirname + '.' subname = _filename_as_modname(self.title) if modname: if subna...
def getenvironment(self): if self.path: file = self.path dir = os.path.dirname(file) # check if we're part of a package modname = "" while os.path.exists(os.path.join(dir, "__init__.py")): dir, dirname = os.path.split(dir) modname = modname + dirname + '.' subname = _filename_as_modname(self.title) if modname: if subna...
10,207
def getenvironment(self): if self.path: file = self.path dir = os.path.dirname(file) # check if we're part of a package modname = "" while os.path.exists(os.path.join(dir, "__init__.py")): dir, dirname = os.path.split(dir) modname = modname + dirname + '.' subname = _filename_as_modname(self.title) if modname: if subna...
def getenvironment(self): if self.path: file = self.path dir = os.path.dirname(file) # check if we're part of a package modname = "" while os.path.exists(os.path.join(dir, "__init__.py")): dir, dirname = os.path.split(dir) modname = modname + dirname + '.' subname = _filename_as_modname(self.title) if modname: if subna...
10,208
def _verify(name, expected): computed = eval(name) if abs(computed - expected) > 1e-7: raise ValueError( "computed value for %s deviates too much " "(computed %g, expected %g)" % (name, computed, expected))
def _verify(name, computed, expected): if abs(computed - expected) > 1e-7: raise ValueError( "computed value for %s deviates too much " "(computed %g, expected %g)" % (name, computed, expected))
10,209
def _verify(name, expected): computed = eval(name) if abs(computed - expected) > 1e-7: raise ValueError( "computed value for %s deviates too much " "(computed %g, expected %g)" % (name, computed, expected))
def _verify(name, expected): computed = eval(name) if abs(computed - expected) > 1e-7: raise ValueError( "computed value for %s deviates too much " "(computed %g, expected %g)" % (name, computed, expected))
10,210
def _verify(name, expected): computed = eval(name) if abs(computed - expected) > 1e-7: raise ValueError( "computed value for %s deviates too much " "(computed %g, expected %g)" % (name, computed, expected))
def _verify(name, expected): computed = eval(name) if abs(computed - expected) > 1e-7: raise ValueError( "computed value for %s deviates too much " "(computed %g, expected %g)" % (name, computed, expected))
10,211
def _verify(name, expected): computed = eval(name) if abs(computed - expected) > 1e-7: raise ValueError( "computed value for %s deviates too much " "(computed %g, expected %g)" % (name, computed, expected))
def _verify(name, expected): computed = eval(name) if abs(computed - expected) > 1e-7: raise ValueError( "computed value for %s deviates too much " "(computed %g, expected %g)" % (name, computed, expected))
10,212
def _verify(name, expected): computed = eval(name) if abs(computed - expected) > 1e-7: raise ValueError( "computed value for %s deviates too much " "(computed %g, expected %g)" % (name, computed, expected))
def _verify(name, expected): computed = eval(name) if abs(computed - expected) > 1e-7: raise ValueError( "computed value for %s deviates too much " "(computed %g, expected %g)" % (name, computed, expected))
10,213
def getwelcome(self): if self.debugging: print '*welcome*', `self.welcome` return self.welcome
def getwelcome(self): if self.debugging: print '*welcome*', self.sanitize(self.welcome) return self.welcome
10,214
def putline(self, line): line = line + CRLF if self.debugging > 1: print '*put*', `line` self.sock.send(line)
def putline(self, line): line = line + CRLF if self.debugging > 1: print '*put*', self.sanitize(line) self.sock.send(line)
10,215
def putcmd(self, line): if self.debugging: print '*cmd*', `line` self.putline(line)
def putcmd(self, line): if self.debugging: print '*cmd*', self.sanitize(line) self.putline(line)
10,216
def getline(self): line = self.file.readline() if self.debugging > 1: print '*get*', `line` if not line: raise EOFError if line[-2:] == CRLF: line = line[:-2] elif line[-1:] in CRLF: line = line[:-1] return line
def getline(self): line = self.file.readline() if self.debugging > 1: print '*get*', self.sanitize(line) if not line: raise EOFError if line[-2:] == CRLF: line = line[:-2] elif line[-1:] in CRLF: line = line[:-1] return line
10,217
def getresp(self): resp = self.getmultiline() if self.debugging: print '*resp*', `resp` self.lastresp = resp[:3] c = resp[:1] if c == '4': raise error_temp, resp if c == '5': raise error_perm, resp if c not in '123': raise error_proto, resp return resp
def getresp(self): resp = self.getmultiline() if self.debugging: print '*resp*', self.sanitize(resp) self.lastresp = resp[:3] c = resp[:1] if c == '4': raise error_temp, resp if c == '5': raise error_perm, resp if c not in '123': raise error_proto, resp return resp
10,218
def abort(self): line = 'ABOR' + CRLF if self.debugging > 1: print '*put urgent*', `line` self.sock.send(line, MSG_OOB) resp = self.getmultiline() if resp[:3] not in ('426', '226'): raise error_proto, resp
def abort(self): line = 'ABOR' + CRLF if self.debugging > 1: print '*put urgent*', self.sanitize(line) self.sock.send(line, MSG_OOB) resp = self.getmultiline() if resp[:3] not in ('426', '226'): raise error_proto, resp
10,219
def parse_multipart(fp, pdict): """Parse multipart input. Arguments: fp : input file pdict: dictionary containing other parameters of conten-type header Returns a dictionary just like parse_qs(): keys are the field names, each value is a list of values for that field. This is easy to use but not much good if you a...
def parse_multipart(fp, pdict): """Parse multipart input. Arguments: fp : input file pdict: dictionary containing other parameters of conten-type header Returns a dictionary just like parse_qs(): keys are the field names, each value is a list of values for that field. This is easy to use but not much good if you a...
10,220
def read_multi(self, environ, keep_blank_values, strict_parsing): """Internal: read a part that is itself multipart.""" self.list = [] klass = self.FieldStorageClass or self.__class__ part = klass(self.fp, {}, self.innerboundary, environ, keep_blank_values, strict_parsing) # Throw first part away while not part.done: h...
def read_multi(self, environ, keep_blank_values, strict_parsing): """Internal: read a part that is itself multipart.""" self.list = [] klass = self.FieldStorageClass or self.__class__ part = klass(self.fp, {}, ib, environ, keep_blank_values, strict_parsing) # Throw first part away while not part.done: headers = rfc822....
10,221
def read_multi(self, environ, keep_blank_values, strict_parsing): """Internal: read a part that is itself multipart.""" self.list = [] klass = self.FieldStorageClass or self.__class__ part = klass(self.fp, {}, self.innerboundary, environ, keep_blank_values, strict_parsing) # Throw first part away while not part.done: h...
def read_multi(self, environ, keep_blank_values, strict_parsing): """Internal: read a part that is itself multipart.""" self.list = [] klass = self.FieldStorageClass or self.__class__ part = klass(self.fp, {}, self.innerboundary, environ, keep_blank_values, strict_parsing) # Throw first part away while not part.done: h...
10,222
def onecmd(self, line): line = string.strip(line) if line == '?': line = 'help' elif line == '!': if hasattr(self, 'do_shell'): line = 'shell' else: return self.default(line) elif not line: return self.emptyline() self.lastcmd = line i, n = 0, len(line) while i < n and line[i] in self.identchars: i = i+1 cmd, arg = lin...
def onecmd(self, line): line = string.strip(line) if not line: return self.emptyline() elif line[0] == '?': line = 'help ' + line[1:] elif line[0] == '!': if hasattr(self, 'do_shell'): line = 'shell' else: return self.default(line) elif not line: return self.emptyline() self.lastcmd = line i, n = 0, len(line) while i <...
10,223
def onecmd(self, line): line = string.strip(line) if line == '?': line = 'help' elif line == '!': if hasattr(self, 'do_shell'): line = 'shell' else: return self.default(line) elif not line: return self.emptyline() self.lastcmd = line i, n = 0, len(line) while i < n and line[i] in self.identchars: i = i+1 cmd, arg = lin...
def onecmd(self, line): line = string.strip(line) if line == '?': line = 'help' elif line == '!': if hasattr(self, 'do_shell'): line = 'shell ' + line[1:] else: return self.default(line) elif not line: return self.emptyline() self.lastcmd = line i, n = 0, len(line) while i < n and line[i] in self.identchars: i = i+1 cm...
10,224
def onecmd(self, line): line = string.strip(line) if line == '?': line = 'help' elif line == '!': if hasattr(self, 'do_shell'): line = 'shell' else: return self.default(line) elif not line: return self.emptyline() self.lastcmd = line i, n = 0, len(line) while i < n and line[i] in self.identchars: i = i+1 cmd, arg = lin...
def onecmd(self, line): line = string.strip(line) if line == '?': line = 'help' elif line == '!': if hasattr(self, 'do_shell'): line = 'shell' else: return self.default(line) self.lastcmd = line i, n = 0, len(line) while i < n and line[i] in self.identchars: i = i+1 cmd, arg = line[:i], string.strip(line[i:]) if cmd ==...
10,225
def initfp(self, file): self._file = file self._version = 0 self._decomp = None self._markers = [] self._soundpos = 0 form = self._file.read(4) if form != 'FORM': raise Error, 'file does not start with FORM id' formlength = _read_long(self._file) if formlength <= 0: raise Error, 'invalid FORM chunk data size' formdata ...
def initfp(self, file): self._file = file self._version = 0 self._decomp = None self._markers = [] self._soundpos = 0 form = self._file.read(4) if form != 'FORM': raise Error, 'file does not start with FORM id' formlength = _read_long(self._file) if formlength <= 0: raise Error, 'invalid FORM chunk data size' formdata ...
10,226
def readframes(self, nframes): if self._ssnd_seek_needed: self._ssnd_chunk.rewind() dummy = self._ssnd_chunk.read(8) pos = self._soundpos * self._nchannels * self._sampwidth if self._decomp: if self._comptype in ('ULAW', 'ALAW'): pos = pos / 2 if pos: self._ssnd_chunk.setpos(pos + 8) self._ssnd_seek_needed = 0 size = n...
def readframes(self, nframes): if self._ssnd_seek_needed: self._ssnd_chunk.rewind() dummy = self._ssnd_chunk.read(8) pos = self._soundpos * self._nchannels * self._sampwidth if self._decomp: if self._comptype in ('ULAW', 'ALAW'): pos = pos / 2 if pos: self._ssnd_chunk.setpos(pos + 8) self._ssnd_seek_needed = 0 size = n...
10,227
def main(): # overridable context prefix = None # settable with -p option exec_prefix = None # settable with -P option extensions = [] path = sys.path[:] modargs = 0 debug = 1 odir = '' win = sys.platform[:3] == 'win' # modules that are imported by the Python runtime implicits = ...
def main(): # overridable context prefix = None # settable with -p option exec_prefix = None # settable with -P option extensions = [] path = sys.path[:] modargs = 0 debug = 1 odir = '' win = sys.platform[:3] == 'win' # modules that are imported by the Python runtime implicits = ...
10,228
def __init__(self, name=None, mode="r", fileobj=None): """Open an (uncompressed) tar archive `name'. `mode' is either 'r' to read from an existing archive, 'a' to append data to an existing file or 'w' to create a new file overwriting an existing one. `mode' defaults to 'r'. If `fileobj' is given, it is used for readin...
def __init__(self, name=None, mode="r", fileobj=None): """Open an (uncompressed) tar archive `name'. `mode' is either 'r' to read from an existing archive, 'a' to append data to an existing file or 'w' to create a new file overwriting an existing one. `mode' defaults to 'r'. If `fileobj' is given, it is used for readin...
10,229
def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9): """Open gzip compressed tar archive name for reading or writing. Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": raise ValueError("mode must be 'r' or 'w'")
def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9): """Open gzip compressed tar archive name for reading or writing. Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": raise ValueError("mode must be 'r' or 'w'")
10,230
def add(self, name, arcname=None, recursive=True): """Add the file `name' to the archive. `name' may be any type of file (directory, fifo, symbolic link, etc.). If given, `arcname' specifies an alternative name for the file in the archive. Directories are added recursively by default. This can be avoided by setting `re...
def add(self, name, arcname=None, recursive=True): """Add the file `name' to the archive. `name' may be any type of file (directory, fifo, symbolic link, etc.). If given, `arcname' specifies an alternative name for the file in the archive. Directories are added recursively by default. This can be avoided by setting `re...
10,231
def makefile(self, tarinfo, targetpath): """Make a file called targetpath. """ source = self.extractfile(tarinfo) target = open(targetpath, "wb") copyfileobj(source, target) source.close() target.close()
def makefile(self, tarinfo, targetpath): """Make a file called targetpath. """ source = self.extractfile(tarinfo) target = _open(targetpath, "wb") copyfileobj(source, target) source.close() target.close()
10,232
def wrap(self, text): """wrap(text : string) -> [string]
def wrap(self, text): """wrap(text : string) -> [string]
10,233
def fill(self, text): """fill(text : string) -> string
def fill(self, text): """fill(text : string) -> string
10,234
def fill(self, text): """fill(text : string) -> string
def fill(self, text): """fill(text : string) -> string
10,235
def __init__(self, timer=None): self.timings = {} self.cur = None self.cmd = ""
def __init__(self, timer=None): self.timings = {} self.cur = None self.cmd = ""
10,236
def __init__(self, timer=None): self.timings = {} self.cur = None self.cmd = ""
def __init__(self, timer=None): self.timings = {} self.cur = None self.cmd = ""
10,237
def __init__(self, timer=None): self.timings = {} self.cur = None self.cmd = ""
def __init__(self, timer=None): self.timings = {} self.cur = None self.cmd = ""
10,238
def __init__(self, timer=None): self.timings = {} self.cur = None self.cmd = ""
def __init__(self, timer=None): self.timings = {} self.cur = None self.cmd = ""
10,239
def __init__(self, timer=None): self.timings = {} self.cur = None self.cmd = ""
def __init__(self, timer=None): self.timings = {} self.cur = None self.cmd = ""
10,240
def __init__(self, timer=None): self.timings = {} self.cur = None self.cmd = ""
def __init__(self, timer=None): self.timings = {} self.cur = None self.cmd = ""
10,241
def __init__(self, timer=None): self.timings = {} self.cur = None self.cmd = ""
def __init__(self, timer=None): self.timings = {} self.cur = None self.cmd = ""
10,242
def trace_dispatch(self, frame, event, arg): t = self.timer() t = t[0] + t[1] - self.t # No Calibration constant # t = t[0] + t[1] - self.t - .00053 # Calibration constant
def trace_dispatch(self, frame, event, arg): timer = self.timer t = timer() t = t[0] + t[1] - self.t # No Calibration constant # t = t[0] + t[1] - self.t - .00053 # Calibration constant
10,243
def trace_dispatch(self, frame, event, arg): t = self.timer() t = t[0] + t[1] - self.t # No Calibration constant # t = t[0] + t[1] - self.t - .00053 # Calibration constant
def trace_dispatch(self, frame, event, arg): t = self.timer() t = t[0] + t[1] - self.t # No Calibration constant # t = t[0] + t[1] - self.t - .00053 # Calibration constant
10,244
def trace_dispatch(self, frame, event, arg): t = self.timer() t = t[0] + t[1] - self.t # No Calibration constant # t = t[0] + t[1] - self.t - .00053 # Calibration constant
def trace_dispatch(self, frame, event, arg): t = self.timer() t = t[0] + t[1] - self.t # No Calibration constant # t = t[0] + t[1] - self.t - .00053 # Calibration constant
10,245
def trace_dispatch_i(self, frame, event, arg): t = self.timer() - self.t # - 1 # Integer calibration constant if self.dispatch[event](frame,t): self.t = self.timer() else: self.t = self.timer() - t # put back unrecorded delta return
def trace_dispatch_i(self, frame, event, arg): t = self.timer() - self.t # - 1 # Integer calibration constant if self.dispatch[event](frame,t): self.t = self.timer() else: self.t = self.timer() - t # put back unrecorded delta return
10,246
def trace_dispatch_i(self, frame, event, arg): t = self.timer() - self.t # - 1 # Integer calibration constant if self.dispatch[event](frame,t): self.t = self.timer() else: self.t = self.timer() - t # put back unrecorded delta return
def trace_dispatch_i(self, frame, event, arg): t = self.timer() - self.t # - 1 # Integer calibration constant if self.dispatch[event](frame,t): self.t = self.timer() else: self.t = self.timer() - t # put back unrecorded delta return
10,247
def trace_dispatch_mac(self, frame, event, arg): t = self.timer()/60.0 - self.t # - 1 # Integer calibration constant if self.dispatch[event](frame,t): self.t = self.timer()/60.0 else: self.t = self.timer()/60.0 - t # put back unrecorded delta return
def trace_dispatch_mac(self, frame, event, arg): t = self.timer()/60.0 - self.t # - 1 # Integer calibration constant if self.dispatch[event](frame,t): self.t = self.timer()/60.0 else: self.t = self.timer()/60.0 - t # put back unrecorded delta return
10,248
def trace_dispatch_l(self, frame, event, arg): t = self.get_time() - self.t
def trace_dispatch_l(self, frame, event, arg): t = self.get_time() - self.t
10,249
def trace_dispatch_call(self, frame, t): fcode = frame.f_code fn = (fcode.co_filename, fcode.co_firstlineno, fcode.co_name) self.cur = (t, 0, 0, fn, frame, self.cur) if self.timings.has_key(fn): cc, ns, tt, ct, callers = self.timings[fn] self.timings[fn] = cc, ns + 1, tt, ct, callers else: self.timings[fn] = 0, 0, 0, 0...
def trace_dispatch_call(self, frame, t): fcode = frame.f_code fn = (fcode.co_filename, fcode.co_firstlineno, fcode.co_name) self.cur = (t, 0, 0, fn, frame, self.cur) timings = self.timings if timings.has_key(fn): cc, ns, tt, ct, callers = timings[fn] timings[fn] = cc, ns + 1, tt, ct, callers else: timings[fn] = 0, 0, 0...
10,250
def trace_dispatch_return(self, frame, t): # if not frame is self.cur[-2]: raise "Bad return", self.cur[3]
def trace_dispatch_return(self, frame, t): # if not frame is self.cur[-2]: raise "Bad return", self.cur[3]
10,251
def trace_dispatch_return(self, frame, t): # if not frame is self.cur[-2]: raise "Bad return", self.cur[3]
def trace_dispatch_return(self, frame, t): # if not frame is self.cur[-2]: raise "Bad return", self.cur[3]
10,252
def simulate_call(self, name): code = self.fake_code('profile', 0, name) if self.cur: pframe = self.cur[-2] else: pframe = None frame = self.fake_frame(code, pframe) a = self.dispatch['call'](frame, 0) return
def simulate_call(self, name): code = self.fake_code('profile', 0, name) if self.cur: pframe = self.cur[-2] else: pframe = None frame = self.fake_frame(code, pframe) a = self.dispatch['call'](self, frame, 0) return
10,253
def simulate_cmd_complete(self): t = self.get_time() - self.t while self.cur[-1]: # We *can* cause assertion errors here if # dispatch_trace_return checks for a frame match! a = self.dispatch['return'](self.cur[-2], t) t = 0 self.t = self.get_time() - t
def simulate_cmd_complete(self): get_time = self.get_time t = get_time() - self.t while self.cur[-1]: # We *can* cause assertion errors here if # dispatch_trace_return checks for a frame match! a = self.dispatch['return'](self.cur[-2], t) t = 0 self.t = self.get_time() - t
10,254
def simulate_cmd_complete(self): t = self.get_time() - self.t while self.cur[-1]: # We *can* cause assertion errors here if # dispatch_trace_return checks for a frame match! a = self.dispatch['return'](self.cur[-2], t) t = 0 self.t = self.get_time() - t
def simulate_cmd_complete(self): t = self.get_time() - self.t while self.cur[-1]: # We *can* cause assertion errors here if # dispatch_trace_return checks for a frame match! a = self.dispatch['return'](self, self.cur[-2], t) t = 0 self.t = self.get_time() - t
10,255
def simulate_cmd_complete(self): t = self.get_time() - self.t while self.cur[-1]: # We *can* cause assertion errors here if # dispatch_trace_return checks for a frame match! a = self.dispatch['return'](self.cur[-2], t) t = 0 self.t = self.get_time() - t
def simulate_cmd_complete(self): t = self.get_time() - self.t while self.cur[-1]: # We *can* cause assertion errors here if # dispatch_trace_return checks for a frame match! a = self.dispatch['return'](self.cur[-2], t) t = 0 self.t = self.get_time() - t
10,256
def runcall(self, func, *args): self.set_cmd(`func`) sys.setprofile(self.dispatcher) try: return apply(func, args) finally: sys.setprofile(None)
def runcall(self, func, *args, **kw): self.set_cmd(`func`) sys.setprofile(self.dispatcher) try: return apply(func, args) finally: sys.setprofile(None)
10,257
def runcall(self, func, *args): self.set_cmd(`func`) sys.setprofile(self.dispatcher) try: return apply(func, args) finally: sys.setprofile(None)
def runcall(self, func, *args): self.set_cmd(`func`) sys.setprofile(self.dispatcher) try: return apply(func, args, kw) finally: sys.setprofile(None)
10,258
def calibrate(self, m): # Modified by Tim Peters n = m s = self.get_time() while n: self.simple() n = n - 1 f = self.get_time() my_simple = f - s #print "Simple =", my_simple,
def calibrate(self, m): # Modified by Tim Peters n = m s = get_time() while n: self.simple() n = n - 1 f = self.get_time() my_simple = f - s #print "Simple =", my_simple,
10,259
def calibrate(self, m): # Modified by Tim Peters n = m s = self.get_time() while n: self.simple() n = n - 1 f = self.get_time() my_simple = f - s #print "Simple =", my_simple,
def calibrate(self, m): # Modified by Tim Peters n = m s = self.get_time() while n: self.simple() n = n - 1 f = get_time() my_simple = f - s #print "Simple =", my_simple,
10,260
def calibrate(self, m): # Modified by Tim Peters n = m s = self.get_time() while n: self.simple() n = n - 1 f = self.get_time() my_simple = f - s #print "Simple =", my_simple,
def calibrate(self, m): # Modified by Tim Peters n = m s = get_time() while n: self.simple() n = n - 1 f = self.get_time() my_simple = f - s #print "Simple =", my_simple,
10,261
def calibrate(self, m): # Modified by Tim Peters n = m s = self.get_time() while n: self.simple() n = n - 1 f = self.get_time() my_simple = f - s #print "Simple =", my_simple,
def calibrate(self, m): # Modified by Tim Peters n = m s = self.get_time() while n: self.simple() n = n - 1 f = get_time() my_simple = f - s #print "Simple =", my_simple,
10,262
def Stats(*args): print 'Report generating functions are in the "pstats" module\a'
def Stats(*args): print 'Report generating functions are in the "pstats" module\a'
10,263
def hitter(ctl, part, self=self): if part: self._hit(part)
def hitter(ctl, part, self=self): if part: self._hit(part)
10,264
def visit(pattern, dirname, names): if os.path.islink(dirname): names[:] = [] return if os.path.ismount(dirname): print 'descend into', dirname n = len(pattern) for name in names: name = os.path.join(dirname, name) try: linkto = os.readlink(name) if linkto[:n] == pattern: print name, '->', linkto except os.error: pass
def main(): try: opts, args = getopt.getopt(sys.argv[1:], '') if len(args) < 2: raise getopt.error, 'not enough arguments' except getopt.error, msg: sys.stdout = sys.stderr print msg print 'usage: findlinksto pattern directory ...' sys.exit(2) pat, dirs = args[0], args[1:] prog = regex.compile(pat) for dirname in dirs:...
10,265
def visit(pattern, dirname, names): if os.path.islink(dirname): names[:] = [] return if os.path.ismount(dirname): print 'descend into', dirname n = len(pattern) for name in names: name = os.path.join(dirname, name) try: linkto = os.readlink(name) if linkto[:n] == pattern: print name, '->', linkto except os.error: pass
def visit(pattern, dirname, names): if os.path.islink(dirname): names[:] = [] return if os.path.ismount(dirname): print 'descend into', dirname for name in names: name = os.path.join(dirname, name) try: linkto = os.readlink(name) if linkto[:n] == pattern: print name, '->', linkto except os.error: pass
10,266
def visit(pattern, dirname, names): if os.path.islink(dirname): names[:] = [] return if os.path.ismount(dirname): print 'descend into', dirname n = len(pattern) for name in names: name = os.path.join(dirname, name) try: linkto = os.readlink(name) if linkto[:n] == pattern: print name, '->', linkto except os.error: pass
def visit(pattern, dirname, names): if os.path.islink(dirname): names[:] = [] return if os.path.ismount(dirname): print 'descend into', dirname n = len(pattern) for name in names: name = os.path.join(dirname, name) try: linkto = os.readlink(name) if prog.search(linkto) >= 0: print name, '->', linkto except os.error: pa...
10,267
def makeusermenus(self): m = Wapplication.Menu(self.menubar, "File") newitem = FrameWork.MenuItem(m, "New", "N", 'new') openitem = FrameWork.MenuItem(m, "Open"+ELIPSES, "O", 'open') openbynameitem = FrameWork.MenuItem(m, "Open File by Name"+ELIPSES, "D", 'openbyname') self.openrecentmenu = FrameWork.SubMenu(m, "Open Re...
def makeusermenus(self): m = Wapplication.Menu(self.menubar, "File") newitem = FrameWork.MenuItem(m, "New", "N", 'new') openitem = FrameWork.MenuItem(m, "Open"+ELLIPSIS, "O", 'open') openbynameitem = FrameWork.MenuItem(m, "Open File by Name"+ELLIPSIS, "D", 'openbyname') self.openrecentmenu = FrameWork.SubMenu(m, "Open ...
10,268
def makeusermenus(self): m = Wapplication.Menu(self.menubar, "File") newitem = FrameWork.MenuItem(m, "New", "N", 'new') openitem = FrameWork.MenuItem(m, "Open"+ELIPSES, "O", 'open') openbynameitem = FrameWork.MenuItem(m, "Open File by Name"+ELIPSES, "D", 'openbyname') self.openrecentmenu = FrameWork.SubMenu(m, "Open Re...
def makeusermenus(self): m = Wapplication.Menu(self.menubar, "File") newitem = FrameWork.MenuItem(m, "New", "N", 'new') openitem = FrameWork.MenuItem(m, "Open"+ELIPSES, "O", 'open') openbynameitem = FrameWork.MenuItem(m, "Open File by Name"+ELIPSES, "D", 'openbyname') self.openrecentmenu = FrameWork.SubMenu(m, "Open Re...
10,269
def makeusermenus(self): m = Wapplication.Menu(self.menubar, "File") newitem = FrameWork.MenuItem(m, "New", "N", 'new') openitem = FrameWork.MenuItem(m, "Open"+ELIPSES, "O", 'open') openbynameitem = FrameWork.MenuItem(m, "Open File by Name"+ELIPSES, "D", 'openbyname') self.openrecentmenu = FrameWork.SubMenu(m, "Open Re...
def makeusermenus(self): m = Wapplication.Menu(self.menubar, "File") newitem = FrameWork.MenuItem(m, "New", "N", 'new') openitem = FrameWork.MenuItem(m, "Open"+ELIPSES, "O", 'open') openbynameitem = FrameWork.MenuItem(m, "Open File by Name"+ELIPSES, "D", 'openbyname') self.openrecentmenu = FrameWork.SubMenu(m, "Open Re...
10,270
def makeusermenus(self): m = Wapplication.Menu(self.menubar, "File") newitem = FrameWork.MenuItem(m, "New", "N", 'new') openitem = FrameWork.MenuItem(m, "Open"+ELIPSES, "O", 'open') openbynameitem = FrameWork.MenuItem(m, "Open File by Name"+ELIPSES, "D", 'openbyname') self.openrecentmenu = FrameWork.SubMenu(m, "Open Re...
def makeusermenus(self): m = Wapplication.Menu(self.menubar, "File") newitem = FrameWork.MenuItem(m, "New", "N", 'new') openitem = FrameWork.MenuItem(m, "Open"+ELIPSES, "O", 'open') openbynameitem = FrameWork.MenuItem(m, "Open File by Name"+ELIPSES, "D", 'openbyname') self.openrecentmenu = FrameWork.SubMenu(m, "Open Re...
10,271
def makeusermenus(self): m = Wapplication.Menu(self.menubar, "File") newitem = FrameWork.MenuItem(m, "New", "N", 'new') openitem = FrameWork.MenuItem(m, "Open"+ELIPSES, "O", 'open') openbynameitem = FrameWork.MenuItem(m, "Open File by Name"+ELIPSES, "D", 'openbyname') self.openrecentmenu = FrameWork.SubMenu(m, "Open Re...
def makeusermenus(self): m = Wapplication.Menu(self.menubar, "File") newitem = FrameWork.MenuItem(m, "New", "N", 'new') openitem = FrameWork.MenuItem(m, "Open"+ELIPSES, "O", 'open') openbynameitem = FrameWork.MenuItem(m, "Open File by Name"+ELIPSES, "D", 'openbyname') self.openrecentmenu = FrameWork.SubMenu(m, "Open Re...
10,272
def makeusermenus(self): m = Wapplication.Menu(self.menubar, "File") newitem = FrameWork.MenuItem(m, "New", "N", 'new') openitem = FrameWork.MenuItem(m, "Open"+ELIPSES, "O", 'open') openbynameitem = FrameWork.MenuItem(m, "Open File by Name"+ELIPSES, "D", 'openbyname') self.openrecentmenu = FrameWork.SubMenu(m, "Open Re...
def makeusermenus(self): m = Wapplication.Menu(self.menubar, "File") newitem = FrameWork.MenuItem(m, "New", "N", 'new') openitem = FrameWork.MenuItem(m, "Open"+ELIPSES, "O", 'open') openbynameitem = FrameWork.MenuItem(m, "Open File by Name"+ELIPSES, "D", 'openbyname') self.openrecentmenu = FrameWork.SubMenu(m, "Open Re...
10,273
def getabouttext(self): return "About Python IDE"+ELIPSES
def getabouttext(self): return "About Python IDE"+ELLIPSIS
10,274
def _charset(charset, fixup): # internal: optimize character set out = [] charmap = [0]*256 try: for op, av in charset: if op is NEGATE: out.append((op, av)) elif op is LITERAL: charmap[fixup(av)] = 1 elif op is RANGE: for i in range(fixup(av[0]), fixup(av[1])+1): charmap[i] = 1 elif op is CATEGORY: # FIXME: could appe...
def _charset(charset, fixup=None): # internal: optimize character set out = [] charmap = [0]*256 try: for op, av in charset: if op is NEGATE: out.append((op, av)) elif op is LITERAL: charmap[fixup(av)] = 1 elif op is RANGE: for i in range(fixup(av[0]), fixup(av[1])+1): charmap[i] = 1 elif op is CATEGORY: # FIXME: could...
10,275
def verisnot(a, b): if a is b: raise TestFailed, "%r is %r" % (a, b)
def verisnot(a, b): if a is b: raise TestFailed, "%r is %r" % (a, b)
10,276
def pack_items(items, indent = 0): items = map(lambda (k, v), type = type, simp = SIMPLE_TYPES, indent = indent: (k, v, not type(v) in simp, indent), items) return tuple_caselesssort(items)
def pack_items(items, indent = 0): items = [(k, v, not isinstance(v, SIMPLE_TYPES), indent) for k, v in items] return tuple_caselesssort(items)
10,277
def testPackageRequire(self): tcl = self.interp tcl.eval('package require Tclx') tcl.eval('keylset a b.c 1') self.assertEqual(tcl.eval('keylget a b.c'),'1')
def testPackageRequire(self): tcl = self.interp tcl.eval('package require Tclx') tcl.eval('keylset a b.c 1') self.assertEqual(tcl.eval('keylget a b.c'),'1')
10,278
def testLoadTkFailure(self): import os old_display = None import sys if sys.platform.startswith('win'): return # no failure possible on windows? if 'DISPLAY' in os.environ: old_display = os.environ['DISPLAY'] del os.environ['DISPLAY'] # on some platforms, deleting environment variables # doesn't actually carry through ...
def testLoadTkFailure(self): import os old_display = None import sys if sys.platform.startswith('win') or sys.platform.startswith('darwin'): return # no failure possible on windows? if 'DISPLAY' in os.environ: old_display = os.environ['DISPLAY'] del os.environ['DISPLAY'] # on some platforms, deleting environment variab...
10,279
def findnames(file, prefix=""): names = {} for line in file.readlines(): if line[0] == '!': continue fields = line.split() name, tag = fields[0], fields[-1] if tag == 'd' and name.endswith('_H'): continue if name.startswith(prefix): names[name] = tag return names
def findnames(file, prefixes=()): names = {} for line in file.readlines(): if line[0] == '!': continue fields = line.split() name, tag = fields[0], fields[-1] if tag == 'd' and name.endswith('_H'): continue if name.startswith(prefix): names[name] = tag return names
10,280
def findnames(file, prefix=""): names = {} for line in file.readlines(): if line[0] == '!': continue fields = line.split() name, tag = fields[0], fields[-1] if tag == 'd' and name.endswith('_H'): continue if name.startswith(prefix): names[name] = tag return names
def findnames(file, prefix=""): names = {} for line in file.xreadlines(): if line[0] == '!': continue fields = line.split() name, tag = fields[0], fields[-1] if tag == 'd' and name.endswith('_H'): continue if name.startswith(prefix): names[name] = tag return names
10,281
def findnames(file, prefix=""): names = {} for line in file.readlines(): if line[0] == '!': continue fields = line.split() name, tag = fields[0], fields[-1] if tag == 'd' and name.endswith('_H'): continue if name.startswith(prefix): names[name] = tag return names
def findnames(file, prefix=""): names = {} for line in file.readlines(): if line[0] == '!': continue fields = line.split() name, tag = fields[0], fields[-1] if tag == 'd' and name.endswith('_H'): continue if prefixes: sw = name.startswith for prefix in prefixes: if sw(prefix): names[name] = tag else: names[name] = tag ...
10,282
def print_undoc_symbols(prefix, docdir, incdir): docs = [] for sect in DOCSECTIONS: for file in glob.glob(os.path.join(docdir, sect, "*.tex")): docs.append(open(file).read()) docs = "\n".join(docs) incfiles = os.path.join(incdir, INCLUDEPATTERN) fp = os.popen("ctags -IDL_IMPORT --c-types=%s -f - %s" % (TAG_KINDS, i...
def print_undoc_symbols(prefix, docdir, incdir): docs = [] for sect in DOCSECTIONS: for file in glob.glob(os.path.join(docdir, sect, "*.tex")): docs.append(open(file).read()) docs = "\n".join(docs) incfiles = os.path.join(incdir, INCLUDEPATTERN) fp = os.popen("ctags -IDL_IMPORT --c-types=%s -f - %s" % (TAG_KINDS, i...
10,283
def print_undoc_symbols(prefix, docdir, incdir): docs = [] for sect in DOCSECTIONS: for file in glob.glob(os.path.join(docdir, sect, "*.tex")): docs.append(open(file).read()) docs = "\n".join(docs) incfiles = os.path.join(incdir, INCLUDEPATTERN) fp = os.popen("ctags -IDL_IMPORT --c-types=%s -f - %s" % (TAG_KINDS, i...
def print_undoc_symbols(prefix, docdir, incdir): docs = [] for sect in DOCSECTIONS: for file in glob.glob(os.path.join(docdir, sect, "*.tex")): docs.append(open(file).read()) docs = "\n".join(docs) incfiles = os.path.join(incdir, INCLUDEPATTERN) fp = os.popen("ctags -IDL_IMPORT --c-types=%s -f - %s" % (TAG_KINDS, i...
10,284
def bind(self, sequence=None, command=None): return self.canvas.tag_bind(self.id, sequence, command)
def bind(self, sequence=None, command=None): return self.canvas.tag_bind(self.id, sequence, command)
10,285
def lower(self, belowthis=None): self.canvas.lower(self.id, belowthis)
def lower(self, belowthis=None): self.canvas.lower(self.id, belowthis)
10,286
def tkraise(self, abovethis=None): self.canvas.tkraise(self.id, abovethis)
def tkraise(self, abovethis=None): self.canvas.tkraise(self.id, abovethis)
10,287
def bind(self, sequence=None, command=None): return self.canvas.tag_bind(self.id, sequence, command)
def bind(self, sequence=None, command=None): return self.canvas.tag_bind(self.id, sequence, command)
10,288
def lower(self, belowThis=None): self._do('lower', belowThis)
def lower(self, belowThis=None): self._do('lower', belowThis)
10,289
def tkraise(self, aboveThis=None): self._do('raise', aboveThis)
def tkraise(self, aboveThis=None): self._do('raise', aboveThis)
10,290
def read(self, size): """Read 'size' bytes from remote.""" # sslobj.read() sometimes returns < size bytes chunks = [] read = 0 while read < size: data = self.sslobj.read(size-read) read += len(data) chunks.append(size)
def read(self, size): """Read 'size' bytes from remote.""" # sslobj.read() sometimes returns < size bytes chunks = [] read = 0 while read < size: data = self.sslobj.read(size-read) read += len(data) chunks.append(size)
10,291
def check(a, b): if a != b: print '*** check failed: %s != %s' % (repr(a), repr(b)) else: print '%s == %s: OK' % (repr(a), repr(b))
def check(a, b): if a != b: print '*** check failed: %s != %s' % (repr(a), repr(b)) else: print '%s == %s: OK' % (a, b)
10,292
def get_arg_text(ob): "Get a string describing the arguments for the given object" argText = "" if ob is not None: argOffset = 0 if type(ob)==types.ClassType: # Look for the highest __init__ in the class chain. fob = _find_constructor(ob) if fob is None: fob = lambda: None else: argOffset = 1 elif type(ob)==types.Metho...
def get_arg_text(ob): "Get a string describing the arguments for the given object" argText = "" if ob is not None: argOffset = 0 if type(ob)==types.ClassType: # Look for the highest __init__ in the class chain. fob = _find_constructor(ob) if fob is None: fob = lambda: None else: argOffset = 1 elif type(ob)==types.Metho...
10,293
def get_arg_text(ob): "Get a string describing the arguments for the given object" argText = "" if ob is not None: argOffset = 0 if type(ob)==types.ClassType: # Look for the highest __init__ in the class chain. fob = _find_constructor(ob) if fob is None: fob = lambda: None else: argOffset = 1 elif type(ob)==types.Metho...
def get_arg_text(ob): "Get a string describing the arguments for the given object" argText = "" if ob is not None: argOffset = 0 if type(ob)==types.ClassType: # Look for the highest __init__ in the class chain. fob = _find_constructor(ob) if fob is None: fob = lambda: None else: argOffset = 1 elif type(ob)==types.Metho...
10,294
def check_extensions_list (self, extensions): """Ensure that the list of extensions (presumably provided as a command option 'extensions') is valid, i.e. it is a list of Extension objects. We also support the old-style list of 2-tuples, where the tuples are (ext_name, build_info), which are converted to Extension inst...
def check_extensions_list (self, extensions): """Ensure that the list of extensions (presumably provided as a command option 'extensions') is valid, i.e. it is a list of Extension objects. We also support the old-style list of 2-tuples, where the tuples are (ext_name, build_info), which are converted to Extension inst...
10,295
def splitbins(bins): # split a sparse integer table into two tables, such as: # value = t2[(t1[char>>shift]<<shift)+(char&mask)] # and value == 0 means no data bytes = sys.maxint for shift in range(16): bin1 = [] bin2 = [] size = 2**shift bincache = {} for i in range(0, len(bins), size): bin = bins[i:i+size] index = ...
def splitbins(bins): # split a sparse integer table into two tables, such as: # value = t2[(t1[char>>shift]<<shift)+(char&mask)] # and value == 0 means no data bytes = sys.maxint for shift in range(16): bin1 = [] bin2 = [] size = 2**shift bincache = {} for i in range(0, len(bins), size): bin = bins[i:i+size] index = ...
10,296
def splitbins(bins): # split a sparse integer table into two tables, such as: # value = t2[(t1[char>>shift]<<shift)+(char&mask)] # and value == 0 means no data bytes = sys.maxint for shift in range(16): bin1 = [] bin2 = [] size = 2**shift bincache = {} for i in range(0, len(bins), size): bin = bins[i:i+size] index = ...
def splitbins(bins): # split a sparse integer table into two tables, such as: # value = t2[(t1[char>>shift]<<shift)+(char&mask)] # and value == 0 means no data bytes = sys.maxint for shift in range(16): bin1 = [] bin2 = [] size = 2**shift bincache = {} for i in range(0, len(t), size): bin = t[i:i+size] index = bincac...
10,297
def splitbins(bins): # split a sparse integer table into two tables, such as: # value = t2[(t1[char>>shift]<<shift)+(char&mask)] # and value == 0 means no data bytes = sys.maxint for shift in range(16): bin1 = [] bin2 = [] size = 2**shift bincache = {} for i in range(0, len(bins), size): bin = bins[i:i+size] index = ...
def splitbins(bins): # split a sparse integer table into two tables, such as: # value = t2[(t1[char>>shift]<<shift)+(char&mask)] # and value == 0 means no data bytes = sys.maxint for shift in range(16): bin1 = [] bin2 = [] size = 2**shift bincache = {} for i in range(0, len(bins), size): bin = bins[i:i+size] index = ...
10,298
def splitbins(bins): # split a sparse integer table into two tables, such as: # value = t2[(t1[char>>shift]<<shift)+(char&mask)] # and value == 0 means no data bytes = sys.maxint for shift in range(16): bin1 = [] bin2 = [] size = 2**shift bincache = {} for i in range(0, len(bins), size): bin = bins[i:i+size] index = ...
def splitbins(bins): # split a sparse integer table into two tables, such as: # value = t2[(t1[char>>shift]<<shift)+(char&mask)] # and value == 0 means no data bytes = sys.maxint for shift in range(16): bin1 = [] bin2 = [] size = 2**shift bincache = {} for i in range(0, len(bins), size): bin = bins[i:i+size] index = ...
10,299