rem
stringlengths 1
322k
| add
stringlengths 0
2.05M
| context
stringlengths 4
228k
| meta
stringlengths 156
215
|
---|---|---|---|
import tempfile filename = tempfile.mktemp() self.__tempfiles.append(filename) | import tempfile filename = tempfile.mktemp() self.__tempfiles.append(filename) | def retrieve(self, url, filename=None): url = unwrap(url) if self.tempcache and self.tempcache.has_key(url): return self.tempcache[url] type, url1 = splittype(url) if not filename and (not type or type == 'file'): try: fp = self.open_local_file(url1) del fp return url2pathname(splithost(url1)[1]), None except IOError, msg: pass fp = self.open(url) headers = fp.info() if not filename: import tempfile filename = tempfile.mktemp() self.__tempfiles.append(filename) result = filename, headers if self.tempcache is not None: self.tempcache[url] = result tfp = open(filename, 'wb') bs = 1024*8 block = fp.read(bs) while block: tfp.write(block) block = fp.read(bs) fp.close() tfp.close() del fp del tfp return result | fcea3a44cb5bc4ca94c174353aba37f481e83a11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fcea3a44cb5bc4ca94c174353aba37f481e83a11/urllib.py |
realhost = None | realhost = None | def open_http(self, url, data=None): import httplib if type(url) is type(""): host, selector = splithost(url) user_passwd, host = splituser(host) realhost = host else: host, selector = url urltype, rest = splittype(selector) user_passwd = None if string.lower(urltype) != 'http': realhost = None else: realhost, rest = splithost(rest) user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) #print "proxy via http:", host, selector if not host: raise IOError, ('http error', 'no host given') if user_passwd: import base64 auth = string.strip(base64.encodestring(user_passwd)) else: auth = None h = httplib.HTTP(host) 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 + '\r\n') errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, "http:" + url) else: return self.http_error(url, fp, errcode, errmsg, headers) | fcea3a44cb5bc4ca94c174353aba37f481e83a11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fcea3a44cb5bc4ca94c174353aba37f481e83a11/urllib.py |
realhost, rest = splithost(rest) user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) | realhost, rest = splithost(rest) user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) | def open_http(self, url, data=None): import httplib if type(url) is type(""): host, selector = splithost(url) user_passwd, host = splituser(host) realhost = host else: host, selector = url urltype, rest = splittype(selector) user_passwd = None if string.lower(urltype) != 'http': realhost = None else: realhost, rest = splithost(rest) user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) #print "proxy via http:", host, selector if not host: raise IOError, ('http error', 'no host given') if user_passwd: import base64 auth = string.strip(base64.encodestring(user_passwd)) else: auth = None h = httplib.HTTP(host) 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 + '\r\n') errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, "http:" + url) else: return self.http_error(url, fp, errcode, errmsg, headers) | fcea3a44cb5bc4ca94c174353aba37f481e83a11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fcea3a44cb5bc4ca94c174353aba37f481e83a11/urllib.py |
if url[:2] == '//' and url[2:3] != '/': return self.open_ftp(url) else: return self.open_local_file(url) | if url[:2] == '//' and url[2:3] != '/': return self.open_ftp(url) else: return self.open_local_file(url) | def open_file(self, url): if url[:2] == '//' and url[2:3] != '/': return self.open_ftp(url) else: return self.open_local_file(url) | fcea3a44cb5bc4ca94c174353aba37f481e83a11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fcea3a44cb5bc4ca94c174353aba37f481e83a11/urllib.py |
return addinfourl(fp, headers, "http:" + url) | return addinfourl(fp, headers, "http:" + url) | def http_error_default(self, url, fp, errcode, errmsg, headers): return addinfourl(fp, headers, "http:" + url) | fcea3a44cb5bc4ca94c174353aba37f481e83a11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fcea3a44cb5bc4ca94c174353aba37f481e83a11/urllib.py |
scheme, realm = match.groups() | scheme, realm = match.groups() | def http_error_401(self, url, fp, errcode, errmsg, headers): 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': return self.retry_http_basic_auth( url, realm) | fcea3a44cb5bc4ca94c174353aba37f481e83a11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fcea3a44cb5bc4ca94c174353aba37f481e83a11/urllib.py |
import re _typeprog = re.compile('^([^/:]+):') match = _typeprog.match(url) | import re _typeprog = re.compile('^([^/:]+):') match = _typeprog.match(url) | def splittype(url): global _typeprog if _typeprog is None: import re _typeprog = re.compile('^([^/:]+):') match = _typeprog.match(url) if match: scheme = match.group(1) return scheme, url[len(scheme) + 1:] return None, url | fcea3a44cb5bc4ca94c174353aba37f481e83a11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fcea3a44cb5bc4ca94c174353aba37f481e83a11/urllib.py |
import re _hostprog = re.compile('^//([^/]+)(.*)$') | import re _hostprog = re.compile('^//([^/]+)(.*)$') | def splithost(url): 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 | fcea3a44cb5bc4ca94c174353aba37f481e83a11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fcea3a44cb5bc4ca94c174353aba37f481e83a11/urllib.py |
import re _userprog = re.compile('^([^@]*)@(.*)$') | import re _userprog = re.compile('^([^@]*)@(.*)$') | def splituser(host): global _userprog if _userprog is None: import re _userprog = re.compile('^([^@]*)@(.*)$') match = _userprog.match(host) if match: return match.group(1, 2) return None, host | fcea3a44cb5bc4ca94c174353aba37f481e83a11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fcea3a44cb5bc4ca94c174353aba37f481e83a11/urllib.py |
import re _passwdprog = re.compile('^([^:]*):(.*)$') | import re _passwdprog = re.compile('^([^:]*):(.*)$') | def splitpasswd(user): global _passwdprog if _passwdprog is None: import re _passwdprog = re.compile('^([^:]*):(.*)$') match = _passwdprog.match(user) if match: return match.group(1, 2) return user, None | fcea3a44cb5bc4ca94c174353aba37f481e83a11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fcea3a44cb5bc4ca94c174353aba37f481e83a11/urllib.py |
import re _portprog = re.compile('^(.*):([0-9]+)$') | import re _portprog = re.compile('^(.*):([0-9]+)$') | def splitport(host): global _portprog if _portprog is None: import re _portprog = re.compile('^(.*):([0-9]+)$') match = _portprog.match(host) if match: return match.group(1, 2) return host, None | fcea3a44cb5bc4ca94c174353aba37f481e83a11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fcea3a44cb5bc4ca94c174353aba37f481e83a11/urllib.py |
import re _nportprog = re.compile('^(.*):(.*)$') | import re _nportprog = re.compile('^(.*):(.*)$') | def splitnport(host, defport=-1): global _nportprog if _nportprog is None: import re _nportprog = re.compile('^(.*):(.*)$') match = _nportprog.match(host) if match: host, port = match.group(1, 2) try: if not port: raise string.atoi_error, "no digits" nport = string.atoi(port) except string.atoi_error: nport = None return host, nport return host, defport | fcea3a44cb5bc4ca94c174353aba37f481e83a11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fcea3a44cb5bc4ca94c174353aba37f481e83a11/urllib.py |
host, port = match.group(1, 2) try: if not port: raise string.atoi_error, "no digits" nport = string.atoi(port) except string.atoi_error: nport = None return host, nport | host, port = match.group(1, 2) try: if not port: raise string.atoi_error, "no digits" nport = string.atoi(port) except string.atoi_error: nport = None return host, nport | def splitnport(host, defport=-1): global _nportprog if _nportprog is None: import re _nportprog = re.compile('^(.*):(.*)$') match = _nportprog.match(host) if match: host, port = match.group(1, 2) try: if not port: raise string.atoi_error, "no digits" nport = string.atoi(port) except string.atoi_error: nport = None return host, nport return host, defport | fcea3a44cb5bc4ca94c174353aba37f481e83a11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fcea3a44cb5bc4ca94c174353aba37f481e83a11/urllib.py |
import re _queryprog = re.compile('^(.*)\?([^?]*)$') | import re _queryprog = re.compile('^(.*)\?([^?]*)$') | def splitquery(url): global _queryprog if _queryprog is None: import re _queryprog = re.compile('^(.*)\?([^?]*)$') match = _queryprog.match(url) if match: return match.group(1, 2) return url, None | fcea3a44cb5bc4ca94c174353aba37f481e83a11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fcea3a44cb5bc4ca94c174353aba37f481e83a11/urllib.py |
import re _tagprog = re.compile('^(.*) | import re _tagprog = re.compile('^(.*) | def splittag(url): global _tagprog if _tagprog is None: import re _tagprog = re.compile('^(.*)#([^#]*)$') match = _tagprog.match(url) if match: return match.group(1, 2) return url, None | fcea3a44cb5bc4ca94c174353aba37f481e83a11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fcea3a44cb5bc4ca94c174353aba37f481e83a11/urllib.py |
import re _valueprog = re.compile('^([^=]*)=(.*)$') match = _valueprog.match(attr) | import re _valueprog = re.compile('^([^=]*)=(.*)$') match = _valueprog.match(attr) | def splitvalue(attr): global _valueprog if _valueprog is None: import re _valueprog = re.compile('^([^=]*)=(.*)$') match = _valueprog.match(attr) if match: return match.group(1, 2) return attr, None | fcea3a44cb5bc4ca94c174353aba37f481e83a11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fcea3a44cb5bc4ca94c174353aba37f481e83a11/urllib.py |
import re _quoteprog = re.compile('%[0-9a-fA-F][0-9a-fA-F]') | import re _quoteprog = re.compile('%[0-9a-fA-F][0-9a-fA-F]') | def unquote(s): global _quoteprog if _quoteprog is None: import re _quoteprog = re.compile('%[0-9a-fA-F][0-9a-fA-F]') i = 0 n = len(s) res = [] while 0 <= i < n: match = _quoteprog.search(s, i) if not match: res.append(s[i:]) break j = match.start(0) res.append(s[i:j] + chr(string.atoi(s[j+1:j+3], 16))) i = j+3 return string.joinfields(res, '') | fcea3a44cb5bc4ca94c174353aba37f481e83a11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fcea3a44cb5bc4ca94c174353aba37f481e83a11/urllib.py |
if '+' in s: s = string.join(string.split(s, '+'), ' ') return unquote(s) | if '+' in s: s = string.join(string.split(s, '+'), ' ') return unquote(s) | def unquote_plus(s): if '+' in s: # replace '+' with ' ' s = string.join(string.split(s, '+'), ' ') return unquote(s) | fcea3a44cb5bc4ca94c174353aba37f481e83a11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fcea3a44cb5bc4ca94c174353aba37f481e83a11/urllib.py |
if ' ' in s: s = string.join(string.split(s, ' '), '+') return quote(s, safe + '+') else: return quote(s, safe) | if ' ' in s: s = string.join(string.split(s, ' '), '+') return quote(s, safe + '+') else: return quote(s, safe) | def quote_plus(s, safe = '/'): if ' ' in s: # replace ' ' with '+' s = string.join(string.split(s, ' '), '+') return quote(s, safe + '+') else: return quote(s, safe) | fcea3a44cb5bc4ca94c174353aba37f481e83a11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fcea3a44cb5bc4ca94c174353aba37f481e83a11/urllib.py |
table = string.maketrans("", "") data = string.translate(data, table, "\r") | table = string.maketrans("", "") data = string.translate(data, table, "\r") | def test(): import sys args = sys.argv[1:] if not args: args = [ '/etc/passwd', 'file:/etc/passwd', 'file://localhost/etc/passwd', 'ftp://ftp.python.org/etc/passwd', 'gopher://gopher.micro.umn.edu/1/', 'http://www.python.org/index.html', ] try: for url in args: print '-'*10, url, '-'*10 fn, h = urlretrieve(url) print fn, h if h: print '======' for k in h.keys(): print k + ':', h[k] print '======' fp = open(fn, 'rb') data = fp.read() del fp if '\r' in data: table = string.maketrans("", "") data = string.translate(data, table, "\r") print data fn, h = None, None print '-'*40 finally: urlcleanup() | fcea3a44cb5bc4ca94c174353aba37f481e83a11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fcea3a44cb5bc4ca94c174353aba37f481e83a11/urllib.py |
self.mkpath (os.path.dirname (obj)) | self.mkpath(os.path.dirname(obj)) | def compile (self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None): | 9785481e9d4764ad00cdf3c5c92c436452d1c1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9785481e9d4764ad00cdf3c5c92c436452d1c1ae/bcppcompiler.py |
def compile (self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None): | 9785481e9d4764ad00cdf3c5c92c436452d1c1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9785481e9d4764ad00cdf3c5c92c436452d1c1ae/bcppcompiler.py |
||
ldflags = self.ldflags_shared_debug | ld_args = self.ldflags_shared_debug[:] | def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None): | 9785481e9d4764ad00cdf3c5c92c436452d1c1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9785481e9d4764ad00cdf3c5c92c436452d1c1ae/bcppcompiler.py |
ldflags = self.ldflags_shared | ld_args = self.ldflags_shared[:] objects = map(os.path.normpath, objects) | def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None): | 9785481e9d4764ad00cdf3c5c92c436452d1c1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9785481e9d4764ad00cdf3c5c92c436452d1c1ae/bcppcompiler.py |
libraries.append ('mypylib') | objects.insert(0, startup_obj) | def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None): | 9785481e9d4764ad00cdf3c5c92c436452d1c1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9785481e9d4764ad00cdf3c5c92c436452d1c1ae/bcppcompiler.py |
def_file = os.path.join (build_temp, '%s.def' % modname) f = open (def_file, 'w') f.write ('EXPORTS\n') | temp_dir = os.path.dirname(objects[0]) def_file = os.path.join (temp_dir, '%s.def' % modname) contents = ['EXPORTS'] | def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None): | 9785481e9d4764ad00cdf3c5c92c436452d1c1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9785481e9d4764ad00cdf3c5c92c436452d1c1ae/bcppcompiler.py |
f.write (' %s=_%s\n' % (sym, sym)) ld_args = ldflags + [startup_obj] + objects + \ [',%s,,' % output_filename] + \ libraries + [',' + def_file] | contents.append(' %s=_%s' % (sym, sym)) self.execute(write_file, (def_file, contents), "writing %s" % def_file) for l in library_dirs: ld_args.append("/L%s" % os.path.normpath(l)) ld_args.extend(objects) ld_args.extend([',',output_filename]) ld_args.extend([',', ',']) for lib in libraries: libfile = self.find_library_file(library_dirs, lib, debug) if libfile is None: ld_args.append(lib) else: ld_args.append(libfile) ld_args.extend([',',def_file]) | def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None): | 9785481e9d4764ad00cdf3c5c92c436452d1c1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9785481e9d4764ad00cdf3c5c92c436452d1c1ae/bcppcompiler.py |
ld_args.extend (extra_postargs) | ld_args.extend(extra_postargs) | def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None): | 9785481e9d4764ad00cdf3c5c92c436452d1c1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9785481e9d4764ad00cdf3c5c92c436452d1c1ae/bcppcompiler.py |
"don't know how to set runtime library search path for MSVC++" | ("don't know how to set runtime library search path " "for Borland C++") | def runtime_library_dir_option (self, dir): raise DistutilsPlatformError, \ "don't know how to set runtime library search path for MSVC++" | 9785481e9d4764ad00cdf3c5c92c436452d1c1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9785481e9d4764ad00cdf3c5c92c436452d1c1ae/bcppcompiler.py |
def find_library_file (self, dirs, lib): | def find_library_file (self, dirs, lib, debug=0): | def find_library_file (self, dirs, lib): | 9785481e9d4764ad00cdf3c5c92c436452d1c1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9785481e9d4764ad00cdf3c5c92c436452d1c1ae/bcppcompiler.py |
['extract-all', 'default-domain', 'escape', 'help', | ['extract-all', 'default-domain=', 'escape', 'help', | def main(): global default_keywords try: opts, args = getopt.getopt( sys.argv[1:], 'ad:DEhk:Kno:p:S:Vvw:x:', ['extract-all', 'default-domain', 'escape', 'help', 'keyword=', 'no-default-keywords', 'add-location', 'no-location', 'output=', 'output-dir=', 'style=', 'verbose', 'version', 'width=', 'exclude-file=', 'docstrings', ]) except getopt.error, msg: usage(1, msg) # for holding option values class Options: # constants GNU = 1 SOLARIS = 2 # defaults extractall = 0 # FIXME: currently this option has no effect at all. escape = 0 keywords = [] outpath = '' outfile = 'messages.pot' writelocations = 1 locationstyle = GNU verbose = 0 width = 78 excludefilename = '' docstrings = 0 options = Options() locations = {'gnu' : options.GNU, 'solaris' : options.SOLARIS, } # parse options for opt, arg in opts: if opt in ('-h', '--help'): usage(0) elif opt in ('-a', '--extract-all'): options.extractall = 1 elif opt in ('-d', '--default-domain'): options.outfile = arg + '.pot' elif opt in ('-E', '--escape'): options.escape = 1 elif opt in ('-D', '--docstrings'): options.docstrings = 1 elif opt in ('-k', '--keyword'): options.keywords.append(arg) elif opt in ('-K', '--no-default-keywords'): default_keywords = [] elif opt in ('-n', '--add-location'): options.writelocations = 1 elif opt in ('--no-location',): options.writelocations = 0 elif opt in ('-S', '--style'): options.locationstyle = locations.get(arg.lower()) if options.locationstyle is None: usage(1, _('Invalid value for --style: %s') % arg) elif opt in ('-o', '--output'): options.outfile = arg elif opt in ('-p', '--output-dir'): options.outpath = arg elif opt in ('-v', '--verbose'): options.verbose = 1 elif opt in ('-V', '--version'): print _('pygettext.py (xgettext for Python) %s') % __version__ sys.exit(0) elif opt in ('-w', '--width'): try: options.width = int(arg) except ValueError: usage(1, _('--width argument must be an integer: %s') % arg) elif opt in ('-x', '--exclude-file'): options.excludefilename = arg # calculate escapes make_escapes(options.escape) # calculate all keywords options.keywords.extend(default_keywords) # initialize list of strings to exclude if options.excludefilename: try: fp = open(options.excludefilename) options.toexclude = fp.readlines() fp.close() except IOError: print >> sys.stderr, _( "Can't read --exclude-file: %s") % options.excludefilename sys.exit(1) else: options.toexclude = [] # slurp through all the files eater = TokenEater(options) for filename in args: if filename == '-': if options.verbose: print _('Reading standard input') fp = sys.stdin closep = 0 else: if options.verbose: print _('Working on %s') % filename fp = open(filename) closep = 1 try: eater.set_filename(filename) try: tokenize.tokenize(fp.readline, eater) except tokenize.TokenError, e: print >> sys.stderr, '%s: %s, line %d, column %d' % ( e[0], filename, e[1][0], e[1][1]) finally: if closep: fp.close() # write the output if options.outfile == '-': fp = sys.stdout closep = 0 else: if options.outpath: options.outfile = os.path.join(options.outpath, options.outfile) fp = open(options.outfile, 'w') closep = 1 try: eater.write(fp) finally: if closep: fp.close() | 9186d1028d9b696d168e631295aa20b1d8204ab0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9186d1028d9b696d168e631295aa20b1d8204ab0/pygettext.py |
f = open(filename, 'r') | f = open(filename, 'rb') | def whathdr(filename): """Recognize sound headers""" f = open(filename, 'r') h = f.read(512) for tf in tests: res = tf(h, f) if res: return res return None | 09f0346a464d41b643b3e0e707ce9004e347ea8d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/09f0346a464d41b643b3e0e707ce9004e347ea8d/sndhdr.py |
def __init__(self, name=""): """Construct a TarInfo object. name is the optional name of the member. """ | 14cab674653252113190b16078d9d939372d8557 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/14cab674653252113190b16078d9d939372d8557/tarfile.py |
||
self.prefix = "" | def __init__(self, name=""): """Construct a TarInfo object. name is the optional name of the member. """ | 14cab674653252113190b16078d9d939372d8557 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/14cab674653252113190b16078d9d939372d8557/tarfile.py |
|
tarinfo.prefix = buf[345:500] | prefix = buf[345:500].rstrip(NUL) if prefix and not tarinfo.issparse(): tarinfo.name = prefix + "/" + tarinfo.name | def frombuf(cls, buf): """Construct a TarInfo object from a 512 byte string buffer. """ if len(buf) != BLOCKSIZE: raise ValueError("truncated header") if buf.count(NUL) == BLOCKSIZE: raise ValueError("empty header") | 14cab674653252113190b16078d9d939372d8557 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/14cab674653252113190b16078d9d939372d8557/tarfile.py |
"""Return a tar header block as a 512 byte string. """ | """Return a tar header as a string of 512 byte blocks. """ buf = "" type = self.type prefix = "" if self.name.endswith("/"): type = DIRTYPE name = normpath(self.name) if type == DIRTYPE: name += "/" linkname = self.linkname if linkname: linkname = normpath(linkname) if posix: if self.size > MAXSIZE_MEMBER: raise ValueError("file is too large (>= 8 GB)") if len(self.linkname) > LENGTH_LINK: raise ValueError("linkname is too long (>%d)" % (LENGTH_LINK)) if len(name) > LENGTH_NAME: prefix = name[:LENGTH_PREFIX + 1] while prefix and prefix[-1] != "/": prefix = prefix[:-1] name = name[len(prefix):] prefix = prefix[:-1] if not prefix or len(name) > LENGTH_NAME: raise ValueError("name is too long") else: if len(self.linkname) > LENGTH_LINK: buf += self._create_gnulong(self.linkname, GNUTYPE_LONGLINK) if len(name) > LENGTH_NAME: buf += self._create_gnulong(name, GNUTYPE_LONGNAME) | def tobuf(self, posix=False): """Return a tar header block as a 512 byte string. """ parts = [ stn(self.name, 100), itn(self.mode & 07777, 8, posix), itn(self.uid, 8, posix), itn(self.gid, 8, posix), itn(self.size, 12, posix), itn(self.mtime, 12, posix), " ", # checksum field self.type, stn(self.linkname, 100), stn(MAGIC, 6), stn(VERSION, 2), stn(self.uname, 32), stn(self.gname, 32), itn(self.devmajor, 8, posix), itn(self.devminor, 8, posix), stn(self.prefix, 155) ] | 14cab674653252113190b16078d9d939372d8557 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/14cab674653252113190b16078d9d939372d8557/tarfile.py |
stn(self.name, 100), | stn(name, 100), | def tobuf(self, posix=False): """Return a tar header block as a 512 byte string. """ parts = [ stn(self.name, 100), itn(self.mode & 07777, 8, posix), itn(self.uid, 8, posix), itn(self.gid, 8, posix), itn(self.size, 12, posix), itn(self.mtime, 12, posix), " ", # checksum field self.type, stn(self.linkname, 100), stn(MAGIC, 6), stn(VERSION, 2), stn(self.uname, 32), stn(self.gname, 32), itn(self.devmajor, 8, posix), itn(self.devminor, 8, posix), stn(self.prefix, 155) ] | 14cab674653252113190b16078d9d939372d8557 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/14cab674653252113190b16078d9d939372d8557/tarfile.py |
self.type, | type, | def tobuf(self, posix=False): """Return a tar header block as a 512 byte string. """ parts = [ stn(self.name, 100), itn(self.mode & 07777, 8, posix), itn(self.uid, 8, posix), itn(self.gid, 8, posix), itn(self.size, 12, posix), itn(self.mtime, 12, posix), " ", # checksum field self.type, stn(self.linkname, 100), stn(MAGIC, 6), stn(VERSION, 2), stn(self.uname, 32), stn(self.gname, 32), itn(self.devmajor, 8, posix), itn(self.devminor, 8, posix), stn(self.prefix, 155) ] | 14cab674653252113190b16078d9d939372d8557 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/14cab674653252113190b16078d9d939372d8557/tarfile.py |
stn(self.prefix, 155) | stn(prefix, 155) | def tobuf(self, posix=False): """Return a tar header block as a 512 byte string. """ parts = [ stn(self.name, 100), itn(self.mode & 07777, 8, posix), itn(self.uid, 8, posix), itn(self.gid, 8, posix), itn(self.size, 12, posix), itn(self.mtime, 12, posix), " ", # checksum field self.type, stn(self.linkname, 100), stn(MAGIC, 6), stn(VERSION, 2), stn(self.uname, 32), stn(self.gname, 32), itn(self.devmajor, 8, posix), itn(self.devminor, 8, posix), stn(self.prefix, 155) ] | 14cab674653252113190b16078d9d939372d8557 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/14cab674653252113190b16078d9d939372d8557/tarfile.py |
buf = struct.pack("%ds" % BLOCKSIZE, "".join(parts)) | buf += struct.pack("%ds" % BLOCKSIZE, "".join(parts)) | def tobuf(self, posix=False): """Return a tar header block as a 512 byte string. """ parts = [ stn(self.name, 100), itn(self.mode & 07777, 8, posix), itn(self.uid, 8, posix), itn(self.gid, 8, posix), itn(self.size, 12, posix), itn(self.mtime, 12, posix), " ", # checksum field self.type, stn(self.linkname, 100), stn(MAGIC, 6), stn(VERSION, 2), stn(self.uname, 32), stn(self.gname, 32), itn(self.devmajor, 8, posix), itn(self.devminor, 8, posix), stn(self.prefix, 155) ] | 14cab674653252113190b16078d9d939372d8557 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/14cab674653252113190b16078d9d939372d8557/tarfile.py |
buf = buf[:148] + "%06o\0" % chksum + buf[155:] | buf = buf[:-364] + "%06o\0" % chksum + buf[-357:] | def tobuf(self, posix=False): """Return a tar header block as a 512 byte string. """ parts = [ stn(self.name, 100), itn(self.mode & 07777, 8, posix), itn(self.uid, 8, posix), itn(self.gid, 8, posix), itn(self.size, 12, posix), itn(self.mtime, 12, posix), " ", # checksum field self.type, stn(self.linkname, 100), stn(MAGIC, 6), stn(VERSION, 2), stn(self.uname, 32), stn(self.gname, 32), itn(self.devmajor, 8, posix), itn(self.devminor, 8, posix), stn(self.prefix, 155) ] | 14cab674653252113190b16078d9d939372d8557 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/14cab674653252113190b16078d9d939372d8557/tarfile.py |
tarinfo.name = normpath(tarinfo.name) if tarinfo.isdir(): tarinfo.name += "/" if tarinfo.linkname: tarinfo.linkname = normpath(tarinfo.linkname) if tarinfo.size > MAXSIZE_MEMBER: if self.posix: raise ValueError("file is too large (>= 8 GB)") else: self._dbg(2, "tarfile: Created GNU tar largefile header") if len(tarinfo.linkname) > LENGTH_LINK: if self.posix: raise ValueError("linkname is too long (>%d)" % (LENGTH_LINK)) else: self._create_gnulong(tarinfo.linkname, GNUTYPE_LONGLINK) tarinfo.linkname = tarinfo.linkname[:LENGTH_LINK -1] self._dbg(2, "tarfile: Created GNU tar extension LONGLINK") if len(tarinfo.name) > LENGTH_NAME: if self.posix: prefix = tarinfo.name[:LENGTH_PREFIX + 1] while prefix and prefix[-1] != "/": prefix = prefix[:-1] name = tarinfo.name[len(prefix):] prefix = prefix[:-1] if not prefix or len(name) > LENGTH_NAME: raise ValueError("name is too long (>%d)" % (LENGTH_NAME)) tarinfo.name = name tarinfo.prefix = prefix else: self._create_gnulong(tarinfo.name, GNUTYPE_LONGNAME) tarinfo.name = tarinfo.name[:LENGTH_NAME - 1] self._dbg(2, "tarfile: Created GNU tar extension LONGNAME") self.fileobj.write(tarinfo.tobuf(self.posix)) self.offset += BLOCKSIZE | tarinfo = copy.copy(tarinfo) buf = tarinfo.tobuf(self.posix) self.fileobj.write(buf) self.offset += len(buf) | def addfile(self, tarinfo, fileobj=None): """Add the TarInfo object `tarinfo' to the archive. If `fileobj' is given, tarinfo.size bytes are read from it and added to the archive. You can create TarInfo objects using gettarinfo(). On Windows platforms, `fileobj' should always be opened with mode 'rb' to avoid irritation about the file size. """ self._check("aw") | 14cab674653252113190b16078d9d939372d8557 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/14cab674653252113190b16078d9d939372d8557/tarfile.py |
tarinfo.name = normpath(os.path.join(tarinfo.prefix.rstrip(NUL), tarinfo.name)) | def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m | 14cab674653252113190b16078d9d939372d8557 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/14cab674653252113190b16078d9d939372d8557/tarfile.py |
|
tarinfo.prefix = "" | def proc_sparse(self, tarinfo): """Process a GNU sparse header plus extra headers. """ buf = tarinfo.buf sp = _ringbuffer() pos = 386 lastpos = 0L realpos = 0L # There are 4 possible sparse structs in the # first header. for i in xrange(4): try: offset = nti(buf[pos:pos + 12]) numbytes = nti(buf[pos + 12:pos + 24]) except ValueError: break if offset > lastpos: sp.append(_hole(lastpos, offset - lastpos)) sp.append(_data(offset, numbytes, realpos)) realpos += numbytes lastpos = offset + numbytes pos += 24 | 14cab674653252113190b16078d9d939372d8557 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/14cab674653252113190b16078d9d939372d8557/tarfile.py |
|
def _create_gnulong(self, name, type): """Write a GNU longname/longlink member to the TarFile. It consists of an extended tar header, with the length of the longname as size, followed by data blocks, which contain the longname as a null terminated string. """ name += NUL tarinfo = TarInfo() tarinfo.name = "././@LongLink" tarinfo.type = type tarinfo.mode = 0 tarinfo.size = len(name) self.fileobj.write(tarinfo.tobuf()) self.offset += BLOCKSIZE self.fileobj.write(name) blocks, remainder = divmod(tarinfo.size, BLOCKSIZE) if remainder > 0: self.fileobj.write(NUL * (BLOCKSIZE - remainder)) blocks += 1 self.offset += blocks * BLOCKSIZE | def __iter__(self): """Provide an iterator object. """ if self._loaded: return iter(self.members) else: return TarIter(self) | 14cab674653252113190b16078d9d939372d8557 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/14cab674653252113190b16078d9d939372d8557/tarfile.py |
|
blocknum = blocknum + 1 | read += len(block) blocknum += 1 | def retrieve(self, url, filename=None, reporthook=None, data=None): """retrieve(url) returns (filename, headers) for a local object or (tempfilename, headers) for a remote object.""" url = unwrap(toBytes(url)) if self.tempcache and url in self.tempcache: return self.tempcache[url] type, url1 = splittype(url) if filename is None and (not type or type == 'file'): try: fp = self.open_local_file(url1) hdrs = fp.info() del fp return url2pathname(splithost(url1)[1]), hdrs except IOError, msg: pass fp = self.open(url, data) headers = fp.info() if filename: tfp = open(filename, 'wb') else: import tempfile garbage, path = splittype(url) garbage, path = splithost(path or "") path, garbage = splitquery(path or "") path, garbage = splitattr(path or "") suffix = os.path.splitext(path)[1] (fd, filename) = tempfile.mkstemp(suffix) self.__tempfiles.append(filename) tfp = os.fdopen(fd, 'wb') result = filename, headers if self.tempcache is not None: self.tempcache[url] = result bs = 1024*8 size = -1 blocknum = 1 if reporthook: if "content-length" in headers: size = int(headers["Content-Length"]) reporthook(0, bs, size) block = fp.read(bs) if reporthook: reporthook(1, bs, size) while block: tfp.write(block) block = fp.read(bs) blocknum = blocknum + 1 if reporthook: reporthook(blocknum, bs, size) fp.close() tfp.close() del fp del tfp return result | ff4621ea3c2427b340b9612009e86f4b5a1352a4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ff4621ea3c2427b340b9612009e86f4b5a1352a4/urllib.py |
def putrequest(self, method, url): | def putrequest(self, method, url, skip_host=0): | def putrequest(self, method, url): """Send a request to the server. | 565dd907942e7aa0a4087a7c6a4488a4566f1b9f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/565dd907942e7aa0a4087a7c6a4488a4566f1b9f/httplib.py |
if url.startswith('http:'): nil, netloc, nil, nil, nil = urlsplit(url) self.putheader('Host', netloc) elif self.port == HTTP_PORT: self.putheader('Host', netloc) else: self.putheader('Host', "%s:%s" % (self.host, self.port)) | if not skip_host: netloc = '' if url.startswith('http'): nil, netloc, nil, nil, nil = urlsplit(url) if netloc: self.putheader('Host', netloc) elif self.port == HTTP_PORT: self.putheader('Host', self.host) else: self.putheader('Host', "%s:%s" % (self.host, self.port)) | def putrequest(self, method, url): """Send a request to the server. | 565dd907942e7aa0a4087a7c6a4488a4566f1b9f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/565dd907942e7aa0a4087a7c6a4488a4566f1b9f/httplib.py |
self.putrequest(method, url) | if (headers.has_key('Host') or [k for k in headers.iterkeys() if k.lower() == "host"]): self.putrequest(method, url, skip_host=1) else: self.putrequest(method, url) | def _send_request(self, method, url, body, headers): self.putrequest(method, url) | 565dd907942e7aa0a4087a7c6a4488a4566f1b9f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/565dd907942e7aa0a4087a7c6a4488a4566f1b9f/httplib.py |
self.format_all(map(lambda (mtime, file): file, list)) | self.format_all(map(lambda (mtime, file): file, list), headers=0) | def do_recent(self): | f01b9c728270577ad8c2d426c32e9e7be35e1617 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f01b9c728270577ad8c2d426c32e9e7be35e1617/faqwiz.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. | b7d18aba05e94e0dfc876b8d5318a3526b80bcb4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b7d18aba05e94e0dfc876b8d5318a3526b80bcb4/ConfigParser.py |
release = '98' | release = 'postMe' | def win32_ver(release='',version='',csd='',ptype=''): """ Get additional version information from the Windows Registry and return a tuple (version,csd,ptype) referring to version number, CSD level and OS type (multi/single processor). As a hint: ptype returns 'Uniprocessor Free' on single processor NT machines and 'Multiprocessor Free' on multi processor machines. The 'Free' refers to the OS version being free of debugging code. It could also state 'Checked' which means the OS version uses debugging code, i.e. code that checks arguments, ranges, etc. (Thomas Heller). Note: this function only works if Mark Hammond's win32 package is installed and obviously only runs on Win32 compatible platforms. """ # XXX Is there any way to find out the processor type on WinXX ? # XXX Is win32 available on Windows CE ? # Adapted from code posted by Karl Putland to comp.lang.python. # Import the needed APIs try: import win32api except ImportError: return release,version,csd,ptype from win32api import RegQueryValueEx,RegOpenKeyEx,RegCloseKey,GetVersionEx from win32con import HKEY_LOCAL_MACHINE,VER_PLATFORM_WIN32_NT,\ VER_PLATFORM_WIN32_WINDOWS # Find out the registry key and some general version infos maj,min,buildno,plat,csd = GetVersionEx() version = '%i.%i.%i' % (maj,min,buildno & 0xFFFF) if csd[:13] == 'Service Pack ': csd = 'SP' + csd[13:] if plat == VER_PLATFORM_WIN32_WINDOWS: regkey = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion' # Try to guess the release name if maj == 4: if min == 0: release = '95' else: release = '98' elif maj == 5: release = '2000' elif plat == VER_PLATFORM_WIN32_NT: regkey = 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion' if maj <= 4: release = 'NT' elif maj == 5: release = '2000' else: if not release: # E.g. Win3.1 with win32s release = '%i.%i' % (maj,min) return release,version,csd,ptype # Open the registry key try: keyCurVer = RegOpenKeyEx(HKEY_LOCAL_MACHINE,regkey) # Get a value to make sure the key exists... RegQueryValueEx(keyCurVer,'SystemRoot') except: return release,version,csd,ptype # Parse values #subversion = _win32_getvalue(keyCurVer, # 'SubVersionNumber', # ('',1))[0] #if subversion: # release = release + subversion # 95a, 95b, etc. build = _win32_getvalue(keyCurVer, 'CurrentBuildNumber', ('',1))[0] ptype = _win32_getvalue(keyCurVer, 'CurrentType', (ptype,1))[0] # Normalize version version = _norm_version(version,build) # Close key RegCloseKey(keyCurVer) return release,version,csd,ptype | ea974cc15e33c987a26d4c43845cc095b2eeb985 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ea974cc15e33c987a26d4c43845cc095b2eeb985/platform.py |
release = '2000' | if min == 0: release = '2000' elif min == 1: release = 'XP' elif min == 2: release = '2003Server' else: release = 'post2003' | def win32_ver(release='',version='',csd='',ptype=''): """ Get additional version information from the Windows Registry and return a tuple (version,csd,ptype) referring to version number, CSD level and OS type (multi/single processor). As a hint: ptype returns 'Uniprocessor Free' on single processor NT machines and 'Multiprocessor Free' on multi processor machines. The 'Free' refers to the OS version being free of debugging code. It could also state 'Checked' which means the OS version uses debugging code, i.e. code that checks arguments, ranges, etc. (Thomas Heller). Note: this function only works if Mark Hammond's win32 package is installed and obviously only runs on Win32 compatible platforms. """ # XXX Is there any way to find out the processor type on WinXX ? # XXX Is win32 available on Windows CE ? # Adapted from code posted by Karl Putland to comp.lang.python. # Import the needed APIs try: import win32api except ImportError: return release,version,csd,ptype from win32api import RegQueryValueEx,RegOpenKeyEx,RegCloseKey,GetVersionEx from win32con import HKEY_LOCAL_MACHINE,VER_PLATFORM_WIN32_NT,\ VER_PLATFORM_WIN32_WINDOWS # Find out the registry key and some general version infos maj,min,buildno,plat,csd = GetVersionEx() version = '%i.%i.%i' % (maj,min,buildno & 0xFFFF) if csd[:13] == 'Service Pack ': csd = 'SP' + csd[13:] if plat == VER_PLATFORM_WIN32_WINDOWS: regkey = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion' # Try to guess the release name if maj == 4: if min == 0: release = '95' else: release = '98' elif maj == 5: release = '2000' elif plat == VER_PLATFORM_WIN32_NT: regkey = 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion' if maj <= 4: release = 'NT' elif maj == 5: release = '2000' else: if not release: # E.g. Win3.1 with win32s release = '%i.%i' % (maj,min) return release,version,csd,ptype # Open the registry key try: keyCurVer = RegOpenKeyEx(HKEY_LOCAL_MACHINE,regkey) # Get a value to make sure the key exists... RegQueryValueEx(keyCurVer,'SystemRoot') except: return release,version,csd,ptype # Parse values #subversion = _win32_getvalue(keyCurVer, # 'SubVersionNumber', # ('',1))[0] #if subversion: # release = release + subversion # 95a, 95b, etc. build = _win32_getvalue(keyCurVer, 'CurrentBuildNumber', ('',1))[0] ptype = _win32_getvalue(keyCurVer, 'CurrentType', (ptype,1))[0] # Normalize version version = _norm_version(version,build) # Close key RegCloseKey(keyCurVer) return release,version,csd,ptype | ea974cc15e33c987a26d4c43845cc095b2eeb985 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ea974cc15e33c987a26d4c43845cc095b2eeb985/platform.py |
_platform_cache_terse = None _platform_cache_not_terse = None _platform_aliased_cache_terse = None _platform_aliased_cache_not_terse = None | _platform_cache = {} | def python_compiler(): """ Returns a string identifying the compiler used for compiling Python. """ return _sys_version()[3] | ea974cc15e33c987a26d4c43845cc095b2eeb985 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ea974cc15e33c987a26d4c43845cc095b2eeb985/platform.py |
global _platform_cache_terse, _platform_cache_not_terse global _platform_aliased_cache_terse, _platform_aliased_cache_not_terse if not aliased and terse and (_platform_cache_terse is not None): return _platform_cache_terse elif not aliased and not terse and (_platform_cache_not_terse is not None): return _platform_cache_not_terse elif terse and _platform_aliased_cache_terse is not None: return _platform_aliased_cache_terse elif not terse and _platform_aliased_cache_not_terse is not None: return _platform_aliased_cache_not_terse | result = _platform_cache.get((aliased, terse), None) if result is not None: return result | def platform(aliased=0, terse=0): """ Returns a single string identifying the underlying platform with as much useful information as possible (but no more :). The output is intended to be human readable rather than machine parseable. It may look different on different platforms and this is intended. If "aliased" is true, the function will use aliases for various platforms that report system names which differ from their common names, e.g. SunOS will be reported as Solaris. The system_alias() function is used to implement this. Setting terse to true causes the function to return only the absolute minimum information needed to identify the platform. """ global _platform_cache_terse, _platform_cache_not_terse global _platform_aliased_cache_terse, _platform_aliased_cache_not_terse if not aliased and terse and (_platform_cache_terse is not None): return _platform_cache_terse elif not aliased and not terse and (_platform_cache_not_terse is not None): return _platform_cache_not_terse elif terse and _platform_aliased_cache_terse is not None: return _platform_aliased_cache_terse elif not terse and _platform_aliased_cache_not_terse is not None: return _platform_aliased_cache_not_terse # Get uname information and then apply platform specific cosmetics # to it... system,node,release,version,machine,processor = uname() if machine == processor: processor = '' if aliased: system,release,version = system_alias(system,release,version) if system == 'Windows': # MS platforms rel,vers,csd,ptype = win32_ver(version) if terse: platform = _platform(system,release) else: platform = _platform(system,release,version,csd) elif system in ('Linux',): # Linux based systems distname,distversion,distid = dist('') if distname and not terse: platform = _platform(system,release,machine,processor, 'with', distname,distversion,distid) else: # If the distribution name is unknown check for libc vs. glibc libcname,libcversion = libc_ver(sys.executable) platform = _platform(system,release,machine,processor, 'with', libcname+libcversion) elif system == 'Java': # Java platforms r,v,vminfo,(os_name,os_version,os_arch) = java_ver() if terse: platform = _platform(system,release,version) else: platform = _platform(system,release,version, 'on', os_name,os_version,os_arch) elif system == 'MacOS': # MacOS platforms if terse: platform = _platform(system,release) else: platform = _platform(system,release,machine) else: # Generic handler if terse: platform = _platform(system,release) else: bits,linkage = architecture(sys.executable) platform = _platform(system,release,machine,processor,bits,linkage) if aliased and terse: _platform_aliased_cache_terse = platform elif aliased and not terse: _platform_aliased_cache_not_terse = platform elif terse: pass else: if terse: _platform_cache_terse = platform else: _platform_cache_not_terse = platform return platform | ea974cc15e33c987a26d4c43845cc095b2eeb985 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ea974cc15e33c987a26d4c43845cc095b2eeb985/platform.py |
if aliased and terse: _platform_aliased_cache_terse = platform elif aliased and not terse: _platform_aliased_cache_not_terse = platform elif terse: pass else: if terse: _platform_cache_terse = platform else: _platform_cache_not_terse = platform | _platform_cache[(aliased, terse)] = platform | def platform(aliased=0, terse=0): """ Returns a single string identifying the underlying platform with as much useful information as possible (but no more :). The output is intended to be human readable rather than machine parseable. It may look different on different platforms and this is intended. If "aliased" is true, the function will use aliases for various platforms that report system names which differ from their common names, e.g. SunOS will be reported as Solaris. The system_alias() function is used to implement this. Setting terse to true causes the function to return only the absolute minimum information needed to identify the platform. """ global _platform_cache_terse, _platform_cache_not_terse global _platform_aliased_cache_terse, _platform_aliased_cache_not_terse if not aliased and terse and (_platform_cache_terse is not None): return _platform_cache_terse elif not aliased and not terse and (_platform_cache_not_terse is not None): return _platform_cache_not_terse elif terse and _platform_aliased_cache_terse is not None: return _platform_aliased_cache_terse elif not terse and _platform_aliased_cache_not_terse is not None: return _platform_aliased_cache_not_terse # Get uname information and then apply platform specific cosmetics # to it... system,node,release,version,machine,processor = uname() if machine == processor: processor = '' if aliased: system,release,version = system_alias(system,release,version) if system == 'Windows': # MS platforms rel,vers,csd,ptype = win32_ver(version) if terse: platform = _platform(system,release) else: platform = _platform(system,release,version,csd) elif system in ('Linux',): # Linux based systems distname,distversion,distid = dist('') if distname and not terse: platform = _platform(system,release,machine,processor, 'with', distname,distversion,distid) else: # If the distribution name is unknown check for libc vs. glibc libcname,libcversion = libc_ver(sys.executable) platform = _platform(system,release,machine,processor, 'with', libcname+libcversion) elif system == 'Java': # Java platforms r,v,vminfo,(os_name,os_version,os_arch) = java_ver() if terse: platform = _platform(system,release,version) else: platform = _platform(system,release,version, 'on', os_name,os_version,os_arch) elif system == 'MacOS': # MacOS platforms if terse: platform = _platform(system,release) else: platform = _platform(system,release,machine) else: # Generic handler if terse: platform = _platform(system,release) else: bits,linkage = architecture(sys.executable) platform = _platform(system,release,machine,processor,bits,linkage) if aliased and terse: _platform_aliased_cache_terse = platform elif aliased and not terse: _platform_aliased_cache_not_terse = platform elif terse: pass else: if terse: _platform_cache_terse = platform else: _platform_cache_not_terse = platform return platform | ea974cc15e33c987a26d4c43845cc095b2eeb985 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ea974cc15e33c987a26d4c43845cc095b2eeb985/platform.py |
def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': raise httplib.UnimplementedFileMode() return StringIO.StringIO(self.text) | d909c02d45f659c228159645ab18245faae03fa7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d909c02d45f659c228159645ab18245faae03fa7/test_httplib.py |
||
body = "HTTP/1.1 200 Ok\r\n\r\nText" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock, 1) resp.begin() print resp.read() resp.close() | import sys | def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': raise httplib.UnimplementedFileMode() return StringIO.StringIO(self.text) | d909c02d45f659c228159645ab18245faae03fa7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d909c02d45f659c228159645ab18245faae03fa7/test_httplib.py |
body = "HTTP/1.1 400.100 Not Ok\r\n\r\nText" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock, 1) try: | def test(): buf = StringIO.StringIO() _stdout = sys.stdout try: sys.stdout = buf _test() finally: sys.stdout = _stdout s = buf.getvalue() for line in s.split("\n"): print line.strip() def _test(): body = "HTTP/1.1 200 Ok\r\n\r\nText" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock, 1) | def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': raise httplib.UnimplementedFileMode() return StringIO.StringIO(self.text) | d909c02d45f659c228159645ab18245faae03fa7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d909c02d45f659c228159645ab18245faae03fa7/test_httplib.py |
except httplib.BadStatusLine: print "BadStatusLine raised as expected" else: print "Expect BadStatusLine" | print resp.read() resp.close() | def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': raise httplib.UnimplementedFileMode() return StringIO.StringIO(self.text) | d909c02d45f659c228159645ab18245faae03fa7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d909c02d45f659c228159645ab18245faae03fa7/test_httplib.py |
body = "HTTP/1.1 400.100 Not Ok\r\n\r\nText" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock, 1) try: resp.begin() except httplib.BadStatusLine: print "BadStatusLine raised as expected" else: print "Expect BadStatusLine" | def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': raise httplib.UnimplementedFileMode() return StringIO.StringIO(self.text) | d909c02d45f659c228159645ab18245faae03fa7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d909c02d45f659c228159645ab18245faae03fa7/test_httplib.py |
|
for hp in ("www.python.org:abc", "www.python.org:"): try: h = httplib.HTTP(hp) except httplib.InvalidURL: print "InvalidURL raised as expected" else: print "Expect InvalidURL" | def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': raise httplib.UnimplementedFileMode() return StringIO.StringIO(self.text) | d909c02d45f659c228159645ab18245faae03fa7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d909c02d45f659c228159645ab18245faae03fa7/test_httplib.py |
|
text = ('HTTP/1.1 200 OK\r\n' 'Set-Cookie: Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"\r\n' 'Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1";' ' Path="/acme"\r\n' '\r\n' 'No body\r\n') hdr = ('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"' ', ' 'Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme"') s = FakeSocket(text) r = httplib.HTTPResponse(s, 1) r.begin() cookies = r.getheader("Set-Cookie") if cookies != hdr: raise AssertionError, "multiple headers not combined properly" | for hp in ("www.python.org:abc", "www.python.org:"): try: h = httplib.HTTP(hp) except httplib.InvalidURL: print "InvalidURL raised as expected" else: print "Expect InvalidURL" text = ('HTTP/1.1 200 OK\r\n' 'Set-Cookie: Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"\r\n' 'Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1";' ' Path="/acme"\r\n' '\r\n' 'No body\r\n') hdr = ('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"' ', ' 'Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme"') s = FakeSocket(text) r = httplib.HTTPResponse(s, 1) r.begin() cookies = r.getheader("Set-Cookie") if cookies != hdr: raise AssertionError, "multiple headers not combined properly" test() | def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': raise httplib.UnimplementedFileMode() return StringIO.StringIO(self.text) | d909c02d45f659c228159645ab18245faae03fa7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d909c02d45f659c228159645ab18245faae03fa7/test_httplib.py |
def register(name, klass, instance=None): | def register(name, klass, instance=None, update_tryorder=1): | def register(name, klass, instance=None): """Register a browser connector and, optionally, connection.""" _browsers[name.lower()] = [klass, instance] | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
def get(using=None): """Return a browser launcher instance appropriate for the environment.""" if using is not None: alternatives = [using] else: alternatives = _tryorder for browser in alternatives: if '%s' in browser: # User gave us a command line, don't mess with it. return GenericBrowser(browser) else: # User gave us a browser name. try: command = _browsers[browser.lower()] except KeyError: command = _synthesize(browser) if command[1] is None: return command[0]() else: return command[1] raise Error("could not locate runnable browser") | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
||
if command[1] is None: | if command[1] is not None: return command[1] elif command[0] is not None: | def get(using=None): """Return a browser launcher instance appropriate for the environment.""" if using is not None: alternatives = [using] else: alternatives = _tryorder for browser in alternatives: if '%s' in browser: # User gave us a command line, don't mess with it. return GenericBrowser(browser) else: # User gave us a browser name. try: command = _browsers[browser.lower()] except KeyError: command = _synthesize(browser) if command[1] is None: return command[0]() else: return command[1] raise Error("could not locate runnable browser") | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
else: return command[1] | def get(using=None): """Return a browser launcher instance appropriate for the environment.""" if using is not None: alternatives = [using] else: alternatives = _tryorder for browser in alternatives: if '%s' in browser: # User gave us a command line, don't mess with it. return GenericBrowser(browser) else: # User gave us a browser name. try: command = _browsers[browser.lower()] except KeyError: command = _synthesize(browser) if command[1] is None: return command[0]() else: return command[1] raise Error("could not locate runnable browser") | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
|
get().open(url, new, autoraise) | for name in _tryorder: browser = get(name) if browser.open(url, new, autoraise): return True return False | def open(url, new=0, autoraise=1): get().open(url, new, autoraise) | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
get().open(url, 1) def _synthesize(browser): | return open(url, 1) def open_new_tab(url): return open(url, 2) def _synthesize(browser, update_tryorder=1): | def open_new(url): get().open(url, 1) | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
if not os.path.exists(browser): | cmd = browser.split()[0] if not _iscommand(cmd): | def _synthesize(browser): """Attempt to synthesize a controller base on existing controllers. This is useful to create a controller when a user specifies a path to an entry in the BROWSER environment variable -- we can copy a general controller to operate using a specific installation of the desired browser in this way. If we can't create a controller in this way, or if there is no executable for the requested browser, return [None, None]. """ if not os.path.exists(browser): return [None, None] name = os.path.basename(browser) try: command = _browsers[name.lower()] except KeyError: return [None, None] # now attempt to clone to fit the new name: controller = command[1] if controller and name.lower() == controller.basename: import copy controller = copy.copy(controller) controller.name = browser controller.basename = os.path.basename(browser) register(browser, None, controller) return [None, controller] return [None, None] | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
name = os.path.basename(browser) | name = os.path.basename(cmd) | def _synthesize(browser): """Attempt to synthesize a controller base on existing controllers. This is useful to create a controller when a user specifies a path to an entry in the BROWSER environment variable -- we can copy a general controller to operate using a specific installation of the desired browser in this way. If we can't create a controller in this way, or if there is no executable for the requested browser, return [None, None]. """ if not os.path.exists(browser): return [None, None] name = os.path.basename(browser) try: command = _browsers[name.lower()] except KeyError: return [None, None] # now attempt to clone to fit the new name: controller = command[1] if controller and name.lower() == controller.basename: import copy controller = copy.copy(controller) controller.name = browser controller.basename = os.path.basename(browser) register(browser, None, controller) return [None, controller] return [None, None] | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
register(browser, None, controller) | register(browser, None, controller, update_tryorder) | def _synthesize(browser): """Attempt to synthesize a controller base on existing controllers. This is useful to create a controller when a user specifies a path to an entry in the BROWSER environment variable -- we can copy a general controller to operate using a specific installation of the desired browser in this way. If we can't create a controller in this way, or if there is no executable for the requested browser, return [None, None]. """ if not os.path.exists(browser): return [None, None] name = os.path.basename(browser) try: command = _browsers[name.lower()] except KeyError: return [None, None] # now attempt to clone to fit the new name: controller = command[1] if controller and name.lower() == controller.basename: import copy controller = copy.copy(controller) controller.name = browser controller.basename = os.path.basename(browser) register(browser, None, controller) return [None, controller] return [None, None] | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
"""Return True if cmd can be found on the executable search path.""" | """Return True if cmd is executable or can be found on the executable search path.""" if _isexecutable(cmd): return True | def _iscommand(cmd): """Return True if cmd can be found on the executable search path.""" path = os.environ.get("PATH") if not path: return False for d in path.split(os.pathsep): exe = os.path.join(d, cmd) if os.path.isfile(exe): return True return False | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
if os.path.isfile(exe): | if _isexecutable(exe): | def _iscommand(cmd): """Return True if cmd can be found on the executable search path.""" path = os.environ.get("PATH") if not path: return False for d in path.split(os.pathsep): exe = os.path.join(d, cmd) if os.path.isfile(exe): return True return False | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
PROCESS_CREATION_DELAY = 4 class GenericBrowser: | class BaseBrowser(object): """Parent class for all browsers.""" def __init__(self, name=""): self.name = name def open_new(self, url): return self.open(url, 1) def open_new_tab(self, url): return self.open(url, 2) class GenericBrowser(BaseBrowser): """Class for all browsers started with a command and without remote functionality.""" | def _iscommand(cmd): """Return True if cmd can be found on the executable search path.""" path = os.environ.get("PATH") if not path: return False for d in path.split(os.pathsep): exe = os.path.join(d, cmd) if os.path.isfile(exe): return True return False | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
self.basename = os.path.basename(self.name) | def __init__(self, cmd): self.name, self.args = cmd.split(None, 1) self.basename = os.path.basename(self.name) | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
|
os.system(command % url) def open_new(self, url): self.open(url) class Netscape: "Launcher class for Netscape browsers." def __init__(self, name): self.name = name self.basename = os.path.basename(name) def _remote(self, action, autoraise): raise_opt = ("-noraise", "-raise")[autoraise] cmd = "%s %s -remote '%s' >/dev/null 2>&1" % (self.name, raise_opt, action) | rc = os.system(command % url) return not rc class UnixBrowser(BaseBrowser): """Parent class for all Unix browsers with remote functionality.""" raise_opts = None remote_cmd = '' remote_action = None remote_action_newwin = None remote_action_newtab = None remote_background = False def _remote(self, url, action, autoraise): autoraise = int(bool(autoraise)) raise_opt = self.raise_opts and self.raise_opts[autoraise] or '' cmd = "%s %s %s '%s' >/dev/null 2>&1" % (self.name, raise_opt, self.remote_cmd, action) if remote_background: cmd += ' &' | def open(self, url, new=0, autoraise=1): assert "'" not in url command = "%s %s" % (self.name, self.args) os.system(command % url) | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
import time os.system("%s &" % self.name) time.sleep(PROCESS_CREATION_DELAY) rc = os.system(cmd) | rc = os.system("%s %s" % (self.name, url)) | def _remote(self, action, autoraise): raise_opt = ("-noraise", "-raise")[autoraise] cmd = "%s %s -remote '%s' >/dev/null 2>&1" % (self.name, raise_opt, action) rc = os.system(cmd) if rc: import time os.system("%s &" % self.name) time.sleep(PROCESS_CREATION_DELAY) rc = os.system(cmd) return not rc | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
if new: self._remote("openURL(%s, new-window)"%url, autoraise) | assert "'" not in url if new == 0: action = self.remote_action elif new == 1: action = self.remote_action_newwin elif new == 2: if self.remote_action_newtab is None: action = self.remote_action_newwin else: action = self.remote_action_newtab | def open(self, url, new=0, autoraise=1): if new: self._remote("openURL(%s, new-window)"%url, autoraise) else: self._remote("openURL(%s)" % url, autoraise) | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
self._remote("openURL(%s)" % url, autoraise) def open_new(self, url): self.open(url, 1) class Galeon: """Launcher class for Galeon browsers.""" def __init__(self, name): self.name = name self.basename = os.path.basename(name) def _remote(self, action, autoraise): raise_opt = ("--noraise", "")[autoraise] cmd = "%s %s %s >/dev/null 2>&1" % (self.name, raise_opt, action) rc = os.system(cmd) if rc: import time os.system("%s >/dev/null 2>&1 &" % self.name) time.sleep(PROCESS_CREATION_DELAY) rc = os.system(cmd) return not rc def open(self, url, new=0, autoraise=1): if new: self._remote("-w '%s'" % url, autoraise) else: self._remote("-n '%s'" % url, autoraise) def open_new(self, url): self.open(url, 1) class Konqueror: | raise Error("Bad 'new' parameter to open(); expected 0, 1, or 2, got %s" % new) return self._remote(url, action % url, autoraise) class Mozilla(UnixBrowser): """Launcher class for Mozilla/Netscape browsers.""" raise_opts = ("-noraise", "-raise") remote_cmd = '-remote' remote_action = "openURL(%s)" remote_action_newwin = "openURL(%s,new-window)" remote_action_newtab = "openURL(%s,new-tab)" Netscape = Mozilla class Galeon(UnixBrowser): """Launcher class for Galeon/Epiphany browsers.""" raise_opts = ("-noraise", "") remote_action = "-n '%s'" remote_action_newwin = "-w '%s'" remote_background = True class Konqueror(BaseBrowser): | def open(self, url, new=0, autoraise=1): if new: self._remote("openURL(%s, new-window)"%url, autoraise) else: self._remote("openURL(%s)" % url, autoraise) | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
def __init__(self): if _iscommand("konqueror"): self.name = self.basename = "konqueror" else: self.name = self.basename = "kfm" def _remote(self, action): | def _remote(self, url, action): | def __init__(self): if _iscommand("konqueror"): self.name = self.basename = "konqueror" else: self.name = self.basename = "kfm" | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
import time if self.basename == "konqueror": os.system(self.name + " --silent &") else: os.system(self.name + " -d &") time.sleep(PROCESS_CREATION_DELAY) rc = os.system(cmd) | if _iscommand("konqueror"): rc = os.system(self.name + " --silent '%s' &" % url) elif _iscommand("kfm"): rc = os.system(self.name + " -d '%s'" % url) | def _remote(self, action): cmd = "kfmclient %s >/dev/null 2>&1" % action rc = os.system(cmd) if rc: import time if self.basename == "konqueror": os.system(self.name + " --silent &") else: os.system(self.name + " -d &") time.sleep(PROCESS_CREATION_DELAY) rc = os.system(cmd) return not rc | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
def open(self, url, new=1, autoraise=1): | def open(self, url, new=0, autoraise=1): | def open(self, url, new=1, autoraise=1): # XXX Currently I know no way to prevent KFM from # opening a new win. assert "'" not in url self._remote("openURL '%s'" % url) | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
self._remote("openURL '%s'" % url) open_new = open class Grail: | if new == 2: action = "newTab '%s'" % url else: action = "openURL '%s'" % url ok = self._remote(url, action) return ok class Opera(UnixBrowser): "Launcher class for Opera browser." raise_opts = ("", "-raise") remote_cmd = '-remote' remote_action = "openURL(%s)" remote_action_newwin = "openURL(%s,new-window)" remote_action_newtab = "openURL(%s,new-page)" class Elinks(UnixBrowser): "Launcher class for Elinks browsers." remote_cmd = '-remote' remote_action = "openURL(%s)" remote_action_newwin = "openURL(%s,new-window)" remote_action_newtab = "openURL(%s,new-tab)" def _remote(self, url, action, autoraise): cmd = "%s %s '%s' 2>/dev/null" % (self.name, self.remote_cmd, action) rc = os.system(cmd) if rc: rc = os.system("%s %s" % (self.name, url)) return not rc class Grail(BaseBrowser): | def open(self, url, new=1, autoraise=1): # XXX Currently I know no way to prevent KFM from # opening a new win. assert "'" not in url self._remote("openURL '%s'" % url) | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
self._remote("LOADNEW " + url) | ok = self._remote("LOADNEW " + url) | def open(self, url, new=0, autoraise=1): if new: self._remote("LOADNEW " + url) else: self._remote("LOAD " + url) | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
self._remote("LOAD " + url) def open_new(self, url): self.open(url, 1) class WindowsDefault: def open(self, url, new=0, autoraise=1): os.startfile(url) def open_new(self, url): self.open(url) | ok = self._remote("LOAD " + url) return ok | def open(self, url, new=0, autoraise=1): if new: self._remote("LOADNEW " + url) else: self._remote("LOAD " + url) | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
if os.environ.get("TERM") or os.environ.get("DISPLAY"): _tryorder = ["links", "lynx", "w3m"] if os.environ.get("TERM"): if _iscommand("links"): register("links", None, GenericBrowser("links '%s'")) if _iscommand("lynx"): register("lynx", None, GenericBrowser("lynx '%s'")) if _iscommand("w3m"): register("w3m", None, GenericBrowser("w3m '%s'")) if os.environ.get("DISPLAY"): _tryorder = ["galeon", "skipstone", "mozilla-firefox", "mozilla-firebird", "mozilla", "netscape", "kfm", "grail"] + _tryorder for browser in ("mozilla-firefox", "mozilla-firebird", "mozilla", "netscape"): if _iscommand(browser): register(browser, None, Netscape(browser)) if _iscommand("mosaic"): register("mosaic", None, GenericBrowser( "mosaic '%s' >/dev/null &")) if _iscommand("galeon"): register("galeon", None, Galeon("galeon")) if _iscommand("skipstone"): register("skipstone", None, GenericBrowser( "skipstone '%s' >/dev/null &")) if _iscommand("kfm") or _iscommand("konqueror"): register("kfm", Konqueror, Konqueror()) if _iscommand("grail"): register("grail", Grail, None) class InternetConfig: def open(self, url, new=0, autoraise=1): ic.launchurl(url) def open_new(self, url): self.open(url) | if os.environ.get("DISPLAY"): for browser in ("mozilla-firefox", "firefox", "mozilla-firebird", "firebird", "mozilla", "netscape"): if _iscommand(browser): register(browser, None, Mozilla(browser)) if _iscommand("gconftool-2"): gc = 'gconftool-2 -g /desktop/gnome/url-handlers/http/command' out = os.popen(gc) commd = out.read().strip() retncode = out.close() if retncode == None and len(commd) != 0: register("gnome", None, GenericBrowser( commd + " '%s' >/dev/null &")) if _iscommand("kfm") or _iscommand("konqueror"): register("kfm", Konqueror, Konqueror()) for browser in ("galeon", "epiphany"): if _iscommand(browser): register(browser, None, Galeon(browser)) if _iscommand("skipstone"): register("skipstone", None, GenericBrowser("skipstone '%s' &")) if _iscommand("opera"): register("opera", None, Opera("opera")) if _iscommand("mosaic"): register("mosaic", None, GenericBrowser("mosaic '%s' &")) if _iscommand("grail"): register("grail", Grail, None) if os.environ.get("TERM"): if _iscommand("links"): register("links", None, GenericBrowser("links '%s'")) if _iscommand("elinks"): register("elinks", None, Elinks("elinks")) if _iscommand("lynx"): register("lynx", None, GenericBrowser("lynx '%s'")) if _iscommand("w3m"): register("w3m", None, GenericBrowser("w3m '%s'")) | def open_new(self, url): self.open(url) | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
_tryorder = ["netscape", "windows-default"] | class WindowsDefault(BaseBrowser): def open(self, url, new=0, autoraise=1): os.startfile(url) return True _tryorder = [] _browsers = {} for browser in ("firefox", "firebird", "mozilla", "netscape", "opera"): if _iscommand(browser): register(browser, None, GenericBrowser(browser + ' %s')) | def open_new(self, url): self.open(url) | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
_tryorder = ["internet-config"] register("internet-config", InternetConfig) | class InternetConfig(BaseBrowser): def open(self, url, new=0, autoraise=1): ic.launchurl(url) return True register("internet-config", InternetConfig, update_tryorder=-1) if sys.platform == 'darwin': class MacOSX(BaseBrowser): """Launcher class for Aqua browsers on Mac OS X Optionally specify a browser name on instantiation. Note that this will not work for Aqua browsers if the user has moved the application package after installation. If no browser is specified, the default browser, as specified in the Internet System Preferences panel, will be used. """ def __init__(self, name): self.name = name def open(self, url, new=0, autoraise=1): assert "'" not in url new = int(bool(new)) if self.name == "default": script = _safequote('open location "%s"', url) else: if self.name == "OmniWeb": toWindow = "" else: toWindow = "toWindow %d" % (new - 1) cmd = _safequote('OpenURL "%s"', url) script = '''tell application "%s" activate %s %s end tell''' % (self.name, cmd, toWindow) osapipe = os.popen("osascript", "w") if osapipe is None: return False osapipe.write(script) rc = osapipe.close() return not rc register("MacOSX", None, MacOSX('default'), -1) | def open_new(self, url): self.open(url) | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
if sys.platform[:3] == "os2" and _iscommand("netscape.exe"): _tryorder = ["os2netscape"] | if sys.platform[:3] == "os2" and _iscommand("netscape"): _tryorder = [] _browsers = {} | def open_new(self, url): self.open(url) | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
GenericBrowser("start netscape.exe %s")) | GenericBrowser("start netscape %s"), -1) | def open_new(self, url): self.open(url) | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
def open_new(self, url): self.open(url) | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
||
_tryorder = os.environ["BROWSER"].split(os.pathsep) for cmd in _tryorder: if not cmd.lower() in _browsers: if _iscommand(cmd.lower()): register(cmd.lower(), None, GenericBrowser( "%s '%%s'" % cmd.lower())) cmd = None del cmd _tryorder = filter(lambda x: x.lower() in _browsers or x.find("%s") > -1, _tryorder) | _userchoices = os.environ["BROWSER"].split(os.pathsep) _userchoices.reverse() for cmdline in _userchoices: if cmdline != '': _synthesize(cmdline, -1) cmdline = None del cmdline del _userchoices | def open_new(self, url): self.open(url) | 336cf8e9a006f0abbd7712771acc892711f93ebd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/336cf8e9a006f0abbd7712771acc892711f93ebd/webbrowser.py |
s.bind('', self.port) | s.bind(('', self.port)) | def __init__(self, port=None, connection_hook=None): self.connections = [] self.port = port or self.default_port self.connection_hook = connection_hook | 64627dee239f18823f2f1f561685897452ec9a2d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/64627dee239f18823f2f1f561685897452ec9a2d/protocol.py |
except BClass, v: raise TestFailed except AClass, v: | except BClass, v: | def __init__(self, ignore): | c4b2bf86f2179cf8ce9518c7c1e3fff7fc58361a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c4b2bf86f2179cf8ce9518c7c1e3fff7fc58361a/test_opcodes.py |
else: raise TestFailed | def __init__(self, ignore): | c4b2bf86f2179cf8ce9518c7c1e3fff7fc58361a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c4b2bf86f2179cf8ce9518c7c1e3fff7fc58361a/test_opcodes.py |
|
last = last + 1 | last = min(self.maxx, last+1) | def _end_of_line(self, y): "Go to the location of the first blank on the given line." last = self.maxx while 1: if ascii.ascii(self.win.inch(y, last)) != ascii.SP: last = last + 1 break elif last == 0: break last = last - 1 return last | 9b298800e161e9504f7a2eb83e264732f35f2c36 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9b298800e161e9504f7a2eb83e264732f35f2c36/textpad.py |
parts = ctype.split('/') if len(parts) > 0: return ctype.split('/')[0] return failobj | if ctype.count('/') <> 1: return failobj return ctype.split('/')[0] | def get_main_type(self, failobj=None): """Return the message's main content type if present.""" missing = [] ctype = self.get_type(missing) if ctype is missing: return failobj parts = ctype.split('/') if len(parts) > 0: return ctype.split('/')[0] return failobj | 8b6fb51a00b698e73dce077dd98e026502b96e90 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8b6fb51a00b698e73dce077dd98e026502b96e90/Message.py |
parts = ctype.split('/') if len(parts) > 1: return ctype.split('/')[1] return failobj | if ctype.count('/') <> 1: return failobj return ctype.split('/')[1] def get_content_type(self): """Returns the message's content type. The returned string is coerced to lowercase and returned as a ingle string of the form `maintype/subtype'. If there was no Content-Type: header in the message, the default type as give by get_default_type() will be returned. Since messages always have a default type this will always return a value. The current state of RFC standards define a message's default type to be text/plain unless it appears inside a multipart/digest container, in which case it would be message/rfc822. """ missing = [] value = self.get('content-type', missing) if value is missing: return self.get_default_type() return paramre.split(value)[0].lower().strip() def get_content_maintype(self): """Returns the message's main content type. This is the `maintype' part of the string returned by get_content_type(). If no slash is found in the full content type, a ValueError is raised. """ ctype = self.get_content_type() if ctype.count('/') <> 1: raise ValueError, 'No maintype found in: %s' % ctype return ctype.split('/')[0] def get_content_subtype(self): """Returns the message's sub content type. This is the `subtype' part of the string returned by get_content_type(). If no slash is found in the full content type, a ValueError is raised. """ ctype = self.get_content_type() if ctype.count('/') <> 1: raise ValueError, 'No subtype found in: %s' % ctype return ctype.split('/')[1] | def get_subtype(self, failobj=None): """Return the message's content subtype if present.""" missing = [] ctype = self.get_type(missing) if ctype is missing: return failobj parts = ctype.split('/') if len(parts) > 1: return ctype.split('/')[1] return failobj | 8b6fb51a00b698e73dce077dd98e026502b96e90 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8b6fb51a00b698e73dce077dd98e026502b96e90/Message.py |
ctype must be either "text/plain" or "message/rfc822". The default content type is not stored in the Content-Type: header. """ if ctype not in ('text/plain', 'message/rfc822'): raise ValueError( 'first arg must be either "text/plain" or "message/rfc822"') | ctype should be either "text/plain" or "message/rfc822", although this is not enforced. The default content type is not stored in the Content-Type: header. """ | def set_default_type(self, ctype): """Set the `default' content type. | 8b6fb51a00b698e73dce077dd98e026502b96e90 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8b6fb51a00b698e73dce077dd98e026502b96e90/Message.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.