bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def interaction(self, message, fid, iid): ##print "interaction: (%s, %s, %s)" % (`message`,`fid`, `iid`) frame = FrameProxy(self.conn, fid) info = None # XXX for now self.gui.interaction(message, frame, info)
def interaction(self, message, fid, iid): ##print "interaction: (%s, %s, %s)" % (`message`,`fid`, `iid`) frame = FrameProxy(self.conn, fid) info = None # XXX for now self.gui.interaction(message, frame, info)
10,800
def interaction(self, message, fid, iid): ##print "interaction: (%s, %s, %s)" % (`message`,`fid`, `iid`) frame = FrameProxy(self.conn, fid) info = None # XXX for now self.gui.interaction(message, frame, info)
def interaction(self, message, fid, iid): ##print "interaction: (%s, %s, %s)" % (`message`,`fid`, `iid`) frame = FrameProxy(self.conn, fid) info = None # XXX for now self.gui.interaction(message, frame, info)
10,801
def get_stack(self, frame, tb): stack, i = self.call("get_stack", frame._fid, None) stack = [(FrameProxy(self.conn, fid), k) for fid, k in stack] return stack, i
def get_stack(self, frame, tbid): stack, i = self.call("get_stack", frame._fid, tbid) stack = [(FrameProxy(self.conn, fid), k) for fid, k in stack] return stack, i
10,802
def clear_all_file_breaks(self, filename): msg = self.call("clear_all_file_breaks", filename)
defreturn msg clear_all_file_breaks(self,return msg filename):return msg msgreturn msg =return msg self.call("clear_all_file_breaks",return msg filename)return msg
10,803
test('capwords', u'abc\t def \nghi', u'Abc Def Ghi')
test('capwords', u'abc\t def \nghi', u'Abc Def Ghi')
10,804
def ckmsg(src, msg): try: compile(src, '<fragment>', 'exec') except SyntaxError, e: print e.msg if e.msg == msg: print "ok" else: print "expected:", msg else: print "failed to get expected SyntaxError"
def ckmsg(src, msg): try: compile(src, '<fragment>', 'exec') except SyntaxError, e: print e.msg if e.msg == msg: print "ok" else: print "expected:", msg else: print "failed to get expected SyntaxError"
10,805
def test_capi1(): try: _testcapi.raise_exception(BadException, 1) except TypeError, err: exc, err, tb = sys.exc_info() co = tb.tb_frame.f_code assert co.co_name == "test_capi1" assert co.co_filename.endswith('test_exceptions.py') else: print "Expected exception"
def test_capi1(): try: _testcapi.raise_exception(BadException, 1) except TypeError, err: exc, err, tb = sys.exc_info() co = tb.tb_frame.f_code assert co.co_name == "test_capi1" assert co.co_filename.endswith('test_exceptions.py') else: print "Expected exception"
10,806
def test_capi2(): try: _testcapi.raise_exception(BadException, 0) except RuntimeError, err: exc, err, tb = sys.exc_info() co = tb.tb_frame.f_code assert co.co_name == "__init__" assert co.co_filename.endswith('test_exceptions.py') co2 = tb.tb_frame.f_back.f_code assert co2.co_name == "test_capi2" else: print "Expected ...
def test_capi2(): try: _testcapi.raise_exception(BadException, 0) except RuntimeError, err: exc, err, tb = sys.exc_info() co = tb.tb_frame.f_code assert co.co_name == "__init__" assert co.co_filename.endswith('test_exceptions.py') co2 = tb.tb_frame.f_back.f_code assert co2.co_name == "test_capi2" else: print "Expected ...
10,807
def __init__ (self, sock=None, map=None): if sock: self.set_socket (sock, map) # I think it should inherit this anyway self.socket.setblocking (0) self.connected = 1 self.addr = sock.getpeername() else: self.socket = None
def __init__ (self, sock=None, map=None): if sock: self.set_socket (sock, map) # I think it should inherit this anyway self.socket.setblocking (0) self.connected = 1 try: self.addr = sock.getpeername() except socket.error: pass else: self.socket = None
10,808
def basic(src): print "Testing basic accessors..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) L = cf.sections() L.sort() verify(L == ['Commented Bar', 'Foo Bar', 'Internationalized Stuff', 'Spacey Bar'], "unexpected list of section names") # The use of spaces in the section names serv...
def basic(src): print "Testing basic accessors..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) L = cf.sections() L.sort() verify(L == [r'Commented Bar', r'Foo Bar', r'Internationalized Stuff', r'Section\with$weird%characters[' '\t', r'Spacey Bar', ], "unexpected list of section names") ...
10,809
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_...
10,810
def notationDecl(self, name, publicId, systemId):
def notationDecl(self, name, publicId, systemId):
10,811
def unparsedEntityDecl(self, name, publicId, systemId, ndata):
def unparsedEntityDecl(self, name, publicId, systemId, ndata):
10,812
def resolveEntity(self, publicId, systemId):
def resolveEntity(self, publicId, systemId):
10,813
def resolveEntity(self, publicId, systemId):
def resolveEntity(self, publicId, systemId):
10,814
def test_list(): l = [] l.append(l) gc.collect() del l assert gc.collect() == 1
def test_list(): l = [] l.append(l) gc.collect() del l if gc.collect() != 1: raise TestFailed
10,815
def test_dict(): d = {} d[1] = d gc.collect() del d assert gc.collect() == 1
def test_dict(): d = {} d[1] = d gc.collect() del d if gc.collect() != 1: raise TestFailed
10,816
def test_tuple(): # since tuples are immutable we close the loop with a list l = [] t = (l,) l.append(t) gc.collect() del t del l assert gc.collect() == 2
def test_tuple(): # since tuples are immutable we close the loop with a list l = [] t = (l,) l.append(t) gc.collect() del t del l if gc.collect() != 2: raise TestFailed
10,817
def test_class(): class A: pass A.a = A gc.collect() del A assert gc.collect() > 0
def test_class(): class A: pass A.a = A gc.collect() del A if gc.collect() == 0: raise TestFailed
10,818
def test_instance(): class A: pass a = A() a.a = a gc.collect() del a assert gc.collect() > 0
def test_instance(): class A: pass a = A() a.a = a gc.collect() del a if gc.collect() == 0: raise TestFailed
10,819
def __init__(self): self.init = self.__init__
def __init__(self): self.init = self.__init__
10,820
def __del__(self): pass
def __del__(self): pass
10,821
def __del__(self): pass
def __del__(self): pass
10,822
exec("def f(): pass\n") in d
exec("def f(): pass\n") in d
10,823
def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == xml.dom.core.ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep))
def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == xml.dom.core.ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep))
10,824
def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == xml.dom.core.ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep))
def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == xml.dom.core.ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep))
10,825
def fixup_paras_helper(doc, container): # document is already normalized children = container.childNodes start = 0 start_fixed = 0 i = 0 SKIP_ELEMENTS = PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS for child in children: if child.nodeType == xml.dom.core.ELEMENT: if child.tagName in FIXUP_PARA_ELEMENTS: fixup_paras_help...
def fixup_paras_helper(doc, container): # document is already normalized children = container.childNodes start = 0 start_fixed = 0 i = len(children) SKIP_ELEMENTS = PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS for child in children: if child.nodeType == xml.dom.core.ELEMENT: if child.tagName in FIXUP_PARA_ELEMENTS: fixu...
10,826
def fixup_paras_helper(doc, container): # document is already normalized children = container.childNodes start = 0 start_fixed = 0 i = 0 SKIP_ELEMENTS = PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS for child in children: if child.nodeType == xml.dom.core.ELEMENT: if child.tagName in FIXUP_PARA_ELEMENTS: fixup_paras_help...
def fixup_paras_helper(doc, container): # document is already normalized children = container.childNodes start = 0 start_fixed = 0 i = 0 SKIP_ELEMENTS = PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS if DEBUG_PARA_FIXER: sys.stderr.write("fixup_paras_helper() called on <%s>; %d, %d\n" % (container.tagName, start, i)) if i...
10,827
def postcmd(self, stop, line): if stop: return stop return None
def postcmd(self, stop, line): if stop: return stop return None
10,828
def postcmd(self, stop, line): if stop: return stop return None
def postcmd(self, stop, line): if stop: return stop return None
10,829
def user_line(self, frame): """This function is called when we stop or break at this line.""" if self._wait_for_mainpyfile: if (self.mainpyfile != self.canonic(frame.f_code.co_filename) or frame.f_lineno<= 0): return self._wait_for_mainpyfile = 0 self.interaction(frame, None)
def user_line(self, frame): """This function is called when we stop or break at this line.""" if self._wait_for_mainpyfile: if (self.mainpyfile != self.canonic(frame.f_code.co_filename) or frame.f_lineno<= 0): return self._wait_for_mainpyfile = 0 self.interaction(frame, None)
10,830
def _parsebody(self, container, fp): # Parse the body, but first split the payload on the content-type # boundary if present. boundary = container.get_boundary() isdigest = (container.get_content_type() == 'multipart/digest') # If there's a boundary, split the payload text into its constituent # parts and parse each se...
def _parsebody(self, container, fp): # Parse the body, but first split the payload on the content-type # boundary if present. boundary = container.get_boundary() isdigest = (container.get_content_type() == 'multipart/digest') # If there's a boundary, split the payload text into its constituent # parts and parse each se...
10,831
def hexescape(char): """Escape char as RFC 2396 specifies""" hex_repr = hex(ord(char))[2:].upper() if len(hex_repr) == 1: hex_repr = "0%s" % hex_repr return "%" + hex_repr
def hexescape(char): """Escape char as RFC 2396 specifies""" hex_repr = hex(ord(char))[2:].upper() if len(hex_repr) == 1: hex_repr = "0%s" % hex_repr return "%" + hex_repr
10,832
def test_basic_proxy(self): o = C() self.check_proxy(o, weakref.proxy(o))
def test_basic_proxy(self): o = C() self.check_proxy(o, weakref.proxy(o))
10,833
def parse_makefile(fp, g=None): """Parse a Makefile-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary. """ if g is None: g = {} variable_rx = re.compile("([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.*)\n") done =...
def parse_makefile(fp, g=None): """Parse a Makefile-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary. """ if g is None: g = {} variable_rx = re.compile("([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.*)\n") done =...
10,834
def path(path): return test_support.findfile(path)
def path(path): return test_support.findfile(path)
10,835
def test_main(): if gzip: # create testtar.tar.gz gzip.open(tarname("gz"), "wb").write(file(tarname(), "rb").read()) if bz2: # create testtar.tar.bz2 bz2.BZ2File(tarname("bz2"), "wb").write(file(tarname(), "rb").read()) tests = [ ReadTest, ReadStreamTest, WriteTest, WriteStreamTest ] if gzip: tests.extend([ ReadTestG...
def test_main(): if gzip: # create testtar.tar.gz gzip.open(tarname("gz"), "wb").write(file(tarname(), "rb").read()) if bz2: # create testtar.tar.bz2 bz2.BZ2File(tarname("bz2"), "wb").write(file(tarname(), "rb").read()) tests = [ ReadTest, ReadStreamTest, WriteTest, WriteStreamTest ] if gzip: tests.extend([ ReadTestG...
10,836
def m1(self, arg): return whatever**2
def m1(self, arg): return whatever**2
10,837
def error(self, msg, *args): sys.stderr.write('MH error: %\n' % (msg % args))
def error(self, msg, *args): sys.stderr.write('MH error: %\n' % (msg % args))
10,838
def makefolder(self, name): protect = pickline(self.profile, 'Folder-Protect') if protect and isnumeric(protect): mode = eval('0' + protect) else: mode = FOLDER_PROTECT os.mkdir(os.path.join(self.getpath(), name), mode)
def makefolder(self, name): protect = pickline(self.profile, 'Folder-Protect') if protect and isnumeric(protect): mode = string.atoi(protect, 8) else: mode = FOLDER_PROTECT os.mkdir(os.path.join(self.getpath(), name), mode)
10,839
def listmessages(self): messages = [] for name in os.listdir(self.getfullname()): if isnumeric(name): messages.append(eval(name)) messages.sort() if messages: self.last = max(messages) else: self.last = 0 return messages
def listmessages(self): messages = [] for name in os.listdir(self.getfullname()): if name[0] != "," and \ numericprog.match(name) == len(name): messages.append(string.atoi(name)) messages.sort() if messages: self.last = max(messages) else: self.last = 0 return messages
10,840
def openmessage(self, n): path = self.getmessagefilename(n) return Message(self, n)
def openmessage(self, n): return Message(self, n)
10,841
def updateline(file, key, value, casefold = 1): try: f = open(file, 'r') lines = f.readlines() f.close() except IOError: lines = [] pat = key + ':\(.*\)\n' if casefold: prog = regex.compile(pat, regex.casefold) else: prog = regex.compile(pat) if value is None: newline = None else: newline = '%s: %s' % (key, value) for ...
def updateline(file, key, value, casefold = 1): try: f = open(file, 'r') lines = f.readlines() f.close() except IOError: lines = [] pat = key + ':\(.*\)\n' if casefold: prog = regex.compile(pat, regex.casefold) else: prog = regex.compile(pat) if value is None: newline = None else: newline = '%s: %s\n' % (key, value) fo...
10,842
def __and__(self, other): """Return the intersection of two sets as a new set.
def __and__(self, other): """Return the intersection of two sets as a new set.
10,843
def __xor__(self, other): """Return the symmetric difference of two sets as a new set.
def __xor__(self, other): """Return the symmetric difference of two sets as a new set.
10,844
def __sub__(self, other): """Return the difference of two sets as a new Set.
def __sub__(self, other): """Return the difference of two sets as a new Set.
10,845
def __sub__(self, other): """Return the difference of two sets as a new Set.
def __sub__(self, other): """Return the difference of two sets as a new Set.
10,846
def issubset(self, other): """Report whether another set contains this set.""" self._binary_sanity_check(other) if len(self) > len(other): # Fast check for obvious cases return False otherdata = other._data for elt in self: if elt not in otherdata: return False return True
def issubset(self, other): """Report whether another set contains this set.""" self._binary_sanity_check(other) if len(self) > len(other): # Fast check for obvious cases return False for elt in ifilter(other._data.has_key, self, True): return False return True
10,847
def issuperset(self, other): """Report whether this set contains another set.""" self._binary_sanity_check(other) if len(self) < len(other): # Fast check for obvious cases return False selfdata = self._data for elt in other: if elt not in selfdata: return False return True
def issuperset(self, other): """Report whether this set contains another set.""" self._binary_sanity_check(other) if len(self) < len(other): # Fast check for obvious cases return False for elt in ifilter(self._data.has_key, other, True): return False return True
10,848
def __init__(self, flist=None, tb=None): self.flist = flist self.stack = get_stack(tb) self.text = get_exception()
def __init__(self, flist=None, tb=None): self.flist = flist self.stack = get_stack(tb) self.text = get_exception()
10,849
def GetText(self): frame, lineno = self.info try: modname = frame.f_globals["__name__"] except: modname = "?" code = frame.f_code filename = code.co_filename funcname = code.co_name sourceline = linecache.getline(filename, lineno) sourceline = sourceline.strip() if funcname in ("?", "", None): item = "%s, line %d: %s" ...
def GetText(self): frame, lineno = self.info try: modname = frame.f_globals["__name__"] except: modname = "?" code = frame.f_code filename = code.co_filename funcname = code.co_name sourceline = linecache.getline(filename, lineno) sourceline = sourceline.strip() if funcname in ("?", "", None): item = "%s, line %d: %s" ...
10,850
def get_stack(t=None, f=None): if t is None: t = sys.last_traceback stack = [] if t and t.tb_frame is f: t = t.tb_next while f is not None: stack.append((f, f.f_lineno)) if f is self.botframe: break f = f.f_back stack.reverse() while t is not None: stack.append((t.tb_frame, t.tb_lineno)) t = t.tb_next return stack
def get_stack(t=None, f=None): if t is None: t = sys.last_traceback stack = [] if t and t.tb_frame is f: t = t.tb_next while f is not None: stack.append((f, f.f_lineno)) if f is self.botframe: break f = f.f_back stack.reverse() while t is not None: stack.append((t.tb_frame, t.tb_lineno)) t = t.tb_next return stack
10,851
def write_manifest (self): """Write the file list in 'self.files' (presumably as filled in by 'find_defaults()' and 'read_template()') to the manifest file named by 'self.manifest'."""
def write_manifest (self): """Write the file list in 'self.files' (presumably as filled in by 'find_defaults()' and 'read_template()') to the manifest file named by 'self.manifest'."""
10,852
def load_macros(self, version): vsbase = r"Software\Microsoft\VisualStudio\%0.1f" % version self.set_macro("VCInstallDir", vsbase + r"\Setup\VC", "productdir") self.set_macro("VSInstallDir", vsbase + r"\Setup\VS", "productdir") net = r"Software\Microsoft\.NETFramework" self.set_macro("FrameworkDir", net, "installroot")...
def load_macros(self, version): vsbase = r"Software\Microsoft\VisualStudio\%0.1f" % version self.set_macro("VCInstallDir", vsbase + r"\Setup\VC", "productdir") self.set_macro("VSInstallDir", vsbase + r"\Setup\VS", "productdir") net = r"Software\Microsoft\.NETFramework" self.set_macro("FrameworkDir", net, "installroot")...
10,853
def test_boom(): a = Boom() b = Boom() a.attr = b b.attr = a gc.collect() garbagelen = len(gc.garbage) del a, b # a<->b are in a trash cycle now. Collection will invoke Boom.__getattr__ # (to see whether a and b have __del__ methods), and __getattr__ deletes # the internal "attr" attributes as a side effect. That ca...
def test_boom(): a = Boom() b = Boom() a.attr = b b.attr = a gc.collect() garbagelen = len(gc.garbage) del a, b # a<->b are in a trash cycle now. Collection will invoke Boom.__getattr__ # (to see whether a and b have __del__ methods), and __getattr__ deletes # the internal "attr" attributes as a side effect. That ca...
10,854
def _make_spec_file(self): """Generate the text of an RPM spec file and return it as a list of strings (one per line). """ # definitions and headers spec_file = [ '%define name ' + self.distribution.get_name(), '%define version ' + self.distribution.get_version(), '%define release ' + self.release, '', 'Summary: ' + se...
def _make_spec_file(self): """Generate the text of an RPM spec file and return it as a list of strings (one per line). """ # definitions and headers spec_file = [ '%define name ' + self.distribution.get_name(), '%define version ' + self.distribution.get_version(), '%define release ' + self.release, '', 'Summary: ' + se...
10,855
def make_connection(self, host): # create a HTTPS connection object from a host descriptor # host may be a string, or a (host, x509-dict) tuple import httplib if isinstance(host, TupleType): host, x509 = host else: x509 = {} try: HTTPS = httplib.HTTPS except AttributeError: raise NotImplementedError,\ "your version of ...
def make_connection(self, host): # create a HTTPS connection object from a host descriptor # host may be a string, or a (host, x509-dict) tuple import httplib host, extra_headers, x509 = self.get_host_info(host) try: HTTPS = httplib.HTTPS except AttributeError: raise NotImplementedError,\ "your version of httplib doesn...
10,856
def make_connection(self, host): # create a HTTPS connection object from a host descriptor # host may be a string, or a (host, x509-dict) tuple import httplib if isinstance(host, TupleType): host, x509 = host else: x509 = {} try: HTTPS = httplib.HTTPS except AttributeError: raise NotImplementedError,\ "your version of ...
def make_connection(self, host): # create a HTTPS connection object from a host descriptor # host may be a string, or a (host, x509-dict) tuple import httplib if isinstance(host, TupleType): host, x509 = host else: x509 = {} try: HTTPS = httplib.HTTPS except AttributeError: raise NotImplementedError( "your version of h...
10,857
def make_connection(self, host): # create a HTTPS connection object from a host descriptor # host may be a string, or a (host, x509-dict) tuple import httplib if isinstance(host, TupleType): host, x509 = host else: x509 = {} try: HTTPS = httplib.HTTPS except AttributeError: raise NotImplementedError,\ "your version of ...
def make_connection(self, host): # create a HTTPS connection object from a host descriptor # host may be a string, or a (host, x509-dict) tuple import httplib if isinstance(host, TupleType): host, x509 = host else: x509 = {} try: HTTPS = httplib.HTTPS except AttributeError: raise NotImplementedError,\ "your version of ...
10,858
def splithost(url): """splithost('//host[:port]/path') --> 'host[:port]', '/path'.""" global _hostprog if _hostprog is None: import re _hostprog = re.compile('^//([^/]*)(.*)$') match = _hostprog.match(url) if match: return match.group(1, 2) return None, url
def splithost(url): """splithost('//host[:port]/path') --> 'host[:port]', '/path'.""" global _hostprog if _hostprog is None: import re _hostprog = re.compile('^//([^/?]*)(.*)$') match = _hostprog.match(url) if match: return match.group(1, 2) return None, url
10,859
def test_timezone(self): # Test timezone directives. # When gmtime() is used with %Z, entire result of strftime() is empty. # Check for equal timezone names deals with bad locale info when this # occurs; first found in FreeBSD 4.4. strp_output = _strptime.strptime("UTC", "%Z") self.failUnlessEqual(strp_output.tm_isdst,...
def test_timezone(self): # Test timezone directives. # When gmtime() is used with %Z, entire result of strftime() is empty. # Check for equal timezone names deals with bad locale info when this # occurs; first found in FreeBSD 4.4. strp_output = _strptime.strptime("UTC", "%Z") self.failUnlessEqual(strp_output.tm_isdst,...
10,860
def basename(s): return split(s)[1]
defbasename(s):returnsplit(s)[1]
10,861
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 ...
10,862
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 ...
10,863
def find_library_file(compiler, libname, std_dirs, paths): filename = compiler.library_filename(libname, lib_type='shared') result = find_file(filename, std_dirs, paths) if result is not None: return result filename = compiler.library_filename(libname, lib_type='static') result = find_file(filename, std_dirs, paths) r...
def find_library_file(compiler, libname, std_dirs, paths): filename = compiler.library_filename(libname, lib_type='shared') result = find_file(filename, std_dirs, paths) if result is not None: return result filename = compiler.library_filename(libname, lib_type='static') result = find_file(filename, std_dirs, paths) r...
10,864
def generate(self): # XXX This should use long strings and %(varname)s substitution!
def generate(self): # XXX This should use long strings and %(varname)s substitution!
10,865
def generate(self): # XXX This should use long strings and %(varname)s substitution!
def generate(self): # XXX This should use long strings and %(varname)s substitution!
10,866
def cmdloop(self, intro=None): self.preloop() if intro is not None: self.intro = intro if self.intro: print self.intro stop = None while not stop: if self.cmdqueue: line = self.cmdqueue[0] del self.cmdqueue[0] else: try: line = raw_input(self.prompt) except EOFError: line = 'EOF' line = self.precmd(line) stop = self.on...
def cmdloop(self, intro=None): self.preloop() if intro is not None: self.intro = intro if self.intro: print self.intro stop = None while not stop: if self.cmdqueue: line = self.cmdqueue[0] del self.cmdqueue[0] else: if self.use_rawinput: try: line = raw_input(self.prompt) except EOFError: line = 'EOF' else: sys.stdout....
10,867
def test_others(self): cm = self.checkModule
def test_others(self): cm = self.checkModule
10,868
def setUp(self): # In Python, audiotest.au lives in Lib/test not Lib/test/data fp = open(findfile('audiotest.au'), 'rb') try: self._audiodata = fp.read() finally: fp.close() self._au = MIMEAudio(self._audiodata)
def setUp(self): # In Python, audiotest.au lives in Lib/test not Lib/test/data datadir = os.path.join(os.path.dirname(landmark), 'data', '') fp = open(findfile('audiotest.au', datadir), 'rb') try: self._audiodata = fp.read() finally: fp.close() self._au = MIMEAudio(self._audiodata)
10,869
def guess_type(self, path): """Guess the type of a file.
def if not mimetypes.inited: mimetypes.init() guess_type(self, if not mimetypes.inited: mimetypes.init() path): if not mimetypes.inited: mimetypes.init() """Guess if not mimetypes.inited: mimetypes.init() the if not mimetypes.inited: mimetypes.init() type if not mimetypes.inited: mimetypes.init() of if not mimetypes.in...
10,870
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
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
10,871
def rev(self): if self._rev is not None: return self._rev L = list(self) L.reverse() self._rev = self.__class__(u"".join(L)) return self._rev
defverify(unicode(u).__class__ is unicode) rev(self):verify(unicode(u).__class__ is unicode) ifverify(unicode(u).__class__ is unicode) self._revverify(unicode(u).__class__ is unicode) isverify(unicode(u).__class__ is unicode) notverify(unicode(u).__class__ is unicode) None:verify(unicode(u).__class__ is unicode) return...
10,872
def write_toc_entry(entry, fp, layer): stype, snum, title, pageno, toc = entry s = "\\pdfoutline goto name{page.%d}" % pageno if toc: s = "%s count -%d" % (s, len(toc)) if snum: title = "%s %s" % (snum, title) s = "%s {%s}\n" % (s, title) fp.write(s) for entry in toc: write_toc_entry(entry, fp, layer + 1)
def write_toc_entry(entry, fp, layer): stype, snum, title, pageno, toc = entry s = "\\pdfoutline goto name{page.%dx}" % pageno if toc: s = "%s count -%d" % (s, len(toc)) if snum: title = "%s %s" % (snum, title) s = "%s {%s}\n" % (s, title) fp.write(s) for entry in toc: write_toc_entry(entry, fp, layer + 1)
10,873
def test_partition(self):
def test_partition(self):
10,874
def __init__(self, parent, title = None):
def __init__(self, parent, title = None):
10,875
def buttonbox(self): '''add standard button box.
def buttonbox(self): '''add standard button box.
10,876
def cancel(self, event=None):
def cancel(self, event=None):
10,877
def getboolean(self, section, option): v = self.get(section, option) val = int(v) if val not in (0, 1): raise ValueError, 'Not a boolean: %s' % v return val
def getboolean(self, section, option): states = {'1': 1, 'yes': 1, 'true': 1, 'on': 1, '0': 0, 'no': 0, 'false': 0, 'off': 0} v = self.get(section, option) if not states.has_key(v.lower()): raise ValueError, 'Not a boolean: %s' % v return val
10,878
def getboolean(self, section, option): v = self.get(section, option) val = int(v) if val not in (0, 1): raise ValueError, 'Not a boolean: %s' % v return val
def getboolean(self, section, option): v = self.get(section, option) val = int(v) if val not in (0, 1): raise ValueError, 'Not a boolean: %s' % v return val
10,879
def write_results_file(self, path, lines, lnotab, lines_hit): """Return a coverage results file in path."""
def write_results_file(self, path, lines, lnotab, lines_hit): """Return a coverage results file in path."""
10,880
def open_https(self, url, data=None): """Use HTTPS protocol.""" import httplib user_passwd = None proxy_passwd = None if isinstance(url, str): host, selector = splithost(url) if host: user_passwd, host = splituser(host) host = unquote(host) realhost = host else: host, selector = url # here, we determine, whether the pr...
def open_https(self, url, data=None): """Use HTTPS protocol.""" import httplib user_passwd = None proxy_passwd = None if isinstance(url, str): host, selector = splithost(url) if host: user_passwd, host = splituser(host) host = unquote(host) realhost = host else: host, selector = url # here, we determine, whether the pr...
10,881
def main(): # overridable context prefix = None # settable with -p option exec_prefix = None # settable with -P option extensions = [] exclude = [] # settable with -x option addn_link = [] # settable with -l, but only honored under Windows. path = sys.p...
def main(): # overridable context prefix = None # settable with -p option exec_prefix = None # settable with -P option extensions = [] exclude = [] # settable with -x option addn_link = [] # settable with -l, but only honored under Windows. path = sys.p...
10,882
def checkdir(self, path, istop): files = os.listdir(path) rv = [] todo = [] for f in files: if self.exc.match(f): continue fullname = os.path.join(path, f) if self.inc.match(fullname) == None: if os.path.isdir(fullname): todo.append(fullname) else: rv.append(fullname) for d in todo: if len(rv) > 500: if istop: rv.appen...
def checkdir(self, path, istop): files = os.listdir(path) rv = [] todo = [] for f in files: if self.exc.match(f): continue fullname = os.path.join(path, f) if DEBUG: print 'checkpath', fullname matchvalue = self.inc.match(fullname) if matchvalue == None: if os.path.isdir(fullname): todo.append(fullname) else: rv.append...
10,883
def rundir(self, path, destprefix, doit): files = os.listdir(path) todo = [] rv = 1 for f in files: if self.exc.match(f): continue fullname = os.path.join(path, f) if os.path.isdir(fullname): todo.append(fullname) else: dest = self.inc.match(fullname) if dest == None: print 'Not yet resolved:', fullname rv = 0 if dest:...
def rundir(self, path, destprefix, doit): files = os.listdir(path) todo = [] rv = 1 for f in files: if self.exc.match(f): continue fullname = os.path.join(path, f) if os.path.isdir(fullname): todo.append(fullname) else: dest = self.inc.match(fullname) if dest == None: print 'Not yet resolved:', fullname rv = 0 if dest:...
10,884
def _find_module(fullname, path=None): """Version of imp.find_module() that handles hierarchical module names""" file = None for tgt in fullname.split('.'): if file is not None: file.close() # close intermediate files (file, filename, descr) = imp.find_module(tgt, path) if descr[2] == imp.PY_SOURCE: break ...
def _find_module(fullname, path=None): """Version of imp.find_module() that handles hierarchical module names""" file = None for tgt in fullname.split('.'): if file is not None: file.close() # close intermediate files (file, filename, descr) = imp.find_module(tgt, path) if descr[2] == imp.PY_SOURCE: break ...
10,885
def savefilename(self, url): type, rest = urllib.splittype(url) host, path = urllib.splithost(rest) while path[:1] == "/": path = path[1:] user, host = urllib.splituser(host) host, port = urllib.splitnport(host) host = string.lower(host) if not path or path[-1] == "/": path = path + "index.html" if os.sep != "/": path ...
def savefilename(self, url): type, rest = urllib.splittype(url) host, path = urllib.splithost(rest) while path[:1] == "/": path = path[1:] user, host = urllib.splituser(host) host, port = urllib.splitnport(host) host = string.lower(host) if not path or path[-1] == "/": path = path + "index.html" if os.sep != "/": path ...
10,886
def __init__(self, recipients): self.recipients = recipients self.args = ( recipients,)
def__init__(self,recipients):self.recipients=recipientsself.args=(recipients,)
10,887
def helo(self, name=''): """SMTP 'helo' command. Hostname to send for this command defaults to the FQDN of the local host. """ name=string.strip(name) if len(name)==0: name = socket.gethostname() try: name = socket.gethostbyaddr(name)[0] except socket.error: pass self.putcmd("helo",name) (code,msg)=self.getreply() self...
def helo(self, name=''): """SMTP 'helo' command. Hostname to send for this command defaults to the FQDN of the local host. """ self.putcmd("helo", _get_fqdn_hostname(name)) (code,msg)=self.getreply() self.helo_resp=msg return (code,msg)
10,888
def ehlo(self, name=''): """ SMTP 'ehlo' command. Hostname to send for this command defaults to the FQDN of the local host. """ name=string.strip(name) if len(name)==0: name = socket.gethostname() try: name = socket.gethostbyaddr(name)[0] except socket.error: pass self.putcmd("ehlo",name) (code,msg)=self.getreply() # A...
def ehlo(self, name=''): """ SMTP 'ehlo' command. Hostname to send for this command defaults to the FQDN of the local host. """ self.putcmd("ehlo", _get_fqdn_hostname(name)) (code,msg)=self.getreply() # According to RFC1869 some (badly written) # MTA's will disconnect on an ehlo. Toss an exception if # that happens -dd...
10,889
def __rdivmod__(self, other): "Divide two Rats, returning quotient and remainder (reversed args).""" if isint(other): other = Rat(other) elif not isRat(other): return NotImplemented return divmod(other, self)
def __rdivmod__(self, other): """Divide two Rats, returning quotient and remainder (reversed args).""" if isint(other): other = Rat(other) elif not isRat(other): return NotImplemented return divmod(other, self)
10,890
def __init__(self, proxies=None, **x509): if proxies is None: proxies = getproxies() assert hasattr(proxies, 'has_key'), "proxies must be a mapping" self.proxies = proxies self.key_file = x509.get('key_file') self.cert_file = x509.get('cert_file') server_version = "Python-urllib/%s" % __version__ self.addheaders = [('U...
def __init__(self, proxies=None, **x509): if proxies is None: proxies = getproxies() assert hasattr(proxies, 'has_key'), "proxies must be a mapping" self.proxies = proxies self.key_file = x509.get('key_file') self.cert_file = x509.get('cert_file') self.addheaders = [('User-agent', self.version)] self.__tempfiles = [] s...
10,891
def test_sparse(self): """Test sparse member extraction. """ if self.sep != "|": f1 = self.tar.extractfile("S-SPARSE") f2 = self.tar.extractfile("S-SPARSE-WITH-NULLS") self.assert_(f1.read() == f2.read(), "_FileObject failed on sparse file member")
def test_sparse(self): """Test sparse member extraction. """ if self.sep != "|": f1 = self.tar.extractfile("S-SPARSE") f2 = self.tar.extractfile("/S-SPARSE-WITH-NULLS") self.assert_(f1.read() == f2.read(), "_FileObject failed on sparse file member")
10,892
def test_readlines(self): """Test readlines() method of _FileObject. """ if self.sep != "|": filename = "0-REGTYPE-TEXT" self.tar.extract(filename, dirname()) lines1 = file(os.path.join(dirname(), filename), "r").readlines() lines2 = self.tar.extractfile(filename).readlines() self.assert_(lines1 == lines2, "_FileObject...
def test_readlines(self): """Test readlines() method of _FileObject. """ if self.sep != "|": filename = "/0-REGTYPE-TEXT" self.tar.extract(filename, dirname()) lines1 = file(os.path.join(dirname(), filename), "r").readlines() lines2 = self.tar.extractfile(filename).readlines() self.assert_(lines1 == lines2, "_FileObjec...
10,893
def test_readlines(self): """Test readlines() method of _FileObject. """ if self.sep != "|": filename = "0-REGTYPE-TEXT" self.tar.extract(filename, dirname()) lines1 = file(os.path.join(dirname(), filename), "r").readlines() lines2 = self.tar.extractfile(filename).readlines() self.assert_(lines1 == lines2, "_FileObject...
def test_readlines(self): """Test readlines() method of _FileObject. """ if self.sep != "|": filename = "0-REGTYPE-TEXT" self.tar.extract(filename, dirname()) lines1 = file(os.path.join(dirname(), filename), "rU").readlines() lines2 = self.tar.extractfile(filename).readlines() self.assert_(lines1 == lines2, "_FileObjec...
10,894
def test_seek(self): """Test seek() method of _FileObject, incl. random reading. """ if self.sep != "|": filename = "0-REGTYPE" self.tar.extract(filename, dirname()) data = file(os.path.join(dirname(), filename), "rb").read()
def test_seek(self): """Test seek() method of _FileObject, incl. random reading. """ if self.sep != "|": filename = "/0-REGTYPE" self.tar.extract(filename, dirname()) data = file(os.path.join(dirname(), filename), "rb").read()
10,895
def urlretrieve(url, filename=None): global _urlopener if not _urlopener: _urlopener = FancyURLopener() if filename: return _urlopener.retrieve(url, filename) else: return _urlopener.retrieve(url)
def urlretrieve(url, filename=None): global _urlopener if not _urlopener: _urlopener = FancyURLopener() if filename: return _urlopener.retrieve(url, filename) else: return _urlopener.retrieve(url)
10,896
def urlretrieve(url, filename=None): global _urlopener if not _urlopener: _urlopener = FancyURLopener() if filename: return _urlopener.retrieve(url, filename) else: return _urlopener.retrieve(url)
def urlretrieve(url, filename=None): global _urlopener if not _urlopener: _urlopener = FancyURLopener() if filename: return _urlopener.retrieve(url, filename) else: return _urlopener.retrieve(url)
10,897
def cleanup(self): # This code sometimes runs when the rest of this module # has already been deleted, so it can't use any globals # or import anything. if self.__tempfiles: for file in self.__tempfiles: try: self.__unlink(file) except: pass del self.__tempfiles[:] if self.tempcache: self.tempcache.clear()
def cleanup(self): # This code sometimes runs when the rest of this module # has already been deleted, so it can't use any globals # or import anything. if self.__tempfiles: for file in self.__tempfiles: try: self.__unlink(file) except: pass del self.__tempfiles[:] if self.tempcache: self.tempcache.clear()
10,898
def open(self, fullurl, data=None): fullurl = unwrap(fullurl) if self.tempcache and self.tempcache.has_key(fullurl): filename, headers = self.tempcache[fullurl] fp = open(filename, 'rb') return addinfourl(fp, headers, fullurl) type, url = splittype(fullurl) if not type: type = 'file' if self.proxies.has_key(type): prox...
def open(self, fullurl, data=None): fullurl = unwrap(fullurl) if self.tempcache and self.tempcache.has_key(fullurl): filename, headers = self.tempcache[fullurl] fp = open(filename, 'rb') return addinfourl(fp, headers, fullurl) type, url = splittype(fullurl) if not type: type = 'file' if self.proxies.has_key(type): prox...
10,899