rem
stringlengths 1
322k
| add
stringlengths 0
2.05M
| context
stringlengths 4
228k
| meta
stringlengths 156
215
|
---|---|---|---|
base = basename(self.packageRootFolder) + ".info" path = join(self.resourceFolder, base) | base = self.packageInfo["Title"] + ".info" path = join(self.packageResourceFolder, base) | def _addInfo(self): "Write .info file containing installing options." | 997429a5f47037de601ff9bd7d4bd4b538927106 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/997429a5f47037de601ff9bd7d4bd4b538927106/buildpkg.py |
base = basename(self.packageRootFolder) + ".bom" bomPath = join(self.resourceFolder, base) cmd = "mkbom %s %s" % (self.packageRootFolder, bomPath) | base = self.packageInfo["Title"] + ".bom" bomPath = join(self.packageResourceFolder, base) cmd = "mkbom %s %s" % (self.sourceFolder, bomPath) | def _addBom(self): "Write .bom file containing 'Bill of Materials'." | 997429a5f47037de601ff9bd7d4bd4b538927106 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/997429a5f47037de601ff9bd7d4bd4b538927106/buildpkg.py |
packageRootFolder = self.packageRootFolder try: d = dirname(packageRootFolder) os.chdir(packageRootFolder) base = basename(packageRootFolder) + ".pax" archPath = join(d, self.resourceFolder, base) cmd = "pax -w -f %s %s" % (archPath, ".") res = os.system(cmd) cmd = "gzip %s" % archPath res = os.system(cmd) except: pass | os.chdir(self.sourceFolder) base = basename(self.packageInfo["Title"]) + ".pax" self.archPath = join(self.packageResourceFolder, base) cmd = "pax -w -f %s %s" % (self.archPath, ".") res = os.system(cmd) cmd = "gzip %s" % self.archPath res = os.system(cmd) | def _addArchive(self): "Write .pax.gz file, a compressed archive using pax/gzip." | 997429a5f47037de601ff9bd7d4bd4b538927106 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/997429a5f47037de601ff9bd7d4bd4b538927106/buildpkg.py |
if not self.packageResourceFolder: | if not self.resourceFolder: | def _addResources(self): "Add Welcome/ReadMe/License files, .lproj folders and scripts." | 997429a5f47037de601ff9bd7d4bd4b538927106 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/997429a5f47037de601ff9bd7d4bd4b538927106/buildpkg.py |
pattern = join(self.packageResourceFolder, pat) | pattern = join(self.resourceFolder, pat) | def _addResources(self): "Add Welcome/ReadMe/License files, .lproj folders and scripts." | 997429a5f47037de601ff9bd7d4bd4b538927106 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/997429a5f47037de601ff9bd7d4bd4b538927106/buildpkg.py |
pattern = join(self.packageResourceFolder, packageName + pat) | pattern = join(self.resourceFolder, packageName + pat) | def _addResources(self): "Add Welcome/ReadMe/License files, .lproj folders and scripts." | 997429a5f47037de601ff9bd7d4bd4b538927106 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/997429a5f47037de601ff9bd7d4bd4b538927106/buildpkg.py |
files.append(f) | files.append((f, f)) | def _addResources(self): "Add Welcome/ReadMe/License files, .lproj folders and scripts." | 997429a5f47037de601ff9bd7d4bd4b538927106 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/997429a5f47037de601ff9bd7d4bd4b538927106/buildpkg.py |
files.append(f) | files.append((f, f)) elif f in ["pre-upgrade", "pre-install", "post-upgrade", "post-install"]: files.append((f, self.packageInfo["Title"]+"."+f)) | def _addResources(self): "Add Welcome/ReadMe/License files, .lproj folders and scripts." | 997429a5f47037de601ff9bd7d4bd4b538927106 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/997429a5f47037de601ff9bd7d4bd4b538927106/buildpkg.py |
files.append(f) | files.append((f,f)) | def _addResources(self): "Add Welcome/ReadMe/License files, .lproj folders and scripts." | 997429a5f47037de601ff9bd7d4bd4b538927106 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/997429a5f47037de601ff9bd7d4bd4b538927106/buildpkg.py |
files.append(f) | files.append((f,f)) | def _addResources(self): "Add Welcome/ReadMe/License files, .lproj folders and scripts." | 997429a5f47037de601ff9bd7d4bd4b538927106 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/997429a5f47037de601ff9bd7d4bd4b538927106/buildpkg.py |
for g in files: f = join(self.packageResourceFolder, g) | for src, dst in files: f = join(self.resourceFolder, src) | def _addResources(self): "Add Welcome/ReadMe/License files, .lproj folders and scripts." | 997429a5f47037de601ff9bd7d4bd4b538927106 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/997429a5f47037de601ff9bd7d4bd4b538927106/buildpkg.py |
shutil.copy(f, self.resourceFolder) | shutil.copy(f, os.path.join(self.packageResourceFolder, dst)) | def _addResources(self): "Add Welcome/ReadMe/License files, .lproj folders and scripts." | 997429a5f47037de601ff9bd7d4bd4b538927106 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/997429a5f47037de601ff9bd7d4bd4b538927106/buildpkg.py |
d = join(self.resourceFolder, basename(f)) | d = join(self.packageResourceFolder, dst) | def _addResources(self): "Add Welcome/ReadMe/License files, .lproj folders and scripts." | 997429a5f47037de601ff9bd7d4bd4b538927106 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/997429a5f47037de601ff9bd7d4bd4b538927106/buildpkg.py |
packageRootFolder = self.packageRootFolder files = GlobDirectoryWalker(packageRootFolder) | files = GlobDirectoryWalker(self.sourceFolder) | def _addSizes(self): "Write .sizes file with info about number and size of files." | 997429a5f47037de601ff9bd7d4bd4b538927106 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/997429a5f47037de601ff9bd7d4bd4b538927106/buildpkg.py |
installedSize = installedSize + os.stat(f)[6] d = dirname(packageRootFolder) base = basename(packageRootFolder) + ".pax.gz" archPath = join(d, self.resourceFolder, base) | installedSize = installedSize + os.lstat(f)[6] | def _addSizes(self): "Write .sizes file with info about number and size of files." | 997429a5f47037de601ff9bd7d4bd4b538927106 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/997429a5f47037de601ff9bd7d4bd4b538927106/buildpkg.py |
zippedSize = os.stat(archPath)[6] | zippedSize = os.stat(self.archPath+ ".gz")[6] | def _addSizes(self): "Write .sizes file with info about number and size of files." | 997429a5f47037de601ff9bd7d4bd4b538927106 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/997429a5f47037de601ff9bd7d4bd4b538927106/buildpkg.py |
base = basename(packageRootFolder) + ".sizes" f = open(join(self.resourceFolder, base), "w") format = "NumFiles %d\nInstalledSize %d\nCompressedSize %d" | base = self.packageInfo["Title"] + ".sizes" f = open(join(self.packageResourceFolder, base), "w") format = "NumFiles %d\nInstalledSize %d\nCompressedSize %d\n" | def _addSizes(self): "Write .sizes file with info about number and size of files." | 997429a5f47037de601ff9bd7d4bd4b538927106 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/997429a5f47037de601ff9bd7d4bd4b538927106/buildpkg.py |
del os | fp = None try: fp = open(TESTFN, 'w+') except IOError: TMP_TESTFN = os.path.join('/tmp', TESTFN) try: fp = open(TMP_TESTFN, 'w+') TESTFN = TMP_TESTFN del TMP_TESTFN except IOError: print ('WARNING: tests will fail, unable to write to: %s or %s' % (TESTFN, TMP_TESTFN)) if fp is not None: fp.close() try: os.unlink(TESTFN) except: pass del os, fp | def fcmp(x, y): # fuzzy comparison function if type(x) == type(0.0) or type(y) == type(0.0): try: x, y = coerce(x, y) fuzz = (abs(x) + abs(y)) * FUZZ if abs(x-y) <= fuzz: return 0 except: pass elif type(x) == type(y) and type(x) in (type(()), type([])): for i in range(min(len(x), len(y))): outcome = fcmp(x[i], y[i]) if outcome != 0: return outcome return cmp(len(x), len(y)) return cmp(x, y) | 26a1eefd0f28bbdee48cd38a5c0cb9ba5ff37768 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/26a1eefd0f28bbdee48cd38a5c0cb9ba5ff37768/test_support.py |
stats = os.stat(localname) | try: stats = os.stat(localname) except OSError, e: raise IOError(e.errno, e.strerror, e.filename) | def open_local_file(self, url): """Use local file.""" import mimetypes, mimetools, rfc822, StringIO host, file = splithost(url) localname = url2pathname(file) stats = os.stat(localname) size = stats.st_size modified = rfc822.formatdate(stats.st_mtime) mtype = mimetypes.guess_type(url)[0] headers = mimetools.Message(StringIO.StringIO( 'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' % (mtype or 'text/plain', size, modified))) if not host: urlfile = file if file[:1] == '/': urlfile = 'file://' + file return addinfourl(open(localname, 'rb'), headers, urlfile) host, port = splitport(host) if not port \ and socket.gethostbyname(host) in (localhost(), thishost()): urlfile = file if file[:1] == '/': urlfile = 'file://' + file return addinfourl(open(localname, 'rb'), headers, urlfile) raise IOError, ('local file error', 'not on local host') | a2da305211c23fc7090f95540cc1b793e474f9c1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a2da305211c23fc7090f95540cc1b793e474f9c1/urllib.py |
dist = self.distribution | metadata = self.distribution.metadata | def check_metadata (self): | 535f2d9ace100ce354630d1f26d1c45644970364 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/535f2d9ace100ce354630d1f26d1c45644970364/sdist.py |
if not (hasattr (dist, attr) and getattr (dist, attr)): | if not (hasattr (metadata, attr) and getattr (metadata, attr)): | def check_metadata (self): | 535f2d9ace100ce354630d1f26d1c45644970364 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/535f2d9ace100ce354630d1f26d1c45644970364/sdist.py |
if dist.author: if not dist.author_email: | if metadata.author: if not metadata.author_email: | def check_metadata (self): | 535f2d9ace100ce354630d1f26d1c45644970364 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/535f2d9ace100ce354630d1f26d1c45644970364/sdist.py |
elif dist.maintainer: if not dist.maintainer_email: | elif metadata.maintainer: if not metadata.maintainer_email: | def check_metadata (self): | 535f2d9ace100ce354630d1f26d1c45644970364 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/535f2d9ace100ce354630d1f26d1c45644970364/sdist.py |
def makeconfig(infp, outfp, modules): | def makeconfig(infp, outfp, modules, with_ifdef=0): | def makeconfig(infp, outfp, modules): m1 = regex.compile('-- ADDMODULE MARKER 1 --') m2 = regex.compile('-- ADDMODULE MARKER 2 --') while 1: line = infp.readline() if not line: break outfp.write(line) if m1 and m1.search(line) >= 0: m1 = None for mod in modules: if mod in never: continue outfp.write('extern void init%s();\n' % mod) elif m2 and m2.search(line) >= 0: m2 = None for mod in modules: if mod in never: continue outfp.write('\t{"%s", init%s},\n' % (mod, mod)) if m1: sys.stderr.write('MARKER 1 never found\n') elif m2: sys.stderr.write('MARKER 2 never found\n') | 8bd738278ede0e1e74e1bd05b629e380026d7984 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8bd738278ede0e1e74e1bd05b629e380026d7984/makeconfig.py |
traceback.print_exc() | traceback.print_exc(file=sys.stdout) | def runtest(hier, code): root = tempfile.mktemp() mkhier(root, hier) savepath = sys.path[:] codefile = tempfile.mktemp() f = open(codefile, "w") f.write(code) f.close() try: sys.path.insert(0, root) if verbose: print "sys.path =", sys.path try: execfile(codefile, globals(), {}) except: traceback.print_exc() finally: sys.path[:] = savepath try: cleanout(root) except (os.error, IOError): pass os.remove(codefile) | 10887a3067c4755f0bcbcf4b049ba1df513ed4ce /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/10887a3067c4755f0bcbcf4b049ba1df513ed4ce/test_pkg.py |
("t1", [("t1", None)], "import ni"), | ("t1", [("t1", None)], "import t1"), | def runtest(hier, code): root = tempfile.mktemp() mkhier(root, hier) savepath = sys.path[:] codefile = tempfile.mktemp() f = open(codefile, "w") f.write(code) f.close() try: sys.path.insert(0, root) if verbose: print "sys.path =", sys.path try: execfile(codefile, globals(), {}) except: traceback.print_exc() finally: sys.path[:] = savepath try: cleanout(root) except (os.error, IOError): pass os.remove(codefile) | 10887a3067c4755f0bcbcf4b049ba1df513ed4ce /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/10887a3067c4755f0bcbcf4b049ba1df513ed4ce/test_pkg.py |
l.grid(row=self.row, col=0, sticky="w") | l.grid(row=self.row, column=0, sticky="w") | def make_entry(self, label, var): l = Label(self.top, text=label) l.grid(row=self.row, col=0, sticky="w") e = Entry(self.top, textvariable=var, exportselection=0) e.grid(row=self.row, col=1, sticky="we") self.row = self.row + 1 return e | eb58f5d6cdc3d693eedc40229a5f161babf6920a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/eb58f5d6cdc3d693eedc40229a5f161babf6920a/SearchDialogBase.py |
e.grid(row=self.row, col=1, sticky="we") | e.grid(row=self.row, column=1, sticky="we") | def make_entry(self, label, var): l = Label(self.top, text=label) l.grid(row=self.row, col=0, sticky="w") e = Entry(self.top, textvariable=var, exportselection=0) e.grid(row=self.row, col=1, sticky="we") self.row = self.row + 1 return e | eb58f5d6cdc3d693eedc40229a5f161babf6920a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/eb58f5d6cdc3d693eedc40229a5f161babf6920a/SearchDialogBase.py |
f.grid(row=self.row, col=0, columnspan=2, sticky="we") | f.grid(row=self.row, column=0, columnspan=2, sticky="we") | def make_frame(self): f = Frame(self.top) f.grid(row=self.row, col=0, columnspan=2, sticky="we") self.row = self.row + 1 return f | eb58f5d6cdc3d693eedc40229a5f161babf6920a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/eb58f5d6cdc3d693eedc40229a5f161babf6920a/SearchDialogBase.py |
self.__delete() | try: self.__delete() except: pass | def __bootstrap(self): try: self.__started = 1 _active_limbo_lock.acquire() _active[_get_ident()] = self del _limbo[self] _active_limbo_lock.release() if __debug__: self._note("%s.__bootstrap(): thread started", self) try: self.run() except SystemExit: if __debug__: self._note("%s.__bootstrap(): raised SystemExit", self) except: if __debug__: self._note("%s.__bootstrap(): unhandled exception", self) s = _StringIO() _print_exc(file=s) _sys.stderr.write("Exception in thread %s:\n%s\n" % (self.getName(), s.getvalue())) else: if __debug__: self._note("%s.__bootstrap(): normal return", self) finally: self.__stop() self.__delete() | f21b2aafa9b78891b568264a32f40ee8a8384aa1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f21b2aafa9b78891b568264a32f40ee8a8384aa1/threading.py |
want = int((have - 1) / self.indentwidth) * self.indentwidth | want = ((have - 1) // self.indentwidth) * self.indentwidth | def smart_backspace_event(self, event): text = self.text first, last = self.editwin.get_selection_indices() if first and last: text.delete(first, last) text.mark_set("insert", first) return "break" # Delete whitespace left, until hitting a real char or closest # preceding virtual tab stop. chars = text.get("insert linestart", "insert") if chars == '': if text.compare("insert", ">", "1.0"): # easy: delete preceding newline text.delete("insert-1c") else: text.bell() # at start of buffer return "break" if chars[-1] not in " \t": # easy: delete preceding real char text.delete("insert-1c") return "break" # Ick. It may require *inserting* spaces if we back up over a # tab character! This is written to be clear, not fast. expand, tabwidth = string.expandtabs, self.tabwidth have = len(expand(chars, tabwidth)) assert have > 0 want = int((have - 1) / self.indentwidth) * self.indentwidth ncharsdeleted = 0 while 1: chars = chars[:-1] ncharsdeleted = ncharsdeleted + 1 have = len(expand(chars, tabwidth)) if have <= want or chars[-1] not in " \t": break text.undo_block_start() text.delete("insert-%dc" % ncharsdeleted, "insert") if have < want: text.insert("insert", ' ' * (want - have)) text.undo_block_stop() return "break" | 8cf2704a59421d2cbb1ce1a52b21c1b158064d84 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8cf2704a59421d2cbb1ce1a52b21c1b158064d84/AutoIndent.py |
effective = (int(effective / tabwidth) + 1) * tabwidth | effective = (effective // tabwidth + 1) * tabwidth | def classifyws(s, tabwidth): raw = effective = 0 for ch in s: if ch == ' ': raw = raw + 1 effective = effective + 1 elif ch == '\t': raw = raw + 1 effective = (int(effective / tabwidth) + 1) * tabwidth else: break return raw, effective | 8cf2704a59421d2cbb1ce1a52b21c1b158064d84 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8cf2704a59421d2cbb1ce1a52b21c1b158064d84/AutoIndent.py |
ctype = msg.get_content_type() main, sub = ctype.split('/') | main = msg.get_content_maintype() sub = msg.get_content_subtype() | def _dispatch(self, msg): # Get the Content-Type: for the message, then try to dispatch to # self._handle_<maintype>_<subtype>(). If there's no handler for the # full MIME type, then dispatch to self._handle_<maintype>(). If # that's missing too, then dispatch to self._writeBody(). ctype = msg.get_content_type() # We do have a Content-Type: header. main, sub = ctype.split('/') specific = UNDERSCORE.join((main, sub)).replace('-', '_') meth = getattr(self, '_handle_' + specific, None) if meth is None: generic = main.replace('-', '_') meth = getattr(self, '_handle_' + generic, None) if meth is None: meth = self._writeBody meth(msg) | dfea3b3963228fc149c586463b01fcaf39510902 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dfea3b3963228fc149c586463b01fcaf39510902/Generator.py |
self.badmodules[name] = {m.__name__:None} | if not self.badmodules.has_key(name): self.badmodules[name] = {} self.badmodules[name][m.__name__] = None | def scan_code(self, co, m): code = co.co_code n = len(code) i = 0 lastname = None while i < n: c = code[i] i = i+1 op = ord(c) if op >= dis.HAVE_ARGUMENT: oparg = ord(code[i]) + ord(code[i+1])*256 i = i+2 if op == IMPORT_NAME: name = lastname = co.co_names[oparg] if not self.badmodules.has_key(lastname): try: self.import_hook(name, m) except ImportError, msg: self.msg(2, "ImportError:", str(msg)) self.badmodules[name] = {m.__name__:None} elif op == IMPORT_FROM: name = co.co_names[oparg] assert lastname is not None if not self.badmodules.has_key(lastname): try: self.import_hook(lastname, m, [name]) except ImportError, msg: self.msg(2, "ImportError:", str(msg)) fullname = lastname + "." + name self.badmodules[fullname] = {m.__name__:None} else: lastname = None for c in co.co_consts: if isinstance(c, type(co)): self.scan_code(c, m) | fdd302820ec8f8af0baa3e58a2795d00f14dffcb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fdd302820ec8f8af0baa3e58a2795d00f14dffcb/modulefinder.py |
self.badmodules[fullname] = {m.__name__:None} | if not self.badmodules.has_key(fullname): self.badmodules[fullname] = {} self.badmodules[fullname][m.__name__] = None | def scan_code(self, co, m): code = co.co_code n = len(code) i = 0 lastname = None while i < n: c = code[i] i = i+1 op = ord(c) if op >= dis.HAVE_ARGUMENT: oparg = ord(code[i]) + ord(code[i+1])*256 i = i+2 if op == IMPORT_NAME: name = lastname = co.co_names[oparg] if not self.badmodules.has_key(lastname): try: self.import_hook(name, m) except ImportError, msg: self.msg(2, "ImportError:", str(msg)) self.badmodules[name] = {m.__name__:None} elif op == IMPORT_FROM: name = co.co_names[oparg] assert lastname is not None if not self.badmodules.has_key(lastname): try: self.import_hook(lastname, m, [name]) except ImportError, msg: self.msg(2, "ImportError:", str(msg)) fullname = lastname + "." + name self.badmodules[fullname] = {m.__name__:None} else: lastname = None for c in co.co_consts: if isinstance(c, type(co)): self.scan_code(c, m) | fdd302820ec8f8af0baa3e58a2795d00f14dffcb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fdd302820ec8f8af0baa3e58a2795d00f14dffcb/modulefinder.py |
if code in self.BUGGY_RANGE_CHECK: | if not PY_STRUCT_RANGE_CHECKING and code in self.BUGGY_RANGE_CHECK: | def test_one(self, x, pack=struct.pack, unpack=struct.unpack, unhexlify=binascii.unhexlify): if verbose: print "trying std", self.formatpair, "on", x, "==", hex(x) | e27337b5d01a63f6874382175221936780e50acd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e27337b5d01a63f6874382175221936780e50acd/test_struct.py |
if 0: | if PY_STRUCT_RANGE_CHECKING: | def test_1229380(): for endian in ('', '>', '<'): for cls in (int, long): for fmt in ('B', 'H', 'I', 'L'): any_err(struct.pack, endian + fmt, cls(-1)) any_err(struct.pack, endian + 'B', cls(300)) any_err(struct.pack, endian + 'H', cls(70000)) any_err(struct.pack, endian + 'I', sys.maxint * 4L) any_err(struct.pack, endian + 'L', sys.maxint * 4L) | e27337b5d01a63f6874382175221936780e50acd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e27337b5d01a63f6874382175221936780e50acd/test_struct.py |
def test_monotonic(self): data = hamlet_scene * 8 * 16 last = length = len(zlib.compress(data, 0)) self.failUnless(last > len(data), "compress level 0 always expands") for level in range(10): length = len(zlib.compress(data, level)) self.failUnless(length <= last, 'compress level %d more effective than %d!' % ( level-1, level)) last = length | def test_monotonic(self): # higher compression levels should not expand compressed size data = hamlet_scene * 8 * 16 last = length = len(zlib.compress(data, 0)) self.failUnless(last > len(data), "compress level 0 always expands") for level in range(10): length = len(zlib.compress(data, level)) self.failUnless(length <= last, 'compress level %d more effective than %d!' % ( level-1, level)) last = length | 6d362b25c5125070ddd58f0bfaf79cb67e4f2cd4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6d362b25c5125070ddd58f0bfaf79cb67e4f2cd4/test_zlib.py |
|
self.sock.send(str) | if self.sock: self.sock.send(str) else: raise SMTPServerDisconnected | def send(self, str): """Send `str' to the server.""" if self.debuglevel > 0: print 'send:', `str` self.sock.send(str) | fc40a8316a552ff4c67489498100c2457a32bd20 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fc40a8316a552ff4c67489498100c2457a32bd20/smtplib.py |
(note : multiline responces converted to a single, multiline string) | (note : multiline responces converted to a single, multiline string) | def getreply(self): """Get a reply from the server. Returns a tuple consisting of: - server response code (e.g. '250', or such, if all goes well) Note: returns -1 if it can't read responce code. - server response string corresponding to response code | fc40a8316a552ff4c67489498100c2457a32bd20 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fc40a8316a552ff4c67489498100c2457a32bd20/smtplib.py |
print 'reply: retcode (%s); Msg: %s' % (errcode,errmsg) | print 'reply: retcode (%s); Msg: %s' % (errcode,errmsg) | def getreply(self): """Get a reply from the server. Returns a tuple consisting of: - server response code (e.g. '250', or such, if all goes well) Note: returns -1 if it can't read responce code. - server response string corresponding to response code | fc40a8316a552ff4c67489498100c2457a32bd20 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fc40a8316a552ff4c67489498100c2457a32bd20/smtplib.py |
""" SMTP 'help' command. Returns help text from server """ | """ SMTP 'help' command. Returns help text from server """ | def help(self): """ SMTP 'help' command. Returns help text from server """ | fc40a8316a552ff4c67489498100c2457a32bd20 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fc40a8316a552ff4c67489498100c2457a32bd20/smtplib.py |
def data(self,msg): """ SMTP 'DATA' command. Sends message data to server. Automatically quotes lines beginning with a period per rfc821 """ | fc40a8316a552ff4c67489498100c2457a32bd20 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fc40a8316a552ff4c67489498100c2457a32bd20/smtplib.py |
||
def data(self,msg): """ SMTP 'DATA' command. Sends message data to server. Automatically quotes lines beginning with a period per rfc821 """ | fc40a8316a552ff4c67489498100c2457a32bd20 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fc40a8316a552ff4c67489498100c2457a32bd20/smtplib.py |
||
This method will return normally if the mail is accepted for at least one recipiant .Otherwise it will throw an exception (either SMTPSenderRefused,SMTPRecipientsRefused, or SMTPDataError) That is, if this method does not throw an excception, then someone | This method will return normally if the mail is accepted for at least one recipiant. Otherwise it will throw an exception (either SMTPSenderRefused, SMTPRecipientsRefused, or SMTPDataError) That is, if this method does not throw an exception, then someone | def sendmail(self,from_addr,to_addrs,msg): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send. | fc40a8316a552ff4c67489498100c2457a32bd20 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fc40a8316a552ff4c67489498100c2457a32bd20/smtplib.py |
It returns a dictionary , with one entry for each recipient that was refused. | It returns a dictionary , with one entry for each recipient that was refused. | def sendmail(self,from_addr,to_addrs,msg): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send. | fc40a8316a552ff4c67489498100c2457a32bd20 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fc40a8316a552ff4c67489498100c2457a32bd20/smtplib.py |
>>> tolist= [ "[email protected]", ... "[email protected]", ... "[email protected]", ... "[email protected]"] | >>> tolist=["[email protected]","[email protected]","[email protected]","[email protected]"] | def sendmail(self,from_addr,to_addrs,msg): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send. | fc40a8316a552ff4c67489498100c2457a32bd20 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fc40a8316a552ff4c67489498100c2457a32bd20/smtplib.py |
In the above example, the message was accepted for delivery to three of the four addresses, and one was rejected, with the error code 550. If all addresses are accepted, then the method will return an empty dictionary. | In the above example, the message was accepted for delivery to three of the four addresses, and one was rejected, with the error code 550. If all addresses are accepted, then the method will return an empty dictionary. | def sendmail(self,from_addr,to_addrs,msg): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send. | fc40a8316a552ff4c67489498100c2457a32bd20 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fc40a8316a552ff4c67489498100c2457a32bd20/smtplib.py |
senderr[each]=(code,resp) | senderrs[each]=(code,resp) | def sendmail(self,from_addr,to_addrs,msg): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send. | fc40a8316a552ff4c67489498100c2457a32bd20 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fc40a8316a552ff4c67489498100c2457a32bd20/smtplib.py |
print "install_lib: compile=%s, optimize=%s" % \ (`self.compile`, `self.optimize`) | def finalize_options (self): | 25a309c0a9abe33755550c2c71d0865ff6c1a72b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/25a309c0a9abe33755550c2c71d0865ff6c1a72b/install_lib.py |
|
def add_windows_to_menu(menu): registry.add_windows_to_menu(menu) | add_windows_to_menu = registry.add_windows_to_menu register_callback = registry.register_callback unregister_callback = registry.unregister_callback call_callbacks = registry.call_callbacks | def add_windows_to_menu(menu): registry.add_windows_to_menu(menu) | 5437ddfa36f785cd8d2a68dc35297173d88ca67c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5437ddfa36f785cd8d2a68dc35297173d88ca67c/WindowList.py |
FILE = file(test_support.TESTFN, 'w') | FILE = file(test_support.TESTFN, 'wb') | def setUp(self): """Setup of a temp file to use for testing""" self.text = "test_urllib: %s\n" % self.__class__.__name__ FILE = file(test_support.TESTFN, 'w') try: FILE.write(self.text) finally: FILE.close() self.pathname = test_support.TESTFN self.returned_obj = urllib.urlopen("file:%s" % self.pathname) | 51735b0569e4bff3f9a2988f0273cd5f1e3ec471 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/51735b0569e4bff3f9a2988f0273cd5f1e3ec471/test_urllib.py |
if line == '.': line = '..' | if line[:1] == '.': line = '.' + line | def post(self, f): resp = self.shortcmd('POST') # Raises error_??? if posting is not allowed if resp[0] <> '3': raise error_reply, resp while 1: line = f.readline() if not line: break if line[-1] == '\n': line = line[:-1] if line == '.': line = '..' self.putline(line) self.putline('.') return self.getresp() | e2ed9df64573ce99db942acaa6f3a820448b717f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e2ed9df64573ce99db942acaa6f3a820448b717f/nntplib.py |
if line == '.': line = '..' | if line[:1] == '.': line = '.' + line | def ihave(self, id, f): resp = self.shortcmd('IHAVE ' + id) # Raises error_??? if the server already has it if resp[0] <> '3': raise error_reply, resp while 1: line = f.readline() if not line: break if line[-1] == '\n': line = line[:-1] if line == '.': line = '..' self.putline(line) self.putline('.') return self.getresp() | e2ed9df64573ce99db942acaa6f3a820448b717f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e2ed9df64573ce99db942acaa6f3a820448b717f/nntplib.py |
- excample: the Example object that failed | - example: the Example object that failed | def output_difference(self, example, got, optionflags): """ Return a string describing the differences between the expected output for a given example (`example`) and the actual output (`got`). `optionflags` is the set of option flags used to compare `want` and `got`. """ want = example.want # If <BLANKLINE>s are being used, then replace blank lines # with <BLANKLINE> in the actual output string. if not (optionflags & DONT_ACCEPT_BLANKLINE): got = re.sub('(?m)^[ ]*(?=\n)', BLANKLINE_MARKER, got) | c082cb72a58bd4d6beb6c34d55c653b810776274 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c082cb72a58bd4d6beb6c34d55c653b810776274/doctest.py |
def __init__(self, _class=Message.Message): | def __init__(self, _class=Message.Message, strict=1): | def __init__(self, _class=Message.Message): """Parser of RFC 2822 and MIME email messages. | f6caeba03a59944602f7c0eec69c9f275f9608eb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f6caeba03a59944602f7c0eec69c9f275f9608eb/Parser.py |
def parse(self, fp): | self._strict = strict def parse(self, fp, headersonly=0): | def __init__(self, _class=Message.Message): """Parser of RFC 2822 and MIME email messages. | f6caeba03a59944602f7c0eec69c9f275f9608eb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f6caeba03a59944602f7c0eec69c9f275f9608eb/Parser.py |
self._parsebody(root, fp) | if not headersonly: self._parsebody(root, fp) | def parse(self, fp): root = self._class() self._parseheaders(root, fp) self._parsebody(root, fp) return root | f6caeba03a59944602f7c0eec69c9f275f9608eb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f6caeba03a59944602f7c0eec69c9f275f9608eb/Parser.py |
def parsestr(self, text): return self.parse(StringIO(text)) | def parsestr(self, text, headersonly=0): return self.parse(StringIO(text), headersonly=headersonly) | def parsestr(self, text): return self.parse(StringIO(text)) | f6caeba03a59944602f7c0eec69c9f275f9608eb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f6caeba03a59944602f7c0eec69c9f275f9608eb/Parser.py |
else: | elif self._strict: | def _parseheaders(self, container, fp): # Parse the headers, returning a list of header/value pairs. None as # the header means the Unix-From header. lastheader = '' lastvalue = [] lineno = 0 while 1: # Don't strip the line before we test for the end condition, # because whitespace-only header lines are RFC compliant # continuation lines. line = fp.readline() if not line: break line = line.splitlines()[0] if not line: break # Ignore the trailing newline lineno += 1 # Check for initial Unix From_ line if line.startswith('From '): if lineno == 1: container.set_unixfrom(line) continue else: raise Errors.HeaderParseError( 'Unix-from in headers after first rfc822 header') # Header continuation line if line[0] in ' \t': if not lastheader: raise Errors.HeaderParseError( 'Continuation line seen before first header') lastvalue.append(line) continue # Normal, non-continuation header. BAW: this should check to make # sure it's a legal header, e.g. doesn't contain spaces. Also, we # should expose the header matching algorithm in the API, and # allow for a non-strict parsing mode (that ignores the line # instead of raising the exception). i = line.find(':') if i < 0: raise Errors.HeaderParseError( 'Not a header, not a continuation') if lastheader: container[lastheader] = NL.join(lastvalue) lastheader = line[:i] lastvalue = [line[i+1:].lstrip()] # Make sure we retain the last header if lastheader: container[lastheader] = NL.join(lastvalue) | f6caeba03a59944602f7c0eec69c9f275f9608eb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f6caeba03a59944602f7c0eec69c9f275f9608eb/Parser.py |
raise Errors.HeaderParseError( 'Not a header, not a continuation') | if self._strict: raise Errors.HeaderParseError( "Not a header, not a continuation: ``%s''"%line) elif lineno == 1 and line.startswith('--'): continue else: raise Errors.HeaderParseError( "Not a header, not a continuation: ``%s''"%line) | def _parseheaders(self, container, fp): # Parse the headers, returning a list of header/value pairs. None as # the header means the Unix-From header. lastheader = '' lastvalue = [] lineno = 0 while 1: # Don't strip the line before we test for the end condition, # because whitespace-only header lines are RFC compliant # continuation lines. line = fp.readline() if not line: break line = line.splitlines()[0] if not line: break # Ignore the trailing newline lineno += 1 # Check for initial Unix From_ line if line.startswith('From '): if lineno == 1: container.set_unixfrom(line) continue else: raise Errors.HeaderParseError( 'Unix-from in headers after first rfc822 header') # Header continuation line if line[0] in ' \t': if not lastheader: raise Errors.HeaderParseError( 'Continuation line seen before first header') lastvalue.append(line) continue # Normal, non-continuation header. BAW: this should check to make # sure it's a legal header, e.g. doesn't contain spaces. Also, we # should expose the header matching algorithm in the API, and # allow for a non-strict parsing mode (that ignores the line # instead of raising the exception). i = line.find(':') if i < 0: raise Errors.HeaderParseError( 'Not a header, not a continuation') if lastheader: container[lastheader] = NL.join(lastvalue) lastheader = line[:i] lastvalue = [line[i+1:].lstrip()] # Make sure we retain the last header if lastheader: container[lastheader] = NL.join(lastvalue) | f6caeba03a59944602f7c0eec69c9f275f9608eb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f6caeba03a59944602f7c0eec69c9f275f9608eb/Parser.py |
start += len(mo.group(0)) * (1 + isdigest) | start += len(mo.group(0)) | def _parsebody(self, container, fp): # Parse the body, but first split the payload on the content-type # boundary if present. boundary = container.get_boundary() isdigest = (container.get_type() == 'multipart/digest') # If there's a boundary, split the payload text into its constituent # parts and parse each separately. Otherwise, just parse the rest of # the body as a single message. Note: any exceptions raised in the # recursive parse need to have their line numbers coerced. if boundary: preamble = epilogue = None # Split into subparts. The first boundary we're looking for won't # have the leading newline since we're at the start of the body # text. separator = '--' + boundary payload = fp.read() start = payload.find(separator) if start < 0: raise Errors.BoundaryError( "Couldn't find starting boundary: %s" % boundary) if start > 0: # there's some pre-MIME boundary preamble preamble = payload[0:start] # Find out what kind of line endings we're using start += len(separator) cre = re.compile('\r\n|\r|\n') mo = cre.search(payload, start) if mo: start += len(mo.group(0)) * (1 + isdigest) # We create a compiled regexp first because we need to be able to # specify the start position, and the module function doesn't # support this signature. :( cre = re.compile('(?P<sep>\r\n|\r|\n)' + re.escape(separator) + '--') mo = cre.search(payload, start) if not mo: raise Errors.BoundaryError( "Couldn't find terminating boundary: %s" % boundary) terminator = mo.start() linesep = mo.group('sep') if mo.end() < len(payload): # there's some post-MIME boundary epilogue epilogue = payload[mo.end():] # We split the textual payload on the boundary separator, which # includes the trailing newline. If the container is a # multipart/digest then the subparts are by default message/rfc822 # instead of text/plain. In that case, they'll have an extra # newline before the headers to distinguish the message's headers # from the subpart headers. separator += linesep * (1 + isdigest) parts = payload[start:terminator].split(linesep + separator) for part in parts: msgobj = self.parsestr(part) container.preamble = preamble container.epilogue = epilogue container.attach(msgobj) elif container.get_main_type() == 'multipart': # Very bad. A message is a multipart with no boundary! raise Errors.BoundaryError( 'multipart message with no defined boundary') elif container.get_type() == 'message/delivery-status': # This special kind of type contains blocks of headers separated # by a blank line. We'll represent each header block as a # separate Message object blocks = [] while 1: blockmsg = self._class() self._parseheaders(blockmsg, fp) if not len(blockmsg): # No more header blocks left break blocks.append(blockmsg) container.set_payload(blocks) elif container.get_main_type() == 'message': # Create a container for the payload, but watch out for there not # being any headers left try: msg = self.parse(fp) except Errors.HeaderParseError: msg = self._class() self._parsebody(msg, fp) container.attach(msg) else: container.set_payload(fp.read()) | f6caeba03a59944602f7c0eec69c9f275f9608eb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f6caeba03a59944602f7c0eec69c9f275f9608eb/Parser.py |
if not mo: | if mo: terminator = mo.start() linesep = mo.group('sep') if mo.end() < len(payload): epilogue = payload[mo.end():] elif self._strict: | def _parsebody(self, container, fp): # Parse the body, but first split the payload on the content-type # boundary if present. boundary = container.get_boundary() isdigest = (container.get_type() == 'multipart/digest') # If there's a boundary, split the payload text into its constituent # parts and parse each separately. Otherwise, just parse the rest of # the body as a single message. Note: any exceptions raised in the # recursive parse need to have their line numbers coerced. if boundary: preamble = epilogue = None # Split into subparts. The first boundary we're looking for won't # have the leading newline since we're at the start of the body # text. separator = '--' + boundary payload = fp.read() start = payload.find(separator) if start < 0: raise Errors.BoundaryError( "Couldn't find starting boundary: %s" % boundary) if start > 0: # there's some pre-MIME boundary preamble preamble = payload[0:start] # Find out what kind of line endings we're using start += len(separator) cre = re.compile('\r\n|\r|\n') mo = cre.search(payload, start) if mo: start += len(mo.group(0)) * (1 + isdigest) # We create a compiled regexp first because we need to be able to # specify the start position, and the module function doesn't # support this signature. :( cre = re.compile('(?P<sep>\r\n|\r|\n)' + re.escape(separator) + '--') mo = cre.search(payload, start) if not mo: raise Errors.BoundaryError( "Couldn't find terminating boundary: %s" % boundary) terminator = mo.start() linesep = mo.group('sep') if mo.end() < len(payload): # there's some post-MIME boundary epilogue epilogue = payload[mo.end():] # We split the textual payload on the boundary separator, which # includes the trailing newline. If the container is a # multipart/digest then the subparts are by default message/rfc822 # instead of text/plain. In that case, they'll have an extra # newline before the headers to distinguish the message's headers # from the subpart headers. separator += linesep * (1 + isdigest) parts = payload[start:terminator].split(linesep + separator) for part in parts: msgobj = self.parsestr(part) container.preamble = preamble container.epilogue = epilogue container.attach(msgobj) elif container.get_main_type() == 'multipart': # Very bad. A message is a multipart with no boundary! raise Errors.BoundaryError( 'multipart message with no defined boundary') elif container.get_type() == 'message/delivery-status': # This special kind of type contains blocks of headers separated # by a blank line. We'll represent each header block as a # separate Message object blocks = [] while 1: blockmsg = self._class() self._parseheaders(blockmsg, fp) if not len(blockmsg): # No more header blocks left break blocks.append(blockmsg) container.set_payload(blocks) elif container.get_main_type() == 'message': # Create a container for the payload, but watch out for there not # being any headers left try: msg = self.parse(fp) except Errors.HeaderParseError: msg = self._class() self._parsebody(msg, fp) container.attach(msg) else: container.set_payload(fp.read()) | f6caeba03a59944602f7c0eec69c9f275f9608eb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f6caeba03a59944602f7c0eec69c9f275f9608eb/Parser.py |
"Couldn't find terminating boundary: %s" % boundary) terminator = mo.start() linesep = mo.group('sep') if mo.end() < len(payload): epilogue = payload[mo.end():] | "Couldn't find terminating boundary: %s" % boundary) else: endre = re.compile('(?P<sep>\r\n|\r|\n){2}$') mo = endre.search(payload) if not mo: raise Errors.BoundaryError( "Couldn't find terminating boundary, and no "+ "trailing empty line") else: linesep = mo.group('sep') terminator = len(payload) | def _parsebody(self, container, fp): # Parse the body, but first split the payload on the content-type # boundary if present. boundary = container.get_boundary() isdigest = (container.get_type() == 'multipart/digest') # If there's a boundary, split the payload text into its constituent # parts and parse each separately. Otherwise, just parse the rest of # the body as a single message. Note: any exceptions raised in the # recursive parse need to have their line numbers coerced. if boundary: preamble = epilogue = None # Split into subparts. The first boundary we're looking for won't # have the leading newline since we're at the start of the body # text. separator = '--' + boundary payload = fp.read() start = payload.find(separator) if start < 0: raise Errors.BoundaryError( "Couldn't find starting boundary: %s" % boundary) if start > 0: # there's some pre-MIME boundary preamble preamble = payload[0:start] # Find out what kind of line endings we're using start += len(separator) cre = re.compile('\r\n|\r|\n') mo = cre.search(payload, start) if mo: start += len(mo.group(0)) * (1 + isdigest) # We create a compiled regexp first because we need to be able to # specify the start position, and the module function doesn't # support this signature. :( cre = re.compile('(?P<sep>\r\n|\r|\n)' + re.escape(separator) + '--') mo = cre.search(payload, start) if not mo: raise Errors.BoundaryError( "Couldn't find terminating boundary: %s" % boundary) terminator = mo.start() linesep = mo.group('sep') if mo.end() < len(payload): # there's some post-MIME boundary epilogue epilogue = payload[mo.end():] # We split the textual payload on the boundary separator, which # includes the trailing newline. If the container is a # multipart/digest then the subparts are by default message/rfc822 # instead of text/plain. In that case, they'll have an extra # newline before the headers to distinguish the message's headers # from the subpart headers. separator += linesep * (1 + isdigest) parts = payload[start:terminator].split(linesep + separator) for part in parts: msgobj = self.parsestr(part) container.preamble = preamble container.epilogue = epilogue container.attach(msgobj) elif container.get_main_type() == 'multipart': # Very bad. A message is a multipart with no boundary! raise Errors.BoundaryError( 'multipart message with no defined boundary') elif container.get_type() == 'message/delivery-status': # This special kind of type contains blocks of headers separated # by a blank line. We'll represent each header block as a # separate Message object blocks = [] while 1: blockmsg = self._class() self._parseheaders(blockmsg, fp) if not len(blockmsg): # No more header blocks left break blocks.append(blockmsg) container.set_payload(blocks) elif container.get_main_type() == 'message': # Create a container for the payload, but watch out for there not # being any headers left try: msg = self.parse(fp) except Errors.HeaderParseError: msg = self._class() self._parsebody(msg, fp) container.attach(msg) else: container.set_payload(fp.read()) | f6caeba03a59944602f7c0eec69c9f275f9608eb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f6caeba03a59944602f7c0eec69c9f275f9608eb/Parser.py |
separator += linesep * (1 + isdigest) | separator += linesep | def _parsebody(self, container, fp): # Parse the body, but first split the payload on the content-type # boundary if present. boundary = container.get_boundary() isdigest = (container.get_type() == 'multipart/digest') # If there's a boundary, split the payload text into its constituent # parts and parse each separately. Otherwise, just parse the rest of # the body as a single message. Note: any exceptions raised in the # recursive parse need to have their line numbers coerced. if boundary: preamble = epilogue = None # Split into subparts. The first boundary we're looking for won't # have the leading newline since we're at the start of the body # text. separator = '--' + boundary payload = fp.read() start = payload.find(separator) if start < 0: raise Errors.BoundaryError( "Couldn't find starting boundary: %s" % boundary) if start > 0: # there's some pre-MIME boundary preamble preamble = payload[0:start] # Find out what kind of line endings we're using start += len(separator) cre = re.compile('\r\n|\r|\n') mo = cre.search(payload, start) if mo: start += len(mo.group(0)) * (1 + isdigest) # We create a compiled regexp first because we need to be able to # specify the start position, and the module function doesn't # support this signature. :( cre = re.compile('(?P<sep>\r\n|\r|\n)' + re.escape(separator) + '--') mo = cre.search(payload, start) if not mo: raise Errors.BoundaryError( "Couldn't find terminating boundary: %s" % boundary) terminator = mo.start() linesep = mo.group('sep') if mo.end() < len(payload): # there's some post-MIME boundary epilogue epilogue = payload[mo.end():] # We split the textual payload on the boundary separator, which # includes the trailing newline. If the container is a # multipart/digest then the subparts are by default message/rfc822 # instead of text/plain. In that case, they'll have an extra # newline before the headers to distinguish the message's headers # from the subpart headers. separator += linesep * (1 + isdigest) parts = payload[start:terminator].split(linesep + separator) for part in parts: msgobj = self.parsestr(part) container.preamble = preamble container.epilogue = epilogue container.attach(msgobj) elif container.get_main_type() == 'multipart': # Very bad. A message is a multipart with no boundary! raise Errors.BoundaryError( 'multipart message with no defined boundary') elif container.get_type() == 'message/delivery-status': # This special kind of type contains blocks of headers separated # by a blank line. We'll represent each header block as a # separate Message object blocks = [] while 1: blockmsg = self._class() self._parseheaders(blockmsg, fp) if not len(blockmsg): # No more header blocks left break blocks.append(blockmsg) container.set_payload(blocks) elif container.get_main_type() == 'message': # Create a container for the payload, but watch out for there not # being any headers left try: msg = self.parse(fp) except Errors.HeaderParseError: msg = self._class() self._parsebody(msg, fp) container.attach(msg) else: container.set_payload(fp.read()) | f6caeba03a59944602f7c0eec69c9f275f9608eb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f6caeba03a59944602f7c0eec69c9f275f9608eb/Parser.py |
msgobj = self.parsestr(part) | if isdigest: if part[0] == linesep: msgobj = self._class() part = part[1:] else: parthdrs, part = part.split(linesep+linesep, 1) msgobj = self.parsestr(parthdrs, headersonly=1) submsgobj = self.parsestr(part) msgobj.attach(submsgobj) msgobj.set_default_type('message/rfc822') else: msgobj = self.parsestr(part) | def _parsebody(self, container, fp): # Parse the body, but first split the payload on the content-type # boundary if present. boundary = container.get_boundary() isdigest = (container.get_type() == 'multipart/digest') # If there's a boundary, split the payload text into its constituent # parts and parse each separately. Otherwise, just parse the rest of # the body as a single message. Note: any exceptions raised in the # recursive parse need to have their line numbers coerced. if boundary: preamble = epilogue = None # Split into subparts. The first boundary we're looking for won't # have the leading newline since we're at the start of the body # text. separator = '--' + boundary payload = fp.read() start = payload.find(separator) if start < 0: raise Errors.BoundaryError( "Couldn't find starting boundary: %s" % boundary) if start > 0: # there's some pre-MIME boundary preamble preamble = payload[0:start] # Find out what kind of line endings we're using start += len(separator) cre = re.compile('\r\n|\r|\n') mo = cre.search(payload, start) if mo: start += len(mo.group(0)) * (1 + isdigest) # We create a compiled regexp first because we need to be able to # specify the start position, and the module function doesn't # support this signature. :( cre = re.compile('(?P<sep>\r\n|\r|\n)' + re.escape(separator) + '--') mo = cre.search(payload, start) if not mo: raise Errors.BoundaryError( "Couldn't find terminating boundary: %s" % boundary) terminator = mo.start() linesep = mo.group('sep') if mo.end() < len(payload): # there's some post-MIME boundary epilogue epilogue = payload[mo.end():] # We split the textual payload on the boundary separator, which # includes the trailing newline. If the container is a # multipart/digest then the subparts are by default message/rfc822 # instead of text/plain. In that case, they'll have an extra # newline before the headers to distinguish the message's headers # from the subpart headers. separator += linesep * (1 + isdigest) parts = payload[start:terminator].split(linesep + separator) for part in parts: msgobj = self.parsestr(part) container.preamble = preamble container.epilogue = epilogue container.attach(msgobj) elif container.get_main_type() == 'multipart': # Very bad. A message is a multipart with no boundary! raise Errors.BoundaryError( 'multipart message with no defined boundary') elif container.get_type() == 'message/delivery-status': # This special kind of type contains blocks of headers separated # by a blank line. We'll represent each header block as a # separate Message object blocks = [] while 1: blockmsg = self._class() self._parseheaders(blockmsg, fp) if not len(blockmsg): # No more header blocks left break blocks.append(blockmsg) container.set_payload(blocks) elif container.get_main_type() == 'message': # Create a container for the payload, but watch out for there not # being any headers left try: msg = self.parse(fp) except Errors.HeaderParseError: msg = self._class() self._parsebody(msg, fp) container.attach(msg) else: container.set_payload(fp.read()) | f6caeba03a59944602f7c0eec69c9f275f9608eb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f6caeba03a59944602f7c0eec69c9f275f9608eb/Parser.py |
window.do_activate(modifiers & 1, event) | window.do_activate(message & 1, event) | def do_suspendresume(self, event): (what, message, when, where, modifiers) = event wid = FrontWindow() if wid and self._windows.has_key(wid): window = self._windows[wid] window.do_activate(modifiers & 1, event) | 1a5eb04d479320fdf01829dfc8e35adf789cc837 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1a5eb04d479320fdf01829dfc8e35adf789cc837/FrameWork.py |
verify(u'\u20ac'.encode('utf-8') == \ ''.join((chr(0xe2), chr(0x82), chr(0xac))) ) verify(u'\ud800\udc02'.encode('utf-8') == \ ''.join((chr(0xf0), chr(0x90), chr(0x80), chr(0x82))) ) verify(u'\ud84d\udc56'.encode('utf-8') == \ ''.join((chr(0xf0), chr(0xa3), chr(0x91), chr(0x96))) ) | verify(u'\u20ac'.encode('utf-8') == '\xe2\x82\xac') verify(u'\ud800\udc02'.encode('utf-8') == '\xf0\x90\x80\x82') verify(u'\ud84d\udc56'.encode('utf-8') == '\xf0\xa3\x91\x96') verify(u'\ud800'.encode('utf-8') == '\xed\xa0\x80') verify(u'\udc00'.encode('utf-8') == '\xed\xb0\x80') verify((u'\ud800\udc02'*1000).encode('utf-8') == '\xf0\x90\x80\x82'*1000) | def __str__(self): return self.x | 3688a882d36fe60be85a9dc8a54d033de356da31 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3688a882d36fe60be85a9dc8a54d033de356da31/test_unicode.py |
verify(unicode(''.join((chr(0xf0), chr(0xa3), chr(0x91), chr(0x96))), 'utf-8') == u'\U00023456' ) verify(unicode(''.join((chr(0xf0), chr(0x90), chr(0x80), chr(0x82))), 'utf-8') == u'\U00010002' ) verify(unicode(''.join((chr(0xe2), chr(0x82), chr(0xac))), 'utf-8') == u'\u20ac' ) | verify(unicode('\xf0\xa3\x91\x96', 'utf-8') == u'\U00023456' ) verify(unicode('\xf0\x90\x80\x82', 'utf-8') == u'\U00010002' ) verify(unicode('\xe2\x82\xac', 'utf-8') == u'\u20ac' ) | def __str__(self): return self.x | 3688a882d36fe60be85a9dc8a54d033de356da31 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3688a882d36fe60be85a9dc8a54d033de356da31/test_unicode.py |
def test_bad_sys_path(self): import sys orig_path = sys.path coverage = hotshot._hotshot.coverage try: # verify we require a list for sys.path sys.path = 'abc' self.assertRaises(RuntimeError, coverage, test_support.TESTFN) # verify sys.path exists del sys.path self.assertRaises(RuntimeError, coverage, test_support.TESTFN) finally: sys.path = orig_path | df44ab7b1cfb97b29712f40db422f27b2d8d1838 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/df44ab7b1cfb97b29712f40db422f27b2d8d1838/test_hotshot.py |
||
while 1: | depth = 0 while depth < 10: depth = depth + 1 | def get(self, section, option, raw=0, vars=None): """Get an option value for a given section. | 72ce85823cb9da79aa2663fd5d6eeecb3dad7b9c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/72ce85823cb9da79aa2663fd5d6eeecb3dad7b9c/ConfigParser.py |
def __init__(self, display=1, logdir=None, context=5, file=None): | def __init__(self, display=1, logdir=None, context=5, file=None, format="html"): | def __init__(self, display=1, logdir=None, context=5, file=None): self.display = display # send tracebacks to browser if true self.logdir = logdir # log tracebacks to files if not None self.context = context # number of source code lines per frame self.file = file or sys.stdout # place to send the output | 364ca40c2a053718f67c2032769de1f1fd76bb22 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/364ca40c2a053718f67c2032769de1f1fd76bb22/cgitb.py |
self.file.write(reset()) | if self.format == "html": self.file.write(reset()) formatter = (self.format=="html") and html or text plain = False | def handle(self, info=None): info = info or sys.exc_info() self.file.write(reset()) | 364ca40c2a053718f67c2032769de1f1fd76bb22 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/364ca40c2a053718f67c2032769de1f1fd76bb22/cgitb.py |
text, doc = 0, html(info, self.context) | doc = formatter(info, self.context) | def handle(self, info=None): info = info or sys.exc_info() self.file.write(reset()) | 364ca40c2a053718f67c2032769de1f1fd76bb22 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/364ca40c2a053718f67c2032769de1f1fd76bb22/cgitb.py |
text, doc = 1, ''.join(traceback.format_exception(*info)) | doc = ''.join(traceback.format_exception(*info)) plain = True | def handle(self, info=None): info = info or sys.exc_info() self.file.write(reset()) | 364ca40c2a053718f67c2032769de1f1fd76bb22 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/364ca40c2a053718f67c2032769de1f1fd76bb22/cgitb.py |
if text: | if plain: | def handle(self, info=None): info = info or sys.exc_info() self.file.write(reset()) | 364ca40c2a053718f67c2032769de1f1fd76bb22 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/364ca40c2a053718f67c2032769de1f1fd76bb22/cgitb.py |
(fd, path) = tempfile.mkstemp(suffix=['.html', '.txt'][text], dir=self.logdir) | suffix = ['.html', '.txt'][self.format=="html"] (fd, path) = tempfile.mkstemp(suffix=suffix, dir=self.logdir) | def handle(self, info=None): info = info or sys.exc_info() self.file.write(reset()) | 364ca40c2a053718f67c2032769de1f1fd76bb22 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/364ca40c2a053718f67c2032769de1f1fd76bb22/cgitb.py |
Form.form({key: value}) | Form.form(self, {key: value}) | def __setitem__(self, key, value): Form.form({key: value}) | 49fa2bdaa124e99c62ea901c8151eaa064f79c6d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/49fa2bdaa124e99c62ea901c8151eaa064f79c6d/Tix.py |
return self.tk.call(self.stylename, 'cget', '-%s'%key, value) | return self.tk.call(self.stylename, 'cget', '-%s'%key) | def __getitem__(self,key): return self.tk.call(self.stylename, 'cget', '-%s'%key, value) | 49fa2bdaa124e99c62ea901c8151eaa064f79c6d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/49fa2bdaa124e99c62ea901c8151eaa064f79c6d/Tix.py |
lexer.wordchars = lexer.wordchars + '.' | lexer.wordchars = lexer.wordchars + '.-@' | def __init__(self, file=None): if not file: file = os.path.join(os.environ['HOME'], ".netrc") try: fp = open(file) except: return None self.hosts = {} self.macros = {} lexer = shlex.shlex(fp) lexer.wordchars = lexer.wordchars + '.' while 1: # Look for a machine, default, or macdef top-level keyword toplevel = tt = lexer.get_token() if tt == '' or tt == None: break elif tt == 'machine': entryname = lexer.get_token() elif tt == 'default': entryname = 'default' elif tt == 'macdef': # Just skip to end of macdefs entryname = lexer.get_token() self.macros[entryname] = [] lexer.whitepace = ' \t' while 1: line = lexer.instream.readline() if not line or line == '\012' and tt == '\012': lexer.whitepace = ' \t\r\n' break tt = line self.macros[entryname].append(line) else: raise SyntaxError, "bad toplevel token %s, file %s, line %d" \ % (tt, file, lexer.lineno) | dfbd4c769516f750fb58cc819c7cdfa1592cf3e3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dfbd4c769516f750fb58cc819c7cdfa1592cf3e3/netrc.py |
exec("""def __%(method)s__(self, *args): | exec """def __%(method)s__(self, *args): | exec("""def __%(method)s__(self, *args): print "__%(method)s__:", args | f317a18a4ac6bcdd9b31295af04d27b549c4126a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f317a18a4ac6bcdd9b31295af04d27b549c4126a/test_class.py |
"""%locals(), AllTests.__dict__); | """%locals() in AllTests.__dict__ | exec("""def __%(method)s__(self, *args): print "__%(method)s__:", args | f317a18a4ac6bcdd9b31295af04d27b549c4126a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f317a18a4ac6bcdd9b31295af04d27b549c4126a/test_class.py |
mime_header = regex.compile('\\([ \t(]\\)\\([-a-zA-Z0-9_+]*[\240-\377][-a-zA-Z0-9_+\240-\377]*\\)\\([ \t)]\\|$\\)') | mime_header = regex.compile('\\([ \t(]\\|^\\)\\([-a-zA-Z0-9_+]*[\240-\377][-a-zA-Z0-9_+\240-\377]*\\)\\([ \t)]\\|$\\)') | def mime_encode(line, header): '''Code a single line as quoted-printable. If header is set, quote some extra characters.''' if header: reg = mime_header_char else: reg = mime_char newline = '' if len(line) >= 5 and line[:5] == 'From ': # quote 'From ' at the start of a line for stupid mailers newline = string.upper('=%02x' % ord('F')) line = line[1:] while 1: i = reg.search(line) if i < 0: break newline = newline + line[:i] + \ string.upper('=%02x' % ord(line[i])) line = line[i+1:] line = newline + line newline = '' while len(line) >= 75: i = 73 while line[i] == '=' or line[i-1] == '=': i = i - 1 i = i + 1 newline = newline + line[:i] + '=\n' line = line[i:] return newline + line | 68ded217f72722bb06453b6c36415a8ba2a5864f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/68ded217f72722bb06453b6c36415a8ba2a5864f/mimify.py |
return | return True | 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) | 8d562e6b4f80c248e7eee319f02161d4d2b69b4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8d562e6b4f80c248e7eee319f02161d4d2b69b4f/Wapplication.py |
return | return True | 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) | 8d562e6b4f80c248e7eee319f02161d4d2b69b4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8d562e6b4f80c248e7eee319f02161d4d2b69b4f/Wapplication.py |
self.scriptswalk(path, submenu, done) | if not self.scriptswalk(path, submenu, done): return False | 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) | 8d562e6b4f80c248e7eee319f02161d4d2b69b4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8d562e6b4f80c248e7eee319f02161d4d2b69b4f/Wapplication.py |
if i < 0: return None data[0] = data[0][i+1:] | if i >= 0: data[0] = data[0][i+1:] | def parsedate_tz(data): """Convert a date string to a time tuple. Accounts for military timezones. """ data = data.split() # The FWS after the comma after the day-of-week is optional, so search and # adjust for this. if data[0].endswith(',') or data[0].lower() in _daynames: # There's a dayname here. Skip it del data[0] else: i = data[0].rfind(',') if i < 0: return None data[0] = data[0][i+1:] if len(data) == 3: # RFC 850 date, deprecated stuff = data[0].split('-') if len(stuff) == 3: data = stuff + data[1:] if len(data) == 4: s = data[3] i = s.find('+') if i > 0: data[3:] = [s[:i], s[i+1:]] else: data.append('') # Dummy tz if len(data) < 5: return None data = data[:5] [dd, mm, yy, tm, tz] = data mm = mm.lower() if mm not in _monthnames: dd, mm = mm, dd.lower() if mm not in _monthnames: return None mm = _monthnames.index(mm) + 1 if mm > 12: mm -= 12 if dd[-1] == ',': dd = dd[:-1] i = yy.find(':') if i > 0: yy, tm = tm, yy if yy[-1] == ',': yy = yy[:-1] if not yy[0].isdigit(): yy, tz = tz, yy if tm[-1] == ',': tm = tm[:-1] tm = tm.split(':') if len(tm) == 2: [thh, tmm] = tm tss = '0' elif len(tm) == 3: [thh, tmm, tss] = tm else: return None try: yy = int(yy) dd = int(dd) thh = int(thh) tmm = int(tmm) tss = int(tss) except ValueError: return None tzoffset = None tz = tz.upper() if _timezones.has_key(tz): tzoffset = _timezones[tz] else: try: tzoffset = int(tz) except ValueError: pass # Convert a timezone offset into seconds ; -0500 -> -18000 if tzoffset: if tzoffset < 0: tzsign = -1 tzoffset = -tzoffset else: tzsign = 1 tzoffset = tzsign * ( (tzoffset/100)*3600 + (tzoffset % 100)*60) tuple = (yy, mm, dd, thh, tmm, tss, 0, 0, 0, tzoffset) return tuple | b5dc39f02c47d561110171e014c340844f4a52b3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b5dc39f02c47d561110171e014c340844f4a52b3/_parseaddr.py |
def __init__(self, filename, etype, evalue): | def __init__(self, filename, (type, value, tb)): | def __init__(self, filename, etype, evalue): self.filename = filename self.etype = etype self.evalue = evalue if type(etype) is types.ClassType: etype = etype.__name__ self.args = '%s: %s' % (etype, evalue) | 37f7b38eb6247564c00c8a355ab12268e8486c4e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/37f7b38eb6247564c00c8a355ab12268e8486c4e/pydoc.py |
self.etype = etype self.evalue = evalue if type(etype) is types.ClassType: etype = etype.__name__ self.args = '%s: %s' % (etype, evalue) | self.type = type self.value = value self.tb = tb def __str__(self): t = self.type if type(t) is types.ClassType: t = t.__name__ return 'problem in %s - %s: %s' % (self.filename, t, self.value) | def __init__(self, filename, etype, evalue): self.filename = filename self.etype = etype self.evalue = evalue if type(etype) is types.ClassType: etype = etype.__name__ self.args = '%s: %s' % (etype, evalue) | 37f7b38eb6247564c00c8a355ab12268e8486c4e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/37f7b38eb6247564c00c8a355ab12268e8486c4e/pydoc.py |
raise DocImportError(path, sys.exc_type, sys.exc_value) | raise DocImportError(path, sys.exc_info()) | def importfile(path): """Import a Python source file or compiled file given its path.""" magic = imp.get_magic() file = open(path, 'r') if file.read(len(magic)) == magic: kind = imp.PY_COMPILED else: kind = imp.PY_SOURCE file.close() filename = os.path.basename(path) name, ext = os.path.splitext(filename) file = open(path, 'r') try: module = imp.load_module(name, file, path, (ext, 'r', kind)) except: raise DocImportError(path, sys.exc_type, sys.exc_value) file.close() return module | 37f7b38eb6247564c00c8a355ab12268e8486c4e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/37f7b38eb6247564c00c8a355ab12268e8486c4e/pydoc.py |
init = os.path.join(path, '__init__.py') initc = os.path.join(path, '__init__.pyc') if os.path.isfile(init) or os.path.isfile(initc): return 1 | for ext in ['.py', '.pyc', '.pyo']: if os.path.isfile(os.path.join(path, '__init__' + ext)): return 1 | def ispackage(path): """Guess whether a path refers to a package directory.""" if os.path.isdir(path): init = os.path.join(path, '__init__.py') initc = os.path.join(path, '__init__.pyc') if os.path.isfile(init) or os.path.isfile(initc): return 1 | 37f7b38eb6247564c00c8a355ab12268e8486c4e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/37f7b38eb6247564c00c8a355ab12268e8486c4e/pydoc.py |
def document(self, object, *args): | def document(self, object, name=None, *args): | def document(self, object, *args): """Generate documentation for an object.""" args = (object,) + args if inspect.ismodule(object): return apply(self.docmodule, args) if inspect.isclass(object): return apply(self.docclass, args) if inspect.isroutine(object): return apply(self.docroutine, args) raise TypeError, "don't know how to document objects of type " + \ type(object).__name__ | 37f7b38eb6247564c00c8a355ab12268e8486c4e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/37f7b38eb6247564c00c8a355ab12268e8486c4e/pydoc.py |
args = (object,) + args | args = (object, name) + args | def document(self, object, *args): """Generate documentation for an object.""" args = (object,) + args if inspect.ismodule(object): return apply(self.docmodule, args) if inspect.isclass(object): return apply(self.docclass, args) if inspect.isroutine(object): return apply(self.docroutine, args) raise TypeError, "don't know how to document objects of type " + \ type(object).__name__ | 37f7b38eb6247564c00c8a355ab12268e8486c4e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/37f7b38eb6247564c00c8a355ab12268e8486c4e/pydoc.py |
raise TypeError, "don't know how to document objects of type " + \ type(object).__name__ | return apply(self.docother, args) def fail(self, object, name=None, *args): """Raise an exception for unimplemented types.""" message = "don't know how to document object%s of type %s" % ( name and ' ' + repr(name), type(object).__name__) raise TypeError, message docmodule = docclass = docroutine = docother = fail | def document(self, object, *args): """Generate documentation for an object.""" args = (object,) + args if inspect.ismodule(object): return apply(self.docmodule, args) if inspect.isclass(object): return apply(self.docclass, args) if inspect.isroutine(object): return apply(self.docroutine, args) raise TypeError, "don't know how to document objects of type " + \ type(object).__name__ | 37f7b38eb6247564c00c8a355ab12268e8486c4e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/37f7b38eb6247564c00c8a355ab12268e8486c4e/pydoc.py |
self.maxstring = self.maxother = 50 | self.maxstring = self.maxother = 100 | def __init__(self): Repr.__init__(self) self.maxlist = self.maxtuple = self.maxdict = 10 self.maxstring = self.maxother = 50 | 37f7b38eb6247564c00c8a355ab12268e8486c4e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/37f7b38eb6247564c00c8a355ab12268e8486c4e/pydoc.py |
result = Repr.repr(self, object) return result | return Repr.repr(self, object) | def repr(self, object): result = Repr.repr(self, object) return result | 37f7b38eb6247564c00c8a355ab12268e8486c4e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/37f7b38eb6247564c00c8a355ab12268e8486c4e/pydoc.py |
return cram(stripid(repr(x)), self.maxstring) | return self.escape(cram(stripid(repr(x)), self.maxstring)) | def repr_instance(self, x, level): try: return cram(stripid(repr(x)), self.maxstring) except: return self.escape('<%s instance>' % x.__class__.__name__) | 37f7b38eb6247564c00c8a355ab12268e8486c4e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/37f7b38eb6247564c00c8a355ab12268e8486c4e/pydoc.py |
def multicolumn(self, list, format, cols=4): """Format a list of items into a multi-column list.""" result = '' rows = (len(list)+cols-1)/cols | 37f7b38eb6247564c00c8a355ab12268e8486c4e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/37f7b38eb6247564c00c8a355ab12268e8486c4e/pydoc.py |
||
def heading(self, title, fgcol, bgcol, extras=''): """Format a page heading.""" return """ <p><table width="100%%" cellspacing=0 cellpadding=0 border=0> <tr bgcolor="%s"><td> </td> <td valign=bottom><small><small><br></small></small ><font color="%s" face="helvetica"><br> %s</font></td ><td align=right valign=bottom ><font color="%s" face="helvetica">%s</font></td><td> </td></tr></table> """ % (bgcol, fgcol, title, fgcol, extras or ' ') def section(self, title, fgcol, bgcol, contents, width=20, prelude='', marginalia=None, gap=' '): """Format a section with a heading.""" if marginalia is None: marginalia = ' ' * width result = """ <p><table width="100%%" cellspacing=0 cellpadding=0 border=0> <tr bgcolor="%s"><td rowspan=2> </td> <td colspan=3 valign=bottom><small><small><br></small></small ><font color="%s" face="helvetica, arial"> %s</font></td></tr> """ % (bgcol, fgcol, title) if prelude: result = result + """ <tr><td bgcolor="%s">%s</td> <td bgcolor="%s" colspan=2>%s</td></tr> """ % (bgcol, marginalia, bgcol, prelude) result = result + """ <tr><td bgcolor="%s">%s</td><td>%s</td> """ % (bgcol, marginalia, gap) result = result + '<td width="100%%">%s</td></tr></table>' % contents return result def bigsection(self, title, *args): """Format a section with a big heading.""" title = '<big><strong>%s</strong></big>' % title return apply(self.section, (title,) + args) | def small(self, text): return '<small>%s</small>' % text def grey(self, text): return '<font color=" | def heading(self, title, fgcol, bgcol, extras=''): """Format a page heading.""" return """ | 37f7b38eb6247564c00c8a355ab12268e8486c4e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/37f7b38eb6247564c00c8a355ab12268e8486c4e/pydoc.py |
return '<font color=" | return self.grey(name) | def modpkglink(self, (name, path, ispackage, shadowed)): """Make a link for a module or package to display in an index.""" if shadowed: return '<font color="#909090">%s</font>' % name if path: url = '%s.%s.html' % (path, name) else: url = '%s.html' % name if ispackage: text = '<strong>%s</strong> (package)' % name else: text = name return '<a href="%s">%s</a>' % (url, text) | 37f7b38eb6247564c00c8a355ab12268e8486c4e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/37f7b38eb6247564c00c8a355ab12268e8486c4e/pydoc.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.