bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def debug(self): """Run the test without collecting errors in a TestResult""" self.setUp() getattr(self, self.__testMethodName)() self.tearDown()
def debug(self): """Run the test without collecting errors in a TestResult""" self.setUp() getattr(self, self._testMethodName)() self.tearDown()
18,900
def __exc_info(self): """Return a version of sys.exc_info() with the traceback frame minimised; usually the top level of the traceback frame is not needed. """ exctype, excvalue, tb = sys.exc_info() if sys.platform[:4] == 'java': ## tracebacks look different in Jython return (exctype, excvalue, tb) return (exctype, exc...
def _exc_info(self): """Return a version of sys.exc_info() with the traceback frame minimised; usually the top level of the traceback frame is not needed. """ exctype, excvalue, tb = sys.exc_info() if sys.platform[:4] == 'java': ## tracebacks look different in Jython return (exctype, excvalue, tb) return (exctype, excv...
18,901
def parse_endtag(self, i): rawdata = self.rawdata end = endbracketfind.match(rawdata, i+1) if end is None: return -1 res = tagfind.match(rawdata, i+2) if res is None: if self.literal: self.handle_data(rawdata[i]) return i+1 if not self.__accept_missing_endtag_name: self.syntax_error('no name specified in end tag') tag ...
def parse_endtag(self, i): rawdata = self.rawdata end = endbracketfind.match(rawdata, i+1) if end is None: return -1 res = tagfind.match(rawdata, i+2) if res is None: if self.literal: self.handle_data(rawdata[i]) return i+1 if not self.__accept_missing_endtag_name: self.syntax_error('no name specified in end tag') tag ...
18,902
def testtype(type, example): a = array.array(type) a.append(example) if verbose: print 40*'*' print 'array after append: ', a a.typecode a.itemsize if a.typecode in ('i', 'b', 'h', 'l'): a.byteswap() if a.typecode == 'c': f = open(TESTFN, "w") f.write("The quick brown fox jumps over the lazy dog.\n") f.close() f = op...
def testtype(type, example): a = array.array(type) a.append(example) if verbose: print 40*'*' print 'array after append: ', a a.typecode a.itemsize if a.typecode in ('i', 'b', 'h', 'l'): a.byteswap() if a.typecode == 'c': f = open(TESTFN, "w") f.write("The quick brown fox jumps over the lazy dog.\n") f.close() f = op...
18,903
def get_importer(path_item): """Retrieve a PEP 302 importer for the given path item The returned importer is cached in sys.path_importer_cache if it was newly created by a path hook. If there is no importer, a wrapper around the basic import machinery is returned. This wrapper is never inserted into the importer cach...
def get_importer(path_item): """Retrieve a PEP 302 importer for the given path item The returned importer is cached in sys.path_importer_cache if it was newly created by a path hook. If there is no importer, a wrapper around the basic import machinery is returned. This wrapper is never inserted into the importer cach...
18,904
def get_importer(path_item): """Retrieve a PEP 302 importer for the given path item The returned importer is cached in sys.path_importer_cache if it was newly created by a path hook. If there is no importer, a wrapper around the basic import machinery is returned. This wrapper is never inserted into the importer cach...
def get_importer(path_item): """Retrieve a PEP 302 importer for the given path item The returned importer is cached in sys.path_importer_cache if it was newly created by a path hook. If there is no importer, a wrapper around the basic import machinery is returned. This wrapper is never inserted into the importer cach...
18,905
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 ...
18,906
def get_boundary(self, failobj=None): """Return the boundary associated with the payload if present.
def get_boundary(self, failobj=None): """Return the boundary associated with the payload if present.
18,907
def putcmd(self, cmd, args=""): """Send a command to the server.""" str = '%s %s%s' % (cmd, args, CRLF) self.send(str)
def putcmd(self, cmd, args=""): """Send a command to the server.""" if args == "": str = '%s%s' % (cmd, CRLF) else: str = '%s %s%s' % (cmd, args, CRLF) self.send(str)
18,908
def mail(self,sender,options=[]): """SMTP 'mail' command -- begins mail xfer session.""" optionlist = '' if options and self.does_esmtp: optionlist = string.join(options, ' ') self.putcmd("mail", "FROM:%s %s" % (quoteaddr(sender) ,optionlist)) return self.getreply()
def mail(self,sender,options=[]): """SMTP 'mail' command -- begins mail xfer session.""" optionlist = '' if options and self.does_esmtp: optionlist = ' ' + string.join(options, ' ') self.putcmd("mail", "FROM:%s%s" % (quoteaddr(sender) ,optionlist)) return self.getreply()
18,909
def index(path, archivo, output): f = formatter.AbstractFormatter(AlmostNullWriter()) parser = IdxHlpHtmlParser(f) parser.path = path parser.ft = output fil = path + '/' + archivo parser.feed(open(fil).read()) parser.close()
def index(path, indexpage, output): f = formatter.AbstractFormatter(AlmostNullWriter()) parser = IdxHlpHtmlParser(f) parser.path = path parser.ft = output fil = path + '/' + archivo parser.feed(open(fil).read()) parser.close()
18,910
def index(path, archivo, output): f = formatter.AbstractFormatter(AlmostNullWriter()) parser = IdxHlpHtmlParser(f) parser.path = path parser.ft = output fil = path + '/' + archivo parser.feed(open(fil).read()) parser.close()
def index(path, archivo, output): f = formatter.AbstractFormatter(AlmostNullWriter()) parser = IdxHlpHtmlParser(f) parser.path = path parser.ft = output f = open(path + '/' + indexpage) parser.feed(f.read()) parser.close()
18,911
def index(path, archivo, output): f = formatter.AbstractFormatter(AlmostNullWriter()) parser = IdxHlpHtmlParser(f) parser.path = path parser.ft = output fil = path + '/' + archivo parser.feed(open(fil).read()) parser.close()
def index(path, archivo, output): f = formatter.AbstractFormatter(AlmostNullWriter()) parser = IdxHlpHtmlParser(f) parser.path = path parser.ft = output fil = path + '/' + archivo parser.feed(open(fil).read()) parser.close()
18,912
def content(path, archivo, output): f = formatter.AbstractFormatter(AlmostNullWriter()) parser = TocHlpHtmlParser(f) parser.path = path parser.ft = output fil = path + '/' + archivo parser.feed(open(fil).read()) parser.close()
def content(path, archivo, output): f = formatter.AbstractFormatter(AlmostNullWriter()) parser = TocHlpHtmlParser(f) parser.path = path parser.ft = output f = open(path + '/' + contentpage) parser.feed(f.read()) parser.close()
18,913
def do_index(library, output): output.write('<UL>\n') for book in library: print '\t', book[2] if book[4]: index(book[0], book[4], output) output.write('</UL>\n')
def do_index(library, output): output.write('<UL>\n') for book in library: print '\t', book.title, '-', book.indexpage if book.indexpage: index(book.directory, book.indexpage, output) output.write('</UL>\n')
18,914
def do_content(library, version, output): output.write(contents_header % version) for book in library: print '\t', book[2] output.write(object_sitemap % (book[0]+"/"+book[2], book[1])) if book[3]: content(book[0], book[3], output) output.write(contents_footer)
def do_content(library, version, output): output.write(contents_header % version) for book in library: print '\t', book.title, '-', book.firstpage output.write(object_sitemap % (book.directory + "/" + book.firstpage, book.title)) if book.contentpage: content(book.directory, book.contentpage, output) output.write(conten...
18,915
def do_project(library, output, arch, version): output.write(project_template % locals()) for book in library: directory = book[0] path = directory + '\\%s\n' for page in os.listdir(directory): if page.endswith('.html') or page.endswith('.css'): output.write(path % page)
def do_project(library, output, arch, version): output.write(project_template % locals()) for book in library: directory = book.directory path = directory + '\\%s\n' for page in os.listdir(directory): if page.endswith('.html') or page.endswith('.css'): output.write(path % page)
18,916
def do_it(args = None): if not args: args = sys.argv[1:] if not args: usage() try: optlist, args = getopt.getopt(args, 'ckpv:') except getopt.error, msg: print msg usage() if not args or len(args) > 1: usage() arch = args[0] version = None for opt in optlist: if opt[0] == '-v': version = opt[1] break if not version...
def do_it(args = None): if not args: args = sys.argv[1:] if not args: usage() try: optlist, args = getopt.getopt(args, 'ckpv:') except getopt.error, msg: print msg usage() if not args or len(args) > 1: usage() arch = args[0] version = None for opt in optlist: if opt[0] == '-v': version = opt[1] break if not version...
18,917
def search_function(encoding): # Cache lookup entry = _cache.get(encoding, _unknown) if entry is not _unknown: return entry # Import the module: # # First try to find an alias for the normalized encoding # name and lookup the module using the aliased name, then try to # lookup the module using the standard import sch...
def search_function(encoding): # Cache lookup entry = _cache.get(encoding, _unknown) if entry is not _unknown: return entry # Import the module: # # First try to find an alias for the normalized encoding # name and lookup the module using the aliased name, then try to # lookup the module using the standard import sch...
18,918
def translate(self, table, deletechars=""): return self.__class__(self.data.translate(table, deletechars))
def translate(self, table, deletechars=""): return self.__class__(self.data.translate(table, deletechars))
18,919
def __init__(self, code, msg, sender): self.smtp_code = code self.smtp_error = msg self.sender = sender self.args = (code, msg, sender)
def __init__(self, code, msg, sender): self.smtp_code = code self.smtp_error = msg self.sender = sender self.args = (code, msg, sender)
18,920
def data(self,msg): """SMTP 'DATA' command -- sends message data to server.
def data(self,msg): """SMTP 'DATA' command -- sends message data to server.
18,921
... def foo(cls, y):
... def foo(cls, y):
18,922
... def foo(cls, y):
... def foo(cls, y):
18,923
... def foo(cls, y):
... def foo(cls, y):
18,924
... def foo(cls, y):
... def foo(cls, y):
18,925
... def foo(cls, y): # override C.foo
... def foo(cls, y): # override C.foo
18,926
... def foo(cls, y): # override C.foo
... def foo(cls, y): # override C.foo
18,927
... def setx(self, x):
... def setx(self, x):
18,928
... def save(self):
... def save(self):
18,929
def compileproperty(self, prop): [name, code, what] = prop if code == 'c@#!': # Something silly with plurals. Skip it. return pname = identify(name) if self.namemappers[0].hascode('property', code): # plural forms and such othername, dummy, dummy = self.namemappers[0].findcodename('property', code) if pname == othernam...
def compileproperty(self, prop): [name, code, what] = prop if code == 'c@#!': # Something silly with plurals. Skip it. return pname = identify(name) if self.namemappers[0].hascode('property', code): # plural forms and such othername, dummy, dummy = self.namemappers[0].findcodename('property', code) if pname == othernam...
18,930
def compileproperty(self, prop): [name, code, what] = prop if code == 'c@#!': # Something silly with plurals. Skip it. return pname = identify(name) if self.namemappers[0].hascode('property', code): # plural forms and such othername, dummy, dummy = self.namemappers[0].findcodename('property', code) if pname == othernam...
def compileproperty(self, prop): [name, code, what] = prop if code == 'c@#!': # Something silly with plurals. Skip it. return pname = identify(name) if self.namemappers[0].hascode('property', code): # plural forms and such othername, dummy, dummy = self.namemappers[0].findcodename('property', code) if pname == othernam...
18,931
def fillclasspropsandelems(self, cls): [name, code, desc, properties, elements] = cls cname = identify(name) if self.namemappers[0].hascode('class', code) and \ self.namemappers[0].findcodename('class', code)[0] != cname: # This is an other name (plural or so) for something else. Skip. if self.fp and (elements or len(p...
def fillclasspropsandelems(self, cls): [name, code, desc, properties, elements] = cls cname = identify(name) if self.namemappers[0].hascode('class', code) and \ self.namemappers[0].findcodename('class', code)[0] != cname: # This is an other name (plural or so) for something else. Skip. if self.fp and (elements or len(p...
18,932
def dumpindex(self): if not self.fp: return self.fp.write("\n#\n# Indices of types declared in this module\n#\n") self.fp.write("_classdeclarations = {\n") classlist = self.namemappers[0].getall('class') classlist.sort() for k, v in classlist: self.fp.write("\t%s : %s,\n" % (`k`, v)) self.fp.write("}\n") self.fp.writ...
def dumpindex(self): if not self.fp: return self.fp.write("\n#\n# Indices of types declared in this module\n#\n") self.fp.write("_classdeclarations = {\n") classlist = self.namemappers[0].getall('class') classlist.sort() for k, v in classlist: self.fp.write("\t%s : %s,\n" % (`k`, v)) self.fp.write("}\n") self.fp.writ...
18,933
def test_expat_nsattrs_wattr(): parser = create_parser(1) gather = AttrGatherer() parser.setContentHandler(gather) parser.feed("<doc xmlns:ns='%s' ns:attr='val'/>" % ns_uri) parser.close() attrs = gather._attrs return attrs.getLength() == 1 and \ attrs.getNames() == [(ns_uri, "attr")] and \ attrs.getQNames() == [] a...
def test_expat_nsattrs_wattr(): parser = create_parser(1) gather = AttrGatherer() parser.setContentHandler(gather) parser.feed("<doc xmlns:ns='%s' ns:attr='val'/>" % ns_uri) parser.close() attrs = gather._attrs return attrs.getLength() == 1 and \ attrs.getNames() == [(ns_uri, "attr")] and \ (attrs.getQNames() == [] ...
18,934
def __getattr__(self, attr): # Allow UPPERCASE variants of IMAP4 command methods. if Commands.has_key(attr): return eval("self.%s" % attr.lower()) raise AttributeError("Unknown IMAP4 command: '%s'" % attr)
def __getattr__(self, attr): # Allow UPPERCASE variants of IMAP4 command methods. if Commands.has_key(attr): return getattr(self, attr.lower()) raise AttributeError("Unknown IMAP4 command: '%s'" % attr)
18,935
def __getattr__(self, attr): # Allow UPPERCASE variants of IMAP4 command methods. if Commands.has_key(attr): return eval("self.%s" % attr.lower()) raise AttributeError("Unknown IMAP4 command: '%s'" % attr)
def __getattr__(self, attr): # Allow UPPERCASE variants of IMAP4 command methods. if Commands.has_key(attr): return eval("self.%s" % attr.lower()) raise AttributeError("Unknown IMAP4 command: '%s'" % attr)
18,936
def open(self, host, port): """Setup 'self.sock' and 'self.file'.""" self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.connect((self.host, self.port)) self.file = self.sock.makefile('r')
def open(self, host, port): """Setup connection to remote server on "host:port". This connection will be used by the routines: read, readline, send, shutdown. """ self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.connect((self.host, self.port)) self.file = self.sock.makefile('r')
18,937
def response(self, code): """Return data for response 'code' if received, or None.
def response(self, code): """Return data for response 'code' if received, or None.
18,938
def logout(self): """Shutdown connection to server.
def logout(self): """Shutdown connection to server.
18,939
def search(self, charset, *criteria): """Search mailbox for matching messages.
def search(self, charset, *criteria): """Search mailbox for matching messages.
18,940
def status(self, mailbox, names): """Request named status conditions for mailbox.
def status(self, mailbox, names): """Request named status conditions for mailbox.
18,941
def uid(self, command, *args): """Execute "command arg ..." with messages identified by UID, rather than message number.
def uid(self, command, *args): """Execute "command arg ..." with messages identified by UID, rather than message number.
18,942
def xatom(self, name, *args): """Allow simple extension commands notified by server in CAPABILITY response.
def xatom(self, name, *args): """Allow simple extension commands notified by server in CAPABILITY response.
18,943
def namespace(self): """ Returns IMAP namespaces ala rfc2342 """ name = 'NAMESPACE' typ, dat = self._simple_command(name) return self._untagged_response(typ, dat, name)
def namespace(self): """ Returns IMAP namespaces ala rfc2342 """ name = 'NAMESPACE' typ, dat = self._simple_command(name) return self._untagged_response(typ, dat, name)
18,944
def _command(self, name, *args):
def _command(self, name, *args):
18,945
def _command(self, name, *args):
def _command(self, name, *args):
18,946
def _get_response(self):
def _get_response(self):
18,947
def _get_line(self):
def _get_line(self):
18,948
def print_log(): _mesg('last %d IMAP4 interactions:' % len(_cmd_log)) for secs,line in _cmd_log: _mesg(line, secs)
def print_log(): _mesg('last %d IMAP4 interactions:' % len(_cmd_log)) for secs,line in _cmd_log: _mesg(line, secs)
18,949
def run(cmd, args): _mesg('%s %s' % (cmd, args)) typ, dat = apply(eval('M.%s' % cmd), args) _mesg('%s => %s %s' % (cmd, typ, dat)) return dat
def run(cmd, args): _mesg('%s %s' % (cmd, args)) typ, dat = apply(getattr(M, cmd), args) _mesg('%s => %s %s' % (cmd, typ, dat)) return dat
18,950
def _cnfmerge(cnfs): """Internal function.""" if type(cnfs) is DictionaryType: return cnfs elif type(cnfs) in (NoneType, StringType): return cnfs else: cnf = {} for c in _flatten(cnfs): try: cnf.update(c) except (AttributeError, TypeError), msg: print "_cnfmerge: fallback due to:", msg for k, v in c.items(): cnf[k] = v...
def _cnfmerge(cnfs): """Internal function.""" if type(cnfs) is DictionaryType: return cnfs elif type(cnfs) in (NoneType, StringType): return cnfs else: cnf = {} for c in _flatten(cnfs): try: cnf.update(c) except (AttributeError, TypeError), msg: print "_cnfmerge: fallback due to:", msg for k, v in c.items(): cnf[k] = v...
18,951
def winfo_pointerxy(self): """Return a tupel of x and y coordinates of the pointer on the root window.""" return self._getints( self.tk.call('winfo', 'pointerxy', self._w))
def winfo_pointerxy(self): """Return a tuple of x and y coordinates of the pointer on the root window.""" return self._getints( self.tk.call('winfo', 'pointerxy', self._w))
18,952
def winfo_pointery(self): """Return the y coordinate of the pointer on the root window.""" return getint( self.tk.call('winfo', 'pointery', self._w))
def winfo_pointery(self): """Return the y coordinate of the pointer on the root window.""" return getint( self.tk.call('winfo', 'pointery', self._w))
18,953
def winfo_rgb(self, color): """Return tupel of decimal values for red, green, blue for COLOR in this widget.""" return self._getints( self.tk.call('winfo', 'rgb', self._w, color))
def winfo_rgb(self, color): """Return tuple of decimal values for red, green, blue for COLOR in this widget.""" return self._getints( self.tk.call('winfo', 'rgb', self._w, color))
18,954
def _update(self, iterable): # The main loop for update() and the subclass __init__() methods. data = self._data
def _update(self, iterable): # The main loop for update() and the subclass __init__() methods. data = self._data
18,955
def _update(self, iterable): # The main loop for update() and the subclass __init__() methods. data = self._data
def _update(self, iterable): # The main loop for update() and the subclass __init__() methods. data = self._data
18,956
def _update(self, iterable): # The main loop for update() and the subclass __init__() methods. data = self._data
def _update(self, iterable): # The main loop for update() and the subclass __init__() methods. data = self._data
18,957
def run (self):
def run (self):
18,958
def run (self):
def run (self):
18,959
def get_outputs (self): # This command doesn't have any outputs of its own, so just # get the outputs of all its sub-commands. outputs = [] for (func, cmd) in self.sub_commands: if func is None or func(): outputs.extend (self.run_peer (cmd))
def get_outputs (self): # This command doesn't have any outputs of its own, so just # get the outputs of all its sub-commands. outputs = [] for (func, cmd_name) in self.sub_commands: if func is None or func(): outputs.extend (self.run_peer (cmd))
18,960
def get_outputs (self): # This command doesn't have any outputs of its own, so just # get the outputs of all its sub-commands. outputs = [] for (func, cmd) in self.sub_commands: if func is None or func(): outputs.extend (self.run_peer (cmd))
def get_outputs (self): # This command doesn't have any outputs of its own, so just # get the outputs of all its sub-commands. outputs = [] for (func, cmd) in self.sub_commands: if func is None or func(): outputs.extend (self.run_peer (cmd))
18,961
def _import_hook(self, fqname, globals=None, locals=None, fromlist=None): """Python calls this hook to locate and import a module."""
def _import_hook(self, fqname, globals=None, locals=None, fromlist=None): """Python calls this hook to locate and import a module."""
18,962
def _import_hook(self, fqname, globals=None, locals=None, fromlist=None): """Python calls this hook to locate and import a module."""
def _import_hook(self, fqname, globals=None, locals=None, fromlist=None): """Python calls this hook to locate and import a module."""
18,963
def seek(self, pos, mode = 0): if self.closed: raise ValueError, "I/O operation on closed file" if self.buflist: self.buf = self.buf + string.joinfields(self.buflist, '') self.buflist = [] if mode == 1: pos = pos + self.pos elif mode == 2: pos = pos + self.len self.pos = max(0, pos)
def seek(self, pos, mode = 0): if self.closed: raise ValueError, "I/O operation on closed file" if self.buflist: self.buf += EMPTYSTRING.join(self.buflist) self.buflist = [] if mode == 1: pos = pos + self.pos elif mode == 2: pos = pos + self.len self.pos = max(0, pos)
18,964
def seek(self, pos, mode = 0): if self.closed: raise ValueError, "I/O operation on closed file" if self.buflist: self.buf = self.buf + string.joinfields(self.buflist, '') self.buflist = [] if mode == 1: pos = pos + self.pos elif mode == 2: pos = pos + self.len self.pos = max(0, pos)
def seek(self, pos, mode = 0): if self.closed: raise ValueError, "I/O operation on closed file" if self.buflist: self.buf = self.buf + string.joinfields(self.buflist, '') self.buflist = [] if mode == 1: pos += self.pos elif mode == 2: pos = pos + self.len self.pos = max(0, pos)
18,965
def seek(self, pos, mode = 0): if self.closed: raise ValueError, "I/O operation on closed file" if self.buflist: self.buf = self.buf + string.joinfields(self.buflist, '') self.buflist = [] if mode == 1: pos = pos + self.pos elif mode == 2: pos = pos + self.len self.pos = max(0, pos)
def seek(self, pos, mode = 0): if self.closed: raise ValueError, "I/O operation on closed file" if self.buflist: self.buf = self.buf + string.joinfields(self.buflist, '') self.buflist = [] if mode == 1: pos = pos + self.pos elif mode == 2: pos += self.len self.pos = max(0, pos)
18,966
def read(self, n = -1): if self.closed: raise ValueError, "I/O operation on closed file" if self.buflist: self.buf = self.buf + string.joinfields(self.buflist, '') self.buflist = [] if n < 0: newpos = self.len else: newpos = min(self.pos+n, self.len) r = self.buf[self.pos:newpos] self.pos = newpos return r
def read(self, n = -1): if self.closed: raise ValueError, "I/O operation on closed file" if self.buflist: self.buf += EMPTYSTRING.join(self.buflist) self.buflist = [] if n < 0: newpos = self.len else: newpos = min(self.pos+n, self.len) r = self.buf[self.pos:newpos] self.pos = newpos return r
18,967
def readline(self, length=None): if self.closed: raise ValueError, "I/O operation on closed file" if self.buflist: self.buf = self.buf + string.joinfields(self.buflist, '') self.buflist = [] i = string.find(self.buf, '\n', self.pos) if i < 0: newpos = self.len else: newpos = i+1 if length is not None: if self.pos + len...
def readline(self, length=None): if self.closed: raise ValueError, "I/O operation on closed file" if self.buflist: self.buf += EMPTYSTRING.join(self.buflist) self.buflist = [] i = string.find(self.buf, '\n', self.pos) if i < 0: newpos = self.len else: newpos = i+1 if length is not None: if self.pos + length < newpos: n...
18,968
def readline(self, length=None): if self.closed: raise ValueError, "I/O operation on closed file" if self.buflist: self.buf = self.buf + string.joinfields(self.buflist, '') self.buflist = [] i = string.find(self.buf, '\n', self.pos) if i < 0: newpos = self.len else: newpos = i+1 if length is not None: if self.pos + len...
def readline(self, length=None): if self.closed: raise ValueError, "I/O operation on closed file" if self.buflist: self.buf = self.buf + string.joinfields(self.buflist, '') self.buflist = [] i = self.buf.find('\n', self.pos) if i < 0: newpos = self.len else: newpos = i+1 if length is not None: if self.pos + length < ne...
18,969
def truncate(self, size=None): if self.closed: raise ValueError, "I/O operation on closed file" if size is None: size = self.pos elif size < 0: raise IOError(errno.EINVAL, "Negative size not allowed") elif size < self.pos: self.pos = size self.buf = self.getvalue()[:size]
def truncate(self, size=None): if self.closed: raise ValueError, "I/O operation on closed file" if size is None: size = self.pos elif size < 0: raise IOError(EINVAL, "Negative size not allowed") elif size < self.pos: self.pos = size self.buf = self.getvalue()[:size]
18,970
def write(self, s): if self.closed: raise ValueError, "I/O operation on closed file" if not s: return if self.pos > self.len: self.buflist.append('\0'*(self.pos - self.len)) self.len = self.pos newpos = self.pos + len(s) if self.pos < self.len: if self.buflist: self.buf = self.buf + string.joinfields(self.buflist, '') ...
def write(self, s): if self.closed: raise ValueError, "I/O operation on closed file" if not s: return if self.pos > self.len: self.buflist.append('\0'*(self.pos - self.len)) self.len = self.pos newpos = self.pos + len(s) if self.pos < self.len: if self.buflist: self.buf += EMPTYSTRING.join(self.buflist) self.buflist = ...
18,971
def writelines(self, list): self.write(string.joinfields(list, ''))
def writelines(self, list): self.write(string.joinfields(list, ''))
18,972
def getvalue(self): if self.buflist: self.buf = self.buf + string.joinfields(self.buflist, '') self.buflist = [] return self.buf
def getvalue(self): if self.buflist: self.buf += EMPTYSTRING.join(self.buflist) self.buflist = [] return self.buf
18,973
def triplet_to_pmwrgb(rgbtuple): return map(operator.__div__, rgbtuple, _maxtuple)
def triplet_to_fractional_rgb(rgbtuple): return map(operator.__div__, rgbtuple, _maxtuple)
18,974
def triplet_to_pmwrgb(rgbtuple): return map(operator.__div__, rgbtuple, _maxtuple)
def triplet_to_pmwrgb(rgbtuple): return map(operator.__div__, rgbtuple, _maxtuple)
18,975
def triplet_to_pmwrgb(rgbtuple): return map(operator.__div__, rgbtuple, _maxtuple)
def triplet_to_pmwrgb(rgbtuple): return map(operator.__div__, rgbtuple, _maxtuple)
18,976
def testloop(proto, servers, hdlrcls, testfunc): for svrcls in servers: addr = pickaddr(proto) if verbose: print "ADDR =", addr print "CLASS =", svrcls t = ServerThread(addr, svrcls, hdlrcls) if verbose: print "server created" t.start() if verbose: print "server running" for i in range(NREQ): time.sleep(DELAY) if verbo...
def testloop(proto, servers, hdlrcls, testfunc): for svrcls in servers: addr = pickaddr(proto) if verbose: print "ADDR =", addr print "CLASS =", svrcls t = ServerThread(addr, svrcls, hdlrcls) if verbose: print "server created" t.start() if verbose: print "server running" for i in range(NREQ): time.sleep(DELAY) if verbo...
18,977
def testloop(proto, servers, hdlrcls, testfunc): for svrcls in servers: addr = pickaddr(proto) if verbose: print "ADDR =", addr print "CLASS =", svrcls t = ServerThread(addr, svrcls, hdlrcls) if verbose: print "server created" t.start() if verbose: print "server running" for i in range(NREQ): time.sleep(DELAY) if verbo...
def testloop(proto, servers, hdlrcls, testfunc): for svrcls in servers: addr = pickaddr(proto) if verbose: print "ADDR =", addr print "CLASS =", svrcls t = ServerThread(addr, svrcls, hdlrcls) if verbose: print "server created" t.start() if verbose: print "server running" for i in range(NREQ): time.sleep(DELAY) if verbo...
18,978
def _execvpe(file, args, env=None): if env is not None: func = execve argrest = (args, env) else: func = execv argrest = (args,) env = environ global _notfound head, tail = path.split(file) if head: apply(func, (file,) + argrest) return if env.has_key('PATH'): envpath = env['PATH'] else: envpath = defpath PATH = envpat...
def _execvpe(file, args, env=None): if env is not None: func = execve argrest = (args, env) else: func = execv argrest = (args,) env = environ global _notfound head, tail = path.split(file) if head: apply(func, (file,) + argrest) return if env.has_key('PATH'): envpath = env['PATH'] else: envpath = defpath PATH = envpat...
18,979
def _init_nt(): """Initialize the module as appropriate for NT""" g=globals() # load config.h, though I don't know how useful this is parse_config_h(open( os.path.join(sys.exec_prefix, "include", "config.h")), g) # set basic install directories g['LIBDEST']=os.path.join(sys.exec_prefix, "Lib") g['BINLIBDEST']=os.path.j...
def _init_nt(): """Initialize the module as appropriate for NT""" g=globals() # load config.h, though I don't know how useful this is parse_config_h(open( os.path.join(sys.exec_prefix, "include", "config.h")), g) # set basic install directories g['LIBDEST']=os.path.join(sys.exec_prefix, "Lib") g['BINLIBDEST']= os.path....
18,980
def setUp(self): GettextBaseTest.setUp(self) self.localedir = os.curdir self.mofile = MOFILE gettext.install('gettext', self.localedir)
def setUp(self): GettextBaseTest.setUp(self) self.localedir = os.curdir self.mofile = MOFILE gettext.install('gettext', self.localedir)
18,981
def tearDown(self): GettextBaseTest.tearDown(self)
def tearDown(self): GettextBaseTest.tearDown(self)
18,982
def tearDown(self): GettextBaseTest.tearDown(self)
def tearDown(self): GettextBaseTest.tearDown(self)
18,983
def tearDown(self): GettextBaseTest.tearDown(self)
def tearDown(self): GettextBaseTest.tearDown(self)
18,984
def get_outputs (self): # This command doesn't have any outputs of its own, so just # get the outputs of all its sub-commands. outputs = [] for cmd_name in self.get_sub_commands(): cmd = self.get_finalized_command(cmd_name) # Add the contents of cmd.get_outputs(), ensuring # that outputs doesn't contain duplicate entri...
def get_outputs (self): # This command doesn't have any outputs of its own, so just # get the outputs of all its sub-commands. outputs = [] for cmd_name in self.get_sub_commands(): cmd = self.get_finalized_command(cmd_name) # Add the contents of cmd.get_outputs(), ensuring # that outputs doesn't contain duplicate entri...
18,985
def read(self, size=-1): if self.mode != READ: import errno raise IOError(errno.EBADF, "write() on read-only GzipFile object")
def read(self, size=-1): if self.mode != READ: import errno raise IOError(errno.EBADF, "write() on read-only GzipFile object")
18,986
def run(self): # Copies all .py files, then also copies the txt and gif files build_py.run(self) assert self.packages == [idlelib] for name in txt_files: outfile = self.get_plain_outfile(self.build_lib, [idlelib], name) dir = os.path.dirname(outfile) self.mkpath(dir) self.copy_file(name, outfile, preserve_mode = 0) for...
def run(self): # Copies all .py files, then also copies the txt and gif files build_py.run(self) assert self.packages == [idlelib] for name in txt_files: outfile = self.get_plain_outfile(self.build_lib, [idlelib], name) dir = os.path.dirname(outfile) self.mkpath(dir) self.copy_file(os.path.join(package_dir, name), outf...
18,987
def get_source_files(self): # returns the .py files, the .txt files, and the icons icons = [os.path.join("Icons",name) for name in Icons] return build_py.get_source_files(self)+txt_files+icons
def get_source_files(self): # returns the .py files, the .txt files, and the icons icons = [os.path.join(package_dir, "Icons",name) for name in Icons] txts = [os.path.join(package_dir, name) for name in txt_files] return build_py.get_source_files(self)+txt_files+icons
18,988
def _bytecode_filenames(self, files): files = [n for n in files if n.endswith('.py')] return install_lib._bytecode_filenames(self,files)
def _bytecode_filenames(self, files): files = [n for n in files if n.endswith('.py')] return install_lib._bytecode_filenames(self,files)
18,989
def _bytecode_filenames(self, files): files = [n for n in files if n.endswith('.py')] return install_lib._bytecode_filenames(self,files)
def _bytecode_filenames(self, files): files = [n for n in files if n.endswith('.py')] return install_lib._bytecode_filenames(self,files)
18,990
def leapdays(y1, y2): """Return number of leap years in range [y1, y2). Assume y1 <= y2 and no funny (non-leap century) years.""" return (y2+3)/4 - (y1+3)/4
def leapdays(y1, y2): """Return number of leap years in range [y1, y2). Assume y1 <= y2.""" y1 -= 1 y2 -= 1 return (y2/4 - y1/4) - (y2/100 - y1/100) + (y2/400 - y1/400)
18,991
def __init__(self, name=None, mode="r", fileobj=None): """Open an (uncompressed) tar archive `name'. `mode' is either 'r' to read from an existing archive, 'a' to append data to an existing file or 'w' to create a new file overwriting an existing one. `mode' defaults to 'r'. If `fileobj' is given, it is used for readin...
def __init__(self, name=None, mode="r", fileobj=None): """Open an (uncompressed) tar archive `name'. `mode' is either 'r' to read from an existing archive, 'a' to append data to an existing file or 'w' to create a new file overwriting an existing one. `mode' defaults to 'r'. If `fileobj' is given, it is used for readin...
18,992
def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9): """Open gzip compressed tar archive name for reading or writing. Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": raise ValueError("mode must be 'r' or 'w'")
def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9): """Open gzip compressed tar archive name for reading or writing. Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": raise ValueError("mode must be 'r' or 'w'")
18,993
def add(self, name, arcname=None, recursive=True): """Add the file `name' to the archive. `name' may be any type of file (directory, fifo, symbolic link, etc.). If given, `arcname' specifies an alternative name for the file in the archive. Directories are added recursively by default. This can be avoided by setting `re...
def add(self, name, arcname=None, recursive=True): """Add the file `name' to the archive. `name' may be any type of file (directory, fifo, symbolic link, etc.). If given, `arcname' specifies an alternative name for the file in the archive. Directories are added recursively by default. This can be avoided by setting `re...
18,994
def makefile(self, tarinfo, targetpath): """Make a file called targetpath. """ source = self.extractfile(tarinfo) target = open(targetpath, "wb") copyfileobj(source, target) source.close() target.close()
def makefile(self, tarinfo, targetpath): """Make a file called targetpath. """ source = self.extractfile(tarinfo) target = _open(targetpath, "wb") copyfileobj(source, target) source.close() target.close()
18,995
def test_attr_values_entities(self): """Substitution of entities and charrefs in attribute values""" # SF bug #1452246 self.check_events("""<a b=&lt; c=&lt;&gt; d=&lt-&gt; e='&lt; ' f="&xxx;" g='&#32;&#33;' h='&#500;' i='x?a=b&c=d;'>""", [("starttag", "a", [("b", "<"), ("c", "<>"), ("d", "&lt->"), ("e", "< "), ("f", "&...
def test_attr_values_entities(self): """Substitution of entities and charrefs in attribute values""" # SF bug #1452246 self.check_events("""<a b=&lt; c=&lt;&gt; d=&lt-&gt; e='&lt; ' f="&xxx;" g='&#32;&#33;' h='&#500;' i='x?a=b&c=d;'>""", [("starttag", "a", [("b", "<"), ("c", "<>"), ("d", "&lt->"), ("e", "< "), ("f", "&...
18,996
def test_attr_values_entities(self): """Substitution of entities and charrefs in attribute values""" # SF bug #1452246 self.check_events("""<a b=&lt; c=&lt;&gt; d=&lt-&gt; e='&lt; ' f="&xxx;" g='&#32;&#33;' h='&#500;' i='x?a=b&c=d;'>""", [("starttag", "a", [("b", "<"), ("c", "<>"), ("d", "&lt->"), ("e", "< "), ("f", "&...
def test_attr_values_entities(self): """Substitution of entities and charrefs in attribute values""" # SF bug #1452246 self.check_events("""<a b=&lt; c=&lt;&gt; d=&lt-&gt; e='&lt; ' f="&xxx;" g='&#32;&#33;' h='&#500;' i='x?a=b&c=d;'>""", [("starttag", "a", [("b", "<"), ("c", "<>"), ("d", "&lt->"), ("e", "< "), ("f", "&...
18,997
def d22v(a, b, c=1, d=2, *rest): pass
def d22v(a, b, c=1, d=2, *rest): pass
18,998
def __seqToRE(self, to_convert, directive): """Convert a list to a regex string for matching a directive.
def __seqToRE(self, to_convert, directive): """Convert a list to a regex string for matching a directive.
18,999