bugged stringlengths 4 228k | fixed stringlengths 0 96.3M | __index_level_0__ int64 0 481k |
|---|---|---|
def test_index(self, size): l = [1L, 2L, 3L, 4L, 5L] * (size // 5) self.assertEquals(l.index(1), 0) self.assertEquals(l.index(5, size - 5), size - 1) self.assertEquals(l.index(5, size - 5, size), size - 1) self.assertRaises(ValueError, l.index, 1, size - 4, size) self.assertRaises(ValueError, l.index, 6L) | def test_index(self, size): l = [1L, 2L, 3L, 4L, 5L] * size size *= 5 self.assertEquals(l.index(1), 0) self.assertEquals(l.index(5, size - 5), size - 1) self.assertEquals(l.index(5, size - 5, size), size - 1) self.assertRaises(ValueError, l.index, 1, size - 4, size) self.assertRaises(ValueError, l.index, 6L) | 23,900 |
def test_insert(self, size): l = [1.0] * size l.insert(size - 1, "A") size += 1 self.assertEquals(len(l), size) self.assertEquals(l[-3:], [1.0, "A", 1.0]) | def test_insert(self, size): l = [1.0] * size l.insert(size - 1, "A") size += 1 self.assertEquals(len(l), size) self.assertEquals(l[-3:], [1.0, "A", 1.0]) | 23,901 |
def test_pop(self, size): l = [u"a", u"b", u"c", u"d", u"e"] * (size // 5) self.assertEquals(len(l), size) | def test_pop(self, size): l = [u"a", u"b", u"c", u"d", u"e"] * size size *= 5 self.assertEquals(len(l), size) | 23,902 |
def test_remove(self, size): l = [10] * size self.assertEquals(len(l), size) | def test_remove(self, size): l = [10] * size self.assertEquals(len(l), size) | 23,903 |
def test_reverse(self, size): l = [1, 2, 3, 4, 5] * (size // 5) l.reverse() self.assertEquals(len(l), size) self.assertEquals(l[-5:], [5, 4, 3, 2, 1]) self.assertEquals(l[:5], [5, 4, 3, 2, 1]) | def test_reverse(self, size): l = [1, 2, 3, 4, 5] * size l.reverse() self.assertEquals(len(l), size) self.assertEquals(l[-5:], [5, 4, 3, 2, 1]) self.assertEquals(l[:5], [5, 4, 3, 2, 1]) | 23,904 |
def test_reverse(self, size): l = [1, 2, 3, 4, 5] * (size // 5) l.reverse() self.assertEquals(len(l), size) self.assertEquals(l[-5:], [5, 4, 3, 2, 1]) self.assertEquals(l[:5], [5, 4, 3, 2, 1]) | def test_reverse(self, size): l = [1, 2, 3, 4, 5] * (size // 5) l.reverse() self.assertEquals(len(l), size * 5) self.assertEquals(l[-5:], [5, 4, 3, 2, 1]) self.assertEquals(l[:5], [5, 4, 3, 2, 1]) | 23,905 |
def test_reverse(self, size): l = [1, 2, 3, 4, 5] * (size // 5) l.reverse() self.assertEquals(len(l), size) self.assertEquals(l[-5:], [5, 4, 3, 2, 1]) self.assertEquals(l[:5], [5, 4, 3, 2, 1]) | def test_reverse(self, size): l = [1, 2, 3, 4, 5] * (size // 5) l.reverse() self.assertEquals(len(l), size) self.assertEquals(l[-5:], [5, 4, 3, 2, 1]) self.assertEquals(l[:5], [5, 4, 3, 2, 1]) | 23,906 |
def test_sort(self, size): l = [1, 2, 3, 4, 5] * (size // 5) l.sort() self.assertEquals(len(l), size) self.assertEquals(l.count(1), size // 5) self.assertEquals(l[:10], [1] * 10) self.assertEquals(l[-10:], [5] * 10) | def test_sort(self, size): l = [1, 2, 3, 4, 5] * size l.sort() self.assertEquals(len(l), size) self.assertEquals(l.count(1), size // 5) self.assertEquals(l[:10], [1] * 10) self.assertEquals(l[-10:], [5] * 10) | 23,907 |
def test_sort(self, size): l = [1, 2, 3, 4, 5] * (size // 5) l.sort() self.assertEquals(len(l), size) self.assertEquals(l.count(1), size // 5) self.assertEquals(l[:10], [1] * 10) self.assertEquals(l[-10:], [5] * 10) | def test_sort(self, size): l = [1, 2, 3, 4, 5] * (size // 5) l.sort() self.assertEquals(len(l), size * 5) self.assertEquals(l.count(1), size) self.assertEquals(l[:10], [1] * 10) self.assertEquals(l[-10:], [5] * 10) | 23,908 |
def splituser(host): """splituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'.""" global _userprog if _userprog is None: import re _userprog = re.compile('^([^@]*)@(.*)$') match = _userprog.match(host) if match: return map(unquote, match.group(1, 2)) return None, host | def splituser(host): """splituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'.""" global _userprog if _userprog is None: import re _userprog = re.compile('^(.*)@(.*)$') match = _userprog.match(host) if match: return map(unquote, match.group(1, 2)) return None, host | 23,909 |
def begin(self): self.resetoutput() if use_subprocess: nosub = '' client = self.interp.start_subprocess() if not client: self.close() return None else: nosub = "==== No Subprocess ====" self.write("Python %s on %s\n%s\n%s\nIDLE %s %s\n" % (sys.version, sys.platform, self.COPYRIGHT, self.firewallmessage, idlever.ID... | def begin(self): self.resetoutput() if use_subprocess: nosub = '' client = self.interp.start_subprocess() if not client: self.close() return False else: nosub = "==== No Subprocess ====" self.write("Python %s on %s\n%s\n%s\nIDLE %s %s\n" % (sys.version, sys.platform, self.COPYRIGHT, self.firewallmessage, idlever.I... | 23,910 |
def begin(self): self.resetoutput() if use_subprocess: nosub = '' client = self.interp.start_subprocess() if not client: self.close() return None else: nosub = "==== No Subprocess ====" self.write("Python %s on %s\n%s\n%s\nIDLE %s %s\n" % (sys.version, sys.platform, self.COPYRIGHT, self.firewallmessage, idlever.ID... | def begin(self): self.resetoutput() if use_subprocess: nosub = '' client = self.interp.start_subprocess() if not client: self.close() return None else: nosub = "==== No Subprocess ====" self.write("Python %s on %s\n%s\n%s\nIDLE %s %s\n" % (sys.version, sys.platform, self.COPYRIGHT, self.firewallmessage, idlever.ID... | 23,911 |
def main(): print 'hello world' # XXXX # skip the toolbox initializations, already done # XXXX Should use gestalt here to check for quicktime version Qt.EnterMovies() # Get the movie file fss, ok = macfs.StandardGetFile(QuickTime.MovieFileType) if not ok: sys.exit(0) # Open the window bounds = (175, 75, 175+160, 75+1... | def main(): print 'hello world' # XXXX # skip the toolbox initializations, already done # XXXX Should use gestalt here to check for quicktime version Qt.EnterMovies() # Get the movie file fss, ok = macfs.StandardGetFile(QuickTime.MovieFileType) if not ok: sys.exit(0) # Open the window bounds = (175, 75, 175+160, 75+1... | 23,912 |
def basename(s): return split(s)[1] | defbasename(s):returnsplit(s)[1] | 23,913 |
def commonprefix(m): "Given a list of pathnames, returns the longest common leading component" if not m: return '' n = m[:] for i in range(len(n)): n[i] = n[i].split(os.sep) # if os.sep didn't have any effect, try os.altsep if os.altsep and len(n[i]) == 1: n[i] = n[i].split(os.altsep) prefix = n[0] for item in n: for ... | def commonprefix(m): "Given a list of pathnames, returns the longest common leading component" if not m: return '' n = m[:] for i in range(len(n)): n[i] = n[i].split(os.sep) # if os.sep didn't have any effect, try os.altsep if os.altsep and len(n[i]) == 1: n[i] = n[i].split(os.altsep) prefix = n[0] for item in n: for ... | 23,914 |
def commonprefix(m): "Given a list of pathnames, returns the longest common leading component" if not m: return '' n = m[:] for i in range(len(n)): n[i] = n[i].split(os.sep) # if os.sep didn't have any effect, try os.altsep if os.altsep and len(n[i]) == 1: n[i] = n[i].split(os.altsep) prefix = n[0] for item in n: for ... | def commonprefix(m): "Given a list of pathnames, returns the longest common leading component" if not m: return '' n = m[:] for i in range(len(n)): n[i] = n[i].split(os.sep) # if os.sep didn't have any effect, try os.altsep if os.altsep and len(n[i]) == 1: n[i] = n[i].split(os.altsep) prefix = n[0] for item in n: for ... | 23,915 |
def findsource(object): """Return the entire source file and starting line number for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of all the lines in the file and the line number indexes a line in that list. An IOError is r... | def findsource(object): """Return the entire source file and starting line number for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of all the lines in the file and the line number indexes a line in that list. An IOError is r... | 23,916 |
def findsource(object): """Return the entire source file and starting line number for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of all the lines in the file and the line number indexes a line in that list. An IOError is r... | def findsource(object): """Return the entire source file and starting line number for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of all the lines in the file and the line number indexes a line in that list. An IOError is r... | 23,917 |
def finalize_unix (self): | def finalize_unix (self): | 23,918 |
def handle_extra_path (self): | def handle_extra_path (self): | 23,919 |
def run (self): | def run (self): | 23,920 |
def jabs_op(name, op): opname[op] = name hasjabs.append(op) | def jabs_op(name, op): opname[op] = name hasjabs.append(op) | 23,921 |
def __init__(self, screenName=None, baseName=None, className='Tk', useTk=1): """Return a new Toplevel widget on screen SCREENNAME. A new Tcl interpreter will be created. BASENAME will be used for the identification of the profile file (see readprofile). It is constructed from sys.argv[0] without extensions if None is g... | def __init__(self, screenName=None, baseName=None, className='Tk', useTk=1, sync=0, use=None): """Return a new Toplevel widget on screen SCREENNAME. A new Tcl interpreter will be created. BASENAME will be used for the identification of the profile file (see readprofile). It is constructed from sys.argv[0] without exten... | 23,922 |
def __init__(self, screenName=None, baseName=None, className='Tk', useTk=1): """Return a new Toplevel widget on screen SCREENNAME. A new Tcl interpreter will be created. BASENAME will be used for the identification of the profile file (see readprofile). It is constructed from sys.argv[0] without extensions if None is g... | def __init__(self, screenName=None, baseName=None, className='Tk', useTk=1): """Return a new Toplevel widget on screen SCREENNAME. A new Tcl interpreter will be created. BASENAME will be used for the identification of the profile file (see readprofile). It is constructed from sys.argv[0] without extensions if None is g... | 23,923 |
def do_clear(self, arg): # Three possibilities, tried in this order: # clear -> clear all breaks, ask for confirmation # clear file:lineno -> clear all breaks at file:lineno # clear bpno bpno ... -> clear breakpoints by number if not arg: try: reply = raw_input('Clear all breaks? ') except EOFError: reply = 'no' reply ... | def do_clear(self, arg): # Three possibilities, tried in this order: # clear -> clear all breaks, ask for confirmation # clear file:lineno -> clear all breaks at file:lineno # clear bpno bpno ... -> clear breakpoints by number if not arg: try: reply = raw_input('Clear all breaks? ') except EOFError: reply = 'no' reply ... | 23,924 |
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') | def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') | 23,925 |
def record_sub_info(match_object,sub_info=sub_info): sub_info.append([match_object.group(1)[0],match_object.span()]) return match_object.group(1) | def record_sub_info(match_object,sub_info=sub_info): sub_info.append([match_object.group(1)[0],match_object.span()]) return match_object.group(1) | 23,926 |
def main(): # turn off warnings when deprecated modules are imported import warnings warnings.filterwarnings("ignore",category=DeprecationWarning) setup(name = 'Python standard library', version = '%d.%d' % sys.version_info[:2], cmdclass = {'build_ext':PyBuildExt, 'install':PyBuildInstall}, # The struct module is defin... | def main(): # turn off warnings when deprecated modules are imported import warnings warnings.filterwarnings("ignore",category=DeprecationWarning) setup(name = 'Python standard library', version = '%d.%d' % sys.version_info[:2], cmdclass = {'build_ext':PyBuildExt, 'install':PyBuildInstall, 'install_lib':PyBuildInstallL... | 23,927 |
def rev(self): if self._rev is not None: return self._rev L = list(self) L.reverse() self._rev = self.__class__("".join(L)) return self._rev | defverify(str(s).__class__ is str) rev(self):verify(str(s).__class__ is str) ifverify(str(s).__class__ is str) self._revverify(str(s).__class__ is str) isverify(str(s).__class__ is str) notverify(str(s).__class__ is str) None:verify(str(s).__class__ is str) returnverify(str(s).__class__ is str) self._revverify(str(s)._... | 23,928 |
def weakrefs(): if verbose: print "Testing weak references..." import weakref class C(object): pass c = C() r = weakref.ref(c) verify(r() is c) del c verify(r() is None) del r class NoWeak(object): __slots__ = ['foo'] no = NoWeak() try: weakref.ref(no) except TypeError, msg: verify(str(msg).find("weakly") >= 0) else: v... | def weakrefs(): if verbose: print "Testing weak references..." import weakref class C(object): pass c = C() r = weakref.ref(c) verify(r() is c) del c verify(r() is None) del r class NoWeak(object): __slots__ = ['foo'] no = NoWeak() try: weakref.ref(no) except TypeError, msg: verify(str(msg).find("weak reference") >= 0)... | 23,929 |
def read_mime_types(file): try: f = open(file) except IOError: return None map = {} while 1: line = f.readline() if not line: break words = line.split() for i in range(len(words)): if words[i][0] == '#': del words[i:] break if not words: continue type, suffixes = words[0], words[1:] for suff in suffixes: map['.'+suff] ... | def read_mime_types(file): try: f = open(file) except IOError: return None map = {} while 1: line = f.readline() if not line: break words = line.split() for i in range(len(words)): if words[i][0] == '#': del words[i:] break if not words: continue type, suffixes = words[0], words[1:] for suff in suffixes: map['.'+suff] ... | 23,930 |
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') | def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') | 23,931 |
def writestr(self, zinfo, bytes): """Write a file into the archive. The contents is the string 'bytes'.""" self._writecheck(zinfo) zinfo.file_size = len(bytes) # Uncompressed size zinfo.CRC = binascii.crc32(bytes) # CRC-32 checksum if zinfo.compress_type == ZIP_DEFLATED: co = zlib.compressobj(zlib.Z_D... | def writestr(self, zinfo_or_arcname, bytes): """Write a file into the archive. The contents is the string 'bytes'.""" self._writecheck(zinfo) zinfo.file_size = len(bytes) # Uncompressed size zinfo.CRC = binascii.crc32(bytes) # CRC-32 checksum if zinfo.compress_type == ZIP_DEFLATED: co = zlib.compresso... | 23,932 |
def writestr(self, zinfo, bytes): """Write a file into the archive. The contents is the string 'bytes'.""" self._writecheck(zinfo) zinfo.file_size = len(bytes) # Uncompressed size zinfo.CRC = binascii.crc32(bytes) # CRC-32 checksum if zinfo.compress_type == ZIP_DEFLATED: co = zlib.compressobj(zlib.Z_D... | def writestr(self, zinfo, bytes): """Write a file into the archive. The contents is the string 'bytes'. 'zinfo_or_arcname' is either a ZipInfo instance or the name of the file in the archive.""" if not isinstance(zinfo_or_arcname, ZipInfo): zinfo = ZipInfo(filename=zinfo_or_arcname, date_time=time.localtime(time.time... | 23,933 |
def __init__(self, versionPredicateStr): """Parse a version predicate string. """ # Fields: # name: package name # pred: list of (comparison string, StrictVersion) | def __init__(self, versionPredicateStr): """Parse a version predicate string. """ # Fields: # name: package name # pred: list of (comparison string, StrictVersion) | 23,934 |
def buildPython(): print "Building a universal python" buildDir = os.path.join(WORKDIR, '_bld', 'python') rootDir = os.path.join(WORKDIR, '_root') if os.path.exists(buildDir): shutil.rmtree(buildDir) if os.path.exists(rootDir): shutil.rmtree(rootDir) os.mkdir(buildDir) os.mkdir(rootDir) os.mkdir(os.path.join(rootDir,... | def buildPython(): print "Building a universal python" buildDir = os.path.join(WORKDIR, '_bld', 'python') rootDir = os.path.join(WORKDIR, '_root') if os.path.exists(buildDir): shutil.rmtree(buildDir) if os.path.exists(rootDir): shutil.rmtree(rootDir) os.mkdir(buildDir) os.mkdir(rootDir) os.mkdir(os.path.join(rootDir,... | 23,935 |
def test(expression, result, exception=None): try: r = eval(expression) except: if exception: if not isinstance(sys.exc_value, exception): print expression, "FAILED" # display name, not actual value if exception is sre.error: print "expected", "sre.error" else: print "expected", exception.__name__ print "got", sys.exc_... | def test(expression, result, exception=None): try: r = eval(expression) except: if exception: if not isinstance(sys.exc_value, exception): print expression, "FAILED" # display name, not actual value if exception is sre.error: print "expected", "sre.error" else: print "expected", exception.__name__ print "got", sys.exc_... | 23,936 |
def test(expression, result, exception=None): try: r = eval(expression) except: if exception: if not isinstance(sys.exc_value, exception): print expression, "FAILED" # display name, not actual value if exception is sre.error: print "expected", "sre.error" else: print "expected", exception.__name__ print "got", sys.exc_... | def test(expression, result, exception=None): try: r = eval(expression) except: if exception: if not isinstance(sys.exc_value, exception): print expression, "FAILED" # display name, not actual value if exception is sre.error: print "expected", "sre.error" else: print "expected", exception.__name__ print "got", sys.exc_... | 23,937 |
def test(expression, result, exception=None): try: r = eval(expression) except: if exception: if not isinstance(sys.exc_value, exception): print expression, "FAILED" # display name, not actual value if exception is sre.error: print "expected", "sre.error" else: print "expected", exception.__name__ print "got", sys.exc_... | def test(expression, result, exception=None): try: r = eval(expression) except: if exception: if not isinstance(sys.exc_value, exception): print expression, "FAILED" # display name, not actual value if exception is sre.error: print "expected", "sre.error" else: print "expected", exception.__name__ print "got", sys.exc_... | 23,938 |
def test(expression, result, exception=None): try: r = eval(expression) except: if exception: if not isinstance(sys.exc_value, exception): print expression, "FAILED" # display name, not actual value if exception is sre.error: print "expected", "sre.error" else: print "expected", exception.__name__ print "got", sys.exc_... | def test(expression, result, exception=None): try: r = eval(expression) except: if exception: if not isinstance(sys.exc_value, exception): print expression, "FAILED" # display name, not actual value if exception is sre.error: print "expected", "sre.error" else: print "expected", exception.__name__ print "got", sys.exc_... | 23,939 |
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | 23,940 |
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | 23,941 |
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | 23,942 |
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | 23,943 |
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | 23,944 |
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | 23,945 |
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | 23,946 |
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | 23,947 |
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | 23,948 |
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | 23,949 |
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | 23,950 |
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | 23,951 |
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | 23,952 |
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | 23,953 |
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) | 23,954 |
def update_wrapper(wrapper, wrapped, assigned = WRAPPER_ASSIGNMENTS, updated = WRAPPER_UPDATES): """Update a wrapper function to look like the wrapped function wrapper is the function to be updated wrapped is the original function assigned is a tuple naming the attributes assigned directly from the wrapped function to... | def update_wrapper(wrapper, wrapped, assigned = WRAPPER_ASSIGNMENTS, updated = WRAPPER_UPDATES): """Update a wrapper function to look like the wrapped function wrapper is the function to be updated wrapped is the original function assigned is a tuple naming the attributes assigned directly from the wrapped function to... | 23,955 |
def startElementNS(self, name, qname, attrs): self._cont_handler.startElement(name, attrs) | def startElementNS(self, name, qname, attrs): self._cont_handler.startElement(name, attrs) | 23,956 |
def subconvert(line, ofp, table, discards, autoclosing, endchar=None): stack = [] while line: if line[0] == endchar and not stack: return line[1:] m = _comment_rx.match(line) if m: text = m.group(1) if text: ofp.write("(COMMENT\n") ofp.write("- %s \n" % encode(text)) ofp.write(")COMMENT\n") ofp.write("-\\n\n") | def subconvert(line, ofp, table, discards, autoclosing, endchar=None): stack = [] while line: if line[0] == endchar and not stack: return line[1:] m = _comment_rx.match(line) if m: text = m.group(1) if text: ofp.write("(COMMENT\n") ofp.write("- %s \n" % encode(text)) ofp.write(")COMMENT\n") ofp.write("-\\n\n") | 23,957 |
def convert(ifp, ofp, table={}, discards=(), autoclosing=()): try: subconvert(ifp.read(), ofp, table, discards, autoclosing) except IOError, (err, msg): if err != errno.EPIPE: raise | def convert(ifp, ofp, table={}, discards=(), autoclosing=()): try: subconvert(data, ofp, table, discards, autoclosing) except IOError, (err, msg): if err != errno.EPIPE: raise | 23,958 |
def tearDown(self): del self.db | def tearDown(self): del self.db | 23,959 |
def parse229(resp, peer): '''Parse the '229' response for a EPSV request. Raises error_proto if it does not contain '(|||port|)' Return ('host.addr.as.numbers', port#) tuple.''' if resp[:3] <> '229': raise error_reply, resp left = resp.find('(') if left < 0: raise error_proto, resp right = resp.find(')', left + 1) if ... | def parse229(resp, peer): '''Parse the '229' response for a EPSV request. Raises error_proto if it does not contain '(|||port|)' Return ('host.addr.as.numbers', port#) tuple.''' if resp[:3] <> '229': raise error_reply, resp left = resp.find('(') if left < 0: raise error_proto, resp right = resp.find(')', left + 1) if ... | 23,960 |
def minus(a, b): if len(a) < len(b): a, b = b, a # make sure a is the longest res = a[:] # make a copy for i in range(len(b)): res[i] = res[i] - b[i] return normalize(res) | def minus(a, b): if len(a) < len(b): a, b = b, a # make sure a is the longest res = a[:] # make a copy for i in range(len(b)): res[i] = res[i] - b[i] return normalize(res) | 23,961 |
def __init__(self, filename="NoName", date_time=(1980,1,1,0,0,0)): self.orig_filename = filename # Original file name in archive | def __init__(self, filename="NoName", date_time=(1980,1,1,0,0,0)): self.orig_filename = filename # Original file name in archive | 23,962 |
def _read_eof(self): # We've read to the end of the file, so we have to rewind in order # to reread the 8 bytes containing the CRC and the file size. # We check the that the computed CRC and size of the # uncompressed data matches the stored values. self.fileobj.seek(-8, 1) crc32 = read32(self.fileobj) isize = U32(read... | def _read_eof(self): # We've read to the end of the file, so we have to rewind in order # to reread the 8 bytes containing the CRC and the file size. # We check the that the computed CRC and size of the # uncompressed data matches the stored values. self.fileobj.seek(-8... | 23,963 |
def _read_eof(self): # We've read to the end of the file, so we have to rewind in order # to reread the 8 bytes containing the CRC and the file size. # We check the that the computed CRC and size of the # uncompressed data matches the stored values. self.fileobj.seek(-8, 1) crc32 = read32(self.fileobj) isize = U32(read... | def _read_eof(self): # We've read to the end of the file, so we have to rewind in order # to reread the 8 bytes containing the CRC and the file size. # We check the that the computed CRC and size of the # uncompressed data matches the stored values. self.fileobj.seek(-8, 1) crc32 = read32(self.fileobj) isize = U32(read... | 23,964 |
def close(self): if self.mode == WRITE: self.fileobj.write(self.compress.flush()) write32(self.fileobj, self.crc) # self.size may exceed 2GB write32u(self.fileobj, self.size) self.fileobj = None elif self.mode == READ: self.fileobj = None if self.myfileobj: self.myfileobj.close() self.myfileobj = None | def close(self): if self.mode == WRITE: self.fileobj.write(self.compress.flush()) write32(self.fileobj, self.crc) # self.size may exceed 2GB write32u(self.fileobj, LOWU32(self.size)) self.fileobj = None elif self.mode == READ: self.fileobj = None if self.myfileobj: self.myfileobj.close() self.myfileobj = None | 23,965 |
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.insert(0, '/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.insert(0, '/usr/local/include' ) | def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.insert(0, '/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.insert(0, '/usr/local/include' ) | 23,966 |
def check_module_event(self, event): filename = self.getfilename() if not filename: return if not self.tabnanny(filename): return self.checksyntax(filename) | def check_module_event(self, event=None): filename = self.getfilename() if not filename: return if not self.tabnanny(filename): return self.checksyntax(filename) | 23,967 |
def run_module_event(self, event): """Run the module after setting up the environment. | def run_module_event(self, event): """Run the module after setting up the environment. | 23,968 |
def open(self, path, name, data): self.path = path self.name = name r = (40, 40, 400, 300) w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555) self.wid = w r2 = (0, 0, 345, 245) Qd.SetPort(w) Qd.TextFont(4) Qd.TextSize(9) self.ted = TE.TENew(r2, r2) self.ted.TEAutoView(1) self.ted.TESetText(data) w.DrawGrowIcon() self.... | def open(self, path, name, data): self.path = path self.name = name r = windowbounds(400, 400) w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555) self.wid = w r2 = (0, 0, 345, 245) Qd.SetPort(w) Qd.TextFont(4) Qd.TextSize(9) self.ted = TE.TENew(r2, r2) self.ted.TEAutoView(1) self.ted.TESetText(data) w.DrawGrowIcon() s... | 23,969 |
def open(self, path, name, data): self.path = path self.name = name r = (40, 40, 400, 300) w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555) self.wid = w r2 = (0, 0, 345, 245) Qd.SetPort(w) Qd.TextFont(4) Qd.TextSize(9) self.ted = TE.TENew(r2, r2) self.ted.TEAutoView(1) self.ted.TESetText(data) w.DrawGrowIcon() self.... | def open(self, path, name, data): self.path = path self.name = name r = (40, 40, 400, 300) w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555) self.wid = w vr = 0, 0, r[2]-r[0]-15, r[3]-r[1]-15 dr = (0, 0, vr[2], 0) Qd.SetPort(w) Qd.TextFont(4) Qd.TextSize(9) self.ted = TE.TENew(r2, r2) self.ted.TEAutoView(1) self.ted.... | 23,970 |
def open(self, path, name, data): self.path = path self.name = name r = (40, 40, 400, 300) w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555) self.wid = w r2 = (0, 0, 345, 245) Qd.SetPort(w) Qd.TextFont(4) Qd.TextSize(9) self.ted = TE.TENew(r2, r2) self.ted.TEAutoView(1) self.ted.TESetText(data) w.DrawGrowIcon() self.... | def open(self, path, name, data): self.path = path self.name = name r = (40, 40, 400, 300) w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555) self.wid = w r2 = (0, 0, 345, 245) Qd.SetPort(w) Qd.TextFont(4) Qd.TextSize(9) self.ted = TE.TENew(dr, vr) self.ted.TEAutoView(1) self.ted.TESetText(data) w.DrawGrowIcon() self.... | 23,971 |
def getscrollbarvalues(self): dr = self.ted.destRect vr = self.ted.viewRect height = self.ted.nLines * self.ted.lineHeight vx = self.scalebarvalue(dr[0], dr[2]-dr[0], vr[0], vr[2]) vy = self.scalebarvalue(dr[1], dr[1]+height, vr[1], vr[3]) print dr, vr, height, vx, vy return vx, vy | def getscrollbarvalues(self): dr = self.ted.destRect vr = self.ted.viewRect height = self.ted.nLines * self.ted.lineHeight vx = self.scalebarvalue(dr[0], dr[2]-dr[0], vr[0], vr[2]) vy = self.scalebarvalue(dr[1], dr[1]+height, vr[1], vr[3]) print dr, vr, height, vx, vy return None, vy | 23,972 |
def scrollbar_callback(self, which, what, value): if which == 'y': if what == 'set': height = self.ted.nLines * self.ted.lineHeight cur = self.getscrollbarvalues()[1] delta = (cur-value)*height/32767 if what == '-': delta = self.ted.lineHeight elif what == '--': delta = (self.ted.viewRect[3]-self.ted.lineHeight) if del... | def scrollbar_callback(self, which, what, value): if which == 'y': if what == 'set': height = self.ted.nLines * self.ted.lineHeight cur = self.getscrollbarvalues()[1] delta = (cur-value)*height/32767 if what == '-': delta = self.ted.lineHeight elif what == '--': delta = (self.ted.viewRect[3]-self.ted.lineHeight) if del... | 23,973 |
def idle(self, *args): for l in self._windows.values(): l.do_idle() | def idle(self, *args): for l in self._windows.values(): l.do_idle() | 23,974 |
def handle(self): """Handle a single HTTP request. | def handle(self): """Handle a single HTTP request. | 23,975 |
def handle(self): """Handle a single HTTP request. | def handle(self): """Handle a single HTTP request. | 23,976 |
def handle(self): """Handle a single HTTP request. | def handle(self): """Handle a single HTTP request. | 23,977 |
def handle(self): """Handle a single HTTP request. | def handle(self): """Handle a single HTTP request. | 23,978 |
def handle(self): """Handle a single HTTP request. | def handle(self): """Handle a single HTTP request. | 23,979 |
def handle(self): """Handle a single HTTP request. | def handle(self): """Handle a single HTTP request. | 23,980 |
def copy(self): if self.__class__ is UserDict: return UserDict(self.data) import copy return copy.copy(self) | def copy(self): if self.__class__ is UserDict: return UserDict(self.data) import copy return copy.copy(self) | 23,981 |
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. | def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. | 23,982 |
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. | def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. | 23,983 |
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. | def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. | 23,984 |
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. | def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. | 23,985 |
def paren_open_event(self, event): self._remove_calltip_window() arg_text = get_arg_text(self.get_object_at_cursor()) if arg_text: self.calltip_start = self.text.index("insert") self.calltip = self._make_calltip_window() self.calltip.showtip(arg_text) # dont return "break" so the key is inserted. | defreturn "" paren_open_event(self,return "" event):return "" self._remove_calltip_window()return "" arg_textreturn "" =return "" get_arg_text(self.get_object_at_cursor())return "" ifreturn "" arg_text:return "" self.calltip_startreturn "" =return "" self.text.index("insert")return "" self.calltipreturn "" =return "" s... | 23,986 |
def paren_close_event(self, event): # Now just hides, but later we should check if other # paren'd expressions remain open. # dont return "break" so the key is inserted. self._remove_calltip_window() | defparen_close_event(self,event):#Nowjusthides,butlaterweshouldcheckifother#paren'dexpressionsremainopen.#dontreturn"break"sothekeyisinserted.self._remove_calltip_window() | 23,987 |
def check_calltip_cancel_event(self, event): # This doesnt quite work correctly as it is processed # _before_ the key is handled. Thus, when the "Up" key # is pressed, this test happens before the cursor is moved. # This will do for now. if self.calltip: # If we have moved before the start of the calltip, # or off the... | def check_calltip_cancel_event(self, event): # This doesnt quite work correctly as it is processed # _before_ the key is handled. Thus, when the "Up" key # is pressed, this test happens before the cursor is moved. # This will do for now. if self.calltip: # If we have moved before the start of the calltip, # or off the... | 23,988 |
def get_object_at_cursor(self, wordchars="._" + string.uppercase + string.lowercase + string.digits): # XXX - This need to be moved to a better place # as the "." attribute lookup code can also use it. text = self.text index = 0 while 1: index = index + 1 indexspec = "insert-%dc" % index ch = text.get(indexspec) if ch ... | def get_object_at_cursor(self, wordchars="._" + string.uppercase + string.lowercase + string.digits): # XXX - This need to be moved to a better place # as the "." attribute lookup code can also use it. text = self.text index = 0 while 1: index = index + 1 indexspec = "insert-%dc" % index ch = text.get(indexspec) if ch ... | 23,989 |
def get_object_at_cursor(self, wordchars="._" + string.uppercase + string.lowercase + string.digits): # XXX - This need to be moved to a better place # as the "." attribute lookup code can also use it. text = self.text index = 0 while 1: index = index + 1 indexspec = "insert-%dc" % index ch = text.get(indexspec) if ch ... | def get_object_at_cursor(self, wordchars="._" + string.uppercase + string.lowercase + string.digits): # XXX - This need to be moved to a better place # as the "." attribute lookup code can also use it. text = self.text index = 0 while 1: index = index + 1 indexspec = "insert-%dc" % index ch = text.get(indexspec) if ch ... | 23,990 |
def get_arg_text(ob): # Get a string describing the arguments for the given object. argText = "" if ob is not None: argOffset = 0 # bit of a hack for methods - turn it into a function # but we drop the "self" param. if type(ob)==types.MethodType: ob = ob.im_func argOffset = 1 # Try and build one for Python defined func... | def get_arg_text(ob): # Get a string describing the arguments for the given object. argText = "" if ob is not None: argOffset = 0 # bit of a hack for methods - turn it into a function # but we drop the "self" param. if type(ob)==types.MethodType: ob = ob.im_func argOffset = 1 # Try and build one for Python defined func... | 23,991 |
def get_arg_text(ob): # Get a string describing the arguments for the given object. argText = "" if ob is not None: argOffset = 0 # bit of a hack for methods - turn it into a function # but we drop the "self" param. if type(ob)==types.MethodType: ob = ob.im_func argOffset = 1 # Try and build one for Python defined func... | def get_arg_text(ob): # Get a string describing the arguments for the given object. argText = "" if ob is not None: argOffset = 0 # bit of a hack for methods - turn it into a function # but we drop the "self" param. if type(ob)==types.MethodType: ob = ob.im_func argOffset = 1 # Try and build one for Python defined func... | 23,992 |
def t6(self, a, b=None, *args, **kw): "(a, b=None, ...)" | deft6(self,a,b=None,*args,**kw):"(a,b=None,...)" | 23,993 |
def test( tests ): failed=[] for t in tests: if get_arg_text(t) != t.__doc__: failed.append(t) print "%s - expected %s, but got %s" % (t, `t.__doc__`, `get_arg_text(t)`) print "%d of %d tests failed" % (len(failed), len(tests)) | def test( tests ): failed=[] for t in tests: if get_arg_text(t) != t.__doc__ + "\n" + t.__doc__: failed.append(t) print "%s - expected %s, but got %s" % (t, `t.__doc__`, `get_arg_text(t)`) print "%d of %d tests failed" % (len(failed), len(tests)) | 23,994 |
def test( tests ): failed=[] for t in tests: if get_arg_text(t) != t.__doc__: failed.append(t) print "%s - expected %s, but got %s" % (t, `t.__doc__`, `get_arg_text(t)`) print "%d of %d tests failed" % (len(failed), len(tests)) | def test( tests ): failed=[] for t in tests: if get_arg_text(t) != t.__doc__: failed.append(t) print "%s - expected %s, but got %s" % (t, `t.__doc__`, `get_arg_text(t)`) print "%d of %d tests failed" % (len(failed), len(tests)) | 23,995 |
def callback_wrapper(self, _request, _reply): _parameters, _attributes = aetools.unpackevent(_request) _class = _attributes['evcl'].type _type = _attributes['evid'].type if self.ae_handlers.has_key((_class, _type)): _function = self.ae_handlers[(_class, _type)] elif self.ae_handlers.has_key((_class, '****')): _functio... | def callback_wrapper(self, _request, _reply): _parameters, _attributes = aetools.unpackevent(_request) _class = _attributes['evcl'].type _type = _attributes['evid'].type if self.ae_handlers.has_key((_class, _type)): _function = self.ae_handlers[(_class, _type)] elif self.ae_handlers.has_key((_class, '****')): _functio... | 23,996 |
def _strxor(s1, s2): """Utility method. XOR the two strings s1 and s2 (must have same length). """ return "".join(map(lambda x, y: chr(ord(x) ^ ord(y)), s1, s2)) | trans_5C = "".join ([chr (x ^ 0x5C) for x in xrange(256)]) trans_36 = "".join ([chr (x ^ 0x36) for x in xrange(256)]) | 23,997 |
def __init__(self, key, msg = None, digestmod = None): """Create a new HMAC object. | def __init__(self, key, msg = None, digestmod = None): """Create a new HMAC object. | 23,998 |
def __init__(self, key, msg = None, digestmod = None): """Create a new HMAC object. | def __init__(self, key, msg = None, digestmod = None): """Create a new HMAC object. | 23,999 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.