rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
print >>sys.stderr, _('*** %(file)s:%(lineno)s: Seen unexpected token "%(token)s"') % { 'token': tstring, 'file': self.__curfile, 'lineno': self.__lineno}
print >> sys.stderr, _( '*** %(file)s:%(lineno)s: Seen unexpected token "%(token)s"' ) % { 'token': tstring, 'file': self.__curfile, 'lineno': self.__lineno }
def __openseen(self, ttype, tstring, lineno): if ttype == tokenize.OP and tstring == ')': # We've seen the last of the translatable strings. Record the # line number of the first line of the strings and update the list # of messages seen. Reset state for the next batch. If there # were no strings inside _(), then just ignore this entry. if self.__data: self.__addentry(EMPTYSTRING.join(self.__data)) self.__state = self.__waiting elif ttype == tokenize.STRING: self.__data.append(safe_eval(tstring)) elif ttype not in [tokenize.COMMENT, token.INDENT, token.DEDENT, token.NEWLINE, tokenize.NL]: # warn if we see anything else than STRING or whitespace print >>sys.stderr, _('*** %(file)s:%(lineno)s: Seen unexpected token "%(token)s"') % { 'token': tstring, 'file': self.__curfile, 'lineno': self.__lineno} self.__state = self.__waiting
e04ee70a68045f8d229ab59ad9b0256d0278c745 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e04ee70a68045f8d229ab59ad9b0256d0278c745/pygettext.py
_('*** Seen unexpected token "%(token)s"' % {'token': 'test'})
_('*** Seen unexpected token "%(token)s"') % {'token': 'test'}
def main(): global default_keywords try: opts, args = getopt.getopt( sys.argv[1:], 'ad:DEhk:Kno:p:S:Vvw:x: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', 'no-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 nodocstrings = {} 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 elif opt in ('-X', '--no-docstrings'): fp = open(arg) try: while 1: line = fp.readline() if not line: break options.nodocstrings[line[:-1]] = 1 finally: fp.close() # 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 = [] # resolve args to module lists expanded = [] for arg in args: if arg == '-': expanded.append(arg) else: expanded.extend(getFilesForName(arg)) args = expanded # 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()
e04ee70a68045f8d229ab59ad9b0256d0278c745 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e04ee70a68045f8d229ab59ad9b0256d0278c745/pygettext.py
def main(): global default_keywords try: opts, args = getopt.getopt( sys.argv[1:], 'ad:DEhk:Kno:p:S:Vvw:x: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', 'no-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 nodocstrings = {} 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 elif opt in ('-X', '--no-docstrings'): fp = open(arg) try: while 1: line = fp.readline() if not line: break options.nodocstrings[line[:-1]] = 1 finally: fp.close() # 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 = [] # resolve args to module lists expanded = [] for arg in args: if arg == '-': expanded.append(arg) else: expanded.extend(getFilesForName(arg)) args = expanded # 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()
e04ee70a68045f8d229ab59ad9b0256d0278c745 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e04ee70a68045f8d229ab59ad9b0256d0278c745/pygettext.py
(run, run == 1 and "" or "s", timeTaken))
(run, run != 1 and "s" or "", timeTaken))
def run(self, test): "Run the given test case or test suite." result = self._makeResult() startTime = time.time() test(result) stopTime = time.time() timeTaken = float(stopTime - startTime) result.printErrors() self.stream.writeln(result.separator2) run = result.testsRun self.stream.writeln("Ran %d test%s in %.3fs" % (run, run == 1 and "" or "s", timeTaken)) self.stream.writeln() if not result.wasSuccessful(): self.stream.write("FAILED (") failed, errored = map(len, (result.failures, result.errors)) if failed: self.stream.write("failures=%d" % failed) if errored: if failed: self.stream.write(", ") self.stream.write("errors=%d" % errored) self.stream.writeln(")") else: self.stream.writeln("OK") return result
7616504dcf49d233d38a7518cdd28a9cc6531b74 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7616504dcf49d233d38a7518cdd28a9cc6531b74/unittest.py
if self.groupdict.has_key(name): raise error, "can only use each group name once"
ogid = self.groupdict.get(name, None) if ogid is not None: raise error, ("redefinition of group name %s as group %d; " + "was group %d") % (`name`, gid, ogid)
def opengroup(self, name=None): gid = self.groups self.groups = gid + 1 if name: if self.groupdict.has_key(name): raise error, "can only use each group name once" self.groupdict[name] = gid self.open.append(gid) return gid
7533587d4363d0841232f58d61adc15fa32b4825 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7533587d4363d0841232f58d61adc15fa32b4825/sre_parse.py
return self.try_cpp(headers=[header], include_dirs=include_dirs)
return self.try_cpp(body="/* No body */", headers=[header], include_dirs=include_dirs)
def check_header (self, header, include_dirs=None, library_dirs=None, lang="c"): """Determine if the system header file named by 'header_file' exists and can be found by the preprocessor; return true if so, false otherwise. """ return self.try_cpp(headers=[header], include_dirs=include_dirs)
4013cbd06becfbfbb63b9b524e5c41513f497929 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4013cbd06becfbfbb63b9b524e5c41513f497929/config.py
return '<' + x.__class__.__name__ + ' instance at ' + \ hex(id(x))[2:] + '>'
return '<%s instance at %x>' % (x.__class__.__name__, id(x))
def repr_instance(self, x, level): try: s = __builtin__.repr(x) # Bugs in x.__repr__() can cause arbitrary # exceptions -- then make up something except: return '<' + x.__class__.__name__ + ' instance at ' + \ hex(id(x))[2:] + '>' if len(s) > self.maxstring: i = max(0, (self.maxstring-3)//2) j = max(0, self.maxstring-3-i) s = s[:i] + '...' + s[len(s)-j:] return s
83a643071785959658f7e844ba1a341a7d9a7f46 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/83a643071785959658f7e844ba1a341a7d9a7f46/repr.py
if prog.match(line) == len(line):
if prog.match(line) >= 0:
def pickline(file, key, casefold = 1): try: f = open(file, 'r') except IOError: return None pat = key + ':' if casefold: prog = regex.compile(pat, regex.casefold) else: prog = regex.compile(pat) while 1: line = f.readline() if not line: break if prog.match(line) == len(line): text = line[len(key)+1:] while 1: line = f.readline() if not line or \ line[0] not in string.whitespace: break text = text + line return string.strip(text) return None
ea8ee1dfc5359da79126d78609f4673e0673bb9c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ea8ee1dfc5359da79126d78609f4673e0673bb9c/mhlib.py
except (AttributeError, Tkinter.TclError):
except (KeyboardInterrupt, SystemExit): raise except Exception:
def __del__(self): try: if self.delete_font: self._call("font", "delete", self.name) except (AttributeError, Tkinter.TclError): pass
314fce92dd12a8ff82876bd18845a2249a931fae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/314fce92dd12a8ff82876bd18845a2249a931fae/tkFont.py
Pack the values v2, v2, ... according to fmt, write
Pack the values v1, v2, ... according to fmt, write
def pack_into(fmt, buf, offset, *args): """ Pack the values v2, v2, ... according to fmt, write the packed bytes into the writable buffer buf starting at offset. See struct.__doc__ for more on format strings. """ try: o = _cache[fmt] except KeyError: o = _compile(fmt) return o.pack_into(buf, offset, *args)
499b0e638bf0ede8239fe57ed0b2eb76bc04fa49 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/499b0e638bf0ede8239fe57ed0b2eb76bc04fa49/struct.py
tempcache = None
__tempfiles = []
def urlcleanup(): if _urlopener: _urlopener.cleanup()
2b3fd76cc7599630df68444a7a96e97fddd5c0fb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2b3fd76cc7599630df68444a7a96e97fddd5c0fb/urllib.py
if self.tempcache:
if self.__tempfiles:
def cleanup(self): if self.tempcache: import os for url in self.tempcache.keys(): try: os.unlink(self.tempcache[url][0]) except os.error: pass del self.tempcache[url]
2b3fd76cc7599630df68444a7a96e97fddd5c0fb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2b3fd76cc7599630df68444a7a96e97fddd5c0fb/urllib.py
for url in self.tempcache.keys():
for file in self.__tempfiles:
def cleanup(self): if self.tempcache: import os for url in self.tempcache.keys(): try: os.unlink(self.tempcache[url][0]) except os.error: pass del self.tempcache[url]
2b3fd76cc7599630df68444a7a96e97fddd5c0fb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2b3fd76cc7599630df68444a7a96e97fddd5c0fb/urllib.py
os.unlink(self.tempcache[url][0])
os.unlink(file)
def cleanup(self): if self.tempcache: import os for url in self.tempcache.keys(): try: os.unlink(self.tempcache[url][0]) except os.error: pass del self.tempcache[url]
2b3fd76cc7599630df68444a7a96e97fddd5c0fb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2b3fd76cc7599630df68444a7a96e97fddd5c0fb/urllib.py
del self.tempcache[url]
URLopener.__tempfiles = [] self.tempcache = None
def cleanup(self): if self.tempcache: import os for url in self.tempcache.keys(): try: os.unlink(self.tempcache[url][0]) except os.error: pass del self.tempcache[url]
2b3fd76cc7599630df68444a7a96e97fddd5c0fb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2b3fd76cc7599630df68444a7a96e97fddd5c0fb/urllib.py
i = string.rfind(basepath, '/')
i = string.rfind(basepath[:-1], '/')
def basejoin(base, 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 extraneuous 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, '/') if i > 0: basepath = basepath[:i-1] 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
2b3fd76cc7599630df68444a7a96e97fddd5c0fb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2b3fd76cc7599630df68444a7a96e97fddd5c0fb/urllib.py
basepath = basepath[:i-1]
basepath = basepath[:i+1] elif i == 0: basepath = '/' break else: basepath = ''
def basejoin(base, 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 extraneuous 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, '/') if i > 0: basepath = basepath[:i-1] 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
2b3fd76cc7599630df68444a7a96e97fddd5c0fb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2b3fd76cc7599630df68444a7a96e97fddd5c0fb/urllib.py
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 scheme.lower() == '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)
if not headers.has_key('www-authenticate'): URLopener.http_error_default(self, url, fp, errmsg, headers) stuff = headers['www-authenticate'] import re match = re.match('[ \t]*([^ \t]+)[ \t]+realm="([^"]*)"', stuff) if not match: URLopener.http_error_default(self, url, fp, errcode, errmsg, headers) scheme, realm = match.groups() if scheme.lower() != 'basic': URLopener.http_error_default(self, url, fp, errcode, errmsg, headers) name = 'retry_' + self.type + '_basic_auth' if data is None: return getattr(self,name)(url, realm) else: return getattr(self,name)(url, realm, data)
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 scheme.lower() == '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)
e99bd17ed6ffbb7a6deee9b80b83ce6a9e4e8b10 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e99bd17ed6ffbb7a6deee9b80b83ce6a9e4e8b10/urllib.py
def run (self):
5310e5078ad331631f109e8fa33b8534911f0ce0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5310e5078ad331631f109e8fa33b8534911f0ce0/bdist_rpm.py
srpms = glob.glob(os.path.join(rpm_dir['SRPMS'], "*.rpm")) assert len(srpms) == 1, \ "unexpected number of SRPM files found: %s" % srpms dist_file = ('bdist_rpm', 'any', self._dist_path(srpms[0])) self.distribution.dist_files.append(dist_file) self.move_file(srpms[0], self.dist_dir)
srpm = os.path.join(rpm_dir['SRPMS'], source_rpm) assert(os.path.exists(srpm)) self.move_file(srpm, self.dist_dir)
def run (self):
5310e5078ad331631f109e8fa33b8534911f0ce0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5310e5078ad331631f109e8fa33b8534911f0ce0/bdist_rpm.py
rpms = glob.glob(os.path.join(rpm_dir['RPMS'], "*/*.rpm")) debuginfo = glob.glob(os.path.join(rpm_dir['RPMS'], "*/*debuginfo*.rpm")) if debuginfo: rpms.remove(debuginfo[0]) assert len(rpms) == 1, \ "unexpected number of RPM files found: %s" % rpms dist_file = ('bdist_rpm', get_python_version(), self._dist_path(rpms[0])) self.distribution.dist_files.append(dist_file) self.move_file(rpms[0], self.dist_dir) if debuginfo: dist_file = ('bdist_rpm', get_python_version(), self._dist_path(debuginfo[0])) self.move_file(debuginfo[0], self.dist_dir)
for rpm in binary_rpms: rpm = os.path.join(rpm_dir['RPMS'], rpm) if os.path.exists(rpm): self.move_file(rpm, self.dist_dir)
def run (self):
5310e5078ad331631f109e8fa33b8534911f0ce0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5310e5078ad331631f109e8fa33b8534911f0ce0/bdist_rpm.py
def wm_state(self): """Return the state of this widget as one of normal, icon, iconic (see wm_iconwindow) and withdrawn.""" return self.tk.call('wm', 'state', self._w)
def wm_state(self, newstate=None): """Query or set the state of this widget as one of normal, icon, iconic (see wm_iconwindow), withdrawn, or zoomed (Windows only).""" return self.tk.call('wm', 'state', self._w, newstate)
def wm_state(self): """Return the state of this widget as one of normal, icon, iconic (see wm_iconwindow) and withdrawn.""" return self.tk.call('wm', 'state', self._w)
289ad8f06354eaac2ce8174d52265292a6e71965 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/289ad8f06354eaac2ce8174d52265292a6e71965/Tkinter.py
newurl = '//' + host + selector return self.open_http(newurl)
newurl = 'http://' + host + selector return self.open(newurl)
def retry_http_basic_auth(self, url, realm): 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 = '//' + host + selector return self.open_http(newurl)
e0c0da98d85a343ec0578ce8ce690fb952118a0b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e0c0da98d85a343ec0578ce8ce690fb952118a0b/urllib.py
from pprint import pprint print "options (after parsing config files):" pprint (self.command_options)
parser.__init__()
def parse_config_files (self, filenames=None):
474607777d10562679b1640d3831290b0c4284f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/474607777d10562679b1640d3831290b0c4284f7/dist.py
if opts.help:
if hasattr(opts, 'help') and opts.help:
def _parse_command_opts (self, parser, args):
474607777d10562679b1640d3831290b0c4284f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/474607777d10562679b1640d3831290b0c4284f7/dist.py
cmd_opts[command] = ("command line", value)
cmd_opts[name] = ("command line", value)
def _parse_command_opts (self, parser, args):
474607777d10562679b1640d3831290b0c4284f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/474607777d10562679b1640d3831290b0c4284f7/dist.py
cmd_obj = self.command_obj[command] = klass() self.command_run[command] = 0
cmd_obj = self.command_obj[command] = klass(self) self.have_run[command] = 0 options = self.command_options.get(command) if options: print " setting options:" for (option, (source, value)) in options.items(): print " %s = %s (from %s)" % (option, value, source) setattr(cmd_obj, option, value)
def get_command_obj (self, command, create=1): """Return the command object for 'command'. Normally this object is cached on a previous call to 'get_command_obj()'; if no comand object for 'command' is in the cache, then we either create and return it (if 'create' is true) or return None. """ cmd_obj = self.command_obj.get(command) if not cmd_obj and create: klass = self.get_command_class(command) cmd_obj = self.command_obj[command] = klass() self.command_run[command] = 0
474607777d10562679b1640d3831290b0c4284f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/474607777d10562679b1640d3831290b0c4284f7/dist.py
x = self.dict[headerseen] + "\n " + line.strip()
def readheaders(self): """Read header lines.
22b3a49d3c17c37348e65d06df8683e5b8fc6fd0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/22b3a49d3c17c37348e65d06df8683e5b8fc6fd0/httplib.py
conn = self.msg.getheader('connection') if conn: conn = conn.lower() self.will_close = conn.find('close') != -1 or \ ( self.version != 11 and \ not self.msg.getheader('keep-alive') ) else: self.will_close = self.version != 11 and \ not self.msg.getheader('keep-alive')
self.will_close = self._check_close()
def begin(self): if self.msg is not None: # we've already started reading the response return
22b3a49d3c17c37348e65d06df8683e5b8fc6fd0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/22b3a49d3c17c37348e65d06df8683e5b8fc6fd0/httplib.py
eq(value, 'text/plain; charset=us-ascii; boundary="BOUNDARY"')
eq(value, 'text/plain; charset="us-ascii"; boundary="BOUNDARY"')
def test_set_boundary(self): eq = self.assertEqual # This one has no existing boundary parameter, but the Content-Type: # header appears fifth. msg = self._msgobj('msg_01.txt') msg.set_boundary('BOUNDARY') header, value = msg.items()[4] eq(header.lower(), 'content-type') eq(value, 'text/plain; charset=us-ascii; boundary="BOUNDARY"') # This one has a Content-Type: header, with a boundary, stuck in the # middle of its headers. Make sure the order is preserved; it should # be fifth. msg = self._msgobj('msg_04.txt') msg.set_boundary('BOUNDARY') header, value = msg.items()[4] eq(header.lower(), 'content-type') eq(value, 'multipart/mixed; boundary="BOUNDARY"') # And this one has no Content-Type: header at all. msg = self._msgobj('msg_03.txt') self.assertRaises(Errors.HeaderParseError, msg.set_boundary, 'BOUNDARY')
9546e7972cd7fafa7da597cd433c6a59a3198ad8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9546e7972cd7fafa7da597cd433c6a59a3198ad8/test_email.py
'Content-Type: %s\n' % (mtype or 'text/plain'))) host, file = splithost(url)
'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' % (mtype or 'text/plain', size, modified)))
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')
f0713d3f4d1d9fbd3cc10877822e824103f7affa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f0713d3f4d1d9fbd3cc10877822e824103f7affa/urllib.py
return addinfourl(open(url2pathname(file), 'rb'),
return addinfourl(open(localname, 'rb'),
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')
f0713d3f4d1d9fbd3cc10877822e824103f7affa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f0713d3f4d1d9fbd3cc10877822e824103f7affa/urllib.py
return addinfourl(open(url2pathname(file), 'rb'),
return addinfourl(open(localname, 'rb'),
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')
f0713d3f4d1d9fbd3cc10877822e824103f7affa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f0713d3f4d1d9fbd3cc10877822e824103f7affa/urllib.py
if os.path.isdir (name):
if os.path.isdir (name) or name == '':
def mkpath (name, mode=0777, verbose=0, dry_run=0): """Create a directory and any missing ancestor directories. If the directory already exists, return silently. Raise DistutilsFileError if unable to create some directory along the way (eg. some sub-path exists, but is a file rather than a directory). If 'verbose' is true, print a one-line summary of each mkdir to stdout.""" global PATH_CREATED # XXX what's the better way to handle verbosity? print as we create # each directory in the path (the current behaviour), or only announce # the creation of the whole path? (quite easy to do the latter since # we're not using a recursive algorithm) name = os.path.normpath (name) if os.path.isdir (name): return if PATH_CREATED.get (name): return (head, tail) = os.path.split (name) tails = [tail] # stack of lone dirs to create while head and tail and not os.path.isdir (head): #print "splitting '%s': " % head, (head, tail) = os.path.split (head) #print "to ('%s','%s')" % (head, tail) tails.insert (0, tail) # push next higher dir onto stack #print "stack of tails:", tails # now 'head' contains the deepest directory that already exists # (that is, the child of 'head' in 'name' is the highest directory # that does *not* exist) for d in tails: #print "head = %s, d = %s: " % (head, d), head = os.path.join (head, d) if PATH_CREATED.get (head): continue if verbose: print "creating", head if not dry_run: try: os.mkdir (head) except os.error, (errno, errstr): raise DistutilsFileError, "%s: %s" % (head, errstr) PATH_CREATED[head] = 1
96182d7b68cfb2226af0c0e701b9d35d1aa59603 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/96182d7b68cfb2226af0c0e701b9d35d1aa59603/util.py
raise DistutilsFileError, "%s: %s" % (head, errstr)
raise DistutilsFileError, "'%s': %s" % (head, errstr)
def mkpath (name, mode=0777, verbose=0, dry_run=0): """Create a directory and any missing ancestor directories. If the directory already exists, return silently. Raise DistutilsFileError if unable to create some directory along the way (eg. some sub-path exists, but is a file rather than a directory). If 'verbose' is true, print a one-line summary of each mkdir to stdout.""" global PATH_CREATED # XXX what's the better way to handle verbosity? print as we create # each directory in the path (the current behaviour), or only announce # the creation of the whole path? (quite easy to do the latter since # we're not using a recursive algorithm) name = os.path.normpath (name) if os.path.isdir (name): return if PATH_CREATED.get (name): return (head, tail) = os.path.split (name) tails = [tail] # stack of lone dirs to create while head and tail and not os.path.isdir (head): #print "splitting '%s': " % head, (head, tail) = os.path.split (head) #print "to ('%s','%s')" % (head, tail) tails.insert (0, tail) # push next higher dir onto stack #print "stack of tails:", tails # now 'head' contains the deepest directory that already exists # (that is, the child of 'head' in 'name' is the highest directory # that does *not* exist) for d in tails: #print "head = %s, d = %s: " % (head, d), head = os.path.join (head, d) if PATH_CREATED.get (head): continue if verbose: print "creating", head if not dry_run: try: os.mkdir (head) except os.error, (errno, errstr): raise DistutilsFileError, "%s: %s" % (head, errstr) PATH_CREATED[head] = 1
96182d7b68cfb2226af0c0e701b9d35d1aa59603 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/96182d7b68cfb2226af0c0e701b9d35d1aa59603/util.py
raise DistutilsFileError, "could not open %s: %s" % (src, errstr)
raise DistutilsFileError, \ "could not open '%s': %s" % (src, errstr)
def _copy_file_contents (src, dst, buffer_size=16*1024): """Copy the file 'src' to 'dst'; both must be filenames. Any error opening either file, reading from 'src', or writing to 'dst', raises DistutilsFileError. Data is read/written in chunks of 'buffer_size' bytes (default 16k). No attempt is made to handle anything apart from regular files.""" # Stolen from shutil module in the standard library, but with # custom error-handling added. fsrc = None fdst = None try: try: fsrc = open(src, 'rb') except os.error, (errno, errstr): raise DistutilsFileError, "could not open %s: %s" % (src, errstr) try: fdst = open(dst, 'wb') except os.error, (errno, errstr): raise DistutilsFileError, "could not create %s: %s" % (dst, errstr) while 1: try: buf = fsrc.read (buffer_size) except os.error, (errno, errstr): raise DistutilsFileError, \ "could not read from %s: %s" % (src, errstr) if not buf: break try: fdst.write(buf) except os.error, (errno, errstr): raise DistutilsFileError, \ "could not write to %s: %s" % (dst, errstr) finally: if fdst: fdst.close() if fsrc: fsrc.close()
96182d7b68cfb2226af0c0e701b9d35d1aa59603 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/96182d7b68cfb2226af0c0e701b9d35d1aa59603/util.py
raise DistutilsFileError, "could not create %s: %s" % (dst, errstr)
raise DistutilsFileError, \ "could not create '%s': %s" % (dst, errstr)
def _copy_file_contents (src, dst, buffer_size=16*1024): """Copy the file 'src' to 'dst'; both must be filenames. Any error opening either file, reading from 'src', or writing to 'dst', raises DistutilsFileError. Data is read/written in chunks of 'buffer_size' bytes (default 16k). No attempt is made to handle anything apart from regular files.""" # Stolen from shutil module in the standard library, but with # custom error-handling added. fsrc = None fdst = None try: try: fsrc = open(src, 'rb') except os.error, (errno, errstr): raise DistutilsFileError, "could not open %s: %s" % (src, errstr) try: fdst = open(dst, 'wb') except os.error, (errno, errstr): raise DistutilsFileError, "could not create %s: %s" % (dst, errstr) while 1: try: buf = fsrc.read (buffer_size) except os.error, (errno, errstr): raise DistutilsFileError, \ "could not read from %s: %s" % (src, errstr) if not buf: break try: fdst.write(buf) except os.error, (errno, errstr): raise DistutilsFileError, \ "could not write to %s: %s" % (dst, errstr) finally: if fdst: fdst.close() if fsrc: fsrc.close()
96182d7b68cfb2226af0c0e701b9d35d1aa59603 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/96182d7b68cfb2226af0c0e701b9d35d1aa59603/util.py
"could not read from %s: %s" % (src, errstr)
"could not read from '%s': %s" % (src, errstr)
def _copy_file_contents (src, dst, buffer_size=16*1024): """Copy the file 'src' to 'dst'; both must be filenames. Any error opening either file, reading from 'src', or writing to 'dst', raises DistutilsFileError. Data is read/written in chunks of 'buffer_size' bytes (default 16k). No attempt is made to handle anything apart from regular files.""" # Stolen from shutil module in the standard library, but with # custom error-handling added. fsrc = None fdst = None try: try: fsrc = open(src, 'rb') except os.error, (errno, errstr): raise DistutilsFileError, "could not open %s: %s" % (src, errstr) try: fdst = open(dst, 'wb') except os.error, (errno, errstr): raise DistutilsFileError, "could not create %s: %s" % (dst, errstr) while 1: try: buf = fsrc.read (buffer_size) except os.error, (errno, errstr): raise DistutilsFileError, \ "could not read from %s: %s" % (src, errstr) if not buf: break try: fdst.write(buf) except os.error, (errno, errstr): raise DistutilsFileError, \ "could not write to %s: %s" % (dst, errstr) finally: if fdst: fdst.close() if fsrc: fsrc.close()
96182d7b68cfb2226af0c0e701b9d35d1aa59603 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/96182d7b68cfb2226af0c0e701b9d35d1aa59603/util.py
"could not write to %s: %s" % (dst, errstr)
"could not write to '%s': %s" % (dst, errstr)
def _copy_file_contents (src, dst, buffer_size=16*1024): """Copy the file 'src' to 'dst'; both must be filenames. Any error opening either file, reading from 'src', or writing to 'dst', raises DistutilsFileError. Data is read/written in chunks of 'buffer_size' bytes (default 16k). No attempt is made to handle anything apart from regular files.""" # Stolen from shutil module in the standard library, but with # custom error-handling added. fsrc = None fdst = None try: try: fsrc = open(src, 'rb') except os.error, (errno, errstr): raise DistutilsFileError, "could not open %s: %s" % (src, errstr) try: fdst = open(dst, 'wb') except os.error, (errno, errstr): raise DistutilsFileError, "could not create %s: %s" % (dst, errstr) while 1: try: buf = fsrc.read (buffer_size) except os.error, (errno, errstr): raise DistutilsFileError, \ "could not read from %s: %s" % (src, errstr) if not buf: break try: fdst.write(buf) except os.error, (errno, errstr): raise DistutilsFileError, \ "could not write to %s: %s" % (dst, errstr) finally: if fdst: fdst.close() if fsrc: fsrc.close()
96182d7b68cfb2226af0c0e701b9d35d1aa59603 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/96182d7b68cfb2226af0c0e701b9d35d1aa59603/util.py
"can't copy %s: not a regular file" % src
"can't copy '%s': not a regular file" % src
def copy_file (src, dst, preserve_mode=1, preserve_times=1, update=0, verbose=0, dry_run=0): """Copy a file 'src' to 'dst'. If 'dst' is a directory, then 'src' is copied there with the same name; otherwise, it must be a filename. (If the file exists, it will be ruthlessly clobbered.) If 'preserve_mode' is true (the default), the file's mode (type and permission bits, or whatever is analogous on the current platform) is copied. If 'preserve_times' is true (the default), the last-modified and last-access times are copied as well. If 'update' is true, 'src' will only be copied if 'dst' does not exist, or if 'dst' does exist but is older than 'src'. If 'verbose' is true, then a one-line summary of the copy will be printed to stdout. Return true if the file was copied (or would have been copied), false otherwise (ie. 'update' was true and the destination is up-to-date).""" # XXX doesn't copy Mac-specific metadata from stat import * if not os.path.isfile (src): raise DistutilsFileError, \ "can't copy %s: not a regular file" % src if os.path.isdir (dst): dir = dst dst = os.path.join (dst, os.path.basename (src)) else: dir = os.path.dirname (dst) if update and not newer (src, dst): if verbose: print "not copying %s (output up-to-date)" % src return 0 if verbose: print "copying %s -> %s" % (src, dir) if dry_run: return 1 _copy_file_contents (src, dst) if preserve_mode or preserve_times: st = os.stat (src) # According to David Ascher <[email protected]>, utime() should be done # before chmod() (at least under NT). if preserve_times: os.utime (dst, (st[ST_ATIME], st[ST_MTIME])) if preserve_mode: os.chmod (dst, S_IMODE (st[ST_MODE])) return 1
96182d7b68cfb2226af0c0e701b9d35d1aa59603 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/96182d7b68cfb2226af0c0e701b9d35d1aa59603/util.py
"cannot copy tree %s: not a directory" % src
"cannot copy tree '%s': not a directory" % src
def copy_tree (src, dst, preserve_mode=1, preserve_times=1, preserve_symlinks=0, update=0, verbose=0, dry_run=0): """Copy an entire directory tree 'src' to a new location 'dst'. Both 'src' and 'dst' must be directory names. If 'src' is not a directory, raise DistutilsFileError. If 'dst' does not exist, it is created with 'mkpath()'. The end result of the copy is that every file in 'src' is copied to 'dst', and directories under 'src' are recursively copied to 'dst'. Return the list of files copied (under their output names) -- note that if 'update' is true, this might be less than the list of files considered. Return value is not affected by 'dry_run'. 'preserve_mode' and 'preserve_times' are the same as for 'copy_file'; note that they only apply to regular files, not to directories. If 'preserve_symlinks' is true, symlinks will be copied as symlinks (on platforms that support them!); otherwise (the default), the destination of the symlink will be copied. 'update' and 'verbose' are the same as for 'copy_file'.""" if not dry_run and not os.path.isdir (src): raise DistutilsFileError, \ "cannot copy tree %s: not a directory" % src try: names = os.listdir (src) except os.error, (errno, errstr): if dry_run: names = [] else: raise DistutilsFileError, \ "error listing files in %s: %s" % (src, errstr) if not dry_run: mkpath (dst, verbose=verbose) outputs = [] for n in names: src_name = os.path.join (src, n) dst_name = os.path.join (dst, n) if preserve_symlinks and os.path.islink (src_name): link_dest = os.readlink (src_name) if verbose: print "linking %s -> %s" % (dst_name, link_dest) if not dry_run: os.symlink (link_dest, dst_name) outputs.append (dst_name) elif os.path.isdir (src_name): outputs.extend ( copy_tree (src_name, dst_name, preserve_mode, preserve_times, preserve_symlinks, update, verbose, dry_run)) else: if (copy_file (src_name, dst_name, preserve_mode, preserve_times, update, verbose, dry_run)): outputs.append (dst_name) return outputs
96182d7b68cfb2226af0c0e701b9d35d1aa59603 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/96182d7b68cfb2226af0c0e701b9d35d1aa59603/util.py
"error listing files in %s: %s" % (src, errstr)
"error listing files in '%s': %s" % (src, errstr)
def copy_tree (src, dst, preserve_mode=1, preserve_times=1, preserve_symlinks=0, update=0, verbose=0, dry_run=0): """Copy an entire directory tree 'src' to a new location 'dst'. Both 'src' and 'dst' must be directory names. If 'src' is not a directory, raise DistutilsFileError. If 'dst' does not exist, it is created with 'mkpath()'. The end result of the copy is that every file in 'src' is copied to 'dst', and directories under 'src' are recursively copied to 'dst'. Return the list of files copied (under their output names) -- note that if 'update' is true, this might be less than the list of files considered. Return value is not affected by 'dry_run'. 'preserve_mode' and 'preserve_times' are the same as for 'copy_file'; note that they only apply to regular files, not to directories. If 'preserve_symlinks' is true, symlinks will be copied as symlinks (on platforms that support them!); otherwise (the default), the destination of the symlink will be copied. 'update' and 'verbose' are the same as for 'copy_file'.""" if not dry_run and not os.path.isdir (src): raise DistutilsFileError, \ "cannot copy tree %s: not a directory" % src try: names = os.listdir (src) except os.error, (errno, errstr): if dry_run: names = [] else: raise DistutilsFileError, \ "error listing files in %s: %s" % (src, errstr) if not dry_run: mkpath (dst, verbose=verbose) outputs = [] for n in names: src_name = os.path.join (src, n) dst_name = os.path.join (dst, n) if preserve_symlinks and os.path.islink (src_name): link_dest = os.readlink (src_name) if verbose: print "linking %s -> %s" % (dst_name, link_dest) if not dry_run: os.symlink (link_dest, dst_name) outputs.append (dst_name) elif os.path.isdir (src_name): outputs.extend ( copy_tree (src_name, dst_name, preserve_mode, preserve_times, preserve_symlinks, update, verbose, dry_run)) else: if (copy_file (src_name, dst_name, preserve_mode, preserve_times, update, verbose, dry_run)): outputs.append (dst_name) return outputs
96182d7b68cfb2226af0c0e701b9d35d1aa59603 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/96182d7b68cfb2226af0c0e701b9d35d1aa59603/util.py
target_version = self.target_version if not target_version: assert self.skip_build, "Should have already checked this" target_version = sys.version[0:3] plat_specifier = ".%s-%s" % (get_platform(), target_version) build = self.get_finalized_command('build') build.build_lib = os.path.join(build.build_base, 'lib' + plat_specifier)
if self.distribution.has_ext_modules(): target_version = self.target_version if not target_version: assert self.skip_build, "Should have already checked this" target_version = sys.version[0:3] plat_specifier = ".%s-%s" % (get_platform(), target_version) build = self.get_finalized_command('build') build.build_lib = os.path.join(build.build_base, 'lib' + plat_specifier)
def run (self): if (sys.platform != "win32" and (self.distribution.has_ext_modules() or self.distribution.has_c_libraries())): raise DistutilsPlatformError \ ("distribution contains extensions and/or C libraries; " "must be compiled on a Windows 32 platform")
79d9bfa28f66e031dbc252eabe78cd0aea081f06 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/79d9bfa28f66e031dbc252eabe78cd0aea081f06/bdist_wininst.py
def __init__ (self, dist): """Create and initialize a new Command object. Most importantly, invokes the 'initialize_options()' method, which is the real initializer and depends on the actual command being instantiated. """ # late import because of mutual dependence between these classes from distutils.dist import Distribution
2b2fe94cde439e020ec2a5152e3d3e1dfec6ce9d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2b2fe94cde439e020ec2a5152e3d3e1dfec6ce9d/cmd.py
user,pw = self.passwd.find_user_password(realm, host)
user, pw = self.passwd.find_user_password(realm, req.get_full_url())
def retry_http_basic_auth(self, host, req, realm): user,pw = self.passwd.find_user_password(realm, host) if pw is not None: raw = "%s:%s" % (user, pw) auth = 'Basic %s' % base64.encodestring(raw).strip() if req.headers.get(self.auth_header, None) == auth: return None req.add_header(self.auth_header, auth) return self.parent.open(req) else: return None
b300ae3a79624867cad30fddfb3350f9c731f21c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b300ae3a79624867cad30fddfb3350f9c731f21c/urllib2.py
base = base + ', opaque="%s"' % opaque
base += ', opaque="%s"' % opaque
def get_authorization(self, req, chal): try: realm = chal['realm'] nonce = chal['nonce'] qop = chal.get('qop') algorithm = chal.get('algorithm', 'MD5') # mod_digest doesn't send an opaque, even though it isn't # supposed to be optional opaque = chal.get('opaque', None) except KeyError: return None
b300ae3a79624867cad30fddfb3350f9c731f21c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b300ae3a79624867cad30fddfb3350f9c731f21c/urllib2.py
base = base + ', digest="%s"' % entdig if algorithm != 'MD5': base = base + ', algorithm="%s"' % algorithm
base += ', digest="%s"' % entdig base += ', algorithm="%s"' % algorithm
def get_authorization(self, req, chal): try: realm = chal['realm'] nonce = chal['nonce'] qop = chal.get('qop') algorithm = chal.get('algorithm', 'MD5') # mod_digest doesn't send an opaque, even though it isn't # supposed to be optional opaque = chal.get('opaque', None) except KeyError: return None
b300ae3a79624867cad30fddfb3350f9c731f21c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b300ae3a79624867cad30fddfb3350f9c731f21c/urllib2.py
base = base + ', qop=auth, nc=%s, cnonce="%s"' % (ncvalue, cnonce)
base += ', qop=auth, nc=%s, cnonce="%s"' % (ncvalue, cnonce)
def get_authorization(self, req, chal): try: realm = chal['realm'] nonce = chal['nonce'] qop = chal.get('qop') algorithm = chal.get('algorithm', 'MD5') # mod_digest doesn't send an opaque, even though it isn't # supposed to be optional opaque = chal.get('opaque', None) except KeyError: return None
b300ae3a79624867cad30fddfb3350f9c731f21c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b300ae3a79624867cad30fddfb3350f9c731f21c/urllib2.py
id = 257
def AskString(prompt, default = "", id=257, ok=None, cancel=None): """Display a PROMPT string and a text entry field with a DEFAULT string. Return the contents of the text entry field when the user clicks the OK button or presses Return. Return None when the user clicks the Cancel button. If omitted, DEFAULT is empty. The PROMPT and DEFAULT strings, as well as the return value, can be at most 255 characters long. """ id = 257 d = GetNewDialog(id, -1) if not d: print "Can't get DLOG resource with id =", id return tp, h, rect = d.GetDialogItem(3) SetDialogItemText(h, lf2cr(prompt)) tp, h, rect = d.GetDialogItem(4) SetDialogItemText(h, lf2cr(default)) d.SelectDialogItemText(4, 0, 999)
231fffe1d4582263a430781e0a3435e444399abe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/231fffe1d4582263a430781e0a3435e444399abe/EasyDialogs.py
if hasattr(socket, 'AF_UNIX'): class UnixStreamServer(TCPServer): address_family = socket.AF_UNIX class UnixDatagramServer(UDPServer): address_family = socket.AF_UNIX
def server_activate(self): # No need to call listen() for UDP. pass
67a40e814ca29a8b886d0db018995f9b518785e8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/67a40e814ca29a8b886d0db018995f9b518785e8/SocketServer.py
fp = open(pathname)
fp = open(pathname, "U")
def run_script(self, pathname): self.msg(2, "run_script", pathname) fp = open(pathname) stuff = ("", "r", imp.PY_SOURCE) self.load_module('__main__', fp, pathname, stuff)
74416af9dc7900d30c41a16d3b56cf4ea00ec137 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/74416af9dc7900d30c41a16d3b56cf4ea00ec137/modulefinder.py
fp = open(pathname)
fp = open(pathname, "U")
def load_file(self, pathname): dir, name = os.path.split(pathname) name, ext = os.path.splitext(name) fp = open(pathname) stuff = (ext, "r", imp.PY_SOURCE) self.load_module(name, fp, pathname, stuff)
74416af9dc7900d30c41a16d3b56cf4ea00ec137 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/74416af9dc7900d30c41a16d3b56cf4ea00ec137/modulefinder.py
editor.ted.WEUseText(Res.Resource(Text)) editor.ted.WECalText() editor.SetPort() editor.GetWindow().InvalWindowRect(editor._bounds)
editor.set(Text)
def replaceall(self): editor = findeditor(self) if not editor: return if self.visible: self.getparmsfromwindow() W.SetCursor("watch") find = self.parms["find"] if not find: return findlen = len(find) replace = self.parms["replace"] replacelen = len(replace) Text = editor.get() if not self.parms["casesens"]: find = string.lower(find) text = string.lower(Text) else: text = Text newtext = "" pos = 0 counter = 0 while 1: if self.parms["wholeword"]: wholewordRE = _makewholewordpattern(find) match = wholewordRE.search(text, pos) if match: pos = match.start(1) else: pos = -1 else: pos = string.find(text, find, pos) if pos < 0: break counter = counter + 1 text = text[:pos] + replace + text[pos + findlen:] Text = Text[:pos] + replace + Text[pos + findlen:] pos = pos + replacelen W.SetCursor("arrow") if counter: self.hide() import EasyDialogs from Carbon import Res editor.textchanged() editor.selectionchanged() editor.ted.WEUseText(Res.Resource(Text)) editor.ted.WECalText() editor.SetPort() editor.GetWindow().InvalWindowRect(editor._bounds) #editor.ted.WEUpdate(self.w.wid.GetWindowPort().visRgn) EasyDialogs.Message("Replaced %d occurrences" % counter)
7b0255153f2402d9853b29cc7bd4ea1dce14a997 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7b0255153f2402d9853b29cc7bd4ea1dce14a997/PyEdit.py
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')
3adc4aa2fb58aaca2f7692a37239ee3157887166 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3adc4aa2fb58aaca2f7692a37239ee3157887166/setup.py
min_db_ver = (3, 2)
min_db_ver = (3, 3)
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')
3adc4aa2fb58aaca2f7692a37239ee3157887166 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3adc4aa2fb58aaca2f7692a37239ee3157887166/setup.py
return code.split('.')[:2]
return tuple(code.split('.')[:2])
def _parse_localename(localename): """ Parses the locale code for localename and returns the result as tuple (language code, encoding). The localename is normalized and passed through the locale alias engine. A ValueError is raised in case the locale name cannot be parsed. The language code corresponds to RFC 1766. code and encoding can be None in case the values cannot be determined or are unknown to this implementation. """ code = normalize(localename) if '@' in localename: # Deal with locale modifiers code, modifier = code.split('@') if modifier == 'euro' and '.' not in code: # Assume Latin-9 for @euro locales. This is bogus, # since some systems may use other encodings for these # locales. Also, we ignore other modifiers. return code, 'iso-8859-15' if '.' in code: return code.split('.')[:2] elif code == 'C': return None, None raise ValueError, 'unknown locale: %s' % localename
346e67f80553be5297dccd43db7a71f4b81bdcab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/346e67f80553be5297dccd43db7a71f4b81bdcab/locale.py
return section in self.sections()
return section in self.__sections
def has_section(self, section): """Indicate whether the named section is present in the configuration.
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
sectdict = self.__sections[section].copy()
d.update(self.__sections[section])
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
if section == DEFAULTSECT: sectdict = {} else:
if section != DEFAULTSECT:
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
d = self.__defaults.copy() d.update(sectdict)
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
rawval = d[option]
value = d[option]
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
return rawval
return value return self._interpolate(section, option, value, d) def _interpolate(self, section, option, rawval, vars):
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
value = rawval depth = 0 while depth < 10: depth = depth + 1 if value.find("%(") >= 0:
value = rawval depth = MAX_INTERPOLATION_DEPTH while depth: depth -= 1 if value.find("%(") != -1:
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
value = value % d
value = value % vars
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
if value.find("%(") >= 0:
if value.find("%(") != -1:
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
states = {'1': 1, 'yes': 1, 'true': 1, 'on': 1, '0': 0, 'no': 0, 'false': 0, 'off': 0}
def getboolean(self, section, option): states = {'1': 1, 'yes': 1, 'true': 1, 'on': 1, '0': 0, 'no': 0, 'false': 0, 'off': 0} v = self.get(section, option) if not v.lower() in states: raise ValueError, 'Not a boolean: %s' % v return states[v.lower()]
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
if not v.lower() in states:
if v.lower() not in self._boolean_states:
def getboolean(self, section, option): states = {'1': 1, 'yes': 1, 'true': 1, 'on': 1, '0': 0, 'no': 0, 'false': 0, 'off': 0} v = self.get(section, option) if not v.lower() in states: raise ValueError, 'Not a boolean: %s' % v return states[v.lower()]
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
return states[v.lower()]
return self._boolean_states[v.lower()]
def getboolean(self, section, option): states = {'1': 1, 'yes': 1, 'true': 1, 'on': 1, '0': 0, 'no': 0, 'false': 0, 'off': 0} v = self.get(section, option) if not v.lower() in states: raise ValueError, 'Not a boolean: %s' % v return states[v.lower()]
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
if not section or section == "DEFAULT":
if not section or section == DEFAULTSECT: option = self.optionxform(option)
def has_option(self, section, option): """Check for the existence of a given option in a given section.""" if not section or section == "DEFAULT": return option in self.__defaults elif not self.has_section(section): return 0 else: option = self.optionxform(option) return option in self.__sections[section]
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
elif not self.has_section(section):
elif section not in self.__sections:
def has_option(self, section, option): """Check for the existence of a given option in a given section.""" if not section or section == "DEFAULT": return option in self.__defaults elif not self.has_section(section): return 0 else: option = self.optionxform(option) return option in self.__sections[section]
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
return option in self.__sections[section]
return (option in self.__sections[section] or option in self.__defaults)
def has_option(self, section, option): """Check for the existence of a given option in a given section.""" if not section or section == "DEFAULT": return option in self.__defaults elif not self.has_section(section): return 0 else: option = self.optionxform(option) return option in self.__sections[section]
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
if not section or section == "DEFAULT":
if not section or section == DEFAULTSECT:
def set(self, section, option, value): """Set an option.""" if not section or section == "DEFAULT": sectdict = self.__defaults else: try: sectdict = self.__sections[section] except KeyError: raise NoSectionError(section) option = self.optionxform(option) sectdict[option] = value
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
option = self.optionxform(option) sectdict[option] = value
sectdict[self.optionxform(option)] = value
def set(self, section, option, value): """Set an option.""" if not section or section == "DEFAULT": sectdict = self.__defaults else: try: sectdict = self.__sections[section] except KeyError: raise NoSectionError(section) option = self.optionxform(option) sectdict[option] = value
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
fp.write("[DEFAULT]\n")
fp.write("[%s]\n" % DEFAULTSECT)
def write(self, fp): """Write an .ini-format representation of the configuration state.""" if self.__defaults: fp.write("[DEFAULT]\n") for (key, value) in self.__defaults.items(): fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t'))) fp.write("\n") for section in self.sections(): fp.write("[" + section + "]\n") sectdict = self.__sections[section] for (key, value) in sectdict.items(): if key == "__name__": continue fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t'))) fp.write("\n")
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
for section in self.sections(): fp.write("[" + section + "]\n") sectdict = self.__sections[section] for (key, value) in sectdict.items(): if key == "__name__": continue fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t')))
for section in self.__sections: fp.write("[%s]\n" % section) for (key, value) in self.__sections[section].items(): if key != "__name__": fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t')))
def write(self, fp): """Write an .ini-format representation of the configuration state.""" if self.__defaults: fp.write("[DEFAULT]\n") for (key, value) in self.__defaults.items(): fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t'))) fp.write("\n") for section in self.sections(): fp.write("[" + section + "]\n") sectdict = self.__sections[section] for (key, value) in sectdict.items(): if key == "__name__": continue fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t'))) fp.write("\n")
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
if not section or section == "DEFAULT":
if not section or section == DEFAULTSECT:
def remove_option(self, section, option): """Remove an option.""" if not section or section == "DEFAULT": sectdict = self.__defaults else: try: sectdict = self.__sections[section] except KeyError: raise NoSectionError(section) option = self.optionxform(option) existed = option in sectdict if existed: del sectdict[option] return existed
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
if section in self.__sections:
existed = section in self.__sections if existed:
def remove_section(self, section): """Remove a file section.""" if section in self.__sections: del self.__sections[section] return True else: return False
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
return True else: return False
return existed
def remove_section(self, section): """Remove a file section.""" if section in self.__sections: del self.__sections[section] return True else: return False
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
def remove_section(self, section): """Remove a file section.""" if section in self.__sections: del self.__sections[section] return True else: return False
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
r'(?P<option>[]\-[\w_.*,(){}]+)' r'[ \t]*(?P<vi>[:=])[ \t]*'
r'(?P<option>[^:=\s]+)' r'\s*(?P<vi>[:=])\s*'
def remove_section(self, section): """Remove a file section.""" if section in self.__sections: del self.__sections[section] return True else: return False
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
if line.split()[0].lower() == 'rem' \ and line[0] in "rR":
if line.split(None, 1)[0].lower() == 'rem' and line[0] in "rR":
def __read(self, fp, fpname): """Parse a sectioned setup file.
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
if line[0] in ' \t' and cursect is not None and optname:
if line[0].isspace() and cursect is not None and optname:
def __read(self, fp, fpname): """Parse a sectioned setup file.
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
k = self.optionxform(optname) cursect[k] = "%s\n%s" % (cursect[k], value)
cursect[optname] = "%s\n%s" % (cursect[optname], value)
def __read(self, fp, fpname): """Parse a sectioned setup file.
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
if pos and optval[pos-1].isspace():
if pos != -1 and optval[pos-1].isspace():
def __read(self, fp, fpname): """Parse a sectioned setup file.
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
cursect[self.optionxform(optname)] = optval
optname = self.optionxform(optname) cursect[optname] = optval
def __read(self, fp, fpname): """Parse a sectioned setup file.
c2ff9051d2dace414d5ec928fa3e41edd9297992 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c2ff9051d2dace414d5ec928fa3e41edd9297992/ConfigParser.py
'\(
'\(
def processor(): """ Returns the (true) processor name, e.g. 'amdk6' An empty string is returned if the value cannot be determined. Note that many platforms do not provide this information or simply return the same value as for machine(), e.g. NetBSD does this. """ return uname()[5]
3dafaabfb5abe2ca1dd6d5a8985fb960374f7c7a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3dafaabfb5abe2ca1dd6d5a8985fb960374f7c7a/platform.py
buildno = int(buildno)
def _sys_version(): """ Returns a parsed version of Python's sys.version as tuple (version, buildno, builddate, compiler) referring to the Python version, build number, build date/time as string and the compiler identification string. Note that unlike the Python sys.version, the returned value for the Python version will always include the patchlevel (it defaults to '.0'). """ global _sys_version_cache if _sys_version_cache is not None: return _sys_version_cache version, buildno, builddate, buildtime, compiler = \ _sys_version_parser.match(sys.version).groups() buildno = int(buildno) builddate = builddate + ' ' + buildtime l = string.split(version, '.') if len(l) == 2: l.append('0') version = string.join(l, '.') _sys_version_cache = (version, buildno, builddate, compiler) return _sys_version_cache
3dafaabfb5abe2ca1dd6d5a8985fb960374f7c7a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3dafaabfb5abe2ca1dd6d5a8985fb960374f7c7a/platform.py
if size < 0: size = sys.maxint bufs = [] readsize = min(100, size)
if size < 0: size = sys.maxint readsize = self.min_readsize else: readsize = size bufs = ""
def readline(self, size=-1): if size < 0: size = sys.maxint bufs = [] readsize = min(100, size) # Read from the file in small chunks while True: if size == 0: return "".join(bufs) # Return resulting line
d72aab5e31f831edb2b8e837e2ab387f2db07aee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d72aab5e31f831edb2b8e837e2ab387f2db07aee/gzip.py
if size == 0: return "".join(bufs)
if size == 0: return bufs
def readline(self, size=-1): if size < 0: size = sys.maxint bufs = [] readsize = min(100, size) # Read from the file in small chunks while True: if size == 0: return "".join(bufs) # Return resulting line
d72aab5e31f831edb2b8e837e2ab387f2db07aee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d72aab5e31f831edb2b8e837e2ab387f2db07aee/gzip.py
if size is not None: if i==-1 and len(c) > size: i=size-1 elif size <= i: i = size -1
def readline(self, size=-1): if size < 0: size = sys.maxint bufs = [] readsize = min(100, size) # Read from the file in small chunks while True: if size == 0: return "".join(bufs) # Return resulting line
d72aab5e31f831edb2b8e837e2ab387f2db07aee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d72aab5e31f831edb2b8e837e2ab387f2db07aee/gzip.py
bufs.append(c[:i+1]) self._unread(c[i+1:]) return ''.join(bufs) bufs.append(c) size = size - len(c) readsize = min(size, readsize * 2)
if size <= i: i = size - 1 self._unread(c[i+1:]) return bufs + c[:i+1] else: if len(c) > size: i = size - 1 bufs = bufs + c size = size - len(c) readsize = min(size, int(readsize * 1.1)) if readsize > self.min_readsize: self.min_readsize = readsize
def readline(self, size=-1): if size < 0: size = sys.maxint bufs = [] readsize = min(100, size) # Read from the file in small chunks while True: if size == 0: return "".join(bufs) # Return resulting line
d72aab5e31f831edb2b8e837e2ab387f2db07aee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d72aab5e31f831edb2b8e837e2ab387f2db07aee/gzip.py
if url[:1] != '/': url = '/' + url
if url and url[:1] != '/': url = '/' + url
def urlunparse((scheme, netloc, url, params, query, fragment)): """Put a parsed URL back together again. This may result in a slightly different, but equivalent URL, if the URL that was parsed originally had redundant delimiters, e.g. a ? with an empty query (the draft states that these are equivalent).""" if netloc or (scheme in uses_netloc and url[:2] == '//'): if url[:1] != '/': url = '/' + url url = '//' + (netloc or '') + url if scheme: url = scheme + ':' + url if params: url = url + ';' + params if query: url = url + '?' + query if fragment: url = url + '#' + fragment return url
867952f6e437270cc906af34dba28a9b580ec265 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/867952f6e437270cc906af34dba28a9b580ec265/urlparse.py
return urlunparse((scheme, netloc, path, params, query, fragment))
return url
def urljoin(base, url, allow_fragments = 1): """Join a base URL and a possibly relative URL to form an absolute interpretation of the latter.""" if not base: return url bscheme, bnetloc, bpath, bparams, bquery, bfragment = \ urlparse(base, '', allow_fragments) scheme, netloc, path, params, query, fragment = \ urlparse(url, bscheme, allow_fragments) if scheme != bscheme or scheme not in uses_relative: return urlunparse((scheme, netloc, path, params, query, fragment)) if scheme in uses_netloc: if netloc: return urlunparse((scheme, netloc, path, params, query, fragment)) netloc = bnetloc if path[:1] == '/': return urlunparse((scheme, netloc, path, params, query, fragment)) if not path: return urlunparse((scheme, netloc, bpath, params, query or bquery, fragment)) segments = bpath.split('/')[:-1] + path.split('/') # XXX The stuff below is bogus in various ways... if segments[-1] == '.': segments[-1] = '' while '.' in segments: segments.remove('.') while 1: i = 1 n = len(segments) - 1 while i < n: if segments[i] == '..' and segments[i-1]: del segments[i-1:i+1] break i = i+1 else: break if len(segments) == 2 and segments[1] == '..' and segments[0] == '': segments[-1] = '' elif len(segments) >= 2 and segments[-1] == '..': segments[-2:] = [''] return urlunparse((scheme, netloc, '/'.join(segments), params, query, fragment))
867952f6e437270cc906af34dba28a9b580ec265 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/867952f6e437270cc906af34dba28a9b580ec265/urlparse.py
params, query or bquery, fragment))
params, query, fragment))
def urljoin(base, url, allow_fragments = 1): """Join a base URL and a possibly relative URL to form an absolute interpretation of the latter.""" if not base: return url bscheme, bnetloc, bpath, bparams, bquery, bfragment = \ urlparse(base, '', allow_fragments) scheme, netloc, path, params, query, fragment = \ urlparse(url, bscheme, allow_fragments) if scheme != bscheme or scheme not in uses_relative: return urlunparse((scheme, netloc, path, params, query, fragment)) if scheme in uses_netloc: if netloc: return urlunparse((scheme, netloc, path, params, query, fragment)) netloc = bnetloc if path[:1] == '/': return urlunparse((scheme, netloc, path, params, query, fragment)) if not path: return urlunparse((scheme, netloc, bpath, params, query or bquery, fragment)) segments = bpath.split('/')[:-1] + path.split('/') # XXX The stuff below is bogus in various ways... if segments[-1] == '.': segments[-1] = '' while '.' in segments: segments.remove('.') while 1: i = 1 n = len(segments) - 1 while i < n: if segments[i] == '..' and segments[i-1]: del segments[i-1:i+1] break i = i+1 else: break if len(segments) == 2 and segments[1] == '..' and segments[0] == '': segments[-1] = '' elif len(segments) >= 2 and segments[-1] == '..': segments[-2:] = [''] return urlunparse((scheme, netloc, '/'.join(segments), params, query, fragment))
867952f6e437270cc906af34dba28a9b580ec265 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/867952f6e437270cc906af34dba28a9b580ec265/urlparse.py
if segments[i] == '..' and segments[i-1]:
if (segments[i] == '..' and segments[i-1] not in ('', '..')):
def urljoin(base, url, allow_fragments = 1): """Join a base URL and a possibly relative URL to form an absolute interpretation of the latter.""" if not base: return url bscheme, bnetloc, bpath, bparams, bquery, bfragment = \ urlparse(base, '', allow_fragments) scheme, netloc, path, params, query, fragment = \ urlparse(url, bscheme, allow_fragments) if scheme != bscheme or scheme not in uses_relative: return urlunparse((scheme, netloc, path, params, query, fragment)) if scheme in uses_netloc: if netloc: return urlunparse((scheme, netloc, path, params, query, fragment)) netloc = bnetloc if path[:1] == '/': return urlunparse((scheme, netloc, path, params, query, fragment)) if not path: return urlunparse((scheme, netloc, bpath, params, query or bquery, fragment)) segments = bpath.split('/')[:-1] + path.split('/') # XXX The stuff below is bogus in various ways... if segments[-1] == '.': segments[-1] = '' while '.' in segments: segments.remove('.') while 1: i = 1 n = len(segments) - 1 while i < n: if segments[i] == '..' and segments[i-1]: del segments[i-1:i+1] break i = i+1 else: break if len(segments) == 2 and segments[1] == '..' and segments[0] == '': segments[-1] = '' elif len(segments) >= 2 and segments[-1] == '..': segments[-2:] = [''] return urlunparse((scheme, netloc, '/'.join(segments), params, query, fragment))
867952f6e437270cc906af34dba28a9b580ec265 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/867952f6e437270cc906af34dba28a9b580ec265/urlparse.py
if len(segments) == 2 and segments[1] == '..' and segments[0] == '':
if segments == ['', '..']:
def urljoin(base, url, allow_fragments = 1): """Join a base URL and a possibly relative URL to form an absolute interpretation of the latter.""" if not base: return url bscheme, bnetloc, bpath, bparams, bquery, bfragment = \ urlparse(base, '', allow_fragments) scheme, netloc, path, params, query, fragment = \ urlparse(url, bscheme, allow_fragments) if scheme != bscheme or scheme not in uses_relative: return urlunparse((scheme, netloc, path, params, query, fragment)) if scheme in uses_netloc: if netloc: return urlunparse((scheme, netloc, path, params, query, fragment)) netloc = bnetloc if path[:1] == '/': return urlunparse((scheme, netloc, path, params, query, fragment)) if not path: return urlunparse((scheme, netloc, bpath, params, query or bquery, fragment)) segments = bpath.split('/')[:-1] + path.split('/') # XXX The stuff below is bogus in various ways... if segments[-1] == '.': segments[-1] = '' while '.' in segments: segments.remove('.') while 1: i = 1 n = len(segments) - 1 while i < n: if segments[i] == '..' and segments[i-1]: del segments[i-1:i+1] break i = i+1 else: break if len(segments) == 2 and segments[1] == '..' and segments[0] == '': segments[-1] = '' elif len(segments) >= 2 and segments[-1] == '..': segments[-2:] = [''] return urlunparse((scheme, netloc, '/'.join(segments), params, query, fragment))
867952f6e437270cc906af34dba28a9b580ec265 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/867952f6e437270cc906af34dba28a9b580ec265/urlparse.py
value = value[:m.start()] + done[n] + after
value = value[:m.start()] + str(done[n]) + after
def parse_makefile(fn, g=None): """Parse a Makefile-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary. """ from distutils.text_file import TextFile fp = TextFile(fn, strip_comments=1, skip_blanks=1, join_lines=1) if g is None: g = {} done = {} notdone = {} while 1: line = fp.readline() if line is None: # eof break m = _variable_rx.match(line) if m: n, v = m.group(1, 2) v = string.strip(v) if "$" in v: notdone[n] = v else: try: v = string.atoi(v) except ValueError: pass done[n] = v # do variable interpolation here while notdone: for name in notdone.keys(): value = notdone[name] m = _findvar1_rx.search(value) or _findvar2_rx.search(value) if m: n = m.group(1) if done.has_key(n): after = value[m.end():] value = value[:m.start()] + done[n] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value) del notdone[name] elif notdone.has_key(n): # get it on a subsequent round pass else: done[n] = "" after = value[m.end():] value = value[:m.start()] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value) del notdone[name] else: # bogus variable reference; just drop it since we can't deal del notdone[name] fp.close() # save the results in the global dictionary g.update(done) return g
b11bd03626f2c4bb545bac0ba2150d6e168faccd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b11bd03626f2c4bb545bac0ba2150d6e168faccd/sysconfig.py
except ValueError: pass done[name] = string.strip(value)
except ValueError: done[name] = string.strip(value) else: done[name] = value
def parse_makefile(fn, g=None): """Parse a Makefile-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary. """ from distutils.text_file import TextFile fp = TextFile(fn, strip_comments=1, skip_blanks=1, join_lines=1) if g is None: g = {} done = {} notdone = {} while 1: line = fp.readline() if line is None: # eof break m = _variable_rx.match(line) if m: n, v = m.group(1, 2) v = string.strip(v) if "$" in v: notdone[n] = v else: try: v = string.atoi(v) except ValueError: pass done[n] = v # do variable interpolation here while notdone: for name in notdone.keys(): value = notdone[name] m = _findvar1_rx.search(value) or _findvar2_rx.search(value) if m: n = m.group(1) if done.has_key(n): after = value[m.end():] value = value[:m.start()] + done[n] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value) del notdone[name] elif notdone.has_key(n): # get it on a subsequent round pass else: done[n] = "" after = value[m.end():] value = value[:m.start()] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value) del notdone[name] else: # bogus variable reference; just drop it since we can't deal del notdone[name] fp.close() # save the results in the global dictionary g.update(done) return g
b11bd03626f2c4bb545bac0ba2150d6e168faccd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b11bd03626f2c4bb545bac0ba2150d6e168faccd/sysconfig.py
except ValueError: pass done[name] = string.strip(value)
except ValueError: done[name] = string.strip(value) else: done[name] = value
def parse_makefile(fn, g=None): """Parse a Makefile-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary. """ from distutils.text_file import TextFile fp = TextFile(fn, strip_comments=1, skip_blanks=1, join_lines=1) if g is None: g = {} done = {} notdone = {} while 1: line = fp.readline() if line is None: # eof break m = _variable_rx.match(line) if m: n, v = m.group(1, 2) v = string.strip(v) if "$" in v: notdone[n] = v else: try: v = string.atoi(v) except ValueError: pass done[n] = v # do variable interpolation here while notdone: for name in notdone.keys(): value = notdone[name] m = _findvar1_rx.search(value) or _findvar2_rx.search(value) if m: n = m.group(1) if done.has_key(n): after = value[m.end():] value = value[:m.start()] + done[n] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value) del notdone[name] elif notdone.has_key(n): # get it on a subsequent round pass else: done[n] = "" after = value[m.end():] value = value[:m.start()] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value) del notdone[name] else: # bogus variable reference; just drop it since we can't deal del notdone[name] fp.close() # save the results in the global dictionary g.update(done) return g
b11bd03626f2c4bb545bac0ba2150d6e168faccd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b11bd03626f2c4bb545bac0ba2150d6e168faccd/sysconfig.py
testit('rint(0.7)', math.rint(0.7), 1) testit('rint(-0.3)', math.rint(-0.3), 0) testit('rint(2.5)', math.rint(2.5), 2) testit('rint(3.5)', math.rint(3.5), 4)
try: math.rint except AttributeError: pass else: testit('rint(0.7)', math.rint(0.7), 1) testit('rint(-0.3)', math.rint(-0.3), 0) testit('rint(2.5)', math.rint(2.5), 2) testit('rint(3.5)', math.rint(3.5), 4)
def testmodf(name, (v1, v2), (e1, e2)): if abs(v1-e1) > eps or abs(v2-e2): raise TestFailed, '%s returned %s, expected %s'%\ (name, `v1,v2`, `e1,e2`)
8eded195aafd589b54b51412fd1ca61f6e932bbe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8eded195aafd589b54b51412fd1ca61f6e932bbe/test_math.py