bugged
stringlengths 4
228k
| fixed
stringlengths 0
96.3M
| __index_level_0__
int64 0
481k
|
|---|---|---|
def run(self, result=None): if result is None: result = self.defaultTestResult() result.startTest(self) testMethod = getattr(self, self.__testMethodName) try: try: self.setUp() except KeyboardInterrupt: raise except: result.addError(self, self.__exc_info()) return
|
def run(self, result=None): if result is None: result = self.defaultTestResult() result.startTest(self) testMethod = getattr(self, self.__testMethodName) try: try: self.setUp() except KeyboardInterrupt: raise except: result.addError(self, self._exc_info()) return
| 14,700
|
def run(self, result=None): if result is None: result = self.defaultTestResult() result.startTest(self) testMethod = getattr(self, self.__testMethodName) try: try: self.setUp() except KeyboardInterrupt: raise except: result.addError(self, self.__exc_info()) return
|
def run(self, result=None): if result is None: result = self.defaultTestResult() result.startTest(self) testMethod = getattr(self, self.__testMethodName) try: try: self.setUp() except KeyboardInterrupt: raise except: result.addError(self, self.__exc_info()) return
| 14,701
|
def run(self, result=None): if result is None: result = self.defaultTestResult() result.startTest(self) testMethod = getattr(self, self.__testMethodName) try: try: self.setUp() except KeyboardInterrupt: raise except: result.addError(self, self.__exc_info()) return
|
def run(self, result=None): if result is None: result = self.defaultTestResult() result.startTest(self) testMethod = getattr(self, self.__testMethodName) try: try: self.setUp() except KeyboardInterrupt: raise except: result.addError(self, self._exc_info()) return
| 14,702
|
def run(self, result=None): if result is None: result = self.defaultTestResult() result.startTest(self) testMethod = getattr(self, self.__testMethodName) try: try: self.setUp() except KeyboardInterrupt: raise except: result.addError(self, self.__exc_info()) return
|
def run(self, result=None): if result is None: result = self.defaultTestResult() result.startTest(self) testMethod = getattr(self, self.__testMethodName) try: try: self.setUp() except KeyboardInterrupt: raise except: result.addError(self, self._exc_info()) return
| 14,703
|
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()
| 14,704
|
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, excvalue, tb)
|
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, excvalue, tb)
| 14,705
|
def _read_eof(self): # We've read to the end of the file, so we have to rewind in order # to reread the 8 bytes containing the CRC and the file size. # We check the that the computed CRC and size of the # uncompressed data matches the stored values. Note that the size # stored is the true file size mod 2**32. self.fileobj.seek(-8, 1) crc32 = read32(self.fileobj) isize = U32(read32(self.fileobj)) # may exceed 2GB if U32(crc32) != U32(self.crc): raise ValueError, "CRC check failed" elif isize != LOWU32(self.size): raise ValueError, "Incorrect length of data produced"
|
def _read_eof(self): # We've read to the end of the file, so we have to rewind in order # to reread the 8 bytes containing the CRC and the file size. # We check the that the computed CRC and size of the # uncompressed data matches the stored values. Note that the size # stored is the true file size mod 2**32. self.fileobj.seek(-8, 1) crc32 = read32(self.fileobj) isize = U32(read32(self.fileobj)) # may exceed 2GB if U32(crc32) != U32(self.crc): raise IOError, "CRC check failed" elif isize != LOWU32(self.size): raise ValueError, "Incorrect length of data produced"
| 14,706
|
def _read_eof(self): # We've read to the end of the file, so we have to rewind in order # to reread the 8 bytes containing the CRC and the file size. # We check the that the computed CRC and size of the # uncompressed data matches the stored values. Note that the size # stored is the true file size mod 2**32. self.fileobj.seek(-8, 1) crc32 = read32(self.fileobj) isize = U32(read32(self.fileobj)) # may exceed 2GB if U32(crc32) != U32(self.crc): raise ValueError, "CRC check failed" elif isize != LOWU32(self.size): raise ValueError, "Incorrect length of data produced"
|
def _read_eof(self): # We've read to the end of the file, so we have to rewind in order # to reread the 8 bytes containing the CRC and the file size. # We check the that the computed CRC and size of the # uncompressed data matches the stored values. Note that the size # stored is the true file size mod 2**32. self.fileobj.seek(-8, 1) crc32 = read32(self.fileobj) isize = U32(read32(self.fileobj)) # may exceed 2GB if U32(crc32) != U32(self.crc): raise ValueError, "CRC check failed" elif isize != LOWU32(self.size): raise ValueError, "Incorrect length of data produced"
| 14,707
|
def get_token(self): "Get a token from the input stream (or from stack if it's monempty)" if self.pushback: tok = self.pushback[0] self.pushback = self.pushback[1:] if (self.debug >= 1): print "Popping " + tok return tok tok = '' while 1: nextchar = self.instream.read(1); if nextchar == '\n': self.lineno = self.lineno + 1 if self.debug >= 3: print "In state " + repr(self.state) + " I see character: " + repr(nextchar) if self.state == None: return '' elif self.state == ' ': if not nextchar: self.state = None; # end of file break elif nextchar in self.whitespace: if self.debug >= 2: print "I see whitespace in whitespace state" if self.token: break # emit current token else: continue elif nextchar in self.commenters: self.instream.readline() self.lineno = self.lineno + 1 elif nextchar in self.wordchars: self.token = nextchar self.state = 'a' elif nextchar in self.quotes: self.token = nextchar self.state = nextchar else: self.token = nextchar if self.token: break # emit current token else: continue elif self.state in self.quotes: self.token = self.token + nextchar if nextchar == self.state: self.state = ' ' break elif self.state == 'a': if not nextchar: self.state = None; # end of file break elif nextchar in self.whitespace: if self.debug >= 2: print "I see whitespace in word state" self.state = ' ' if self.token: break # emit current token else: continue elif nextchar in self.commenters: self.instream.readline() self.lineno = self.lineno + 1 elif nextchar in self.wordchars or nextchar in self.quotes: self.token = self.token + nextchar else: self.pushback = [nextchar] + self.pushback if self.debug >= 2: print "I see punctuation in word state" state = ' ' if self.token: break # emit current token else: continue result = self.token self.token = '' if self.debug >= 1: print "Token: " + result return result
|
def get_token(self): "Get a token from the input stream (or from stack if it's monempty)" if self.pushback: tok = self.pushback[0] self.pushback = self.pushback[1:] if (self.debug >= 1): print "Popping " + tok return tok tok = '' while 1: nextchar = self.instream.read(1); if nextchar == '\n': self.lineno = self.lineno + 1 if self.debug >= 3: print "In state " + repr(self.state) + " I see character: " + repr(nextchar) if self.state == None: return '' elif self.state == ' ': if not nextchar: self.state = None; # end of file break elif nextchar in self.whitespace: if self.debug >= 2: print "I see whitespace in whitespace state" if self.token: break # emit current token else: continue elif nextchar in self.commenters: self.instream.readline() self.lineno = self.lineno + 1 elif nextchar in self.wordchars: self.token = nextchar self.state = 'a' elif nextchar in self.quotes: self.token = nextchar self.state = nextchar else: self.token = nextchar if self.token: break # emit current token else: continue elif self.state in self.quotes: self.token = self.token + nextchar if nextchar == self.state: self.self.state = ' ' break elif self.state == 'a': if not nextchar: self.state = None; # end of file break elif nextchar in self.whitespace: if self.debug >= 2: print "I see whitespace in word state" self.self.state = ' ' if self.token: break # emit current token else: continue elif nextchar in self.commenters: self.instream.readline() self.lineno = self.lineno + 1 elif nextchar in self.wordchars or nextchar in self.quotes: self.token = self.token + nextchar else: self.pushback = [nextchar] + self.pushback if self.debug >= 2: print "I see punctuation in word state" self.state = ' ' if self.token: break # emit current token else: continue result = self.token self.token = '' if self.debug >= 1: print "Token: " + result return result
| 14,708
|
def _send_request(self, method, url, body, headers): # If headers already contains a host header, then define the # optional skip_host argument to putrequest(). The check is # harder because field names are case insensitive. if 'Host' in (headers or [k for k in headers.iterkeys() if k.lower() == "host"]): self.putrequest(method, url, skip_host=1) else: self.putrequest(method, url)
|
def _send_request(self, method, url, body, headers): # If headers already contains a host header, then define the # optional skip_host argument to putrequest(). The check is # harder because field names are case insensitive. if 'host' in [k.lower() for k in headers]: self.putrequest(method, url, skip_host=1) else: self.putrequest(method, url)
| 14,709
|
def scriptswalk(self, top, menu, done=None): if done is None: done = {} if done.has_key(top): return done[top] = 1 import os, string try: names = os.listdir(top) except os.error: FrameWork.MenuItem(menu, '(Scripts Folder not found)', None, None) return savedir = os.getcwd() os.chdir(top) for name in names: if name == "CVS": continue try: fsr, isdir, isalias = File.FSResolveAliasFile(name, 1) except: # maybe a broken alias continue path = fsr.as_pathname() if done.has_key(path): continue name = string.strip(name) if os.name == "posix": name = unicode(name, "utf-8") if name[-3:] == '---': menu.addseparator() elif isdir: submenu = FrameWork.SubMenu(menu, name) self.scriptswalk(path, submenu, done) else: creator, type = MacOS.GetCreatorAndType(path) if type == 'TEXT': if name[-3:] == '.py': name = name[:-3] item = FrameWork.MenuItem(menu, name, None, self.domenu_script) self._scripts[(menu.id, item.item)] = path done[path] = 1 os.chdir(savedir)
|
def scriptswalk(self, top, menu, done=None): if done is None: done = {} if done.has_key(top): return True done[top] = 1 import os, string try: names = os.listdir(top) except os.error: FrameWork.MenuItem(menu, '(Scripts Folder not found)', None, None) return True savedir = os.getcwd() os.chdir(top) for name in names: if name == "CVS": continue try: fsr, isdir, isalias = File.FSResolveAliasFile(name, 1) except: # maybe a broken alias continue path = fsr.as_pathname() if done.has_key(path): continue name = string.strip(name) if os.name == "posix": name = unicode(name, "utf-8") if name[-3:] == '---': menu.addseparator() elif isdir: submenu = FrameWork.SubMenu(menu, name) self.scriptswalk(path, submenu, done) else: creator, type = MacOS.GetCreatorAndType(path) if type == 'TEXT': if name[-3:] == '.py': name = name[:-3] item = FrameWork.MenuItem(menu, name, None, self.domenu_script) self._scripts[(menu.id, item.item)] = path done[path] = 1 os.chdir(savedir)
| 14,710
|
def scriptswalk(self, top, menu, done=None): if done is None: done = {} if done.has_key(top): return done[top] = 1 import os, string try: names = os.listdir(top) except os.error: FrameWork.MenuItem(menu, '(Scripts Folder not found)', None, None) return savedir = os.getcwd() os.chdir(top) for name in names: if name == "CVS": continue try: fsr, isdir, isalias = File.FSResolveAliasFile(name, 1) except: # maybe a broken alias continue path = fsr.as_pathname() if done.has_key(path): continue name = string.strip(name) if os.name == "posix": name = unicode(name, "utf-8") if name[-3:] == '---': menu.addseparator() elif isdir: submenu = FrameWork.SubMenu(menu, name) self.scriptswalk(path, submenu, done) else: creator, type = MacOS.GetCreatorAndType(path) if type == 'TEXT': if name[-3:] == '.py': name = name[:-3] item = FrameWork.MenuItem(menu, name, None, self.domenu_script) self._scripts[(menu.id, item.item)] = path done[path] = 1 os.chdir(savedir)
|
def scriptswalk(self, top, menu, done=None): if done is None: done = {} if done.has_key(top): return True done[top] = 1 import os, string try: names = os.listdir(top) except os.error: FrameWork.MenuItem(menu, '(Scripts Folder not found)', None, None) return True savedir = os.getcwd() os.chdir(top) for name in names: if name == "CVS": continue try: fsr, isdir, isalias = File.FSResolveAliasFile(name, 1) except: # maybe a broken alias continue path = fsr.as_pathname() if done.has_key(path): continue name = string.strip(name) if os.name == "posix": name = unicode(name, "utf-8") if name[-3:] == '---': menu.addseparator() elif isdir: submenu = FrameWork.SubMenu(menu, name) self.scriptswalk(path, submenu, done) else: creator, type = MacOS.GetCreatorAndType(path) if type == 'TEXT': if name[-3:] == '.py': name = name[:-3] item = FrameWork.MenuItem(menu, name, None, self.domenu_script) self._scripts[(menu.id, item.item)] = path done[path] = 1 os.chdir(savedir)
| 14,711
|
def scriptswalk(self, top, menu, done=None): if done is None: done = {} if done.has_key(top): return done[top] = 1 import os, string try: names = os.listdir(top) except os.error: FrameWork.MenuItem(menu, '(Scripts Folder not found)', None, None) return savedir = os.getcwd() os.chdir(top) for name in names: if name == "CVS": continue try: fsr, isdir, isalias = File.FSResolveAliasFile(name, 1) except: # maybe a broken alias continue path = fsr.as_pathname() if done.has_key(path): continue name = string.strip(name) if os.name == "posix": name = unicode(name, "utf-8") if name[-3:] == '---': menu.addseparator() elif isdir: submenu = FrameWork.SubMenu(menu, name) self.scriptswalk(path, submenu, done) else: creator, type = MacOS.GetCreatorAndType(path) if type == 'TEXT': if name[-3:] == '.py': name = name[:-3] item = FrameWork.MenuItem(menu, name, None, self.domenu_script) self._scripts[(menu.id, item.item)] = path done[path] = 1 os.chdir(savedir)
|
def scriptswalk(self, top, menu, done=None): if done is None: done = {} if done.has_key(top): return done[top] = 1 import os, string try: names = os.listdir(top) except os.error: FrameWork.MenuItem(menu, '(Scripts Folder not found)', None, None) return savedir = os.getcwd() os.chdir(top) for name in names: if name == "CVS": continue try: fsr, isdir, isalias = File.FSResolveAliasFile(name, 1) except: # maybe a broken alias continue path = fsr.as_pathname() if done.has_key(path): continue name = string.strip(name) if os.name == "posix": name = unicode(name, "utf-8") if name[-3:] == '---': menu.addseparator() elif isdir: submenu = FrameWork.SubMenu(menu, name) if not self.scriptswalk(path, submenu, done): return False else: creator, type = MacOS.GetCreatorAndType(path) if type == 'TEXT': if name[-3:] == '.py': name = name[:-3] item = FrameWork.MenuItem(menu, name, None, self.domenu_script) self._scripts[(menu.id, item.item)] = path done[path] = 1 os.chdir(savedir)
| 14,712
|
def smtp_RCPT(self, arg): print >> DEBUGSTREAM, '===> RCPT', arg if not self.__mailfrom: self.push('503 Error: need MAIL command') return address = self.__getaddr('TO:', arg) if not address: self.push('501 Syntax: RCPT TO: <address>') return if address.lower().startswith('stimpy'): self.push('503 You suck %s' % address) return self.__rcpttos.append(address) print >> DEBUGSTREAM, 'recips:', self.__rcpttos self.push('250 Ok')
|
def smtp_RCPT(self, arg): print >> DEBUGSTREAM, '===> RCPT', arg if not self.__mailfrom: self.push('503 Error: need MAIL command') return address = self.__getaddr('TO:', arg) if not address: self.push('501 Syntax: RCPT TO: <address>') return self.__rcpttos.append(address) print >> DEBUGSTREAM, 'recips:', self.__rcpttos self.push('250 Ok')
| 14,713
|
def __getattr__(self, attr): return getattr(self, self.err)
|
def __getattr__(self, attr): return getattr(self, self.err)
| 14,714
|
def writedocs(dir, pkgpath='', done=None): """Write out HTML documentation for all modules in a directory tree.""" if done is None: done = {} for file in os.listdir(dir): path = os.path.join(dir, file) if ispackage(path): writedocs(path, pkgpath + file + '.', done) elif os.path.isfile(path): modname = inspect.getmodulename(path) if modname: if modname == '__init__': modname = pkgpath[:-1] # remove trailing period else: modname = pkgpath + modname if modname not in done: done[modname] = 1 writedoc(modname)
|
def writedocs(dir, pkgpath='', done=None): """Write out HTML documentation for all modules in a directory tree.""" if done is None: done = {} for file in os.listdir(dir): path = os.path.join(dir, file) if ispackage(path): writedocs(path, pkgpath + file + '.', done) elif os.path.isfile(path): modname = inspect.getmodulename(path) if modname: if modname == '__init__': modname = pkgpath[:-1] # remove trailing period else: modname = pkgpath + modname if modname not in done: done[modname] = 1 writedoc(modname)
| 14,715
|
'METHODS': ('lib/typesmethods', 'class def CLASSES TYPES'),
|
'METHODS': ('lib/typesmethods', 'class def CLASSES TYPES'),
| 14,716
|
'METHODS': ('lib/typesmethods', 'class def CLASSES TYPES'),
|
'METHODS': ('lib/typesmethods', 'class def CLASSES TYPES'),
| 14,717
|
def copytree(src, dst, symlinks=0): """Recursively copy a directory tree using copy2(). The destination directory must not already exist. Error are reported to standard output. If the optional symlinks flag is true, symbolic links in the source tree result in symbolic links in the destination tree; if it is false, the contents of the files pointed to by symbolic links are copied. XXX Consider this example code rather than the ultimate tool. """ names = os.listdir(src) os.mkdir(dst) for name in names: srcname = os.path.join(src, name) dstname = os.path.join(dst, name) try: if symlinks and os.path.islink(srcname): linkto = os.readlink(srcname) os.symlink(linkto, dstname) elif os.path.isdir(srcname): copytree(srcname, dstname, symlinks) else: copy2(srcname, dstname) # XXX What about devices, sockets etc.? except (IOError, os.error), why: print "Can't copy %s to %s: %s" % (`srcname`, `dstname`, str(why))
|
def copytree(src, dst, symlinks=0): """Recursively copy a directory tree using copy2(). The destination directory must not already exist. Error are reported to standard output. If the optional symlinks flag is true, symbolic links in the source tree result in symbolic links in the destination tree; if it is false, the contents of the files pointed to by symbolic links are copied. XXX Consider this example code rather than the ultimate tool. """ names = os.listdir(src) os.mkdir(dst) for name in names: srcname = os.path.join(src, name) dstname = os.path.join(dst, name) try: if symlinks and os.path.islink(srcname): linkto = os.readlink(srcname) os.symlink(linkto, dstname) elif os.path.isdir(srcname): copytree(srcname, dstname, symlinks) else: copy2(srcname, dstname) # XXX What about devices, sockets etc.? except (IOError, os.error), why: errors.append((srcname, dstname, why)) if errors: raise Error, errors
| 14,718
|
def build_extensions (self):
|
defmacros=macros, build_extensionsmacros=macros, (self):
| 14,719
|
def main(): try: opts, args = getopt.getopt(sys.argv[1:], 'm:qv') except getopt.error, msg: sys.stdout = sys.stderr print msg print __doc__%vars(webchecker) sys.exit(2) for o, a in opts: if o == '-m': webchecker.maxpage = string.atoi(a) if o == '-q': webchecker.verbose = 0 if o == '-v': webchecker.verbose = webchecker.verbose + 1 root = Tk(className='Webchecker') root.protocol("WM_DELETE_WINDOW", root.quit) c = CheckerWindow(root) if args: for arg in args[:-1]: c.addroot(arg) c.suggestroot(args[-1]) root.mainloop()
|
def main(): try: opts, args = getopt.getopt(sys.argv[1:], 't:m:qva') except getopt.error, msg: sys.stdout = sys.stderr print msg print __doc__%vars(webchecker) sys.exit(2) for o, a in opts: if o == '-m': webchecker.maxpage = string.atoi(a) if o == '-q': webchecker.verbose = 0 if o == '-v': webchecker.verbose = webchecker.verbose + 1 root = Tk(className='Webchecker') root.protocol("WM_DELETE_WINDOW", root.quit) c = CheckerWindow(root) if args: for arg in args[:-1]: c.addroot(arg) c.suggestroot(args[-1]) root.mainloop()
| 14,720
|
def __init__(self, parent, root=webchecker.DEFROOT): self.__parent = parent
|
def __init__(self, parent, root=webchecker.DEFROOT): self.__parent = parent
| 14,721
|
def dosomething(self): if self.__busy: return self.__busy = 1 if self.todo: l = self.__todo.selectedindices() if l: i = l[0] else: i = 0 self.__todo.list.select_set(i) self.__todo.list.yview(i) url = self.__todo.items[i] self.__checking.config(text="Checking "+url) self.__parent.update() self.dopage(url) else: self.stop() self.__busy = 0 self.go()
|
def dosomething(self): if self.__busy: return self.__busy = 1 if self.todo: l = self.__todo.selectedindices() if l: i = l[0] else: i = 0 self.__todo.list.select_set(i) self.__todo.list.yview(i) url = self.__todo.items[i] self.__checking.config(text="Checking "+self.format_url(url)) self.__parent.update() self.dopage(url) else: self.stop() self.__busy = 0 self.go()
| 14,722
|
def showinfo(self, url): d = self.__details d.clear() d.put("URL: %s\n" % url) if self.bad.has_key(url): d.put("Error: %s\n" % str(self.bad[url])) if url in self.roots: d.put("Note: This is a root URL\n") if self.done.has_key(url): d.put("Status: checked\n") o = self.done[url] elif self.todo.has_key(url): d.put("Status: to check\n") o = self.todo[url] else: d.put("Status: unknown (!)\n") o = [] if self.errors.has_key(url): d.put("Bad links from this page:\n") for triple in self.errors[url]: link, rawlink, msg = triple d.put(" HREF %s" % link) if link != rawlink: d.put(" (%s)" %rawlink) d.put("\n") d.put(" error %s\n" % str(msg)) self.__mp.showpanel("Details") for source, rawlink in o: d.put("Origin: %s" % source) if rawlink != url: d.put(" (%s)" % rawlink) d.put("\n") d.text.yview("1.0")
|
def showinfo(self, url): d = self.__details d.clear() d.put("URL: %s\n" % self.format_url(url)) if self.bad.has_key(url): d.put("Error: %s\n" % str(self.bad[url])) if url in self.roots: d.put("Note: This is a root URL\n") if self.done.has_key(url): d.put("Status: checked\n") o = self.done[url] elif self.todo.has_key(url): d.put("Status: to check\n") o = self.todo[url] else: d.put("Status: unknown (!)\n") o = [] if self.errors.has_key(url): d.put("Bad links from this page:\n") for triple in self.errors[url]: link, rawlink, msg = triple d.put(" HREF %s" % link) if link != rawlink: d.put(" (%s)" %rawlink) d.put("\n") d.put(" error %s\n" % str(msg)) self.__mp.showpanel("Details") for source, rawlink in o: d.put("Origin: %s" % source) if rawlink != url: d.put(" (%s)" % rawlink) d.put("\n") d.text.yview("1.0")
| 14,723
|
def showinfo(self, url): d = self.__details d.clear() d.put("URL: %s\n" % url) if self.bad.has_key(url): d.put("Error: %s\n" % str(self.bad[url])) if url in self.roots: d.put("Note: This is a root URL\n") if self.done.has_key(url): d.put("Status: checked\n") o = self.done[url] elif self.todo.has_key(url): d.put("Status: to check\n") o = self.todo[url] else: d.put("Status: unknown (!)\n") o = [] if self.errors.has_key(url): d.put("Bad links from this page:\n") for triple in self.errors[url]: link, rawlink, msg = triple d.put(" HREF %s" % link) if link != rawlink: d.put(" (%s)" %rawlink) d.put("\n") d.put(" error %s\n" % str(msg)) self.__mp.showpanel("Details") for source, rawlink in o: d.put("Origin: %s" % source) if rawlink != url: d.put(" (%s)" % rawlink) d.put("\n") d.text.yview("1.0")
|
def showinfo(self, url): d = self.__details d.clear() d.put("URL: %s\n" % url) if self.bad.has_key(url): d.put("Error: %s\n" % str(self.bad[url])) if url in self.roots: d.put("Note: This is a root URL\n") if self.done.has_key(url): d.put("Status: checked\n") o = self.done[url] elif self.todo.has_key(url): d.put("Status: to check\n") o = self.todo[url] else: d.put("Status: unknown (!)\n") o = [] if (not url[1]) and self.errors.has_key(url[0]): d.put("Bad links from this page:\n") for triple in self.errors[url]: link, rawlink, msg = triple d.put(" HREF %s" % link) if link != rawlink: d.put(" (%s)" %rawlink) d.put("\n") d.put(" error %s\n" % str(msg)) self.__mp.showpanel("Details") for source, rawlink in o: d.put("Origin: %s" % source) if rawlink != url: d.put(" (%s)" % rawlink) d.put("\n") d.text.yview("1.0")
| 14,724
|
def showinfo(self, url): d = self.__details d.clear() d.put("URL: %s\n" % url) if self.bad.has_key(url): d.put("Error: %s\n" % str(self.bad[url])) if url in self.roots: d.put("Note: This is a root URL\n") if self.done.has_key(url): d.put("Status: checked\n") o = self.done[url] elif self.todo.has_key(url): d.put("Status: to check\n") o = self.todo[url] else: d.put("Status: unknown (!)\n") o = [] if self.errors.has_key(url): d.put("Bad links from this page:\n") for triple in self.errors[url]: link, rawlink, msg = triple d.put(" HREF %s" % link) if link != rawlink: d.put(" (%s)" %rawlink) d.put("\n") d.put(" error %s\n" % str(msg)) self.__mp.showpanel("Details") for source, rawlink in o: d.put("Origin: %s" % source) if rawlink != url: d.put(" (%s)" % rawlink) d.put("\n") d.text.yview("1.0")
|
def showinfo(self, url): d = self.__details d.clear() d.put("URL: %s\n" % url) if self.bad.has_key(url): d.put("Error: %s\n" % str(self.bad[url])) if url in self.roots: d.put("Note: This is a root URL\n") if self.done.has_key(url): d.put("Status: checked\n") o = self.done[url] elif self.todo.has_key(url): d.put("Status: to check\n") o = self.todo[url] else: d.put("Status: unknown (!)\n") o = [] if self.errors.has_key(url): d.put("Bad links from this page:\n") for triple in self.errors[url[0]]: link, rawlink, msg = triple d.put(" HREF %s" % link) if link != rawlink: d.put(" (%s)" %rawlink) d.put("\n") d.put(" error %s\n" % str(msg)) self.__mp.showpanel("Details") for source, rawlink in o: d.put("Origin: %s" % source) if rawlink != url: d.put(" (%s)" % rawlink) d.put("\n") d.text.yview("1.0")
| 14,725
|
def showinfo(self, url): d = self.__details d.clear() d.put("URL: %s\n" % url) if self.bad.has_key(url): d.put("Error: %s\n" % str(self.bad[url])) if url in self.roots: d.put("Note: This is a root URL\n") if self.done.has_key(url): d.put("Status: checked\n") o = self.done[url] elif self.todo.has_key(url): d.put("Status: to check\n") o = self.todo[url] else: d.put("Status: unknown (!)\n") o = [] if self.errors.has_key(url): d.put("Bad links from this page:\n") for triple in self.errors[url]: link, rawlink, msg = triple d.put(" HREF %s" % link) if link != rawlink: d.put(" (%s)" %rawlink) d.put("\n") d.put(" error %s\n" % str(msg)) self.__mp.showpanel("Details") for source, rawlink in o: d.put("Origin: %s" % source) if rawlink != url: d.put(" (%s)" % rawlink) d.put("\n") d.text.yview("1.0")
|
def showinfo(self, url): d = self.__details d.clear() d.put("URL: %s\n" % url) if self.bad.has_key(url): d.put("Error: %s\n" % str(self.bad[url])) if url in self.roots: d.put("Note: This is a root URL\n") if self.done.has_key(url): d.put("Status: checked\n") o = self.done[url] elif self.todo.has_key(url): d.put("Status: to check\n") o = self.todo[url] else: d.put("Status: unknown (!)\n") o = [] if self.errors.has_key(url): d.put("Bad links from this page:\n") for triple in self.errors[url]: link, rawlink, msg = triple d.put(" HREF %s" % self.format_url(link)) if self.format_url(link) != rawlink: d.put(" (%s)" %rawlink) d.put("\n") d.put(" error %s\n" % str(msg)) self.__mp.showpanel("Details") for source, rawlink in o: d.put("Origin: %s" % source) if rawlink != url: d.put(" (%s)" % rawlink) d.put("\n") d.text.yview("1.0")
| 14,726
|
def showinfo(self, url): d = self.__details d.clear() d.put("URL: %s\n" % url) if self.bad.has_key(url): d.put("Error: %s\n" % str(self.bad[url])) if url in self.roots: d.put("Note: This is a root URL\n") if self.done.has_key(url): d.put("Status: checked\n") o = self.done[url] elif self.todo.has_key(url): d.put("Status: to check\n") o = self.todo[url] else: d.put("Status: unknown (!)\n") o = [] if self.errors.has_key(url): d.put("Bad links from this page:\n") for triple in self.errors[url]: link, rawlink, msg = triple d.put(" HREF %s" % link) if link != rawlink: d.put(" (%s)" %rawlink) d.put("\n") d.put(" error %s\n" % str(msg)) self.__mp.showpanel("Details") for source, rawlink in o: d.put("Origin: %s" % source) if rawlink != url: d.put(" (%s)" % rawlink) d.put("\n") d.text.yview("1.0")
|
def showinfo(self, url): d = self.__details d.clear() d.put("URL: %s\n" % url) if self.bad.has_key(url): d.put("Error: %s\n" % str(self.bad[url])) if url in self.roots: d.put("Note: This is a root URL\n") if self.done.has_key(url): d.put("Status: checked\n") o = self.done[url] elif self.todo.has_key(url): d.put("Status: to check\n") o = self.todo[url] else: d.put("Status: unknown (!)\n") o = [] if self.errors.has_key(url): d.put("Bad links from this page:\n") for triple in self.errors[url]: link, rawlink, msg = triple d.put(" HREF %s" % link) if link != rawlink: d.put(" (%s)" %rawlink) d.put("\n") d.put(" error %s\n" % str(msg)) self.__mp.showpanel("Details") for source, rawlink in o: d.put("Origin: %s" % source) if rawlink != self.format_url(url): d.put(" (%s)" % rawlink) d.put("\n") d.text.yview("1.0")
| 14,727
|
def seterror(self, url, triple): webchecker.Checker.seterror(self, url, triple) self.__errors.insert(url) self.newstatus()
|
def seterror(self, url, triple): webchecker.Checker.seterror(self, url, triple) self.__errors.insert((url, '')) self.newstatus()
| 14,728
|
def __init__(self, mp, name, showinfo=None): self.mp = mp self.name = name self.showinfo = showinfo self.panel = mp.addpanel(name) self.list, self.frame = tktools.make_list_box( self.panel, width=60, height=5) self.list.config(exportselection=0) if showinfo: self.list.bind('<Double-Button-1>', self.doubleclick) self.items = []
|
def __init__(self, mp, name, checker, showinfo=None): self.mp = mp self.name = name self.showinfo = showinfo self.panel = mp.addpanel(name) self.list, self.frame = tktools.make_list_box( self.panel, width=60, height=5) self.list.config(exportselection=0) if showinfo: self.list.bind('<Double-Button-1>', self.doubleclick) self.items = []
| 14,729
|
def doubleclick(self, event): l = self.selectedindices() if l: self.showinfo(self.list.get(l[0]))
|
def doubleclick(self, event): l = self.selectedindices() if l: self.showinfo(self.list.get(l[0]))
| 14,730
|
def insert(self, url): if url not in self.items: if not self.items: self.mp.showpanel(self.name) # (I tried sorting alphabetically, but the display is too jumpy) i = len(self.items) self.list.insert(i, url) self.list.yview(i) self.items.insert(i, url)
|
def insert(self, url): if url not in self.items: if not self.items: self.mp.showpanel(self.name) # (I tried sorting alphabetically, but the display is too jumpy) i = len(self.items) self.list.insert(i, self.checker.format_url(url)) self.list.yview(i) self.items.insert(i, url)
| 14,731
|
def onecmd(self, line): """Interpret the argument as though it had been typed in response to the prompt.
|
def onecmd(self, line): """Interpret the argument as though it had been typed in response to the prompt.
| 14,732
|
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module.
|
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module.
| 14,733
|
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module.
|
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module.
| 14,734
|
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module.
|
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module.
| 14,735
|
def initialize(self): self.__paths = [] if os.environ.has_key("MSSdk") and self.find_exe("cl.exe"): # Assume that the SDK set up everything alright; don't try to be # smarter self.cc = "cl.exe" self.linker = "link.exe" self.lib = "lib.exe" self.rc = "rc.exe" self.mc = "mc.exe" else: self.__paths = self.get_msvc_paths("path")
|
def initialize(self): self.__paths = [] if os.environ.has_key("DISTUTILS_USE_SDK") and os.environ.has_key("MSSdk") and self.find_exe("cl.exe"): # Assume that the SDK set up everything alright; don't try to be # smarter self.cc = "cl.exe" self.linker = "link.exe" self.lib = "lib.exe" self.rc = "rc.exe" self.mc = "mc.exe" else: self.__paths = self.get_msvc_paths("path")
| 14,736
|
def link_shared_lib (self, objects, output_libname, libraries=None, library_dirs=None): # XXX should we sanity check the library name? (eg. no # slashes) self.link_shared_object (objects, "lib%s%s" % (output_libname, SO))
|
def link_shared_lib (self, objects, output_libname, libraries=None, library_dirs=None, build_info=None): # XXX should we sanity check the library name? (eg. no # slashes) self.link_shared_object (objects, "lib%s%s" % (output_libname, SO))
| 14,737
|
def link_shared_lib (self, objects, output_libname, libraries=None, library_dirs=None): # XXX should we sanity check the library name? (eg. no # slashes) self.link_shared_object (objects, "lib%s%s" % (output_libname, SO))
|
def link_shared_lib (self, objects, output_libname, libraries=None, library_dirs=None): # XXX should we sanity check the library name? (eg. no # slashes) self.link_shared_object (objects, "lib%s%s" % (output_libname, SO))
| 14,738
|
def link_shared_object (self, objects, output_filename, libraries=None, library_dirs=None):
|
def link_shared_object (self, objects, output_filename, libraries=None, library_dirs=None):
| 14,739
|
def link_shared_object (self, objects, output_filename, libraries=None, library_dirs=None):
|
defif build_info is None: build_info = {} link_shared_objectif build_info is None: build_info = {} (self,if build_info is None: build_info = {} objects,if build_info is None: build_info = {} output_filename,if build_info is None: build_info = {} libraries=None,if build_info is None: build_info = {} library_dirs=None):
| 14,740
|
def object_filenames (self, source_filenames): outnames = [] for inname in source_filenames: outnames.append (re.sub (r'\.(c|C|cc|cxx)$', '.o', inname)) return outnames
|
def object_filenames (self, source_filenames): outnames = [] for inname in source_filenames: outnames.append ( re.sub (r'\.(c|C|cc|cxx|cpp)$', self._obj_ext, inname)) return outnames
| 14,741
|
def shared_object_filename (self, source_filename): return re.sub (r'\.(c|C|cc|cxx)$', SO)
|
def shared_object_filename (self, source_filename): return re.sub (r'\.(c|C|cc|cxx)$', SO)
| 14,742
|
def library_filename (self, libname): return "lib%s.a" % libname
|
def library_filename (self, libname): return "lib%s.a" % libname
| 14,743
|
def shared_library_filename (self, libname): return "lib%s.so" % libname
|
def shared_library_filename (self, libname): return "lib%s.so" % libname
| 14,744
|
def open(self, url, new=0, autoraise=1): cmdline = [self.name] + [arg.replace("%s", url) for arg in self.args] try: p = subprocess.Popen(cmdline, close_fds=True) return not p.wait() except OSError: return False
|
def open(self, url, new=0, autoraise=1): cmdline = [self.name] + [arg.replace("%s", url) for arg in self.args] try: if sys.platform[:3] == 'win': p = subprocess.Popen(cmdline) else: p = subprocess.Popen(cmdline, close_fds=True) return not p.wait() except OSError: return False
| 14,745
|
def open(self, url, new=0, autoraise=1): cmdline = [self.name] + [arg.replace("%s", url) for arg in self.args] setsid = getattr(os, 'setsid', None) if not setsid: setsid = getattr(os, 'setpgrp', None) try: p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid) return (p.poll() is None) except OSError: return False
|
def open(self, url, new=0, autoraise=1): cmdline = [self.name] + [arg.replace("%s", url) for arg in self.args] try: p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid) return (p.poll() is None) except OSError: return False
| 14,746
|
def open(self, url, new=0, autoraise=1): cmdline = [self.name] + [arg.replace("%s", url) for arg in self.args] setsid = getattr(os, 'setsid', None) if not setsid: setsid = getattr(os, 'setpgrp', None) try: p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid) return (p.poll() is None) except OSError: return False
|
def open(self, url, new=0, autoraise=1): cmdline = [self.name] + [arg.replace("%s", url) for arg in self.args] setsid = getattr(os, 'setsid', None) if not setsid: setsid = getattr(os, 'setpgrp', None) try: if sys.platform[:3] == 'win': p = subprocess.Popen(cmdline) else: setsid = getattr(os, 'setsid', None) if not setsid: setsid = getattr(os, 'setpgrp', None) p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid) return (p.poll() is None) except OSError: return False
| 14,747
|
def reset(self): """ Clear the screen, re-center the pen, and set variables to the default values.
|
def reset(self): """ Clear the screen, re-center the pen, and set variables to the default values.
| 14,748
|
def fill(self, flag): """ Call fill(1) before drawing the shape you want to fill, and fill(0) when done.
|
def fill(self, flag): """ Call fill(1) before drawing the shape you want to fill, and fill(0) when done.
| 14,749
|
def fill(self, flag): """ Call fill(1) before drawing the shape you want to fill, and fill(0) when done.
|
def fill(self, flag): """ Call fill(1) before drawing the shape you want to fill, and fill(0) when done.
| 14,750
|
def fill(self, flag): """ Call fill(1) before drawing the shape you want to fill, and fill(0) when done.
|
def fill(self, flag): """ Call fill(1) before drawing the shape you want to fill, and fill(0) when done.
| 14,751
|
def begin_fill(self): """ Called just before drawing a shape to be filled.
|
def begin_fill(self): """ Called just before drawing a shape to be filled.
| 14,752
|
def demo2(): # exercises some new and improved features speed('fast') width(3) # draw a segmented half-circle setheading(towards(0,0)) x,y = position() r = (x**2+y**2)**.5/2.0 right(90) pendown = True for i in range(18): if pendown: up() pendown = False else: down() pendown = True circle(r,10) sleep(2) reset() left(90) # draw a series of triangles l = 10 color("green") width(3) left(180) sp = 5 for i in range(-2,16): if i > 0: color(1.0-0.05*i,0,0.05*i) fill(1) color("green") for j in range(3): forward(l) left(120) l += 10 left(15) if sp > 0: sp = sp-1 speed(speeds[sp]) color(0.25,0,0.75) fill(0) color("green") left(130) up() forward(90) color("red") speed('fastest') down(); # create a second turtle and make the original pursue and catch it turtle=Turtle() turtle.reset() turtle.left(90) turtle.speed('normal') turtle.up() turtle.goto(280,40) turtle.left(24) turtle.down() turtle.speed('fast') turtle.color("blue") turtle.width(2) speed('fastest') # turn default turtle towards new turtle object setheading(towards(turtle)) while ( abs(position()[0]-turtle.position()[0])>4 or abs(position()[1]-turtle.position()[1])>4): turtle.forward(3.5) turtle.left(0.6) # turn default turtle towards new turtle object setheading(towards(turtle)) forward(4) write("CAUGHT! ", move=True)
|
def demo2(): # exercises some new and improved features speed('fast') width(3) # draw a segmented half-circle setheading(towards(0,0)) x,y = position() r = (x**2+y**2)**.5/2.0 right(90) pendown = True for i in range(18): if pendown: up() pendown = False else: down() pendown = True circle(r,10) sleep(2) reset() left(90) # draw a series of triangles l = 10 color("green") width(3) left(180) sp = 5 for i in range(-2,16): if i > 0: color(1.0-0.05*i,0,0.05*i) fill(1) color("green") for j in range(3): forward(l) left(120) l += 10 left(15) if sp > 0: sp = sp-1 speed(speeds[sp]) color(0.25,0,0.75) fill(0) left(120) up() forward(90) color("red") speed('fastest') down(); # create a second turtle and make the original pursue and catch it turtle=Turtle() turtle.reset() turtle.left(90) turtle.speed('normal') turtle.up() turtle.goto(280,40) turtle.left(24) turtle.down() turtle.speed('fast') turtle.color("blue") turtle.width(2) speed('fastest') # turn default turtle towards new turtle object setheading(towards(turtle)) while ( abs(position()[0]-turtle.position()[0])>4 or abs(position()[1]-turtle.position()[1])>4): turtle.forward(3.5) turtle.left(0.6) # turn default turtle towards new turtle object setheading(towards(turtle)) forward(4) write("CAUGHT! ", move=True)
| 14,753
|
def demo2(): # exercises some new and improved features speed('fast') width(3) # draw a segmented half-circle setheading(towards(0,0)) x,y = position() r = (x**2+y**2)**.5/2.0 right(90) pendown = True for i in range(18): if pendown: up() pendown = False else: down() pendown = True circle(r,10) sleep(2) reset() left(90) # draw a series of triangles l = 10 color("green") width(3) left(180) sp = 5 for i in range(-2,16): if i > 0: color(1.0-0.05*i,0,0.05*i) fill(1) color("green") for j in range(3): forward(l) left(120) l += 10 left(15) if sp > 0: sp = sp-1 speed(speeds[sp]) color(0.25,0,0.75) fill(0) color("green") left(130) up() forward(90) color("red") speed('fastest') down(); # create a second turtle and make the original pursue and catch it turtle=Turtle() turtle.reset() turtle.left(90) turtle.speed('normal') turtle.up() turtle.goto(280,40) turtle.left(24) turtle.down() turtle.speed('fast') turtle.color("blue") turtle.width(2) speed('fastest') # turn default turtle towards new turtle object setheading(towards(turtle)) while ( abs(position()[0]-turtle.position()[0])>4 or abs(position()[1]-turtle.position()[1])>4): turtle.forward(3.5) turtle.left(0.6) # turn default turtle towards new turtle object setheading(towards(turtle)) forward(4) write("CAUGHT! ", move=True)
|
def demo2(): # exercises some new and improved features speed('fast') width(3) # draw a segmented half-circle setheading(towards(0,0)) x,y = position() r = (x**2+y**2)**.5/2.0 right(90) pendown = True for i in range(18): if pendown: up() pendown = False else: down() pendown = True circle(r,10) sleep(2) reset() left(90) # draw a series of triangles l = 10 color("green") width(3) left(180) sp = 5 for i in range(-2,16): if i > 0: color(1.0-0.05*i,0,0.05*i) fill(1) color("green") for j in range(3): forward(l) left(120) l += 10 left(15) if sp > 0: sp = sp-1 speed(speeds[sp]) color(0.25,0,0.75) fill(0) color("green") left(130) up() forward(70) right(30) down() color("red") speed('fastest') down(); # create a second turtle and make the original pursue and catch it turtle=Turtle() turtle.reset() turtle.left(90) turtle.speed('normal') turtle.up() turtle.goto(280,40) turtle.left(24) turtle.down() turtle.speed('fast') turtle.color("blue") turtle.width(2) speed('fastest') # turn default turtle towards new turtle object setheading(towards(turtle)) while ( abs(position()[0]-turtle.position()[0])>4 or abs(position()[1]-turtle.position()[1])>4): turtle.forward(3.5) turtle.left(0.6) # turn default turtle towards new turtle object setheading(towards(turtle)) forward(4) write("CAUGHT! ", move=True)
| 14,754
|
def demo2(): # exercises some new and improved features speed('fast') width(3) # draw a segmented half-circle setheading(towards(0,0)) x,y = position() r = (x**2+y**2)**.5/2.0 right(90) pendown = True for i in range(18): if pendown: up() pendown = False else: down() pendown = True circle(r,10) sleep(2) reset() left(90) # draw a series of triangles l = 10 color("green") width(3) left(180) sp = 5 for i in range(-2,16): if i > 0: color(1.0-0.05*i,0,0.05*i) fill(1) color("green") for j in range(3): forward(l) left(120) l += 10 left(15) if sp > 0: sp = sp-1 speed(speeds[sp]) color(0.25,0,0.75) fill(0) color("green") left(130) up() forward(90) color("red") speed('fastest') down(); # create a second turtle and make the original pursue and catch it turtle=Turtle() turtle.reset() turtle.left(90) turtle.speed('normal') turtle.up() turtle.goto(280,40) turtle.left(24) turtle.down() turtle.speed('fast') turtle.color("blue") turtle.width(2) speed('fastest') # turn default turtle towards new turtle object setheading(towards(turtle)) while ( abs(position()[0]-turtle.position()[0])>4 or abs(position()[1]-turtle.position()[1])>4): turtle.forward(3.5) turtle.left(0.6) # turn default turtle towards new turtle object setheading(towards(turtle)) forward(4) write("CAUGHT! ", move=True)
|
def demo2(): # exercises some new and improved features speed('fast') width(3) # draw a segmented half-circle setheading(towards(0,0)) x,y = position() r = (x**2+y**2)**.5/2.0 right(90) pendown = True for i in range(18): if pendown: up() pendown = False else: down() pendown = True circle(r,10) sleep(2) reset() left(90) # draw a series of triangles l = 10 color("green") width(3) left(180) sp = 5 for i in range(-2,16): if i > 0: color(1.0-0.05*i,0,0.05*i) fill(1) color("green") for j in range(3): forward(l) left(120) l += 10 left(15) if sp > 0: sp = sp-1 speed(speeds[sp]) color(0.25,0,0.75) fill(0) color("green") left(130) up() forward(90) color("red") speed("fastest") fill(1) for i in range(4): circle(50,90) right(90) forward(30) right(90) color("yellow") fill(0) left(90) up() forward(30) down(); # create a second turtle and make the original pursue and catch it turtle=Turtle() turtle.reset() turtle.left(90) turtle.speed('normal') turtle.up() turtle.goto(280,40) turtle.left(24) turtle.down() turtle.speed('fast') turtle.color("blue") turtle.width(2) speed("fastest") fill(1) for i in range(4): circle(50,90) right(90) forward(30) right(90) color("yellow") fill(0) left(90) up() forward(30) # turn default turtle towards new turtle object setheading(towards(turtle)) while ( abs(position()[0]-turtle.position()[0])>4 or abs(position()[1]-turtle.position()[1])>4): turtle.forward(3.5) turtle.left(0.6) # turn default turtle towards new turtle object setheading(towards(turtle)) forward(4) write("CAUGHT! ", move=True)
| 14,755
|
def formatException(self, ei): """ Format and return the specified exception information as a string.
|
def formatException(self, ei): """ Format and return the specified exception information as a string.
| 14,756
|
def handleError(self, record): """ Handle errors which occur during an emit() call.
|
def handleError(self, record): """ Handle errors which occur during an emit() call.
| 14,757
|
def __init__(self, filename, mode="a"): """ Open the specified file and use it as the stream for logging. """ StreamHandler.__init__(self, open(filename, mode)) #keep the absolute path, otherwise derived classes which use this #may come a cropper when the current directory changes self.baseFilename = os.path.abspath(filename) self.mode = mode
|
def __init__(self, filename, mode='a', encoding=None): """ Open the specified file and use it as the stream for logging. """ StreamHandler.__init__(self, open(filename, mode)) #keep the absolute path, otherwise derived classes which use this #may come a cropper when the current directory changes self.baseFilename = os.path.abspath(filename) self.mode = mode
| 14,758
|
def __init__(self, filename, mode="a"): """ Open the specified file and use it as the stream for logging. """ StreamHandler.__init__(self, open(filename, mode)) #keep the absolute path, otherwise derived classes which use this #may come a cropper when the current directory changes self.baseFilename = os.path.abspath(filename) self.mode = mode
|
def __init__(self, filename, mode="a"): """ Open the specified file and use it as the stream for logging. """ if codecs is None: encoding = None if encoding is None: stream = open(filename, mode) else: stream = codecs.open(filename, mode, encoding) StreamHandler.__init__(self, stream) #keep the absolute path, otherwise derived classes which use this #may come a cropper when the current directory changes self.baseFilename = os.path.abspath(filename) self.mode = mode
| 14,759
|
def basicConfig(**kwargs): """ Do basic configuration for the logging system. This function does nothing if the root logger already has handlers configured. It is a convenience method intended for use by simple scripts to do one-shot configuration of the logging package. The default behaviour is to create a StreamHandler which writes to sys.stderr, set a formatter using the BASIC_FORMAT format string, and add the handler to the root logger. A number of optional keyword arguments may be specified, which can alter the default behaviour. filename Specifies that a FileHandler be created, using the specified filename, rather than a StreamHandler. filemode Specifies the mode to open the file, if filename is specified (if filemode is unspecified, it defaults to "a"). format Use the specified format string for the handler. datefmt Use the specified date/time format. level Set the root logger level to the specified level. stream Use the specified stream to initialize the StreamHandler. Note that this argument is incompatible with 'filename' - if both are present, 'stream' is ignored. Note that you could specify a stream created using open(filename, mode) rather than passing the filename and mode in. However, it should be remembered that StreamHandler does not close its stream (since it may be using sys.stdout or sys.stderr), whereas FileHandler closes its stream when the handler is closed. """ if len(root.handlers) == 0: filename = kwargs.get("filename") if filename: mode = kwargs.get("filemode", "a") hdlr = FileHandler(filename, mode) else: stream = kwargs.get("stream") hdlr = StreamHandler(stream) fs = kwargs.get("format", BASIC_FORMAT) dfs = kwargs.get("datefmt", None) fmt = Formatter(fs, dfs) hdlr.setFormatter(fmt) root.addHandler(hdlr) level = kwargs.get("level") if level: root.setLevel(level)
|
def basicConfig(**kwargs): """ Do basic configuration for the logging system. This function does nothing if the root logger already has handlers configured. It is a convenience method intended for use by simple scripts to do one-shot configuration of the logging package. The default behaviour is to create a StreamHandler which writes to sys.stderr, set a formatter using the BASIC_FORMAT format string, and add the handler to the root logger. A number of optional keyword arguments may be specified, which can alter the default behaviour. filename Specifies that a FileHandler be created, using the specified filename, rather than a StreamHandler. filemode Specifies the mode to open the file, if filename is specified (if filemode is unspecified, it defaults to 'a'). format Use the specified format string for the handler. datefmt Use the specified date/time format. level Set the root logger level to the specified level. stream Use the specified stream to initialize the StreamHandler. Note that this argument is incompatible with 'filename' - if both are present, 'stream' is ignored. Note that you could specify a stream created using open(filename, mode) rather than passing the filename and mode in. However, it should be remembered that StreamHandler does not close its stream (since it may be using sys.stdout or sys.stderr), whereas FileHandler closes its stream when the handler is closed. """ if len(root.handlers) == 0: filename = kwargs.get("filename") if filename: mode = kwargs.get("filemode", "a") hdlr = FileHandler(filename, mode) else: stream = kwargs.get("stream") hdlr = StreamHandler(stream) fs = kwargs.get("format", BASIC_FORMAT) dfs = kwargs.get("datefmt", None) fmt = Formatter(fs, dfs) hdlr.setFormatter(fmt) root.addHandler(hdlr) level = kwargs.get("level") if level: root.setLevel(level)
| 14,760
|
def basicConfig(**kwargs): """ Do basic configuration for the logging system. This function does nothing if the root logger already has handlers configured. It is a convenience method intended for use by simple scripts to do one-shot configuration of the logging package. The default behaviour is to create a StreamHandler which writes to sys.stderr, set a formatter using the BASIC_FORMAT format string, and add the handler to the root logger. A number of optional keyword arguments may be specified, which can alter the default behaviour. filename Specifies that a FileHandler be created, using the specified filename, rather than a StreamHandler. filemode Specifies the mode to open the file, if filename is specified (if filemode is unspecified, it defaults to "a"). format Use the specified format string for the handler. datefmt Use the specified date/time format. level Set the root logger level to the specified level. stream Use the specified stream to initialize the StreamHandler. Note that this argument is incompatible with 'filename' - if both are present, 'stream' is ignored. Note that you could specify a stream created using open(filename, mode) rather than passing the filename and mode in. However, it should be remembered that StreamHandler does not close its stream (since it may be using sys.stdout or sys.stderr), whereas FileHandler closes its stream when the handler is closed. """ if len(root.handlers) == 0: filename = kwargs.get("filename") if filename: mode = kwargs.get("filemode", "a") hdlr = FileHandler(filename, mode) else: stream = kwargs.get("stream") hdlr = StreamHandler(stream) fs = kwargs.get("format", BASIC_FORMAT) dfs = kwargs.get("datefmt", None) fmt = Formatter(fs, dfs) hdlr.setFormatter(fmt) root.addHandler(hdlr) level = kwargs.get("level") if level: root.setLevel(level)
|
def basicConfig(**kwargs): """ Do basic configuration for the logging system. This function does nothing if the root logger already has handlers configured. It is a convenience method intended for use by simple scripts to do one-shot configuration of the logging package. The default behaviour is to create a StreamHandler which writes to sys.stderr, set a formatter using the BASIC_FORMAT format string, and add the handler to the root logger. A number of optional keyword arguments may be specified, which can alter the default behaviour. filename Specifies that a FileHandler be created, using the specified filename, rather than a StreamHandler. filemode Specifies the mode to open the file, if filename is specified (if filemode is unspecified, it defaults to "a"). format Use the specified format string for the handler. datefmt Use the specified date/time format. level Set the root logger level to the specified level. stream Use the specified stream to initialize the StreamHandler. Note that this argument is incompatible with 'filename' - if both are present, 'stream' is ignored. Note that you could specify a stream created using open(filename, mode) rather than passing the filename and mode in. However, it should be remembered that StreamHandler does not close its stream (since it may be using sys.stdout or sys.stderr), whereas FileHandler closes its stream when the handler is closed. """ if len(root.handlers) == 0: filename = kwargs.get("filename") if filename: mode = kwargs.get("filemode", 'a') hdlr = FileHandler(filename, mode) else: stream = kwargs.get("stream") hdlr = StreamHandler(stream) fs = kwargs.get("format", BASIC_FORMAT) dfs = kwargs.get("datefmt", None) fmt = Formatter(fs, dfs) hdlr.setFormatter(fmt) root.addHandler(hdlr) level = kwargs.get("level") if level: root.setLevel(level)
| 14,761
|
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) outputs.extend(cmd.get_outputs())
|
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) outputs.extend(cmd.get_outputs())
| 14,762
|
def testAttributes(self): # test that exception attributes are happy
|
def testAttributes(self): # test that exception attributes are happy
| 14,763
|
def testAttributes(self): # test that exception attributes are happy
|
def testAttributes(self): # test that exception attributes are happy
| 14,764
|
def testAttributes(self): # test that exception attributes are happy
|
def testAttributes(self): # test that exception attributes are happy
| 14,765
|
def __init__(self, filenames=()): if not inited: init() self.encodings_map = encodings_map.copy() self.suffix_map = suffix_map.copy() self.types_map = types_map.copy() self.common_types = common_types.copy() for name in filenames: self.read(name)
|
def __init__(self, filenames=(), strict=True): if not inited: init() self.encodings_map = encodings_map.copy() self.suffix_map = suffix_map.copy() self.types_map = types_map.copy() self.common_types = common_types.copy() for name in filenames: self.read(name)
| 14,766
|
def __init__(self, filenames=()): if not inited: init() self.encodings_map = encodings_map.copy() self.suffix_map = suffix_map.copy() self.types_map = types_map.copy() self.common_types = common_types.copy() for name in filenames: self.read(name)
|
def __init__(self, filenames=()): if not inited: init() self.encodings_map = encodings_map.copy() self.suffix_map = suffix_map.copy() self.types_map = ({}, {}) self.types_map_inv = ({}, {}) for (ext, type) in types_map.items(): self.add_type(type, ext, True) for (ext, type) in common_types.items(): self.add_type(type, ext, False) for name in filenames: self.read(name)
| 14,767
|
def __init__(self, filenames=()): if not inited: init() self.encodings_map = encodings_map.copy() self.suffix_map = suffix_map.copy() self.types_map = types_map.copy() self.common_types = common_types.copy() for name in filenames: self.read(name)
|
def __init__(self, filenames=()): if not inited: init() self.encodings_map = encodings_map.copy() self.suffix_map = suffix_map.copy() self.types_map = types_map.copy() self.common_types = common_types.copy() for name in filenames: self.read(name)
| 14,768
|
def guess_type(self, url, strict=1): """Guess the type of a file based on its URL.
|
def guess_type(self, url, strict=1): """Guess the type of a file based on its URL.
| 14,769
|
def guess_type(self, url, strict=1): """Guess the type of a file based on its URL.
|
def guess_type(self, url, strict=1): """Guess the type of a file based on its URL.
| 14,770
|
def guess_type(self, url, strict=1): """Guess the type of a file based on its URL.
|
def guess_type(self, url, strict=1): """Guess the type of a file based on its URL.
| 14,771
|
def guess_extension(self, type, strict=1): """Guess the extension for a file based on its MIME type.
|
def guess_all_extensions(self, type, strict=True): """Guess the extensions for a file based on its MIME type. Return value is a list of strings giving the possible filename extensions, including the leading dot ('.'). The extension is not guaranteed to have been associated with any particular data stream, but would be mapped to the MIME type `type' by guess_type(). If no extension can be guessed for `type', None is returned. Optional `strict' argument when false adds a bunch of commonly found, but non-standard types. """ type = type.lower() extensions = self.types_map_inv[True].get(type, []) if not strict: for ext in self.types_map_inv[False].get(type, []): if ext not in extensions: extensions.append(ext) if len(extensions): return extensions def guess_extension(self, type, strict=True): """Guess the extension for a file based on its MIME type.
| 14,772
|
def guess_extension(self, type, strict=1): """Guess the extension for a file based on its MIME type.
|
def guess_extension(self, type, strict=1): """Guess the extension for a file based on its MIME type.
| 14,773
|
def readfp(self, fp): """Read a single mime.types-format file.""" map = self.types_map while 1: line = fp.readline() if not line: break words = line.split() for i in range(len(words)): if words[i][0] == '#': del words[i:] break if not words: continue type, suffixes = words[0], words[1:] for suff in suffixes: map['.' + suff] = type
|
def readfp(self, fp, strict=True): """ Read a single mime.types-format file. If strict is true, information will be added to list of standard types, else to the list of non-standard types. """ while 1: line = fp.readline() if not line: break words = line.split() for i in range(len(words)): if words[i][0] == '#': del words[i:] break if not words: continue type, suffixes = words[0], words[1:] for suff in suffixes: map['.' + suff] = type
| 14,774
|
def readfp(self, fp): """Read a single mime.types-format file.""" map = self.types_map while 1: line = fp.readline() if not line: break words = line.split() for i in range(len(words)): if words[i][0] == '#': del words[i:] break if not words: continue type, suffixes = words[0], words[1:] for suff in suffixes: map['.' + suff] = type
|
def readfp(self, fp): """Read a single mime.types-format file.""" map = self.types_map while 1: line = fp.readline() if not line: break words = line.split() for i in range(len(words)): if words[i][0] == '#': del words[i:] break if not words: continue type, suffixes = words[0], words[1:] for suff in suffixes: map['.' + suff] = type
| 14,775
|
def guess_extension(type, strict=1): """Guess the extension for a file based on its MIME type. Return value is a string giving a filename extension, including the leading dot ('.'). The extension is not guaranteed to have been associated with any particular data stream, but would be mapped to the MIME type `type' by guess_type(). If no extension can be guessed for `type', None is returned. Optional `strict' argument when false adds a bunch of commonly found, but non-standard types. """ init() return guess_extension(type, strict)
|
def guess_all_extensions(type, strict=True): """Guess the extensions for a file based on its MIME type. Return value is a list of strings giving the possible filename extensions, including the leading dot ('.'). The extension is not guaranteed to have been associated with any particular data stream, but would be mapped to the MIME type `type' by guess_type(). If no extension can be guessed for `type', None is returned. Optional `strict' argument when false adds a bunch of commonly found, but non-standard types. """ init() return guess_all_extensions(type, strict) def guess_extension(type, strict=True): """Guess the extension for a file based on its MIME type. Return value is a string giving a filename extension, including the leading dot ('.'). The extension is not guaranteed to have been associated with any particular data stream, but would be mapped to the MIME type `type' by guess_type(). If no extension can be guessed for `type', None is returned. Optional `strict' argument when false adds a bunch of commonly found, but non-standard types. """ init() return guess_extension(type, strict)
| 14,776
|
def init(files=None): global guess_extension, guess_type global suffix_map, types_map, encodings_map, common_types global inited inited = 1 db = MimeTypes() if files is None: files = knownfiles for file in files: if os.path.isfile(file): db.readfp(open(file)) encodings_map = db.encodings_map suffix_map = db.suffix_map types_map = db.types_map guess_extension = db.guess_extension guess_type = db.guess_type common_types = db.common_types
|
def init(files=None): global guess_all_extensions, guess_extension, guess_type global suffix_map, types_map, encodings_map, common_types global inited inited = 1 db = MimeTypes() if files is None: files = knownfiles for file in files: if os.path.isfile(file): db.readfp(open(file)) encodings_map = db.encodings_map suffix_map = db.suffix_map types_map = db.types_map guess_extension = db.guess_extension guess_type = db.guess_type common_types = db.common_types
| 14,777
|
def init(files=None): global guess_extension, guess_type global suffix_map, types_map, encodings_map, common_types global inited inited = 1 db = MimeTypes() if files is None: files = knownfiles for file in files: if os.path.isfile(file): db.readfp(open(file)) encodings_map = db.encodings_map suffix_map = db.suffix_map types_map = db.types_map guess_extension = db.guess_extension guess_type = db.guess_type common_types = db.common_types
|
def init(files=None): global guess_extension, guess_type global suffix_map, types_map, encodings_map, common_types global add_type, inited inited = True db = MimeTypes() if files is None: files = knownfiles for file in files: if os.path.isfile(file): db.readfp(open(file)) encodings_map = db.encodings_map suffix_map = db.suffix_map types_map = db.types_map guess_extension = db.guess_extension guess_type = db.guess_type common_types = db.common_types
| 14,778
|
def init(files=None): global guess_extension, guess_type global suffix_map, types_map, encodings_map, common_types global inited inited = 1 db = MimeTypes() if files is None: files = knownfiles for file in files: if os.path.isfile(file): db.readfp(open(file)) encodings_map = db.encodings_map suffix_map = db.suffix_map types_map = db.types_map guess_extension = db.guess_extension guess_type = db.guess_type common_types = db.common_types
|
def init(files=None): global guess_extension, guess_type global suffix_map, types_map, encodings_map, common_types global inited inited = 1 db = MimeTypes() if files is None: files = knownfiles for file in files: if os.path.isfile(file): db.readfp(open(file)) encodings_map = db.encodings_map suffix_map = db.suffix_map types_map = db.types_map[True] guess_all_extensions = db.guess_all_extensions guess_extension = db.guess_extension guess_type = db.guess_type common_types = db.common_types
| 14,779
|
def init(files=None): global guess_extension, guess_type global suffix_map, types_map, encodings_map, common_types global inited inited = 1 db = MimeTypes() if files is None: files = knownfiles for file in files: if os.path.isfile(file): db.readfp(open(file)) encodings_map = db.encodings_map suffix_map = db.suffix_map types_map = db.types_map guess_extension = db.guess_extension guess_type = db.guess_type common_types = db.common_types
|
def init(files=None): global guess_extension, guess_type global suffix_map, types_map, encodings_map, common_types global inited inited = 1 db = MimeTypes() if files is None: files = knownfiles for file in files: if os.path.isfile(file): db.readfp(open(file)) encodings_map = db.encodings_map suffix_map = db.suffix_map types_map = db.types_map guess_extension = db.guess_extension guess_type = db.guess_type add_type = db.add_type common_types = db.types_map[False]
| 14,780
|
def spilldata(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: base = self.docother(getattr(object, name), name, mod) doc = getattr(value, "__doc__", None) if doc is None: push('<dl><dt>%s</dl>\n' % base) else: doc = self.markup(getdoc(value), self.preformat, funcs, classes, mdict) doc = '<dd><tt>%s</tt>' % doc push('<dl><dt>%s%s</dl>\n' % (base, doc)) push('\n') return attrs
|
def spilldata(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: base = self.docother(getattr(object, name), name, mod) if callable(value): doc = getattr(value, "__doc__", None) else: doc = None if doc is None: push('<dl><dt>%s</dl>\n' % base) else: doc = self.markup(getdoc(value), self.preformat, funcs, classes, mdict) doc = '<dd><tt>%s</tt>' % doc push('<dl><dt>%s%s</dl>\n' % (base, doc)) push('\n') return attrs
| 14,781
|
def spilldata(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: doc = getattr(value, "__doc__", None) push(self.docother(getattr(object, name), name, mod, 70, doc) + '\n') return attrs
|
def spilldata(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: if callable(value): doc = getattr(value, "__doc__", None) else: doc = None push(self.docother(getattr(object, name), name, mod, 70, doc) + '\n') return attrs
| 14,782
|
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1)
|
def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1)
| 14,783
|
def __repr__(self): return ( "<Fault %s: %s>" % (self.faultCode, repr(self.faultString)) )
|
def __repr__(self): return ( "<Fault %s: %s>" % (self.faultCode, repr(self.faultString)) )
| 14,784
|
def _binary(data): # decode xml element contents into a Binary structure value = Binary() value.decode(data) return value
|
def _binary(data): # decode xml element contents into a Binary structure value = Binary() value.decode(data) return value
| 14,785
|
def unpack(self, archive, output=None): tf = tarfile.open(archive, "r") members = tf.getmembers() skip = [] if self._renames: for member in members: for oldprefix, newprefix in self._renames: if oldprefix[:len(self._dir)] == self._dir: oldprefix2 = oldprefix[len(self._dir):] else: oldprefix2 = None if member.name[:len(oldprefix)] == oldprefix: if newprefix is None: skip.append(member) #print 'SKIP', member.name else: member.name = newprefix + member.name[len(oldprefix):] print ' ', member.name break elif oldprefix2 and member.name[:len(oldprefix2)] == oldprefix2: if newprefix is None: skip.append(member) #print 'SKIP', member.name else: member.name = newprefix + member.name[len(oldprefix2):] #print ' ', member.name break else: skip.append(member) #print '????', member.name for member in members: if member in skip: continue tf.extract(member, self._dir) if skip: names = [member.name for member in skip if member.name[-1] != '/'] if names: return "Not all files were unpacked: %s" % " ".join(names)
|
def unpack(self, archive, output=None): tf = tarfile.open(archive, "r") members = tf.getmembers() skip = [] if self._renames: for member in members: for oldprefix, newprefix in self._renames: if oldprefix[:len(self._dir)] == self._dir: oldprefix2 = oldprefix[len(self._dir):] else: oldprefix2 = None if member.name[:len(oldprefix)] == oldprefix: if newprefix is None: skip.append(member) #print 'SKIP', member.name else: member.name = newprefix + member.name[len(oldprefix):] print ' ', member.name break elif oldprefix2 and member.name[:len(oldprefix2)] == oldprefix2: if newprefix is None: skip.append(member) #print 'SKIP', member.name else: member.name = newprefix + member.name[len(oldprefix2):] #print ' ', member.name break else: skip.append(member) #print '????', member.name for member in members: if member in skip: continue tf.extract(member, self._dir) if skip: names = [member.name for member in skip if member.name[-1] != '/'] if names: return "Not all files were unpacked: %s" % " ".join(names)
| 14,786
|
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().replace('-','_'), '%define release ' + self.release.replace('-','_'), '', 'Summary: ' + self.distribution.get_description(), ]
|
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().replace('-','_'), '%define release ' + self.release.replace('-','_'), '', 'Summary: ' + self.distribution.get_description(), ]
| 14,787
|
def closeststack(self, card):
|
def closeststack(self, card):
| 14,788
|
def reset(self):
|
def reset(self):
| 14,789
|
def parseargs(): global DEBUGSTREAM try: opts, args = getopt.getopt( sys.argv[1:], 'nVhc:d', ['class=', 'nosetuid', 'version', 'help', 'debug']) except getopt.error, e: usage(1, e) options = Options() for opt, arg in opts: if opt in ('-h', '--help'): usage(0) elif opt in ('-V', '--version'): print >> sys.stderr, __version__ sys.exit(0) elif opt in ('-n', '--nosetuid'): options.setuid = 0 elif opt in ('-c', '--class'): options.classname = arg elif opt in ('-d', '--debug'): DEBUGSTREAM = sys.stderr # parse the rest of the arguments if len(args) < 1: localspec = 'localhost:8025' remotespec = 'localhost:25' elif len(args) < 2: localspec = args[0] remotespec = 'localhost:25' elif len(args) < 3: localspec = args[0] remotespec = args[1] else: usage(1, 'Invalid arguments: %s' % COMMASPACE.join(args)) # split into host/port pairs i = localspec.find(':') if i < 0: usage(1, 'Bad local spec: %s' % localspec) options.localhost = localspec[:i] try: options.localport = int(localspec[i+1:]) except ValueError: usage(1, 'Bad local port: %s' % localspec) i = remotespec.find(':') if i < 0: usage(1, 'Bad remote spec: %s' % remotespec) options.remotehost = remotespec[:i] try: options.remoteport = int(remotespec[i+1:]) except ValueError: usage(1, 'Bad remote port: %s' % remotespec) return options
|
def parseargs(): global DEBUGSTREAM try: opts, args = getopt.getopt( sys.argv[1:], 'nVhc:d', ['class=', 'nosetuid', 'version', 'help', 'debug']) except getopt.error, e: usage(1, e) options = Options() for opt, arg in opts: if opt in ('-h', '--help'): usage(0) elif opt in ('-V', '--version'): print >> sys.stderr, __version__ sys.exit(0) elif opt in ('-n', '--nosetuid'): options.setuid = 0 elif opt in ('-c', '--class'): options.classname = arg elif opt in ('-d', '--debug'): DEBUGSTREAM = sys.stderr # parse the rest of the arguments if len(args) < 1: localspec = 'localhost:8025' remotespec = 'localhost:25' elif len(args) < 2: localspec = args[0] remotespec = 'localhost:25' elif len(args) < 3: localspec = args[0] remotespec = args[1] else: usage(1, 'Invalid arguments: %s' % COMMASPACE.join(args)) # split into host/port pairs i = localspec.find(':') if i < 0: usage(1, 'Bad local spec: %s' % localspec) options.localhost = localspec[:i] try: options.localport = int(localspec[i+1:]) except ValueError: usage(1, 'Bad local port: %s' % localspec) i = remotespec.find(':') if i < 0: usage(1, 'Bad remote spec: %s' % remotespec) options.remotehost = remotespec[:i] try: options.remoteport = int(remotespec[i+1:]) except ValueError: usage(1, 'Bad remote port: %s' % remotespec) return options
| 14,790
|
def select(e, mods, vars, mod, skipofiles): files = [] for w in mods[mod]: w = treatword(w) if not w: continue w = expandvars(w, vars) for w in string.split(w): if skipofiles and w[-2:] == '.o': continue if w[0] != '-' and w[-2:] in ('.o', '.a'): w = os.path.join(e, w) if w[:2] in ('-L', '-R'): w = w[:2] + os.path.join(e, w[2:]) files.append(w) return files
|
def select(e, mods, vars, mod, skipofiles): files = [] for w in mods[mod]: w = treatword(w) if not w: continue w = expandvars(w, vars) for w in string.split(w): if skipofiles and w[-2:] == '.o': continue if w[0] not in ('-', '$') and w[-2:] in ('.o', '.a'): w = os.path.join(e, w) if w[:2] in ('-L', '-R'): w = w[:2] + os.path.join(e, w[2:]) files.append(w) return files
| 14,791
|
def select(e, mods, vars, mod, skipofiles): files = [] for w in mods[mod]: w = treatword(w) if not w: continue w = expandvars(w, vars) for w in string.split(w): if skipofiles and w[-2:] == '.o': continue if w[0] != '-' and w[-2:] in ('.o', '.a'): w = os.path.join(e, w) if w[:2] in ('-L', '-R'): w = w[:2] + os.path.join(e, w[2:]) files.append(w) return files
|
def select(e, mods, vars, mod, skipofiles): files = [] for w in mods[mod]: w = treatword(w) if not w: continue w = expandvars(w, vars) for w in string.split(w): if skipofiles and w[-2:] == '.o': continue if w[0] != '-' and w[-2:] in ('.o', '.a'): w = os.path.join(e, w) if w[:2] in ('-L', '-R') and w[2:3] != '$': w = w[:2] + os.path.join(e, w[2:]) files.append(w) return files
| 14,792
|
def link (self, target_desc, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None): # First examine a couple of options for things that aren't implemented yet if not target_desc in (self.SHARED_LIBRARY, self.SHARED_OBJECT): raise DistutilsPlatformError, 'Can only make SHARED_LIBRARY or SHARED_OBJECT targets on the Mac' if runtime_library_dirs: raise DistutilsPlatformError, 'Runtime library dirs not implemented yet' if extra_preargs or extra_postargs: raise DistutilsPlatformError, 'Runtime library dirs not implemented yet' if len(export_symbols) != 1: raise DistutilsPlatformError, 'Need exactly one export symbol' # Next there are various things for which we need absolute pathnames. # This is because we (usually) create the project in a subdirectory of # where we are now, and keeping the paths relative is too much work right # now. sources = map(self._filename_to_abs, self.__sources) include_dirs = map(self._filename_to_abs, self.__include_dirs) if objects: objects = map(self._filename_to_abs, objects) else: objects = [] if build_temp: build_temp = self._filename_to_abs(build_temp) else: build_temp = os.curdir() if output_dir: output_filename = os.path.join(output_dir, output_filename) # The output filename needs special handling: splitting it into dir and # filename part. Actually I'm not sure this is really needed, but it # can't hurt. output_filename = self._filename_to_abs(output_filename) output_dir, output_filename = os.path.split(output_filename) # Now we need the short names of a couple of things for putting them # into the project. if output_filename[-8:] == '.ppc.slb': basename = output_filename[:-8] elif output_filename[-11:] == '.carbon.slb': basename = output_filename[:-11] else: basename = os.path.strip(output_filename)[0] projectname = basename + '.mcp' targetname = basename xmlname = basename + '.xml' exportname = basename + '.mcp.exp' prefixname = 'mwerks_%s_config.h'%basename # Create the directories we need distutils.dir_util.mkpath(build_temp, self.verbose, self.dry_run) distutils.dir_util.mkpath(output_dir, self.verbose, self.dry_run) # And on to filling in the parameters for the project builder settings = {} settings['mac_exportname'] = exportname settings['mac_outputdir'] = output_dir settings['mac_dllname'] = output_filename settings['mac_targetname'] = targetname settings['sysprefix'] = sys.prefix settings['mac_sysprefixtype'] = 'Absolute' sourcefilenames = [] sourcefiledirs = [] for filename in sources + objects: dirname, filename = os.path.split(filename) sourcefilenames.append(filename) if not dirname in sourcefiledirs: sourcefiledirs.append(dirname) settings['sources'] = sourcefilenames settings['extrasearchdirs'] = sourcefiledirs + include_dirs + library_dirs if self.dry_run: print 'CALLING LINKER IN', os.getcwd() for key, value in settings.items(): print '%20.20s %s'%(key, value) return # Build the export file exportfilename = os.path.join(build_temp, exportname) if self.verbose: print '\tCreate export file', exportfilename fp = open(exportfilename, 'w') fp.write('%s\n'%export_symbols[0]) fp.close() # Generate the prefix file, if needed, and put it in the settings if self.__macros: prefixfilename = os.path.join(os.getcwd(), os.path.join(build_temp, prefixname)) fp = open(prefixfilename, 'w') fp.write('#include "mwerks_plugin_config.h"\n') for name, value in self.__macros: if value is None: fp.write('#define %s\n'%name) else: fp.write('#define %s "%s"\n'%(name, value)) fp.close() settings['prefixname'] = prefixname
|
def link (self, target_desc, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None): # First examine a couple of options for things that aren't implemented yet if not target_desc in (self.SHARED_LIBRARY, self.SHARED_OBJECT): raise DistutilsPlatformError, 'Can only make SHARED_LIBRARY or SHARED_OBJECT targets on the Mac' if runtime_library_dirs: raise DistutilsPlatformError, 'Runtime library dirs not implemented yet' if extra_preargs or extra_postargs: raise DistutilsPlatformError, 'Runtime library dirs not implemented yet' if len(export_symbols) != 1: raise DistutilsPlatformError, 'Need exactly one export symbol' # Next there are various things for which we need absolute pathnames. # This is because we (usually) create the project in a subdirectory of # where we are now, and keeping the paths relative is too much work right # now. sources = map(self._filename_to_abs, self.__sources) include_dirs = map(self._filename_to_abs, self.__include_dirs) if objects: objects = map(self._filename_to_abs, objects) else: objects = [] if build_temp: build_temp = self._filename_to_abs(build_temp) else: build_temp = os.curdir() if output_dir: output_filename = os.path.join(output_dir, output_filename) # The output filename needs special handling: splitting it into dir and # filename part. Actually I'm not sure this is really needed, but it # can't hurt. output_filename = self._filename_to_abs(output_filename) output_dir, output_filename = os.path.split(output_filename) # Now we need the short names of a couple of things for putting them # into the project. if output_filename[-8:] == '.ppc.slb': basename = output_filename[:-8] elif output_filename[-11:] == '.carbon.slb': basename = output_filename[:-11] else: basename = os.path.strip(output_filename)[0] projectname = basename + '.mcp' targetname = basename xmlname = basename + '.xml' exportname = basename + '.mcp.exp' prefixname = 'mwerks_%s_config.h'%basename # Create the directories we need distutils.dir_util.mkpath(build_temp, self.verbose, self.dry_run) distutils.dir_util.mkpath(output_dir, self.verbose, self.dry_run) # And on to filling in the parameters for the project builder settings = {} settings['mac_exportname'] = exportname settings['mac_outputdir'] = output_dir settings['mac_dllname'] = output_filename settings['mac_targetname'] = targetname settings['sysprefix'] = sys.prefix settings['mac_sysprefixtype'] = 'Absolute' sourcefilenames = [] sourcefiledirs = [] for filename in sources + objects: dirname, filename = os.path.split(filename) sourcefilenames.append(filename) if not dirname in sourcefiledirs: sourcefiledirs.append(dirname) settings['sources'] = sourcefilenames settings['extrasearchdirs'] = sourcefiledirs + include_dirs + library_dirs if self.dry_run: print 'CALLING LINKER IN', os.getcwd() for key, value in settings.items(): print '%20.20s %s'%(key, value) return # Build the export file exportfilename = os.path.join(build_temp, exportname) if self.verbose: print '\tCreate export file', exportfilename fp = open(exportfilename, 'w') fp.write('%s\n'%export_symbols[0]) fp.close() # Generate the prefix file, if needed, and put it in the settings if self.__macros: prefixfilename = os.path.join(os.getcwd(), os.path.join(build_temp, prefixname)) fp = open(prefixfilename, 'w') fp.write('#include "mwerks_plugin_config.h"\n') for name, value in self.__macros: if value is None: fp.write('#define %s\n'%name) else: fp.write('#define %s "%s"\n'%(name, value)) fp.close() settings['prefixname'] = prefixname
| 14,793
|
def discard(self, element): """Remove an element from a set if it is a member.
|
def discard(self, element): """Remove an element from a set if it is a member.
| 14,794
|
def open(self, path, name, data): self.path = path self.name = name r = windowbounds(400, 400) w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555) self.wid = w vr = 0, 0, r[2]-r[0]-15, r[3]-r[1]-15 dr = (0, 0, vr[2], 0) Qd.SetPort(w) Qd.TextFont(4) Qd.TextSize(9) self.ted = TE.TENew(dr, vr) self.ted.TEAutoView(1) self.ted.TESetText(data) w.DrawGrowIcon() self.scrollbars() self.changed = 0 self.do_postopen() self.do_activate(1, None)
|
def open(self, path, name, data): self.path = path self.name = name r = windowbounds(400, 400) w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555) self.wid = w x0, y0, x1, y1 = self.wid.GetWindowPort().portRect x0 = x0 + 4 y0 = y0 + 4 x1 = x1 - 20 y1 = y1 - 20 vr = dr = x0, y0, x1, y1 Qd.SetPort(w) Qd.TextFont(4) Qd.TextSize(9) self.ted = TE.TENew(dr, vr) self.ted.TEAutoView(1) self.ted.TESetText(data) w.DrawGrowIcon() self.scrollbars() self.changed = 0 self.do_postopen() self.do_activate(1, None)
| 14,795
|
def mime_decode_header(line): '''Decode a header line to 8bit.''' newline = '' while 1: i = mime_head.search(line) if i < 0: break match = mime_head.group(0, 1) newline = newline + line[:i] + mime_decode(match[1]) line = line[i + len(match[0]):] return newline + line
|
def mime_decode_header(line): '''Decode a header line to 8bit.''' newline = '' while 1: i = mime_head.search(line) if i < 0: break match0, match1 = mime_head.group(0, 1) match1 = string.join(string.split(match1, '_'), ' ') newline = newline + line[:i] + mime_decode(match1) line = line[i + len(match0):] return newline + line
| 14,796
|
def AskString(prompt, default = "", id=257, ok=None, cancel=None): """Display a PROMPT string and a text entry field with a DEFAULT string. Return the contents of the text entry field when the user clicks the OK button or presses Return. Return None when the user clicks the Cancel button. If omitted, DEFAULT is empty. The PROMPT and DEFAULT strings, as well as the return value, can be at most 255 characters long. """ id = 257 d = GetNewDialog(id, -1) if not d: print "Can't get DLOG resource with id =", id return tp, h, rect = d.GetDialogItem(3) SetDialogItemText(h, lf2cr(prompt)) tp, h, rect = d.GetDialogItem(4) SetDialogItemText(h, lf2cr(default)) d.SelectDialogItemText(4, 0, 999)
|
def AskString(prompt, default = "", id=257, ok=None, cancel=None): """Display a PROMPT string and a text entry field with a DEFAULT string. Return the contents of the text entry field when the user clicks the OK button or presses Return. Return None when the user clicks the Cancel button. If omitted, DEFAULT is empty. The PROMPT and DEFAULT strings, as well as the return value, can be at most 255 characters long. """ d = GetNewDialog(id, -1) if not d: print "Can't get DLOG resource with id =", id return tp, h, rect = d.GetDialogItem(3) SetDialogItemText(h, lf2cr(prompt)) tp, h, rect = d.GetDialogItem(4) SetDialogItemText(h, lf2cr(default)) d.SelectDialogItemText(4, 0, 999)
| 14,797
|
def __getitem__(self, item): if isinstance(item, int): if item < 0: item += self.len if not 0 <= item < self.len: raise IndexError, "out of range" return strftime(self.format, (item,)*9).capitalize() elif isinstance(item, type(slice(0))): return [self[e] for e in range(self.len)].__getslice__(item.start, item.stop)
|
def __getitem__(self, item): if isinstance(item, int): if item < 0: item += self.len if not 0 <= item < self.len: raise IndexError, "out of range" return strftime(self.format, (item,)*8+(0,)).capitalize() elif isinstance(item, type(slice(0))): return [self[e] for e in range(self.len)].__getslice__(item.start, item.stop)
| 14,798
|
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
|
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
| 14,799
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.