rem
stringlengths 1
322k
| add
stringlengths 0
2.05M
| context
stringlengths 4
228k
| meta
stringlengths 156
215
|
---|---|---|---|
"target version can only be" + short_version | "target version can only be %s, or the '--skip_build'" \ " option must be specified" % (short_version,) | def finalize_options (self): if self.bdist_dir is None: bdist_base = self.get_finalized_command('bdist').bdist_base self.bdist_dir = os.path.join(bdist_base, 'wininst') if not self.target_version: self.target_version = "" if self.distribution.has_ext_modules(): short_version = get_python_version() if self.target_version and self.target_version != short_version: raise DistutilsOptionError, \ "target version can only be" + short_version self.target_version = short_version | a19cdad6dc2815f6044c56601e8dd81d9c219631 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a19cdad6dc2815f6044c56601e8dd81d9c219631/bdist_wininst.py |
build_info = "Build %s with distutils-%s" % \ | build_info = "Built %s with distutils-%s" % \ | def get_inidata (self): # Return data describing the installation. | a19cdad6dc2815f6044c56601e8dd81d9c219631 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a19cdad6dc2815f6044c56601e8dd81d9c219631/bdist_wininst.py |
self.detect_ctypes() | self.detect_ctypes(inc_dirs, lib_dirs) | 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') | 9176fc1466c8a896ab57b054bd426e63770e2cfa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9176fc1466c8a896ab57b054bd426e63770e2cfa/setup.py |
(srcdir,) = sysconfig.get_config_vars('srcdir') ffi_builddir = os.path.join(self.build_temp, 'libffi') ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules', '_ctypes', 'libffi')) ffi_configfile = os.path.join(ffi_builddir, 'fficonfig.py') if self.force or not os.path.exists(ffi_configfile): from distutils.dir_util import mkpath mkpath(ffi_builddir) config_args = [] cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \ % (ffi_builddir, ffi_srcdir, " ".join(config_args)) res = os.system(cmd) if res or not os.path.exists(ffi_configfile): print "Failed to configure _ctypes module" return False fficonfig = {} execfile(ffi_configfile, globals(), fficonfig) ffi_srcdir = os.path.join(fficonfig['ffi_srcdir'], 'src') self.compiler.src_extensions.append('.S') include_dirs = [os.path.join(ffi_builddir, 'include'), ffi_builddir, ffi_srcdir] extra_compile_args = fficonfig['ffi_cflags'].split() ext.sources.extend(fficonfig['ffi_sources']) ext.include_dirs.extend(include_dirs) ext.extra_compile_args.extend(extra_compile_args) | if not self.use_system_libffi: (srcdir,) = sysconfig.get_config_vars('srcdir') ffi_builddir = os.path.join(self.build_temp, 'libffi') ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules', '_ctypes', 'libffi')) ffi_configfile = os.path.join(ffi_builddir, 'fficonfig.py') if self.force or not os.path.exists(ffi_configfile): from distutils.dir_util import mkpath mkpath(ffi_builddir) config_args = [] cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \ % (ffi_builddir, ffi_srcdir, " ".join(config_args)) res = os.system(cmd) if res or not os.path.exists(ffi_configfile): print "Failed to configure _ctypes module" return False fficonfig = {} execfile(ffi_configfile, globals(), fficonfig) ffi_srcdir = os.path.join(fficonfig['ffi_srcdir'], 'src') self.compiler.src_extensions.append('.S') include_dirs = [os.path.join(ffi_builddir, 'include'), ffi_builddir, ffi_srcdir] extra_compile_args = fficonfig['ffi_cflags'].split() ext.sources.extend(fficonfig['ffi_sources']) ext.include_dirs.extend(include_dirs) ext.extra_compile_args.extend(extra_compile_args) | def configure_ctypes(self, ext): (srcdir,) = sysconfig.get_config_vars('srcdir') ffi_builddir = os.path.join(self.build_temp, 'libffi') ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules', '_ctypes', 'libffi')) ffi_configfile = os.path.join(ffi_builddir, 'fficonfig.py') | 9176fc1466c8a896ab57b054bd426e63770e2cfa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9176fc1466c8a896ab57b054bd426e63770e2cfa/setup.py |
def detect_ctypes(self): | def detect_ctypes(self, inc_dirs, lib_dirs): self.use_system_libffi = False | def detect_ctypes(self): include_dirs = [] extra_compile_args = [] sources = ['_ctypes/_ctypes.c', '_ctypes/callbacks.c', '_ctypes/callproc.c', '_ctypes/stgdict.c', '_ctypes/cfield.c', '_ctypes/malloc_closure.c'] depends = ['_ctypes/ctypes.h'] | 9176fc1466c8a896ab57b054bd426e63770e2cfa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9176fc1466c8a896ab57b054bd426e63770e2cfa/setup.py |
ssl_incs = find_file('openssl/ssl.h', inc_dirs, | ssl_incs = find_file('openssl/ssl.h', self.compiler.include_dirs, | 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') | 210f5585d272d6f26e1ba64dbd84b726c69f899d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/210f5585d272d6f26e1ba64dbd84b726c69f899d/setup.py |
exec('def f(a, a): pass') | exec 'def f(a, a): pass' | exec('def f(a, a): pass') | 121b6eb018a839bfaf6af22ceb1a9793e62428df /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/121b6eb018a839bfaf6af22ceb1a9793e62428df/test_compile.py |
exec('def f(a = 0, a = 1): pass') | exec 'def f(a = 0, a = 1): pass' | exec('def f(a = 0, a = 1): pass') | 121b6eb018a839bfaf6af22ceb1a9793e62428df /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/121b6eb018a839bfaf6af22ceb1a9793e62428df/test_compile.py |
exec('def f(a): global a; a = 1') | exec 'def f(a): global a; a = 1' | exec('def f(a): global a; a = 1') | 121b6eb018a839bfaf6af22ceb1a9793e62428df /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/121b6eb018a839bfaf6af22ceb1a9793e62428df/test_compile.py |
self.assertEqual(binascii.a2b_qp("= "), "") | self.assertEqual(binascii.a2b_qp("= "), "= ") | def test_qp(self): # A test for SF bug 534347 (segfaults without the proper fix) try: binascii.a2b_qp("", **{1:1}) except TypeError: pass else: self.fail("binascii.a2b_qp(**{1:1}) didn't raise TypeError") self.assertEqual(binascii.a2b_qp("= "), "") self.assertEqual(binascii.a2b_qp("=="), "=") self.assertEqual(binascii.a2b_qp("=AX"), "=AX") self.assertRaises(TypeError, binascii.b2a_qp, foo="bar") self.assertEqual(binascii.a2b_qp("=00\r\n=00"), "\x00\r\n\x00") self.assertEqual( binascii.b2a_qp("\xff\r\n\xff\n\xff"), "=FF\r\n=FF\r\n=FF" ) self.assertEqual( binascii.b2a_qp("0"*75+"\xff\r\n\xff\r\n\xff"), "0"*75+"=\r\n=FF\r\n=FF\r\n=FF" ) | 25aabf4cbb7ff8d1a38f8ef4602a409c00474a30 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/25aabf4cbb7ff8d1a38f8ef4602a409c00474a30/test_binascii.py |
if _os.name == "nt": | if _os.name in ("nt", "ce"): | def wstring_at(ptr, size=0): """wstring_at(addr[, size]) -> string | 09a6f6aad26ddda9a8b8ffe186fb48d4235e7e0d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/09a6f6aad26ddda9a8b8ffe186fb48d4235e7e0d/__init__.py |
result = -2147221231 | def DllGetClassObject(rclsid, riid, ppv): # First ask ctypes.com.server than comtypes.server for the # class object. | 09a6f6aad26ddda9a8b8ffe186fb48d4235e7e0d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/09a6f6aad26ddda9a8b8ffe186fb48d4235e7e0d/__init__.py |
|
ctcom = __import__("ctypes.com.server", globals(), locals(), ['*']) | ccom = __import__("comtypes.server.inprocserver", globals(), locals(), ['*']) | def DllGetClassObject(rclsid, riid, ppv): # First ask ctypes.com.server than comtypes.server for the # class object. | 09a6f6aad26ddda9a8b8ffe186fb48d4235e7e0d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/09a6f6aad26ddda9a8b8ffe186fb48d4235e7e0d/__init__.py |
pass | return -2147221231 | def DllGetClassObject(rclsid, riid, ppv): # First ask ctypes.com.server than comtypes.server for the # class object. | 09a6f6aad26ddda9a8b8ffe186fb48d4235e7e0d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/09a6f6aad26ddda9a8b8ffe186fb48d4235e7e0d/__init__.py |
result = ctcom.DllGetClassObject(rclsid, riid, ppv) if result == -2147221231: try: ccom = __import__("comtypes.server", globals(), locals(), ['*']) except ImportError: pass else: result = ccom.DllGetClassObject(rclsid, riid, ppv) return result | return ccom.DllGetClassObject(rclsid, riid, ppv) | def DllGetClassObject(rclsid, riid, ppv): # First ask ctypes.com.server than comtypes.server for the # class object. | 09a6f6aad26ddda9a8b8ffe186fb48d4235e7e0d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/09a6f6aad26ddda9a8b8ffe186fb48d4235e7e0d/__init__.py |
result = 0 | def DllCanUnloadNow(): # First ask ctypes.com.server than comtypes.server if we can unload or not. # trick py2exe by doing dynamic imports result = 0 # S_OK try: ctcom = __import__("ctypes.com.server", globals(), locals(), ['*']) except ImportError: pass else: result = ctcom.DllCanUnloadNow() if result != 0: # != S_OK return result | 09a6f6aad26ddda9a8b8ffe186fb48d4235e7e0d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/09a6f6aad26ddda9a8b8ffe186fb48d4235e7e0d/__init__.py |
|
ctcom = __import__("ctypes.com.server", globals(), locals(), ['*']) | ccom = __import__("comtypes.server.inprocserver", globals(), locals(), ['*']) | def DllCanUnloadNow(): # First ask ctypes.com.server than comtypes.server if we can unload or not. # trick py2exe by doing dynamic imports result = 0 # S_OK try: ctcom = __import__("ctypes.com.server", globals(), locals(), ['*']) except ImportError: pass else: result = ctcom.DllCanUnloadNow() if result != 0: # != S_OK return result | 09a6f6aad26ddda9a8b8ffe186fb48d4235e7e0d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/09a6f6aad26ddda9a8b8ffe186fb48d4235e7e0d/__init__.py |
pass else: result = ctcom.DllCanUnloadNow() if result != 0: return result try: ccom = __import__("comtypes.server", globals(), locals(), ['*']) except ImportError: return result try: return ccom.DllCanUnloadNow() except AttributeError: pass return result | return 0 return ccom.DllCanUnloadNow() | def DllCanUnloadNow(): # First ask ctypes.com.server than comtypes.server if we can unload or not. # trick py2exe by doing dynamic imports result = 0 # S_OK try: ctcom = __import__("ctypes.com.server", globals(), locals(), ['*']) except ImportError: pass else: result = ctcom.DllCanUnloadNow() if result != 0: # != S_OK return result | 09a6f6aad26ddda9a8b8ffe186fb48d4235e7e0d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/09a6f6aad26ddda9a8b8ffe186fb48d4235e7e0d/__init__.py |
ef = codecs.EncodedFile(f, 'utf-16', 'utf-8') | ef = codecs.EncodedFile(f, 'utf-16-le', 'utf-8') | def test_basic(self): f = StringIO.StringIO('\xed\x95\x9c\n\xea\xb8\x80') ef = codecs.EncodedFile(f, 'utf-16', 'utf-8') self.assertEquals(ef.read(), '\xff\xfe\\\xd5\n\x00\x00\xae') | b8205a11882161968fe9b67871d4000c4b3efb08 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b8205a11882161968fe9b67871d4000c4b3efb08/test_codecs.py |
eq(msg.epilogue, '\n\n') | eq(msg.epilogue, '\n') | def test_mondo_message(self): eq = self.assertEqual neq = self.ndiffAssertEqual msg = self._msgobj('crispin-torture.txt') payload = msg.get_payload() eq(type(payload), ListType) eq(len(payload), 12) eq(msg.preamble, None) eq(msg.epilogue, '\n\n') # Probably the best way to verify the message is parsed correctly is to # dump its structure and compare it against the known structure. fp = StringIO() _structure(msg, fp=fp) neq(fp.getvalue(), """\ | 1b643596a88d4169810116bf0f0d28560896c828 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1b643596a88d4169810116bf0f0d28560896c828/test_email_torture.py |
"""Signals the start of an element. | """Signals the start of an element in non-namespace mode. The name parameter contains the raw XML 1.0 name of the element type as a string and the attrs parameter holds an instance of the Attributes class containing the attributes of the element.""" def endElement(self, name): """Signals the end of an element in non-namespace mode. The name parameter contains the name of the element type, just as with the startElement event.""" def startElementNS(self, name, qname, attrs): """Signals the start of an element in namespace mode. | def startElement(self, name, attrs): """Signals the start of an element. | b4d6bb098776de48275c2e422c608ddfd85f4198 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b4d6bb098776de48275c2e422c608ddfd85f4198/handler.py |
(uri ,localname) tuple, the qname parameter the raw XML 1.0 | (uri, localname) tuple, the qname parameter the raw XML 1.0 | def startElement(self, name, attrs): """Signals the start of an element. | b4d6bb098776de48275c2e422c608ddfd85f4198 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b4d6bb098776de48275c2e422c608ddfd85f4198/handler.py |
def endElement(self, name ): """Signals the end of an element. | def endElementNS(self, name, qname): """Signals the end of an element in namespace mode. | def endElement(self, name ): """Signals the end of an element. | b4d6bb098776de48275c2e422c608ddfd85f4198 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b4d6bb098776de48275c2e422c608ddfd85f4198/handler.py |
as with the startElement event.""" | as with the startElementNS event.""" | def endElement(self, name ): """Signals the end of an element. | b4d6bb098776de48275c2e422c608ddfd85f4198 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b4d6bb098776de48275c2e422c608ddfd85f4198/handler.py |
return addinfourl(fp, headers, url) | return addinfourl(fp, headers, "https:" + url) | def open_https(self, url, data=None): """Use HTTPS protocol.""" import httplib user_passwd = None if type(url) is types.StringType: host, selector = splithost(url) if host: user_passwd, host = splituser(host) host = unquote(host) realhost = host else: host, selector = url urltype, rest = splittype(selector) url = rest user_passwd = None if urltype.lower() != 'https': realhost = None else: realhost, rest = splithost(rest) if realhost: user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) #print "proxy via https:", host, selector if not host: raise IOError, ('https error', 'no host given') if user_passwd: import base64 auth = base64.encodestring(user_passwd).strip() else: auth = None h = httplib.HTTPS(host, 0, key_file=self.key_file, cert_file=self.cert_file) if data is not None: h.putrequest('POST', selector) h.putheader('Content-type', 'application/x-www-form-urlencoded') h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', selector) if auth: h.putheader('Authorization: Basic %s' % auth) if realhost: h.putheader('Host', realhost) for args in self.addheaders: apply(h.putheader, args) h.endheaders() if data is not None: h.send(data) errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, url) else: if data is None: return self.http_error(url, fp, errcode, errmsg, headers) else: return self.http_error(url, fp, errcode, errmsg, headers, data) | b931bf3c55613a58cf403f7e7b04a5c69cfd0763 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b931bf3c55613a58cf403f7e7b04a5c69cfd0763/urllib.py |
class PyShell(MultiEditorWindow): | class PyShell(PyShellEditorWindow): | def write(self, s): # Override base class write self.tkconsole.console.write(s) | 5af7a72d8bc0b7308e2342bdd97bda6d0d190222 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5af7a72d8bc0b7308e2342bdd97bda6d0d190222/PyShell.py |
flist = FileList(root) MultiEditorWindow.__init__(self, flist, None, None) | flist = PyShellFileList(root) PyShellEditorWindow.__init__(self, flist, None, None) | def __init__(self, flist=None): self.interp = ModifiedInterpreter(self) if flist is None: root = Tk() fixwordbreaks(root) root.withdraw() flist = FileList(root) | 5af7a72d8bc0b7308e2342bdd97bda6d0d190222 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5af7a72d8bc0b7308e2342bdd97bda6d0d190222/PyShell.py |
reply = MultiEditorWindow.close(self) | reply = PyShellEditorWindow.close(self) | def close(self): # Extend base class method if self.executing: # XXX Need to ask a question here if not tkMessageBox.askokcancel( "Cancel?", "The program is still running; do you want to cancel it?", default="ok", master=self.text): return "cancel" self.canceled = 1 if self.reading: self.top.quit() return "cancel" reply = MultiEditorWindow.close(self) if reply != "cancel": # Restore std streams sys.stdout = sys.__stdout__ sys.stderr = sys.__stderr__ sys.stdin = sys.__stdin__ # Break cycles self.interp = None self.console = None return reply | 5af7a72d8bc0b7308e2342bdd97bda6d0d190222 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5af7a72d8bc0b7308e2342bdd97bda6d0d190222/PyShell.py |
def interact(self): | def begin(self): | def interact(self): self.resetoutput() self.write("Python %s on %s\n%s\n" % (sys.version, sys.platform, sys.copyright)) try: sys.ps1 except AttributeError: sys.ps1 = ">>> " self.showprompt() import Tkinter Tkinter._default_root = None self.top.mainloop() | 5af7a72d8bc0b7308e2342bdd97bda6d0d190222 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5af7a72d8bc0b7308e2342bdd97bda6d0d190222/PyShell.py |
flist = FileList(root) | flist = PyShellFileList(root) | def main(): global flist, root root = Tk() fixwordbreaks(root) root.withdraw() flist = FileList(root) if sys.argv[1:]: for filename in sys.argv[1:]: flist.open(filename) t = PyShell(flist) t.interact() | 5af7a72d8bc0b7308e2342bdd97bda6d0d190222 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5af7a72d8bc0b7308e2342bdd97bda6d0d190222/PyShell.py |
t.interact() | flist.pyshell = t t.begin() root.mainloop() | def main(): global flist, root root = Tk() fixwordbreaks(root) root.withdraw() flist = FileList(root) if sys.argv[1:]: for filename in sys.argv[1:]: flist.open(filename) t = PyShell(flist) t.interact() | 5af7a72d8bc0b7308e2342bdd97bda6d0d190222 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5af7a72d8bc0b7308e2342bdd97bda6d0d190222/PyShell.py |
i = i - len(argstr) | i = i - len(argstr) - 2 | def send(self, buffer): self.unfinished = self.unfinished + buffer i = 0 n = len(self.unfinished) while i < n: c = self.unfinished[i] i = i+1 if c != ESC: self.add_char(c) continue if i >= n: i = i-1 break c = self.unfinished[i] i = i+1 if c == 'c': self.reset() continue if c <> '[': self.msg('unrecognized: ESC %s', `c`) continue argstr = '' while i < n: c = self.unfinished[i] i = i+1 if c not in '0123456789;': break argstr = argstr + c else: i = i - len(argstr) break | 0b26a19a4f9088702fdef9b8a2e86b0db2217570 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0b26a19a4f9088702fdef9b8a2e86b0db2217570/vt100.py |
from Carbon import AE AE.AEInteractWithUser(50000000) | def quitevent(self, theAppleEvent, theReply): from Carbon import AE AE.AEInteractWithUser(50000000) self._quit() | 122152451e1bc7aaff69d28b8950afa7848c6de6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/122152451e1bc7aaff69d28b8950afa7848c6de6/PythonIDEMain.py |
|
veris(x, None) vereq((spam.spamlist,) + a, a1) | veris(x, spam.spamlist) vereq(a, a1) | def classmethods_in_c(): if verbose: print "Testing C-based class methods..." import xxsubtype as spam a = (1, 2, 3) d = {'abc': 123} x, a1, d1 = spam.spamlist.classmeth(*a, **d) veris(x, None) vereq((spam.spamlist,) + a, a1) vereq(d, d1) x, a1, d1 = spam.spamlist().classmeth(*a, **d) veris(x, None) vereq((spam.spamlist,) + a, a1) vereq(d, d1) | bca1cbc6f895c7f9f003877b1cfc0c649387ae1c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bca1cbc6f895c7f9f003877b1cfc0c649387ae1c/test_descr.py |
veris(x, None) vereq((spam.spamlist,) + a, a1) | veris(x, spam.spamlist) vereq(a, a1) | def classmethods_in_c(): if verbose: print "Testing C-based class methods..." import xxsubtype as spam a = (1, 2, 3) d = {'abc': 123} x, a1, d1 = spam.spamlist.classmeth(*a, **d) veris(x, None) vereq((spam.spamlist,) + a, a1) vereq(d, d1) x, a1, d1 = spam.spamlist().classmeth(*a, **d) veris(x, None) vereq((spam.spamlist,) + a, a1) vereq(d, d1) | bca1cbc6f895c7f9f003877b1cfc0c649387ae1c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bca1cbc6f895c7f9f003877b1cfc0c649387ae1c/test_descr.py |
for ordinal in (-100, 0x20000): | for ordinal in (-100, 0x200000): | def test_fixup(s): s2 = u'\ud800\udc01' test_lecmp(s, s2) s2 = u'\ud900\udc01' test_lecmp(s, s2) s2 = u'\uda00\udc01' test_lecmp(s, s2) s2 = u'\udb00\udc01' test_lecmp(s, s2) s2 = u'\ud800\udd01' test_lecmp(s, s2) s2 = u'\ud900\udd01' test_lecmp(s, s2) s2 = u'\uda00\udd01' test_lecmp(s, s2) s2 = u'\udb00\udd01' test_lecmp(s, s2) s2 = u'\ud800\ude01' test_lecmp(s, s2) s2 = u'\ud900\ude01' test_lecmp(s, s2) s2 = u'\uda00\ude01' test_lecmp(s, s2) s2 = u'\udb00\ude01' test_lecmp(s, s2) s2 = u'\ud800\udfff' test_lecmp(s, s2) s2 = u'\ud900\udfff' test_lecmp(s, s2) s2 = u'\uda00\udfff' test_lecmp(s, s2) s2 = u'\udb00\udfff' test_lecmp(s, s2) | 766e300eaaf8b8ca06a1e98e94fa1c5d1a33eba6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/766e300eaaf8b8ca06a1e98e94fa1c5d1a33eba6/test_unicode.py |
print '*** formatting u"%%c" % %i should give a ValueError' % ordinal | print '*** formatting u"%%c" %% %i should give a ValueError' % ordinal | def test_fixup(s): s2 = u'\ud800\udc01' test_lecmp(s, s2) s2 = u'\ud900\udc01' test_lecmp(s, s2) s2 = u'\uda00\udc01' test_lecmp(s, s2) s2 = u'\udb00\udc01' test_lecmp(s, s2) s2 = u'\ud800\udd01' test_lecmp(s, s2) s2 = u'\ud900\udd01' test_lecmp(s, s2) s2 = u'\uda00\udd01' test_lecmp(s, s2) s2 = u'\udb00\udd01' test_lecmp(s, s2) s2 = u'\ud800\ude01' test_lecmp(s, s2) s2 = u'\ud900\ude01' test_lecmp(s, s2) s2 = u'\uda00\ude01' test_lecmp(s, s2) s2 = u'\udb00\ude01' test_lecmp(s, s2) s2 = u'\ud800\udfff' test_lecmp(s, s2) s2 = u'\ud900\udfff' test_lecmp(s, s2) s2 = u'\uda00\udfff' test_lecmp(s, s2) s2 = u'\udb00\udfff' test_lecmp(s, s2) | 766e300eaaf8b8ca06a1e98e94fa1c5d1a33eba6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/766e300eaaf8b8ca06a1e98e94fa1c5d1a33eba6/test_unicode.py |
and socket.gethostbyname(host) in (localhost(), thishost()): | and socket.gethostbyname(host) in (localhost(), thishost()): | def open_local_file(self, url): """Use local file.""" import mimetypes, mimetools, StringIO mtype = mimetypes.guess_type(url)[0] headers = mimetools.Message(StringIO.StringIO( 'Content-Type: %s\n' % (mtype or 'text/plain'))) host, file = splithost(url) if not host: urlfile = file if file[:1] == '/': urlfile = 'file://' + file return addinfourl(open(url2pathname(file), '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(url2pathname(file), 'rb'), headers, urlfile) raise IOError, ('local file error', 'not on local host') | b49f88bfc122440e6b056b3c051ac3f928a1df92 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b49f88bfc122440e6b056b3c051ac3f928a1df92/urllib.py |
def http_error_302(self, url, fp, errcode, errmsg, headers, data=None): | def http_error_302(self, url, fp, errcode, errmsg, headers, data=None): | def http_error_302(self, url, fp, errcode, errmsg, headers, data=None): """Error 302 -- relocated (temporarily).""" # XXX The server can force infinite recursion here! if headers.has_key('location'): newurl = headers['location'] elif headers.has_key('uri'): newurl = headers['uri'] else: return void = fp.read() fp.close() # In case the server sent a relative URL, join with original: newurl = basejoin("http:" + url, newurl) if data is None: return self.open(newurl) else: return self.open(newurl, data) | b49f88bfc122440e6b056b3c051ac3f928a1df92 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b49f88bfc122440e6b056b3c051ac3f928a1df92/urllib.py |
def http_error_301(self, url, fp, errcode, errmsg, headers, data=None): | def http_error_301(self, url, fp, errcode, errmsg, headers, data=None): | def http_error_301(self, url, fp, errcode, errmsg, headers, data=None): """Error 301 -- also relocated (permanently).""" return self.http_error_302(url, fp, errcode, errmsg, headers, data) | b49f88bfc122440e6b056b3c051ac3f928a1df92 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b49f88bfc122440e6b056b3c051ac3f928a1df92/urllib.py |
def http_error_401(self, url, fp, errcode, errmsg, headers, data=None): | def http_error_401(self, url, fp, errcode, errmsg, headers, data=None): | def http_error_401(self, url, fp, errcode, errmsg, headers, data=None): """Error 401 -- authentication required. See this URL for a description of the basic authentication scheme: http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-v10-spec-00.txt""" if headers.has_key('www-authenticate'): stuff = headers['www-authenticate'] import re match = re.match('[ \t]*([^ \t]+)[ \t]+realm="([^"]*)"', stuff) if match: scheme, realm = match.groups() if string.lower(scheme) == 'basic': name = 'retry_' + self.type + '_basic_auth' if data is None: return getattr(self,name)(url, realm) else: return getattr(self,name)(url, realm, data) | b49f88bfc122440e6b056b3c051ac3f928a1df92 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b49f88bfc122440e6b056b3c051ac3f928a1df92/urllib.py |
def retry_http_basic_auth(self, url, realm, data=None): host, selector = splithost(url) i = string.find(host, '@') + 1 host = host[i:] user, passwd = self.get_user_passwd(host, realm, i) if not (user or passwd): return None host = user + ':' + passwd + '@' + host newurl = 'http://' + host + selector if data is None: return self.open(newurl) else: return self.open(newurl, data) | b49f88bfc122440e6b056b3c051ac3f928a1df92 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b49f88bfc122440e6b056b3c051ac3f928a1df92/urllib.py |
||
host)) | host)) | def prompt_user_passwd(self, host, realm): """Override this in a GUI environment!""" import getpass try: user = raw_input("Enter username for %s at %s: " % (realm, host)) passwd = getpass.getpass("Enter password for %s in %s at %s: " % (user, realm, host)) return user, passwd except KeyboardInterrupt: print return None, None | b49f88bfc122440e6b056b3c051ac3f928a1df92 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b49f88bfc122440e6b056b3c051ac3f928a1df92/urllib.py |
self.endtransfer), conn[1]) | self.endtransfer), conn[1]) | def retrfile(self, file, type): import ftplib self.endtransfer() if type in ('d', 'D'): cmd = 'TYPE A'; isdir = 1 else: cmd = 'TYPE ' + type; isdir = 0 try: self.ftp.voidcmd(cmd) except ftplib.all_errors: self.init() self.ftp.voidcmd(cmd) conn = None if file and not isdir: # Use nlst to see if the file exists at all try: self.ftp.nlst(file) except ftplib.error_perm, reason: raise IOError, ('ftp error', reason), sys.exc_info()[2] # Restore the transfer mode! self.ftp.voidcmd(cmd) # Try to retrieve as a file try: cmd = 'RETR ' + file conn = self.ftp.ntransfercmd(cmd) except ftplib.error_perm, reason: if reason[:3] != '550': raise IOError, ('ftp error', reason), sys.exc_info()[2] if not conn: # Set transfer mode to ASCII! self.ftp.voidcmd('TYPE A') # Try a directory listing if file: cmd = 'LIST ' + file else: cmd = 'LIST' conn = self.ftp.ntransfercmd(cmd) self.busy = 1 # Pass back both a suitably decorated object and a retrieval length return (addclosehook(conn[0].makefile('rb'), self.endtransfer), conn[1]) | b49f88bfc122440e6b056b3c051ac3f928a1df92 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b49f88bfc122440e6b056b3c051ac3f928a1df92/urllib.py |
`id(self)`, `self.fp`) | `id(self)`, `self.fp`) | def __repr__(self): return '<%s at %s whose fp = %s>' % (self.__class__.__name__, `id(self)`, `self.fp`) | b49f88bfc122440e6b056b3c051ac3f928a1df92 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b49f88bfc122440e6b056b3c051ac3f928a1df92/urllib.py |
def basejoin(base, url): """Utility to combine a URL with a base URL to form a new URL.""" type, path = splittype(url) if type: # if url is complete (i.e., it contains a type), return it return url host, path = splithost(path) type, basepath = splittype(base) # inherit type from base if host: # if url contains host, just inherit type if type: return type + '://' + host + path else: # no type inherited, so url must have started with // # just return it return url host, basepath = splithost(basepath) # inherit host basepath, basetag = splittag(basepath) # remove extraneous cruft basepath, basequery = splitquery(basepath) # idem if path[:1] != '/': # non-absolute path name if path[:1] in ('#', '?'): # path is just a tag or query, attach to basepath i = len(basepath) else: # else replace last component i = string.rfind(basepath, '/') if i < 0: # basepath not absolute if host: # host present, make absolute basepath = '/' else: # else keep non-absolute basepath = '' else: # remove last file component basepath = basepath[:i+1] # Interpret ../ (important because of symlinks) while basepath and path[:3] == '../': path = path[3:] i = string.rfind(basepath[:-1], '/') if i > 0: basepath = basepath[:i+1] elif i == 0: basepath = '/' break else: basepath = '' path = basepath + path if type and host: return type + '://' + host + path elif type: return type + ':' + path elif host: return '//' + host + path # don't know what this means else: return path | b49f88bfc122440e6b056b3c051ac3f928a1df92 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b49f88bfc122440e6b056b3c051ac3f928a1df92/urllib.py |
||
match = _hostprog.match(url) | match = _hostprog.match(url) | def splithost(url): """splithost('//host[:port]/path') --> 'host[:port]', '/path'.""" global _hostprog if _hostprog is None: import re _hostprog = re.compile('^//([^/]*)(.*)$') match = _hostprog.match(url) if match: return match.group(1, 2) return None, url | b49f88bfc122440e6b056b3c051ac3f928a1df92 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b49f88bfc122440e6b056b3c051ac3f928a1df92/urllib.py |
always_safe = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ' | always_safe = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ' | def unquote_plus(s): """unquote('%7e/abc+def') -> '~/abc def'""" if '+' in s: # replace '+' with ' ' s = string.join(string.split(s, '+'), ' ') return unquote(s) | b49f88bfc122440e6b056b3c051ac3f928a1df92 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b49f88bfc122440e6b056b3c051ac3f928a1df92/urllib.py |
def quote(s, safe = '/'): """quote('abc def') -> 'abc%20def' Each part of a URL, e.g. the path info, the query, etc., has a different set of reserved characters that must be quoted. RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax lists the following reserved characters. reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | "," Each of these characters is reserved in some component of a URL, but not necessarily in all of them. By default, the quote function is intended for quoting the path section of a URL. Thus, it will not encode '/'. This character is reserved, but in typical usage the quote function is being called on a path where the existing slash characters are used as reserved characters. """ safe = always_safe + safe if _fast_safe_test == safe: return _fast_quote(s) res = list(s) for i in range(len(res)): c = res[i] if c not in safe: res[i] = '%%%02x' % ord(c) return string.join(res, '') | b49f88bfc122440e6b056b3c051ac3f928a1df92 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b49f88bfc122440e6b056b3c051ac3f928a1df92/urllib.py |
||
def getproxies(): """Return a dictionary of scheme -> proxy server URL mappings. | b49f88bfc122440e6b056b3c051ac3f928a1df92 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b49f88bfc122440e6b056b3c051ac3f928a1df92/urllib.py |
||
internetSettings = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, 'Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings') | internetSettings = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, r'Software\Microsoft\Windows\CurrentVersion\Internet Settings') | def getproxies_registry(): """Return a dictionary of scheme -> proxy server URL mappings. | b49f88bfc122440e6b056b3c051ac3f928a1df92 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b49f88bfc122440e6b056b3c051ac3f928a1df92/urllib.py |
if ';' in proxyServer: | if '=' in proxyServer: | def getproxies_registry(): """Return a dictionary of scheme -> proxy server URL mappings. | b49f88bfc122440e6b056b3c051ac3f928a1df92 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b49f88bfc122440e6b056b3c051ac3f928a1df92/urllib.py |
protocol, address = p.split('=') | protocol, address = p.split('=', 1) | def getproxies_registry(): """Return a dictionary of scheme -> proxy server URL mappings. | b49f88bfc122440e6b056b3c051ac3f928a1df92 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b49f88bfc122440e6b056b3c051ac3f928a1df92/urllib.py |
else: proxies['http'] = 'http://%s' % proxyServer proxies['ftp'] = 'ftp://%s' % proxyServer | else: if proxyServer[:5] == 'http:': proxies['http'] = proxyServer else: proxies['http'] = 'http://%s' % proxyServer proxies['ftp'] = 'ftp://%s' % proxyServer | def getproxies_registry(): """Return a dictionary of scheme -> proxy server URL mappings. | b49f88bfc122440e6b056b3c051ac3f928a1df92 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b49f88bfc122440e6b056b3c051ac3f928a1df92/urllib.py |
xover_lines.append(elem[0], elem[1], elem[2], elem[3], elem[4], elem[5:-2], elem[-2], elem[-1]) | xover_lines.append((elem[0], elem[1], elem[2], elem[3], elem[4], string.split(elem[5]), elem[6], elem[7])) | def xover(self,start,end): resp, lines = self.longcmd('XOVER ' + start + '-' + end) xover_lines = [] for line in lines: elem = string.splitfields(line,"\t") try: xover_lines.append(elem[0], elem[1], elem[2], elem[3], elem[4], elem[5:-2], elem[-2], elem[-1]) except IndexError: raise error_data,line return resp,xover_lines | c3fb88be8b5ae8953a35a23c22134f16931361ce /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c3fb88be8b5ae8953a35a23c22134f16931361ce/nntplib.py |
return self.sslobj.read(size) | data = self.sslobj.read(size) while len(data) < size: data += self.sslobj.read(len(data)-size) return data | def read(self, size): """Read 'size' bytes from remote.""" return self.sslobj.read(size) | 0c09293143630e8860e741d9e990993b5454a0ef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0c09293143630e8860e741d9e990993b5454a0ef/imaplib.py |
self.sslobj.write(data) | bytes = len(data) while bytes > 0: sent = self.sslobj.write(data) if sent == bytes: break data = data[sent:] bytes = bytes - sent | def send(self, data): """Send data to remote.""" self.sslobj.write(data) | 0c09293143630e8860e741d9e990993b5454a0ef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0c09293143630e8860e741d9e990993b5454a0ef/imaplib.py |
try: from os import popen2 except NameError: | if hasattr(os, "popen2"): def popen2(cmd, mode='t', bufsize=-1): """Execute the shell command 'cmd' in a sub-process. If 'bufsize' is specified, it sets the buffer size for the I/O pipes. The file objects (child_stdout, child_stdin) are returned.""" w, r = os.popen2(cmd, mode, bufsize) return r, w else: | def wait(self): """Wait for and return the exit status of the child process.""" pid, sts = os.waitpid(self.pid, 0) if pid == self.pid: self.sts = sts _active.remove(self) return self.sts | 9ac81f69b2de4364455ddd532ac4b20c4528f677 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9ac81f69b2de4364455ddd532ac4b20c4528f677/popen2.py |
try: from os import popen3 except NameError: | if hasattr(os, "popen3"): def popen3(cmd, mode='t', bufsize=-1): """Execute the shell command 'cmd' in a sub-process. If 'bufsize' is specified, it sets the buffer size for the I/O pipes. The file objects (child_stdout, child_stdin, child_stderr) are returned.""" w, r, e = os.popen3(cmd, mode, bufsize) return r, w, e else: | def popen2(cmd, mode='t', bufsize=-1): """Execute the shell command 'cmd' in a sub-process. If 'bufsize' is specified, it sets the buffer size for the I/O pipes. The file objects (child_stdout, child_stdin) are returned.""" if type(mode) is type(0) and bufsize == -1: bufsize = mode mode = 't' assert mode in ('t', 'b') _cleanup() inst = Popen3(cmd, 0, bufsize) return inst.fromchild, inst.tochild | 9ac81f69b2de4364455ddd532ac4b20c4528f677 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9ac81f69b2de4364455ddd532ac4b20c4528f677/popen2.py |
try: from os import popen4 except NameError: pass | if hasattr(os, "popen4"): def popen4(cmd, mode='t', bufsize=-1): """Execute the shell command 'cmd' in a sub-process. If 'bufsize' is specified, it sets the buffer size for the I/O pipes. The file objects (child_stdout_stderr, child_stdin) are returned.""" w, r = os.popen4(cmd, mode, bufsize) return r, w else: pass | def popen3(cmd, mode='t', bufsize=-1): """Execute the shell command 'cmd' in a sub-process. If 'bufsize' is specified, it sets the buffer size for the I/O pipes. The file objects (child_stdout, child_stdin, child_stderr) are returned.""" if type(mode) is type(0) and bufsize == -1: bufsize = mode mode = 't' assert mode in ('t', 'b') _cleanup() inst = Popen3(cmd, 1, bufsize) return inst.fromchild, inst.tochild, inst.childerr | 9ac81f69b2de4364455ddd532ac4b20c4528f677 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9ac81f69b2de4364455ddd532ac4b20c4528f677/popen2.py |
z = zipfile.ZipFile(zip_filename, "wb", | z = zipfile.ZipFile(zip_filename, "w", | def visit (z, dirname, names): for name in names: path = os.path.normpath(os.path.join(dirname, name)) if os.path.isfile(path): z.write(path, path) | b61914dd5baf5613bde1d9379cf24992c943ea1f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b61914dd5baf5613bde1d9379cf24992c943ea1f/archive_util.py |
self._ssnd_chunk.setpos(pos + 8) | self._ssnd_chunk.seek(pos + 8) | def readframes(self, nframes): if self._ssnd_seek_needed: self._ssnd_chunk.seek(0) dummy = self._ssnd_chunk.read(8) pos = self._soundpos * self._framesize if pos: self._ssnd_chunk.setpos(pos + 8) self._ssnd_seek_needed = 0 if nframes == 0: return '' data = self._ssnd_chunk.read(nframes * self._framesize) if self._convert and data: data = self._convert(data) self._soundpos = self._soundpos + len(data) / (self._nchannels * self._sampwidth) return data | 2663c13c5bed61f32135446e49429c886a562489 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2663c13c5bed61f32135446e49429c886a562489/aifc.py |
def zipTest(f, compression, srccontents): zip = zipfile.ZipFile(f, "w", compression) zip.write(srcname, "another"+os.extsep+"name") zip.write(srcname, srcname) zip.close() | TESTFN2 = TESTFN + "2" | def zipTest(f, compression, srccontents): zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive zip.write(srcname, "another"+os.extsep+"name") zip.write(srcname, srcname) zip.close() zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive readData2 = zip.read(srcname) readData1 = zip.read("another"+os.extsep+"name") zip.close() if readData1 != srccontents or readData2 != srccontents: raise TestFailed, "Written data doesn't equal read data." | 3caf9c1edd0623231489d998a81511c9fa991f5a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3caf9c1edd0623231489d998a81511c9fa991f5a/test_zipfile.py |
zip = zipfile.ZipFile(f, "r", compression) readData2 = zip.read(srcname) readData1 = zip.read("another"+os.extsep+"name") zip.close() | class TestsWithSourceFile(unittest.TestCase): def setUp(self): line_gen = ("Test of zipfile line %d." % i for i in range(0, 1000)) self.data = '\n'.join(line_gen) | def zipTest(f, compression, srccontents): zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive zip.write(srcname, "another"+os.extsep+"name") zip.write(srcname, srcname) zip.close() zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive readData2 = zip.read(srcname) readData1 = zip.read("another"+os.extsep+"name") zip.close() if readData1 != srccontents or readData2 != srccontents: raise TestFailed, "Written data doesn't equal read data." | 3caf9c1edd0623231489d998a81511c9fa991f5a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3caf9c1edd0623231489d998a81511c9fa991f5a/test_zipfile.py |
if readData1 != srccontents or readData2 != srccontents: raise TestFailed, "Written data doesn't equal read data." | fp = open(TESTFN, "wb") fp.write(self.data) fp.close() | def zipTest(f, compression, srccontents): zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive zip.write(srcname, "another"+os.extsep+"name") zip.write(srcname, srcname) zip.close() zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive readData2 = zip.read(srcname) readData1 = zip.read("another"+os.extsep+"name") zip.close() if readData1 != srccontents or readData2 != srccontents: raise TestFailed, "Written data doesn't equal read data." | 3caf9c1edd0623231489d998a81511c9fa991f5a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3caf9c1edd0623231489d998a81511c9fa991f5a/test_zipfile.py |
try: fp = open(srcname, "wb") for i in range(0, 1000): fp.write("Test of zipfile line %d.\n" % i) fp.close() | zipfp = zipfile.ZipFile(f, "r", compression) self.assertEqual(zipfp.read(TESTFN), self.data) self.assertEqual(zipfp.read("another"+os.extsep+"name"), self.data) zipfp.close() | def zipTest(f, compression, srccontents): zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive zip.write(srcname, "another"+os.extsep+"name") zip.write(srcname, srcname) zip.close() zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive readData2 = zip.read(srcname) readData1 = zip.read("another"+os.extsep+"name") zip.close() if readData1 != srccontents or readData2 != srccontents: raise TestFailed, "Written data doesn't equal read data." | 3caf9c1edd0623231489d998a81511c9fa991f5a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3caf9c1edd0623231489d998a81511c9fa991f5a/test_zipfile.py |
fp = open(srcname, "rb") writtenData = fp.read() fp.close() | def testStored(self): for f in (TESTFN2, TemporaryFile(), StringIO()): self.zipTest(f, zipfile.ZIP_STORED) | def zipTest(f, compression, srccontents): zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive zip.write(srcname, "another"+os.extsep+"name") zip.write(srcname, srcname) zip.close() zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive readData2 = zip.read(srcname) readData1 = zip.read("another"+os.extsep+"name") zip.close() if readData1 != srccontents or readData2 != srccontents: raise TestFailed, "Written data doesn't equal read data." | 3caf9c1edd0623231489d998a81511c9fa991f5a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3caf9c1edd0623231489d998a81511c9fa991f5a/test_zipfile.py |
for file in (zipname, tempfile.TemporaryFile(), StringIO.StringIO()): zipTest(file, zipfile.ZIP_STORED, writtenData) | if zlib: def testDeflated(self): for f in (TESTFN2, TemporaryFile(), StringIO()): self.zipTest(f, zipfile.ZIP_DEFLATED) | def zipTest(f, compression, srccontents): zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive zip.write(srcname, "another"+os.extsep+"name") zip.write(srcname, srcname) zip.close() zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive readData2 = zip.read(srcname) readData1 = zip.read("another"+os.extsep+"name") zip.close() if readData1 != srccontents or readData2 != srccontents: raise TestFailed, "Written data doesn't equal read data." | 3caf9c1edd0623231489d998a81511c9fa991f5a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3caf9c1edd0623231489d998a81511c9fa991f5a/test_zipfile.py |
for file in (zipname, tempfile.TemporaryFile(), StringIO.StringIO()): zipTest(file, zipfile.ZIP_DEFLATED, writtenData) | def tearDown(self): os.remove(TESTFN) os.remove(TESTFN2) | def zipTest(f, compression, srccontents): zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive zip.write(srcname, "another"+os.extsep+"name") zip.write(srcname, srcname) zip.close() zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive readData2 = zip.read(srcname) readData1 = zip.read("another"+os.extsep+"name") zip.close() if readData1 != srccontents or readData2 != srccontents: raise TestFailed, "Written data doesn't equal read data." | 3caf9c1edd0623231489d998a81511c9fa991f5a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3caf9c1edd0623231489d998a81511c9fa991f5a/test_zipfile.py |
finally: if os.path.isfile(srcname): os.unlink(srcname) if os.path.isfile(zipname): os.unlink(zipname) | class OtherTests(unittest.TestCase): def testCloseErroneousFile(self): fp = open(TESTFN, "w") fp.write("this is not a legal zip file\n") fp.close() try: zf = zipfile.ZipFile(TESTFN) except zipfile.BadZipfile: os.unlink(TESTFN) | def zipTest(f, compression, srccontents): zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive zip.write(srcname, "another"+os.extsep+"name") zip.write(srcname, srcname) zip.close() zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive readData2 = zip.read(srcname) readData1 = zip.read("another"+os.extsep+"name") zip.close() if readData1 != srccontents or readData2 != srccontents: raise TestFailed, "Written data doesn't equal read data." | 3caf9c1edd0623231489d998a81511c9fa991f5a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3caf9c1edd0623231489d998a81511c9fa991f5a/test_zipfile.py |
fp = open(srcname, "w") fp.write("this is not a legal zip file\n") fp.close() try: zf = zipfile.ZipFile(srcname) except zipfile.BadZipfile: os.unlink(srcname) | self.assertRaises(IOError, zipfile.ZipFile, TESTFN) | def zipTest(f, compression, srccontents): zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive zip.write(srcname, "another"+os.extsep+"name") zip.write(srcname, srcname) zip.close() zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive readData2 = zip.read(srcname) readData1 = zip.read("another"+os.extsep+"name") zip.close() if readData1 != srccontents or readData2 != srccontents: raise TestFailed, "Written data doesn't equal read data." | 3caf9c1edd0623231489d998a81511c9fa991f5a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3caf9c1edd0623231489d998a81511c9fa991f5a/test_zipfile.py |
try: zipfile.ZipFile(srcname) except IOError: pass else: raise TestFailed("expected creation of readable ZipFile without\n" " a file to raise an IOError.") | self.assertRaises(RuntimeError, zipf.testzip) | def zipTest(f, compression, srccontents): zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive zip.write(srcname, "another"+os.extsep+"name") zip.write(srcname, srcname) zip.close() zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive readData2 = zip.read(srcname) readData1 = zip.read("another"+os.extsep+"name") zip.close() if readData1 != srccontents or readData2 != srccontents: raise TestFailed, "Written data doesn't equal read data." | 3caf9c1edd0623231489d998a81511c9fa991f5a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3caf9c1edd0623231489d998a81511c9fa991f5a/test_zipfile.py |
data = StringIO.StringIO() zipf = zipfile.ZipFile(data, mode="w") zipf.writestr("foo.txt", "O, for a Muse of Fire!") zipf.close() zipf = zipfile.ZipFile(data, mode="r") zipf.close() try: zipf.testzip() except RuntimeError: pass else: raise TestFailed("expected calling .testzip on a closed ZipFile" " to raise a RuntimeError") del data, zipf | if __name__ == "__main__": test_main() | def zipTest(f, compression, srccontents): zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive zip.write(srcname, "another"+os.extsep+"name") zip.write(srcname, srcname) zip.close() zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive readData2 = zip.read(srcname) readData1 = zip.read("another"+os.extsep+"name") zip.close() if readData1 != srccontents or readData2 != srccontents: raise TestFailed, "Written data doesn't equal read data." | 3caf9c1edd0623231489d998a81511c9fa991f5a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3caf9c1edd0623231489d998a81511c9fa991f5a/test_zipfile.py |
"""Decide whether a particular character needs to be quoted. | """Decide whether a particular character needs to be quoted. | def needsquoting(c, quotetabs): """Decide whether a particular character needs to be quoted. The 'quotetabs' flag indicates whether tabs should be quoted.""" if c == '\t': return not quotetabs return c == ESCAPE or not(' ' <= c <= '~') | 77249442a58b4afb561f7c8290d63bea85126d9d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77249442a58b4afb561f7c8290d63bea85126d9d/quopri.py |
The 'quotetabs' flag indicates whether tabs should be quoted.""" if c == '\t': return not quotetabs return c == ESCAPE or not(' ' <= c <= '~') | The 'quotetabs' flag indicates whether tabs should be quoted.""" if c == '\t': return not quotetabs return c == ESCAPE or not(' ' <= c <= '~') | def needsquoting(c, quotetabs): """Decide whether a particular character needs to be quoted. The 'quotetabs' flag indicates whether tabs should be quoted.""" if c == '\t': return not quotetabs return c == ESCAPE or not(' ' <= c <= '~') | 77249442a58b4afb561f7c8290d63bea85126d9d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77249442a58b4afb561f7c8290d63bea85126d9d/quopri.py |
"""Quote a single character.""" if c == ESCAPE: return ESCAPE * 2 else: i = ord(c) return ESCAPE + HEX[i/16] + HEX[i%16] | """Quote a single character.""" i = ord(c) return ESCAPE + HEX[i/16] + HEX[i%16] | def quote(c): """Quote a single character.""" if c == ESCAPE: return ESCAPE * 2 else: i = ord(c) return ESCAPE + HEX[i/16] + HEX[i%16] | 77249442a58b4afb561f7c8290d63bea85126d9d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77249442a58b4afb561f7c8290d63bea85126d9d/quopri.py |
"""Read 'input', apply quoted-printable encoding, and write to 'output'. | """Read 'input', apply quoted-printable encoding, and write to 'output'. | def encode(input, output, quotetabs): """Read 'input', apply quoted-printable encoding, and write to 'output'. 'input' and 'output' are files with readline() and write() methods. The 'quotetabs' flag indicates whether tabs should be quoted.""" while 1: line = input.readline() if not line: break new = '' last = line[-1:] if last == '\n': line = line[:-1] else: last = '' prev = '' for c in line: if needsquoting(c, quotetabs): c = quote(c) if len(new) + len(c) >= MAXLINESIZE: output.write(new + ESCAPE + '\n') new = '' new = new + c prev = c if prev in (' ', '\t'): output.write(new + ESCAPE + '\n\n') else: output.write(new + '\n') | 77249442a58b4afb561f7c8290d63bea85126d9d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77249442a58b4afb561f7c8290d63bea85126d9d/quopri.py |
'input' and 'output' are files with readline() and write() methods. The 'quotetabs' flag indicates whether tabs should be quoted.""" while 1: line = input.readline() if not line: break new = '' last = line[-1:] if last == '\n': line = line[:-1] else: last = '' prev = '' for c in line: if needsquoting(c, quotetabs): c = quote(c) if len(new) + len(c) >= MAXLINESIZE: output.write(new + ESCAPE + '\n') new = '' new = new + c prev = c if prev in (' ', '\t'): output.write(new + ESCAPE + '\n\n') else: output.write(new + '\n') | 'input' and 'output' are files with readline() and write() methods. The 'quotetabs' flag indicates whether tabs should be quoted. """ while 1: line = input.readline() if not line: break new = '' last = line[-1:] if last == '\n': line = line[:-1] else: last = '' prev = '' for c in line: if needsquoting(c, quotetabs): c = quote(c) if len(new) + len(c) >= MAXLINESIZE: output.write(new + ESCAPE + '\n') new = '' new = new + c prev = c if prev in (' ', '\t'): output.write(new + ESCAPE + '\n\n') else: output.write(new + '\n') | def encode(input, output, quotetabs): """Read 'input', apply quoted-printable encoding, and write to 'output'. 'input' and 'output' are files with readline() and write() methods. The 'quotetabs' flag indicates whether tabs should be quoted.""" while 1: line = input.readline() if not line: break new = '' last = line[-1:] if last == '\n': line = line[:-1] else: last = '' prev = '' for c in line: if needsquoting(c, quotetabs): c = quote(c) if len(new) + len(c) >= MAXLINESIZE: output.write(new + ESCAPE + '\n') new = '' new = new + c prev = c if prev in (' ', '\t'): output.write(new + ESCAPE + '\n\n') else: output.write(new + '\n') | 77249442a58b4afb561f7c8290d63bea85126d9d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77249442a58b4afb561f7c8290d63bea85126d9d/quopri.py |
"""Read 'input', apply quoted-printable decoding, and write to 'output'. | """Read 'input', apply quoted-printable decoding, and write to 'output'. | def decode(input, output): """Read 'input', apply quoted-printable decoding, and write to 'output'. 'input' and 'output' are files with readline() and write() methods.""" new = '' while 1: line = input.readline() if not line: break i, n = 0, len(line) if n > 0 and line[n-1] == '\n': partial = 0; n = n-1 # Strip trailing whitespace while n > 0 and line[n-1] in (' ', '\t'): n = n-1 else: partial = 1 while i < n: c = line[i] if c <> ESCAPE: new = new + c; i = i+1 elif i+1 == n and not partial: partial = 1; break elif i+1 < n and line[i+1] == ESCAPE: new = new + ESCAPE; i = i+2 elif i+2 < n and ishex(line[i+1]) and ishex(line[i+2]): new = new + chr(unhex(line[i+1:i+3])); i = i+3 else: # Bad escape sequence -- leave it in new = new + c; i = i+1 if not partial: output.write(new + '\n') new = '' if new: output.write(new) | 77249442a58b4afb561f7c8290d63bea85126d9d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77249442a58b4afb561f7c8290d63bea85126d9d/quopri.py |
'input' and 'output' are files with readline() and write() methods.""" new = '' while 1: line = input.readline() if not line: break i, n = 0, len(line) if n > 0 and line[n-1] == '\n': partial = 0; n = n-1 while n > 0 and line[n-1] in (' ', '\t'): n = n-1 else: partial = 1 while i < n: c = line[i] if c <> ESCAPE: new = new + c; i = i+1 elif i+1 == n and not partial: partial = 1; break elif i+1 < n and line[i+1] == ESCAPE: new = new + ESCAPE; i = i+2 elif i+2 < n and ishex(line[i+1]) and ishex(line[i+2]): new = new + chr(unhex(line[i+1:i+3])); i = i+3 else: new = new + c; i = i+1 if not partial: output.write(new + '\n') new = '' if new: output.write(new) | 'input' and 'output' are files with readline() and write() methods.""" new = '' while 1: line = input.readline() if not line: break i, n = 0, len(line) if n > 0 and line[n-1] == '\n': partial = 0; n = n-1 while n > 0 and line[n-1] in (' ', '\t'): n = n-1 else: partial = 1 while i < n: c = line[i] if c <> ESCAPE: new = new + c; i = i+1 elif i+1 == n and not partial: partial = 1; break elif i+1 < n and line[i+1] == ESCAPE: new = new + ESCAPE; i = i+2 elif i+2 < n and ishex(line[i+1]) and ishex(line[i+2]): new = new + chr(unhex(line[i+1:i+3])); i = i+3 else: new = new + c; i = i+1 if not partial: output.write(new + '\n') new = '' if new: output.write(new) | def decode(input, output): """Read 'input', apply quoted-printable decoding, and write to 'output'. 'input' and 'output' are files with readline() and write() methods.""" new = '' while 1: line = input.readline() if not line: break i, n = 0, len(line) if n > 0 and line[n-1] == '\n': partial = 0; n = n-1 # Strip trailing whitespace while n > 0 and line[n-1] in (' ', '\t'): n = n-1 else: partial = 1 while i < n: c = line[i] if c <> ESCAPE: new = new + c; i = i+1 elif i+1 == n and not partial: partial = 1; break elif i+1 < n and line[i+1] == ESCAPE: new = new + ESCAPE; i = i+2 elif i+2 < n and ishex(line[i+1]) and ishex(line[i+2]): new = new + chr(unhex(line[i+1:i+3])); i = i+3 else: # Bad escape sequence -- leave it in new = new + c; i = i+1 if not partial: output.write(new + '\n') new = '' if new: output.write(new) | 77249442a58b4afb561f7c8290d63bea85126d9d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77249442a58b4afb561f7c8290d63bea85126d9d/quopri.py |
"""Return true if the character 'c' is a hexadecimal digit.""" return '0' <= c <= '9' or 'a' <= c <= 'f' or 'A' <= c <= 'F' | """Return true if the character 'c' is a hexadecimal digit.""" return '0' <= c <= '9' or 'a' <= c <= 'f' or 'A' <= c <= 'F' | def ishex(c): """Return true if the character 'c' is a hexadecimal digit.""" return '0' <= c <= '9' or 'a' <= c <= 'f' or 'A' <= c <= 'F' | 77249442a58b4afb561f7c8290d63bea85126d9d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77249442a58b4afb561f7c8290d63bea85126d9d/quopri.py |
"""Get the integer value of a hexadecimal number.""" bits = 0 for c in s: if '0' <= c <= '9': i = ord('0') elif 'a' <= c <= 'f': i = ord('a')-10 elif 'A' <= c <= 'F': i = ord('A')-10 else: break bits = bits*16 + (ord(c) - i) return bits | """Get the integer value of a hexadecimal number.""" bits = 0 for c in s: if '0' <= c <= '9': i = ord('0') elif 'a' <= c <= 'f': i = ord('a')-10 elif 'A' <= c <= 'F': i = ord('A')-10 else: break bits = bits*16 + (ord(c) - i) return bits | def unhex(s): """Get the integer value of a hexadecimal number.""" bits = 0 for c in s: if '0' <= c <= '9': i = ord('0') elif 'a' <= c <= 'f': i = ord('a')-10 elif 'A' <= c <= 'F': i = ord('A')-10 else: break bits = bits*16 + (ord(c) - i) return bits | 77249442a58b4afb561f7c8290d63bea85126d9d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77249442a58b4afb561f7c8290d63bea85126d9d/quopri.py |
import sys import getopt try: opts, args = getopt.getopt(sys.argv[1:], 'td') except getopt.error, msg: sys.stdout = sys.stderr print msg print "usage: quopri [-t | -d] [file] ..." print "-t: quote tabs" print "-d: decode; default encode" sys.exit(2) deco = 0 tabs = 0 for o, a in opts: if o == '-t': tabs = 1 if o == '-d': deco = 1 if tabs and deco: sys.stdout = sys.stderr print "-t and -d are mutually exclusive" sys.exit(2) if not args: args = ['-'] sts = 0 for file in args: if file == '-': fp = sys.stdin else: try: fp = open(file) except IOError, msg: sys.stderr.write("%s: can't open (%s)\n" % (file, msg)) sts = 1 continue if deco: decode(fp, sys.stdout) else: encode(fp, sys.stdout, tabs) if fp is not sys.stdin: fp.close() if sts: sys.exit(sts) | import sys import getopt try: opts, args = getopt.getopt(sys.argv[1:], 'td') except getopt.error, msg: sys.stdout = sys.stderr print msg print "usage: quopri [-t | -d] [file] ..." print "-t: quote tabs" print "-d: decode; default encode" sys.exit(2) deco = 0 tabs = 0 for o, a in opts: if o == '-t': tabs = 1 if o == '-d': deco = 1 if tabs and deco: sys.stdout = sys.stderr print "-t and -d are mutually exclusive" sys.exit(2) if not args: args = ['-'] sts = 0 for file in args: if file == '-': fp = sys.stdin else: try: fp = open(file) except IOError, msg: sys.stderr.write("%s: can't open (%s)\n" % (file, msg)) sts = 1 continue if deco: decode(fp, sys.stdout) else: encode(fp, sys.stdout, tabs) if fp is not sys.stdin: fp.close() if sts: sys.exit(sts) | def test(): import sys import getopt try: opts, args = getopt.getopt(sys.argv[1:], 'td') except getopt.error, msg: sys.stdout = sys.stderr print msg print "usage: quopri [-t | -d] [file] ..." print "-t: quote tabs" print "-d: decode; default encode" sys.exit(2) deco = 0 tabs = 0 for o, a in opts: if o == '-t': tabs = 1 if o == '-d': deco = 1 if tabs and deco: sys.stdout = sys.stderr print "-t and -d are mutually exclusive" sys.exit(2) if not args: args = ['-'] sts = 0 for file in args: if file == '-': fp = sys.stdin else: try: fp = open(file) except IOError, msg: sys.stderr.write("%s: can't open (%s)\n" % (file, msg)) sts = 1 continue if deco: decode(fp, sys.stdout) else: encode(fp, sys.stdout, tabs) if fp is not sys.stdin: fp.close() if sts: sys.exit(sts) | 77249442a58b4afb561f7c8290d63bea85126d9d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77249442a58b4afb561f7c8290d63bea85126d9d/quopri.py |
test() | test() | def test(): import sys import getopt try: opts, args = getopt.getopt(sys.argv[1:], 'td') except getopt.error, msg: sys.stdout = sys.stderr print msg print "usage: quopri [-t | -d] [file] ..." print "-t: quote tabs" print "-d: decode; default encode" sys.exit(2) deco = 0 tabs = 0 for o, a in opts: if o == '-t': tabs = 1 if o == '-d': deco = 1 if tabs and deco: sys.stdout = sys.stderr print "-t and -d are mutually exclusive" sys.exit(2) if not args: args = ['-'] sts = 0 for file in args: if file == '-': fp = sys.stdin else: try: fp = open(file) except IOError, msg: sys.stderr.write("%s: can't open (%s)\n" % (file, msg)) sts = 1 continue if deco: decode(fp, sys.stdout) else: encode(fp, sys.stdout, tabs) if fp is not sys.stdin: fp.close() if sts: sys.exit(sts) | 77249442a58b4afb561f7c8290d63bea85126d9d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77249442a58b4afb561f7c8290d63bea85126d9d/quopri.py |
"Please save first!") | "The buffer for %s is not saved.\n" % name + "Please save it first!") | def getfilename(self): # Logic to make sure we have a saved filename # XXX Better logic would offer to save! if not self.editwin.get_saved(): self.errorbox("Not saved", "Please save first!") self.editwin.text.focus_set() return filename = self.editwin.io.filename if not filename: self.errorbox("No file name", "This window has no file name") return return filename | 3634112b40bac1086cff2019592beb27e28971c4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3634112b40bac1086cff2019592beb27e28971c4/ScriptBinding.py |
return "Not all files were unpacked: %s" % " ".join(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) | 705553acabe1db64097bbc1bea3b81ff6d8c04f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/705553acabe1db64097bbc1bea3b81ff6d8c04f7/pimp.py |
print "before _get_package_data():" print "vendor =", self.vendor print "packager =", self.packager print "doc_files =", self.doc_files print "changelog =", self.changelog | if DEBUG: print "before _get_package_data():" print "vendor =", self.vendor print "packager =", self.packager print "doc_files =", self.doc_files print "changelog =", self.changelog | def run (self): | efbd071016bdbd5874bc7c626f36021ce75a4841 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/efbd071016bdbd5874bc7c626f36021ce75a4841/bdist_rpm.py |
def TemporaryFile(mode='w+b', bufsize=-1, suffix=""): """Create and return a temporary file (opened read-write by default).""" name = mktemp(suffix) if os.name == 'posix': # Unix -- be very careful fd = os.open(name, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0700) try: os.unlink(name) return os.fdopen(fd, mode, bufsize) except: os.close(fd) raise else: # Non-unix -- can't unlink file that's still open, use wrapper file = open(name, mode, bufsize) return TemporaryFileWrapper(file, name) | 4fd5a06580c2b03f0252553e4024f168ea054353 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4fd5a06580c2b03f0252553e4024f168ea054353/tempfile.py |
||
def set_proxy(self, proxy): self.__proxy = proxy self.type, self.__r_type = splittype(self.__proxy) self.host, XXX = splithost(self.__r_type) self.host = unquote(self.host) | def set_proxy(self, host, type): self.host, self.type = host, type | def set_proxy(self, proxy): self.__proxy = proxy # XXX this code is based on urllib, but it doesn't seem # correct. specifically, if the proxy has a port number then # splittype will return the hostname as the type and the port # will be include with everything else self.type, self.__r_type = splittype(self.__proxy) self.host, XXX = splithost(self.__r_type) self.host = unquote(self.host) self.__r_host = self.__original | 8a18e99008c28156a7ba701ca8d6824a50fb0a9e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8a18e99008c28156a7ba701ca8d6824a50fb0a9e/urllib2.py |
if proto == 'http': dict = self.handle_error[proto] | if proto in ['http', 'https']: dict = self.handle_error['http'] | def error(self, proto, *args): if proto == 'http': # XXX http protocol is special cased dict = self.handle_error[proto] proto = args[2] # YUCK! meth_name = 'http_error_%d' % proto http_err = 1 orig_args = args else: dict = self.handle_error meth_name = proto + '_error' http_err = 0 args = (dict, proto, meth_name) + args result = self._call_chain(*args) if result: return result | 8a18e99008c28156a7ba701ca8d6824a50fb0a9e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8a18e99008c28156a7ba701ca8d6824a50fb0a9e/urllib2.py |
if req.error_302_dict.has_key(newurl): | if len(error_302_dict)>10 or req.error_302_dict.has_key(newurl): | def http_error_302(self, req, fp, code, msg, headers): if headers.has_key('location'): newurl = headers['location'] elif headers.has_key('uri'): newurl = headers['uri'] else: return nil = fp.read() fp.close() | 8a18e99008c28156a7ba701ca8d6824a50fb0a9e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8a18e99008c28156a7ba701ca8d6824a50fb0a9e/urllib2.py |
req.set_proxy(proxy) | type, r_type = splittype(proxy) host, XXX = splithost(r_type) if '@' in host: user_pass, host = host.split('@', 1) user_pass = base64.encode_string(unquote(user_passw)).strip() req.addheader('Proxy-Authorization', user_pass) host = unquote(host) req.set_proxy(host, type) | def proxy_open(self, req, proxy, type): orig_type = req.get_type() req.set_proxy(proxy) if orig_type == type: # let other handlers take care of it # XXX this only makes sense if the proxy is before the # other handlers return None else: # need to start over, because the other handlers don't # grok the proxy's URL type return self.parent.open(req) | 8a18e99008c28156a7ba701ca8d6824a50fb0a9e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8a18e99008c28156a7ba701ca8d6824a50fb0a9e/urllib2.py |
common = os.path.commonprefix((base[1], test[1])) | common = posixpath.commonprefix((base[1], test[1])) | def is_suburi(self, base, test): """Check if test is below base in a URI tree | 8a18e99008c28156a7ba701ca8d6824a50fb0a9e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8a18e99008c28156a7ba701ca8d6824a50fb0a9e/urllib2.py |
class HTTPBasicAuthHandler(BaseHandler): | class HTTPPasswordMgrWithDefaultRealm(HTTPPasswordMgr): def find_user_password(self, realm, authuri): user, password = HTTPPasswordMgr.find_user_password(self,realm,authuri) if user is not None: return user, password return HTTPPasswordMgr.find_user_password(self, None, authuri) class AbstractBasicAuthHandler: | def is_suburi(self, base, test): """Check if test is below base in a URI tree | 8a18e99008c28156a7ba701ca8d6824a50fb0a9e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8a18e99008c28156a7ba701ca8d6824a50fb0a9e/urllib2.py |
def __init__(self): self.passwd = HTTPPasswordMgr() | def __init__(self, password_mgr=None): if password_mgr is None: password_mgr = HTTPPasswordMgr() self.passwd = password_mgr | def __init__(self): self.passwd = HTTPPasswordMgr() self.add_password = self.passwd.add_password self.__current_realm = None # if __current_realm is not None, then the server must have # refused our name/password and is asking for authorization # again. must be careful to set it to None on successful # return. | 8a18e99008c28156a7ba701ca8d6824a50fb0a9e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8a18e99008c28156a7ba701ca8d6824a50fb0a9e/urllib2.py |
def http_error_401(self, req, fp, code, msg, headers): authreq = headers.get('www-authenticate', None) | def http_error_auth_reqed(self, authreq, host, req, headers): authreq = headers.get(authreq, None) | def http_error_401(self, req, fp, code, msg, headers): # XXX could be mult. headers authreq = headers.get('www-authenticate', None) if authreq: mo = HTTPBasicAuthHandler.rx.match(authreq) if mo: scheme, realm = mo.groups() if scheme.lower() == 'basic': return self.retry_http_basic_auth(req, realm) | 8a18e99008c28156a7ba701ca8d6824a50fb0a9e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8a18e99008c28156a7ba701ca8d6824a50fb0a9e/urllib2.py |
mo = HTTPBasicAuthHandler.rx.match(authreq) | mo = AbstractBasicAuthHandler.rx.match(authreq) | def http_error_401(self, req, fp, code, msg, headers): # XXX could be mult. headers authreq = headers.get('www-authenticate', None) if authreq: mo = HTTPBasicAuthHandler.rx.match(authreq) if mo: scheme, realm = mo.groups() if scheme.lower() == 'basic': return self.retry_http_basic_auth(req, realm) | 8a18e99008c28156a7ba701ca8d6824a50fb0a9e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8a18e99008c28156a7ba701ca8d6824a50fb0a9e/urllib2.py |
return self.retry_http_basic_auth(req, realm) def retry_http_basic_auth(self, req, realm): | return self.retry_http_basic_auth(host, req, realm) def retry_http_basic_auth(self, host, req, realm): | def http_error_401(self, req, fp, code, msg, headers): # XXX could be mult. headers authreq = headers.get('www-authenticate', None) if authreq: mo = HTTPBasicAuthHandler.rx.match(authreq) if mo: scheme, realm = mo.groups() if scheme.lower() == 'basic': return self.retry_http_basic_auth(req, realm) | 8a18e99008c28156a7ba701ca8d6824a50fb0a9e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8a18e99008c28156a7ba701ca8d6824a50fb0a9e/urllib2.py |
host = req.get_host() | def retry_http_basic_auth(self, req, realm): if self.__current_realm is None: self.__current_realm = realm else: self.__current_realm = realm return None # XXX host isn't really the correct URI? host = req.get_host() user,pw = self.passwd.find_user_password(realm, host) if pw: raw = "%s:%s" % (user, pw) auth = base64.encodestring(raw).strip() req.add_header('Authorization', 'Basic %s' % auth) resp = self.parent.open(req) self.__current_realm = None return resp else: self.__current_realm = None return None | 8a18e99008c28156a7ba701ca8d6824a50fb0a9e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8a18e99008c28156a7ba701ca8d6824a50fb0a9e/urllib2.py |
|
req.add_header('Authorization', 'Basic %s' % auth) | req.add_header(self.header, 'Basic %s' % auth) | def retry_http_basic_auth(self, req, realm): if self.__current_realm is None: self.__current_realm = realm else: self.__current_realm = realm return None # XXX host isn't really the correct URI? host = req.get_host() user,pw = self.passwd.find_user_password(realm, host) if pw: raw = "%s:%s" % (user, pw) auth = base64.encodestring(raw).strip() req.add_header('Authorization', 'Basic %s' % auth) resp = self.parent.open(req) self.__current_realm = None return resp else: self.__current_realm = None return None | 8a18e99008c28156a7ba701ca8d6824a50fb0a9e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8a18e99008c28156a7ba701ca8d6824a50fb0a9e/urllib2.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.