bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def subn(self, repl, source, count=0): """Return a 2-tuple containing (new_string, number). new_string is the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in the source string by the replacement repl. number is the number of substitutions that were made.""" if count < 0: raise ...
def subn(self, repl, source, count=0): """subn(repl, string[, count=0]) -> tuple Perform the same operation as sub(), but return a tuple (new_string, number_of_subs_made). """ if count < 0: raise error, "negative substitution count" if count == 0: count = sys.maxint n = 0 # Number of matches pos = 0 ...
22,400
def split(self, source, maxsplit=0): """Split the source string by the occurrences of the pattern, returning a list containing the resulting substrings."""
def split(self, source, maxsplit=0): """Split the source string by the occurrences of the pattern, returning a list containing the resulting substrings."""
22,401
def findall(self, source): """Return a list of all non-overlapping matches in the string.
def findall(self, source): """Return a list of all non-overlapping matches in the string.
22,402
def start(self, g = 0): "Return the start of the substring matched by group g" if type(g) == type(''): try: g = self.re.groupindex[g] except (KeyError, TypeError): raise IndexError, 'group %s is undefined' % `g` return self.regs[g][0]
def start(self, g = 0): """start([group=0]) -> int or None Return the index of the start of the substring matched by group; group defaults to zero (meaning the whole matched substring). Return None if group exists but did not contribute to the match. """ if type(g) == type(''): try: g = self.re.groupindex[g] except (...
22,403
def end(self, g = 0): "Return the end of the substring matched by group g" if type(g) == type(''): try: g = self.re.groupindex[g] except (KeyError, TypeError): raise IndexError, 'group %s is undefined' % `g` return self.regs[g][1]
def end(self, g = 0): """end([group=0]) -> int or None Return the indices of the end of the substring matched by group; group defaults to zero (meaning the whole matched substring). Return None if group exists but did not contribute to the match. """ if type(g) == type(''): try: g = self.re.groupindex[g] except (KeyE...
22,404
def span(self, g = 0): "Return (start, end) of the substring matched by group g" if type(g) == type(''): try: g = self.re.groupindex[g] except (KeyError, TypeError): raise IndexError, 'group %s is undefined' % `g` return self.regs[g]
def span(self, g = 0): """span([group=0]) -> tuple Return the 2-tuple (m.start(group), m.end(group)). Note that if group did not contribute to the match, this is (None, None). Group defaults to zero (meaning the whole matched substring). """ if type(g) == type(''): try: g = self.re.groupindex[g] except (KeyError, Typ...
22,405
def groups(self, default=None): "Return a tuple containing all subgroups of the match object" result = [] for g in range(1, self.re._num_regs): a, b = self.regs[g] if a == -1 or b == -1: result.append(default) else: result.append(self.string[a:b]) return tuple(result)
def groups(self, default=None): """groups([default=None]) -> tuple Return a tuple containing all the subgroups of the match, from 1 up to however many groups are in the pattern. The default argument is used for groups that did not participate in the match. """ result = [] for g in range(1, self.re._num_regs): a, b = ...
22,406
def group(self, *groups): "Return one or more groups of the match" if len(groups) == 0: groups = (0,) result = [] for g in groups: if type(g) == type(''): try: g = self.re.groupindex[g] except (KeyError, TypeError): raise IndexError, 'group %s is undefined' % `g` if g >= len(self.regs): raise IndexError, 'group %s is u...
def group(self, *groups): """group([group1, group2, ...]) -> string or tuple Return one or more subgroups of the match. If there is a single argument, the result is a single string; if there are multiple arguments, the result is a tuple with one item per argument. Without arguments, group1 defaults to zero (i.e. the w...
22,407
def __init__(self, filename="NoName", date_time=(1980,1,1,0,0,0)): self.filename = filename # Name of the file in the archive self.date_time = date_time # year, month, day, hour, min, sec # Standard values: self.compress_type = ZIP_STORED # Type of compression for the file self.comment = "" # ...
def __init__(self, filename="NoName", date_time=(1980,1,1,0,0,0)): self.filename = _normpath(filename) # Name of the file in the archive self.date_time = date_time # year, month, day, hour, min, sec # Standard values: self.compress_type = ZIP_STORED # Type of compression for the file self.comment = "" ...
22,408
def _get_exports_list(module): try: return list(module.__all__) except AttributeError: return [n for n in dir(module) if n[0] != '_']
def _get_exports_list(module): try: return list(module.__all__) except AttributeError: return [n for n in dir(module) if n[0] != '_']
22,409
def _get_exports_list(module): try: return list(module.__all__) except AttributeError: return [n for n in dir(module) if n[0] != '_']
def _get_exports_list(module): try: return list(module.__all__) except AttributeError: return [n for n in dir(module) if n[0] != '_']
22,410
def addrobot(self, root): root = urlparse.urljoin(root, "/") if self.robots.has_key(root): return url = urlparse.urljoin(root, "/robots.txt") self.robots[root] = rp = robotparser.RobotFileParser() self.note(2, "Parsing %s", url) rp.debug = self.verbose > 3 rp.set_url(url) try: rp.read() except IOError, msg: self.note(1...
def addrobot(self, root): root = urlparse.urljoin(root, "/") if self.robots.has_key(root): return url = urlparse.urljoin(root, "/robots.txt") self.robots[root] = rp = robotparser.RobotFileParser() self.note(2, "Parsing %s", url) rp.debug = self.verbose > 3 rp.set_url(url) try: rp.read() except (OSError, IOError), msg: ...
22,411
def openpage(self, url_pair): url, fragment = url_pair try: return self.urlopener.open(url) except IOError, msg: msg = self.sanitize(msg) self.note(0, "Error %s", msg) if self.verbose > 0: self.show(" HREF ", url, " from", self.todo[url_pair]) self.setbad(url_pair, msg) return None
def openpage(self, url_pair): url, fragment = url_pair try: return self.urlopener.open(url) except (OSError, IOError), msg: msg = self.sanitize(msg) self.note(0, "Error %s", msg) if self.verbose > 0: self.show(" HREF ", url, " from", self.todo[url_pair]) self.setbad(url_pair, msg) return None
22,412
def finalize_options (self): from distutils import sysconfig
def finalize_options (self): from distutils import sysconfig
22,413
def test_islice(self): for args in [ # islice(args) should agree with range(args) (10, 20, 3), (10, 3, 20), (10, 20), (10, 3), (20,) ]: self.assertEqual(list(islice(xrange(100), *args)), range(*args))
def test_islice(self): for args in [ # islice(args) should agree with range(args) (10, 20, 3), (10, 3, 20), (10, 20), (10, 3), (20,) ]: self.assertEqual(list(islice(xrange(100), *args)), range(*args))
22,414
def test_main(verbose=None): import test_itertools suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestBasicOps)) test_support.run_suite(suite) test_support.run_doctest(test_itertools, verbose) # verify reference counting import sys if verbose and hasattr(sys, "gettotalrefcount"): counts = [] for i in xr...
def test_main(verbose=None): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestBasicOps)) test_support.run_suite(suite) test_support.run_doctest(test_itertools, verbose) # verify reference counting import sys if verbose and hasattr(sys, "gettotalrefcount"): counts = [] for i in xrange(5): test_support....
22,415
def test_main(verbose=None): import test_itertools suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestBasicOps)) test_support.run_suite(suite) test_support.run_doctest(test_itertools, verbose) # verify reference counting import sys if verbose and hasattr(sys, "gettotalrefcount"): counts = [] for i in xr...
def test_main(verbose=None): import test_itertools suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestBasicOps)) test_support.run_suite(suite) # verify reference counting import sys if verbose and hasattr(sys, "gettotalrefcount"): counts = [] for i in xrange(5): test_support.run_suite(suite) counts.appe...
22,416
def test_filter_subclasses(self): # test, that filter() never returns tuple, str or unicode subclasses funcs = (None, lambda x: True) class tuple2(tuple): pass class str2(str): pass inputs = { tuple2: [(), (1,2,3)], str2: ["", "123"] } if have_unicode: class unicode2(unicode): pass inputs[unicode2] = [unicode(), unic...
def test_filter_subclasses(self): # test, that filter() never returns tuple, str or unicode subclasses funcs = (None, lambda x: True) class tuple2(tuple): def __getitem__(self, index): return 2*tuple.__getitem__(self, index) class str2(str): def __getitem__(self, index): return 2*tuple.__getitem__(self, index) inputs =...
22,417
def test_filter_subclasses(self): # test, that filter() never returns tuple, str or unicode subclasses funcs = (None, lambda x: True) class tuple2(tuple): pass class str2(str): pass inputs = { tuple2: [(), (1,2,3)], str2: ["", "123"] } if have_unicode: class unicode2(unicode): pass inputs[unicode2] = [unicode(), unic...
def test_filter_subclasses(self): # test, that filter() never returns tuple, str or unicode subclasses funcs = (None, lambda x: True) class tuple2(tuple): def __getitem__(self, index): return 2*str.__getitem__(self, index) class str2(str): def __getitem__(self, index): return 2*str.__getitem__(self, index) inputs = { t...
22,418
def test_filter_subclasses(self): # test, that filter() never returns tuple, str or unicode subclasses funcs = (None, lambda x: True) class tuple2(tuple): pass class str2(str): pass inputs = { tuple2: [(), (1,2,3)], str2: ["", "123"] } if have_unicode: class unicode2(unicode): pass inputs[unicode2] = [unicode(), unic...
def test_filter_subclasses(self): # test, that filter() never returns tuple, str or unicode subclasses funcs = (None, lambda x: True) class tuple2(tuple): pass class str2(str): pass inputs = { tuple2: {(): (), (1, 2, 3): (1, 2, 3)}, str2: {"": "", "123": "112233"} } if have_unicode: class unicode2(unicode): pass inpu...
22,419
def test_filter_subclasses(self): # test, that filter() never returns tuple, str or unicode subclasses funcs = (None, lambda x: True) class tuple2(tuple): pass class str2(str): pass inputs = { tuple2: [(), (1,2,3)], str2: ["", "123"] } if have_unicode: class unicode2(unicode): pass inputs[unicode2] = [unicode(), unic...
def test_filter_subclasses(self): # test, that filter() never returns tuple, str or unicode subclasses funcs = (None, lambda x: True) class tuple2(tuple): pass class str2(str): pass inputs = { tuple2: [(), (1,2,3)], str2: ["", "123"] } if have_unicode: class unicode2(unicode): pass inputs[unicode2] = [unicode(), unic...
22,420
>>> def f(n):
>>> def f(n):
22,421
def _openDBEnv(cachesize): e = db.DBEnv() if cachesize is not None: if cachesize >= 20480: e.set_cachesize(0, cachesize) else: raise error, "cachesize must be >= 20480" e.open('.', db.DB_PRIVATE | db.DB_CREATE | db.DB_THREAD | db.DB_INIT_LOCK | db.DB_INIT_MPOOL) e.set_lk_detect(db.DB_LOCK_DEFAULT) return e
def _openDBEnv(cachesize): e = db.DBEnv() if cachesize is not None: if cachesize >= 20480: e.set_cachesize(0, cachesize) else: raise error, "cachesize must be >= 20480" e.open('.', db.DB_PRIVATE | db.DB_CREATE | db.DB_THREAD | db.DB_INIT_LOCK | db.DB_INIT_MPOOL) return e
22,422
def __imull__(self, n): self.data += n return self
def __imul__(self, n): self.data *= n return self
22,423
def trace_vdelete(self, mode, cbname): self._tk.call("trace", "vdelete", self._name, mode, cbname) self._tk.deletecommand(cbname)
def trace_vdelete(self, mode, cbname): self._tk.call("trace", "vdelete", self._name, mode, cbname) self._tk.deletecommand(cbname)
22,424
def __calc_date_time(self): # Set self.date_time, self.date, & self.time by using # time.strftime().
def __calc_date_time(self): # Set self.date_time, self.date, & self.time by using # time.strftime().
22,425
def __getitem__(self, i): return self.seq[i]
def __getitem__(self, i): return self.seq[i]
22,426
def preprocess (self, source, output_file=None, macros=None, include_dirs=None, extra_preargs=None, extra_postargs=None):
def preprocess (self, source, output_file=None, macros=None, include_dirs=None, extra_preargs=None, extra_postargs=None):
22,427
def run (self):
def run (self):
22,428
def __init__(self, allow_none): self.funcs = {} self.instance = None self.allow_none = allow_none
def __init__(self, allow_none, encoding): self.funcs = {} self.instance = None self.allow_none = allow_none
22,429
def _marshaled_dispatch(self, data, dispatch_method = None): """Dispatches an XML-RPC method from marshalled (XML) data.
def _marshaled_dispatch(self, data, dispatch_method = None): """Dispatches an XML-RPC method from marshalled (XML) data.
22,430
def _marshaled_dispatch(self, data, dispatch_method = None): """Dispatches an XML-RPC method from marshalled (XML) data.
def _marshaled_dispatch(self, data, dispatch_method = None): """Dispatches an XML-RPC method from marshalled (XML) data.
22,431
def _marshaled_dispatch(self, data, dispatch_method = None): """Dispatches an XML-RPC method from marshalled (XML) data.
def _marshaled_dispatch(self, data, dispatch_method = None): """Dispatches an XML-RPC method from marshalled (XML) data.
22,432
def __init__(self, addr, requestHandler=SimpleXMLRPCRequestHandler, logRequests=True, allow_none=False): self.logRequests = logRequests
def __init__(self, addr, requestHandler=SimpleXMLRPCRequestHandler, logRequests=True, allow_none=False, encoding=None): self.logRequests = logRequests
22,433
def __init__(self, addr, requestHandler=SimpleXMLRPCRequestHandler, logRequests=True, allow_none=False): self.logRequests = logRequests
def __init__(self, addr, requestHandler=SimpleXMLRPCRequestHandler, logRequests=True, allow_none=False): self.logRequests = logRequests
22,434
def __init__(self, allow_none=False): SimpleXMLRPCDispatcher.__init__(self, allow_none)
def __init__(self, allow_none=False): SimpleXMLRPCDispatcher.__init__(self, allow_none)
22,435
def ignored(self, file): if os.path.isdir(file): return True for pat in self.IgnoreList: if fnmatch.fnmatch(file, pat): return True return Falso
def ignored(self, file): if os.path.isdir(file): return True for pat in self.IgnoreList: if fnmatch.fnmatch(file, pat): return True return Falso
22,436
def addwork(self, job): if not job: raise TypeError, 'cannot add null job' self.mutex.acquire() self.work.append(job) self.mutex.release() if len(self.work) == 1: self.todo.release()
def addwork(self, func, args): job = (func, args) self.mutex.acquire() self.work.append(job) self.mutex.release() if len(self.work) == 1: self.todo.release()
22,437
def __init__(self, path = "", title = ""): defaultfontsettings, defaulttabsettings, defaultwindowsize = geteditorprefs() global _scriptuntitledcounter if not path: if title: self.title = title else: self.title = "Untitled Script " + `_scriptuntitledcounter` _scriptuntitledcounter = _scriptuntitledcounter + 1 text = "" ...
def __init__(self, path = "", title = ""): defaultfontsettings, defaulttabsettings, defaultwindowsize = geteditorprefs() global _scriptuntitledcounter if not path: if title: self.title = title else: self.title = "Untitled Script " + `_scriptuntitledcounter` _scriptuntitledcounter = _scriptuntitledcounter + 1 text = "" ...
22,438
def __init__(self, path = "", title = ""): defaultfontsettings, defaulttabsettings, defaultwindowsize = geteditorprefs() global _scriptuntitledcounter if not path: if title: self.title = title else: self.title = "Untitled Script " + `_scriptuntitledcounter` _scriptuntitledcounter = _scriptuntitledcounter + 1 text = "" ...
def __init__(self, path = "", title = ""): defaultfontsettings, defaulttabsettings, defaultwindowsize = geteditorprefs() global _scriptuntitledcounter if not path: if title: self.title = title else: self.title = "Untitled Script " + `_scriptuntitledcounter` _scriptuntitledcounter = _scriptuntitledcounter + 1 text = "" ...
22,439
def test_main(): if skip_expected: raise TestSkipped(TESTDATAFILE + " not found, download from " + "http://www.unicode.org/Public/UNIDATA/" + TESTDATAFILE) part1_data = {} for line in open(TESTDATAFILE): if '#' in line: line = line.split('#')[0] line = line.strip() if not line: continue if line.startswith("@Part"): pa...
def test_main(): if skip_expected: raise TestSkipped(TESTDATAFILE + " not found, download from " + "http://www.unicode.org/Public/3.2-Update/" + TESTDATAFILE) part1_data = {} for line in open(TESTDATAFILE): if '#' in line: line = line.split('#')[0] line = line.strip() if not line: continue if line.startswith("@Part"):...
22,440
def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e
def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e
22,441
def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e
def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e
22,442
def finalize_options (self): self.set_undefined_options('bdist', ('bdist_base', 'bdist_base')) if self.rpm_base is None: if not self.rpm3_mode: raise DistutilsOptionError, \ "you must specify --rpm-base in RPM 2 mode" self.rpm_base = os.path.join(self.bdist_base, "rpm")
def finalize_options (self): self.set_undefined_options('bdist', ('bdist_base', 'bdist_base')) if self.rpm_base is None: if not self.rpm3_mode: raise DistutilsOptionError, \ "you must specify --rpm-base in RPM 2 mode" self.rpm_base = os.path.join(self.bdist_base, "rpm")
22,443
def help_dialog(self, event=None): try: helpfile = os.path.join(os.path.dirname(__file__), self.helpfile) except NameError: helpfile = self.helpfile if self.flist: self.flist.open(helpfile) else: self.io.loadfile(helpfile)
def help_dialog(self, event=None): try: helpfile = os.path.join(os.path.dirname(__file__), self.helpfile) except NameError: helpfile = self.helpfile if self.flist: self.flist.open(helpfile) else: self.io.loadfile(helpfile)
22,444
def python_docs(self, event=None): webbrowser.open(self.help_url)
def python_docs(self, event=None): webbrowser.open(self.help_url)
22,445
def dump_dirs (self, msg): if DEBUG: from distutils.fancy_getopt import longopt_xlate print msg + ":" for opt in self.user_options: opt_name = opt[0] if opt_name[-1] == "=": opt_name = opt_name[0:-1] opt_name = string.translate(opt_name, longopt_xlate) val = getattr(self, opt_name) print " %s: %s" % (opt_name, val)
def dump_dirs (self, msg): if DEBUG: from distutils.fancy_getopt import longopt_xlate print msg + ":" for opt in self.user_options: opt_name = opt[0] if opt_name[-1] == "=": opt_name = opt_name[0:-1] if self.negative_opt.has_key(opt_name): opt_name = string.translate(self.negative_opt[opt_name], longopt_xlate) val = no...
22,446
def main(srcfile): argv0 = sys.argv[0] components = argv0.split(os.sep) argv0 = os.sep.join(components[-2:]) auto_gen_msg = '/* File automatically generated by %s */\n' % argv0 mod = asdl.parse(srcfile) if not asdl.check(mod): sys.exit(1) if INC_DIR: p = "%s/%s-ast.h" % (INC_DIR, mod.name) else: p = "%s-ast.h" % mod.na...
def main(srcfile): argv0 = sys.argv[0] components = argv0.split(os.sep) argv0 = os.sep.join(components[-2:]) auto_gen_msg = '/* File automatically generated by %s */\n' % argv0 mod = asdl.parse(srcfile) if not asdl.check(mod): sys.exit(1) if INC_DIR: p = "%s/%s-ast.h" % (INC_DIR, mod.name) else: p = "%s-ast.h" % mod.na...
22,447
def main(srcfile): argv0 = sys.argv[0] components = argv0.split(os.sep) argv0 = os.sep.join(components[-2:]) auto_gen_msg = '/* File automatically generated by %s */\n' % argv0 mod = asdl.parse(srcfile) if not asdl.check(mod): sys.exit(1) if INC_DIR: p = "%s/%s-ast.h" % (INC_DIR, mod.name) else: p = "%s-ast.h" % mod.na...
def main(srcfile): argv0 = sys.argv[0] components = argv0.split(os.sep) argv0 = os.sep.join(components[-2:]) auto_gen_msg = '/* File automatically generated by %s */\n' % argv0 mod = asdl.parse(srcfile) if not asdl.check(mod): sys.exit(1) if INC_DIR: p = "%s/%s-ast.h" % (INC_DIR, mod.name) else: p = "%s-ast.h" % mod.na...
22,448
def __init__(self, format): self.format = format
def __init__(self, format, len): self.format = format
22,449
def __getitem__(self, item): return strftime(self.format, (item,)*9).capitalize()
def __getitem__(self, item): return strftime(self.format, (item,)*9).capitalize()
22,450
def __getitem__(self, item): return strftime(self.format, (item,)*9).capitalize()
def __getitem__(self, item): return strftime(self.format, (item,)*9).capitalize()
22,451
def __init__(self, sock, debuglevel=0): self.fp = sock.makefile('rb', 0) self.debuglevel = debuglevel
def __init__(self, sock, debuglevel=0, strict=0): self.fp = sock.makefile('rb', 0) self.debuglevel = debuglevel
22,452
def _read_status(self): line = self.fp.readline() if self.debuglevel > 0: print "reply:", repr(line) try: [version, status, reason] = line.split(None, 2) except ValueError: try: [version, status] = line.split(None, 1) reason = "" except ValueError: version = "HTTP/0.9" status = "200" reason = "" if version[:5] != 'HTTP...
def _read_status(self): line = self.fp.readline() if self.debuglevel > 0: print "reply:", repr(line) try: [version, status, reason] = line.split(None, 2) except ValueError: try: [version, status] = line.split(None, 1) reason = "" except ValueError: version = "HTTP/0.9" status = "200" reason = "" if version[:5] != 'HTTP...
22,453
def getheader(self, name, default=None): if self.msg is None: raise ResponseNotReady() return self.msg.getheader(name, default)
def getheader(self, name, default=None): if self.msg is None: raise ResponseNotReady() return self.msg.getheader(name, default)
22,454
def __init__(self, host, port=None): self.sock = None self.__response = None self.__state = _CS_IDLE
def __init__(self, host, port=None): self.sock = None self.__response = None self.__state = _CS_IDLE
22,455
def getresponse(self): "Get the response from the server."
def getresponse(self): "Get the response from the server."
22,456
def __init__(self, host, port=None, key_file=None, cert_file=None): HTTPConnection.__init__(self, host, port) self.key_file = key_file self.cert_file = cert_file
def __init__(self, host, port=None, key_file=None, cert_file=None, strict=None): HTTPConnection.__init__(self, host, port, strict) self.key_file = key_file self.cert_file = cert_file
22,457
def __init__(self, host='', port=None): "Provide a default host, since the superclass requires one."
def __init__(self, host='', port=None, strict=None): "Provide a default host, since the superclass requires one."
22,458
def __init__(self, host='', port=None): "Provide a default host, since the superclass requires one."
def __init__(self, host='', port=None): "Provide a default host, since the superclass requires one."
22,459
def __init__(self, host='', port=None, **x509): # provide a default host, pass the X509 cert info
def __init__(self, host='', port=None, key_file=None, cert_file=None, strict=None): # provide a default host, pass the X509 cert info
22,460
def __init__(self, host='', port=None, **x509): # provide a default host, pass the X509 cert info
def __init__(self, host='', port=None, **x509): # provide a default host, pass the X509 cert info
22,461
def __init__(self, host='', port=None, **x509): # provide a default host, pass the X509 cert info
def __init__(self, host='', port=None, **x509): # provide a default host, pass the X509 cert info
22,462
def visitModule(self, mod): self.emit("""
def visitModule(self, mod): self.emit("""
22,463
def visitModule(self, mod): self.emit("""
def visitModule(self, mod): self.emit("""
22,464
def visitModule(self, mod): self.emit("""
def visitModule(self, mod): self.emit("""
22,465
def visitModule(self, mod): self.emit("""
def visitModule(self, mod): self.emit("""
22,466
def addObj(self, name): self.emit('if(PyDict_SetItemString(d, "%s", (PyObject*)%s_type) < 0) return;' % (name, name), 1)
def addObj(self, name): self.emit('if(PyDict_SetItemString(d, "%s", (PyObject*)%s_type) < 0) return;' % (name, name), 1)
22,467
def __init__(self, file, align=True, bigendian=True, inclheader=False): import struct self.closed = False self.align = align # whether to align to word (2-byte) boundaries if bigendian: strflag = '>' else: strflag = '<' self.file = file self.chunkname = file.read(4) if len(self.chunkname) < 4: raise EOFError try: ...
def __init__(self, file, align=True, bigendian=True, inclheader=False): import struct self.closed = False self.align = align # whether to align to word (2-byte) boundaries if bigendian: strflag = '>' else: strflag = '<' self.file = file self.chunkname = file.read(4) if len(self.chunkname) < 4: raise EOFError try: ...
22,468
>>> def m235():
>>> def m235():
22,469
>>> def f():
>>> def f():
22,470
def test_main(): import doctest, test_generators if 0: # Temporary block to help track down leaks. So far, the blame # has fallen mostly on doctest. for i in range(1000): doctest.master = None doctest.testmod(test_generators) else: doctest.testmod(test_generators)
def test_main(): import doctest, test_generators if 0: # Temporary block to help track down leaks. So far, the blame # has fallen mostly on doctest. for i in range(5000): doctest.master = None doctest.testmod(test_generators) else: doctest.testmod(test_generators)
22,471
def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e
def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e
22,472
def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e
def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e
22,473
def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e
def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e
22,474
def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e
def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e
22,475
def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e
def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e
22,476
def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e
def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e
22,477
def AskYesNoCancel(question, default = 0, yes=None, no=None, cancel=None, id=262): """Display a QUESTION string which can be answered with Yes or No. Return 1 when the user clicks the Yes button. Return 0 when the user clicks the No button. Return -1 when the user clicks the Cancel button. When the user presses Retur...
def AskYesNoCancel(question, default = 0, yes=None, no=None, cancel=None, id=262): """Display a QUESTION string which can be answered with Yes or No. Return 1 when the user clicks the Yes button. Return 0 when the user clicks the No button. Return -1 when the user clicks the Cancel button. When the user presses Retur...
22,478
def copymode(src, dst): """Copy mode bits from src to dst""" st = os.stat(src) mode = stat.S_IMODE(st[stat.ST_MODE]) os.chmod(dst, mode)
def copymode(src, dst): """Copy mode bits from src to dst""" if hasattr(os, 'chmod'): st = os.stat(src) mode = stat.S_IMODE(st[stat.ST_MODE]) os.chmod(dst, mode)
22,479
def copystat(src, dst): """Copy all stat info (mode bits, atime and mtime) from src to dst""" st = os.stat(src) mode = stat.S_IMODE(st[stat.ST_MODE]) os.utime(dst, (st[stat.ST_ATIME], st[stat.ST_MTIME])) os.chmod(dst, mode)
def copystat(src, dst): """Copy all stat info (mode bits, atime and mtime) from src to dst""" st = os.stat(src) mode = stat.S_IMODE(st[stat.ST_MODE]) if hasattr(os, 'utime'): os.utime(dst, (st[stat.ST_ATIME], st[stat.ST_MTIME])) if hasattr(os, 'chmod'): os.chmod(dst, mode)
22,480
def trace_dispatch_exception(self, frame, t): rt, rtt, rct, rfn, rframe, rcur = self.cur if (rframe is frame) and rcur: return self.trace_dispatch_return(rframe, t) return 0
def trace_dispatch_exception(self, frame, t): rt, rtt, rct, rfn, rframe, rcur = self.cur if (rframe is not frame) and rcur: return self.trace_dispatch_return(rframe, t) return 0
22,481
def decode(in_file, out_file=None, mode=None): """Decode uuencoded file""" # # Open the input file, if needed. # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): in_file = open(in_file) # # Read until a begin is encountered or we've exhausted the file # while 1: hdr = in_file.readline() if not hdr...
def decode(in_file, out_file=None, mode=None): """Decode uuencoded file""" # # Open the input file, if needed. # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): in_file = open(in_file) # # Read until a begin is encountered or we've exhausted the file # while 1: hdr = in_file.readline() if not hdr...
22,482
def decode(in_file, out_file=None, mode=None): """Decode uuencoded file""" # # Open the input file, if needed. # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): in_file = open(in_file) # # Read until a begin is encountered or we've exhausted the file # while 1: hdr = in_file.readline() if not hdr...
def decode(in_file, out_file=None, mode=None): """Decode uuencoded file""" # # Open the input file, if needed. # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): in_file = open(in_file) # # Read until a begin is encountered or we've exhausted the file # while 1: hdr = in_file.readline() if not hdr...
22,483
def decode(in_file, out_file=None, mode=None): """Decode uuencoded file""" # # Open the input file, if needed. # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): in_file = open(in_file) # # Read until a begin is encountered or we've exhausted the file # while 1: hdr = in_file.readline() if not hdr...
def decode(in_file, out_file=None, mode=None): """Decode uuencoded file""" # # Open the input file, if needed. # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): in_file = open(in_file) # # Read until a begin is encountered or we've exhausted the file # while 1: hdr = in_file.readline() if not hdr...
22,484
def decode(in_file, out_file=None, mode=None): """Decode uuencoded file""" # # Open the input file, if needed. # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): in_file = open(in_file) # # Read until a begin is encountered or we've exhausted the file # while 1: hdr = in_file.readline() if not hdr...
def decode(in_file, out_file=None, mode=None): """Decode uuencoded file""" # # Open the input file, if needed. # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): in_file = open(in_file) # # Read until a begin is encountered or we've exhausted the file # while 1: hdr = in_file.readline() if not hdr...
22,485
def send(self, str): """Send `str' to the server.""" if self.debuglevel > 0: print 'send:', `str` if self.sock: try: self.sock.send(str) except socket.error: raise SMTPServerDisconnected('Server not connected') else: raise SMTPServerDisconnected('please run connect() first')
def send(self, str): """Send `str' to the server.""" if self.debuglevel > 0: print 'send:', `str` if self.sock: try: sendptr = 0 while sendptr < len(str): sendptr = sendptr + self.sock.send(str[sendptr:]) except socket.error: raise SMTPServerDisconnected('Server not connected') else: raise SMTPServerDisconnected('pleas...
22,486
def compile_and_catch_warning(text): try: compile(text, "<test code>", "exec") except SyntaxWarning, msg: print "got SyntaxWarning as expected" else: print "expected SyntaxWarning"
def compile_and_catch_warning(text): try: compile(text, "<test code>", "exec") except SyntaxError, msg: print "got SyntaxError as expected" else: print "expected SyntaxWarning"
22,487
def compile_and_catch_warning(text): try: compile(text, "<test code>", "exec") except SyntaxWarning, msg: print "got SyntaxWarning as expected" else: print "expected SyntaxWarning"
def compile_and_catch_warning(text): try: compile(text, "<test code>", "exec") except SyntaxWarning, msg: print "got SyntaxWarning as expected" else: print "expected SyntaxError"
22,488
def find_config_files (self): """Find as many configuration files as should be processed for this platform, and return a list of filenames in the order in which they should be parsed. The filenames returned are guaranteed to exist (modulo nasty race conditions).
def find_config_files (self): """Find as many configuration files as should be processed for this platform, and return a list of filenames in the order in which they should be parsed. The filenames returned are guaranteed to exist (modulo nasty race conditions).
22,489
def find_config_files (self): """Find as many configuration files as should be processed for this platform, and return a list of filenames in the order in which they should be parsed. The filenames returned are guaranteed to exist (modulo nasty race conditions).
def find_config_files (self): """Find as many configuration files as should be processed for this platform, and return a list of filenames in the order in which they should be parsed. The filenames returned are guaranteed to exist (modulo nasty race conditions).
22,490
def _run_examples_inner(out, fakeout, examples, globs, verbose, name): import sys, traceback OK, BOOM, FAIL = range(3) NADA = "nothing" stderr = _SpoofOut() failures = 0 for source, want, lineno in examples: if verbose: _tag_out(out, ("Trying", source), ("Expecting", want or NADA)) fakeout.clear() try: exec compile(sou...
def _run_examples_inner(out, fakeout, examples, globs, verbose, name): import sys, traceback OK, BOOM, FAIL = range(3) NADA = "nothing" stderr = _SpoofOut() failures = 0 for source, want, lineno in examples: if verbose: _tag_out(out, ("Trying", source), ("Expecting", want or NADA)) fakeout.clear() try: exec compile(sou...
22,491
def waitchild(options): pid, sts = os.wait(G.busy, options) if pid == G.busy: G.busy = 0 G.stop.enable(0)
def waitchild(options): pid, sts = os.waitpid(G.busy, options) if pid == G.busy: G.busy = 0 G.stop.enable(0)
22,492
def subconvert(line, ofp, table, discards, autoclosing, knownempty, 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\...
def subconvert(line, ofp, table, discards, autoclosing, knownempty, 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\...
22,493
def retrlines(self, cmd, callback = None): '''Retrieve data in line mode. The argument is a RETR or LIST command. The callback function (2nd argument) is called for each line, with trailing CRLF stripped. This creates a new port for you. print_line() is the default callback.''' if not callable(callback): callback = pr...
def retrlines(self, cmd, callback = None): '''Retrieve data in line mode. The argument is a RETR or LIST command. The callback function (2nd argument) is called for each line, with trailing CRLF stripped. This creates a new port for you. print_line() is the default callback.''' if callback is None: callback = print_li...
22,494
def build(self, root, resources=None, **options): """Create a package for some given root folder.
def build(self, root, resources=None, **options): """Create a package for some given root folder.
22,495
def build(self, root, resources=None, **options): """Create a package for some given root folder.
def build(self, root, resources=None, **options): """Create a package for some given root folder.
22,496
def build(self, root, resources=None, **options): """Create a package for some given root folder.
defelif not k in ["OutputDir"]: raise Error, "Unknown package option: %s" % k outputdir = options.get("OutputDir", os.getcwd()) packageName = self.packageInfo["Title"] self.PackageRootFolder = os.path.join(outputdir, packageName + ".pkg") build(self,elif not k in ["OutputDir"]: raise Error, "Unknown package option: ...
22,497
def _makeFolders(self): "Create package folder structure."
def _makeFolders(self): "Create package folder structure."
22,498
def _makeFolders(self): "Create package folder structure."
def _makeFolders(self): "Create package folder structure."
22,499