rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
return namespace['config']
return namespace
def readconfig(): """Read a configuration file, if it doesn't exist create it.""" configname = sys.argv[0] + '.config' if not os.path.exists(configname): confstr = """config = [ ("^.*\.cp$", ":unweave-src"), ("^.*\.h$", ":unweave-include"),
0eea16633adab90227826c3dc96b991829665012 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0eea16633adab90227826c3dc96b991829665012/unweave.py
process(fss.as_pathname())
process(fss.as_pathname(), config)
def main(): config = readconfig() if len(sys.argv) > 1: for file in sys.argv[1:]: if file[-3:] == '.nw': print "Processing", file process(file, config) else: print "Skipping", file else: fss, ok = macfs.PromptGetFile("Select .nw source file", "TEXT") if not ok: sys.exit(0) process(fss.as_pathname())
0eea16633adab90227826c3dc96b991829665012 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0eea16633adab90227826c3dc96b991829665012/unweave.py
if l[:2] == '
if l[:2] == '
def make(filename, outfile): ID = 1 STR = 2 # Compute .mo name from .po name and arguments if filename.endswith('.po'): infile = filename else: infile = filename + '.po' if outfile is None: outfile = os.path.splitext(infile)[0] + '.mo' try: lines = open(infile).readlines() except IOError, msg: print >> sys.stderr, msg sys.exit(1) section = None fuzzy = 0 # Parse the catalog lno = 0 for l in lines: lno += 1 # If we get a comment line after a msgstr, this is a new entry if l[0] == '#' and section == STR: add(msgid, msgstr, fuzzy) section = None fuzzy = 0 # Record a fuzzy mark if l[:2] == '#,' and l.find('fuzzy'): fuzzy = 1 # Skip comments if l[0] == '#': continue # Now we are in a msgid section, output previous section if l.startswith('msgid'): if section == STR: add(msgid, msgstr, fuzzy) section = ID l = l[5:] msgid = msgstr = '' # Now we are in a msgstr section elif l.startswith('msgstr'): section = STR l = l[6:] # Skip empty lines l = l.strip() if not l: continue # XXX: Does this always follow Python escape semantics? l = eval(l) if section == ID: msgid += l elif section == STR: msgstr += l else: print >> sys.stderr, 'Syntax error on %s:%d' % (infile, lno), \ 'before:' print >> sys.stderr, l sys.exit(1) # Add last entry if section == STR: add(msgid, msgstr, fuzzy) # Compute output output = generate() try: open(outfile,"wb").write(output) except IOError,msg: print >> sys.stderr, msg
d9da722d85ebf573ebd497f396e05d6c697ebca0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d9da722d85ebf573ebd497f396e05d6c697ebca0/msgfmt.py
if data is None: return self.open(newurl) else: return self.open(newurl, data)
return self.open(newurl)
def redirect_internal(self, url, fp, errcode, errmsg, headers, data): if 'location' in headers: newurl = headers['location'] elif 'uri' in headers: newurl = headers['uri'] else: return void = fp.read() fp.close() # In case the server sent a relative URL, join with original: newurl = basejoin(self.type + ":" + url, newurl) if data is None: return self.open(newurl) else: return self.open(newurl, data)
fa19f7c20d14d34dfa58bfb9b4055555e46fd437 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fa19f7c20d14d34dfa58bfb9b4055555e46fd437/urllib.py
self.assertRaises(ValueError, lambda: bytes([C(-1)])) self.assertRaises(ValueError, lambda: bytes([C(256)]))
self.assertRaises(ValueError, bytes, [C(-1)]) self.assertRaises(ValueError, bytes, [C(256)])
def __index__(self): return self.i
e06b6b8ff5a380f5e107f2d28f23853bfe20021e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e06b6b8ff5a380f5e107f2d28f23853bfe20021e/test_bytes.py
self.assertRaises(TypeError, lambda: bytes(["0"])) self.assertRaises(TypeError, lambda: bytes([0.0])) self.assertRaises(TypeError, lambda: bytes([None])) self.assertRaises(TypeError, lambda: bytes([C()]))
self.assertRaises(TypeError, bytes, ["0"]) self.assertRaises(TypeError, bytes, [0.0]) self.assertRaises(TypeError, bytes, [None]) self.assertRaises(TypeError, bytes, [C()])
def test_constructor_type_errors(self): class C: pass self.assertRaises(TypeError, lambda: bytes(["0"])) self.assertRaises(TypeError, lambda: bytes([0.0])) self.assertRaises(TypeError, lambda: bytes([None])) self.assertRaises(TypeError, lambda: bytes([C()]))
e06b6b8ff5a380f5e107f2d28f23853bfe20021e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e06b6b8ff5a380f5e107f2d28f23853bfe20021e/test_bytes.py
self.assertRaises(ValueError, lambda: bytes([-1])) self.assertRaises(ValueError, lambda: bytes([-sys.maxint])) self.assertRaises(ValueError, lambda: bytes([-sys.maxint-1])) self.assertRaises(ValueError, lambda: bytes([-sys.maxint-2])) self.assertRaises(ValueError, lambda: bytes([-10**100])) self.assertRaises(ValueError, lambda: bytes([256])) self.assertRaises(ValueError, lambda: bytes([257])) self.assertRaises(ValueError, lambda: bytes([sys.maxint])) self.assertRaises(ValueError, lambda: bytes([sys.maxint+1])) self.assertRaises(ValueError, lambda: bytes([10**100]))
self.assertRaises(ValueError, bytes, [-1]) self.assertRaises(ValueError, bytes, [-sys.maxint]) self.assertRaises(ValueError, bytes, [-sys.maxint-1]) self.assertRaises(ValueError, bytes, [-sys.maxint-2]) self.assertRaises(ValueError, bytes, [-10**100]) self.assertRaises(ValueError, bytes, [256]) self.assertRaises(ValueError, bytes, [257]) self.assertRaises(ValueError, bytes, [sys.maxint]) self.assertRaises(ValueError, bytes, [sys.maxint+1]) self.assertRaises(ValueError, bytes, [10**100])
def test_constructor_value_errors(self): self.assertRaises(ValueError, lambda: bytes([-1])) self.assertRaises(ValueError, lambda: bytes([-sys.maxint])) self.assertRaises(ValueError, lambda: bytes([-sys.maxint-1])) self.assertRaises(ValueError, lambda: bytes([-sys.maxint-2])) self.assertRaises(ValueError, lambda: bytes([-10**100])) self.assertRaises(ValueError, lambda: bytes([256])) self.assertRaises(ValueError, lambda: bytes([257])) self.assertRaises(ValueError, lambda: bytes([sys.maxint])) self.assertRaises(ValueError, lambda: bytes([sys.maxint+1])) self.assertRaises(ValueError, lambda: bytes([10**100]))
e06b6b8ff5a380f5e107f2d28f23853bfe20021e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e06b6b8ff5a380f5e107f2d28f23853bfe20021e/test_bytes.py
file = unquote(file)
def open_local_file(self, url): 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: return addinfourl( open(url2pathname(file), 'rb'), headers, 'file:'+file) host, port = splitport(host) if not port and socket.gethostbyname(host) in ( localhost(), thishost()): file = unquote(file) return addinfourl( open(url2pathname(file), 'rb'), headers, 'file:'+file) raise IOError, ('local file error', 'not on local host')
33add0a95aa6c5ba5dbb8cae7b51a253209ecd6f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/33add0a95aa6c5ba5dbb8cae7b51a253209ecd6f/urllib.py
self.user = unquote(user or '') self.passwd = unquote(passwd or '')
self.user = user self.passwd = passwd
def __init__(self, user, passwd, host, port, dirs): self.user = unquote(user or '') self.passwd = unquote(passwd or '') self.host = host self.port = port self.dirs = [] for dir in dirs: self.dirs.append(unquote(dir)) self.init()
33add0a95aa6c5ba5dbb8cae7b51a253209ecd6f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/33add0a95aa6c5ba5dbb8cae7b51a253209ecd6f/urllib.py
self.dirs = [] for dir in dirs: self.dirs.append(unquote(dir))
self.dirs = dirs
def __init__(self, user, passwd, host, port, dirs): self.user = unquote(user or '') self.passwd = unquote(passwd or '') self.host = host self.port = port self.dirs = [] for dir in dirs: self.dirs.append(unquote(dir)) self.init()
33add0a95aa6c5ba5dbb8cae7b51a253209ecd6f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/33add0a95aa6c5ba5dbb8cae7b51a253209ecd6f/urllib.py
def find_library_file (self, dirs, lib):
def find_library_file (self, dirs, lib, debug=0): if debug: try_names = [lib + "_d", lib] else: try_names = [lib]
def find_library_file (self, dirs, lib):
d142564821b8427e8839742ef0813f776fb7ba78 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d142564821b8427e8839742ef0813f776fb7ba78/msvccompiler.py
libfile = os.path.join (dir, self.library_filename (lib)) if os.path.exists (libfile): return libfile
for name in try_names: libfile = os.path.join(dir, self.library_filename (name)) if os.path.exists(libfile): return libfile
def find_library_file (self, dirs, lib):
d142564821b8427e8839742ef0813f776fb7ba78 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d142564821b8427e8839742ef0813f776fb7ba78/msvccompiler.py
for key, value in headers.iteritems():
for key, value in headers.items():
def __init__(self, url, data=None, headers={}): # unwrap('<URL:type://host/path>') --> 'type://host/path' self.__original = unwrap(url) self.type = None # self.__r_type is what's left after doing the splittype self.host = None self.port = None self.data = data self.headers = {} for key, value in headers.iteritems(): self.add_header(key, value)
c8b188a9e2dc2f5cd60228fddc7eefe0c37192bb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c8b188a9e2dc2f5cd60228fddc7eefe0c37192bb/urllib2.py
for k, v in self.timeout.iteritems():
for k, v in self.timeout.items():
def check_cache(self): # first check for old ones t = time.time() if self.soonest <= t: for k, v in self.timeout.iteritems(): if v < t: self.cache[k].close() del self.cache[k] del self.timeout[k] self.soonest = min(self.timeout.values())
c8b188a9e2dc2f5cd60228fddc7eefe0c37192bb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c8b188a9e2dc2f5cd60228fddc7eefe0c37192bb/urllib2.py
{'message' : 'foo', 'args' : ('foo',)}),
{'message' : 'foo', 'args' : ('foo',), 'filename' : None, 'errno' : None, 'strerror' : None}),
def testAttributes(self): # test that exception attributes are happy
3267d28f9db6f5594167f6262d8882b31542dccf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3267d28f9db6f5594167f6262d8882b31542dccf/test_exceptions.py
{'message' : '', 'args' : ('foo', 'bar')}),
{'message' : '', 'args' : ('foo', 'bar'), 'filename' : None, 'errno' : 'foo', 'strerror' : 'bar'}),
def testAttributes(self): # test that exception attributes are happy
3267d28f9db6f5594167f6262d8882b31542dccf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3267d28f9db6f5594167f6262d8882b31542dccf/test_exceptions.py
{'message' : '', 'args' : ('foo', 'bar')}),
{'message' : '', 'args' : ('foo', 'bar'), 'filename' : 'baz', 'errno' : 'foo', 'strerror' : 'bar'}), (IOError, ('foo', 'bar', 'baz', 'quux'), {'message' : '', 'args' : ('foo', 'bar', 'baz', 'quux')}),
def testAttributes(self): # test that exception attributes are happy
3267d28f9db6f5594167f6262d8882b31542dccf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3267d28f9db6f5594167f6262d8882b31542dccf/test_exceptions.py
find_file(['/usr/include', '/usr/local/include'] + self.include_dirs, 'db_185.h') ):
find_file(inc_dirs, 'db_185.h') ):
def detect_modules(self): # XXX this always gets an empty list -- hardwiring to # a fixed list lib_dirs = self.compiler.library_dirs[:] lib_dirs += ['/lib', '/usr/lib', '/usr/local/lib'] exts = []
a99202a017b69f176c27a4f2cee222a9b4fa9a11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a99202a017b69f176c27a4f2cee222a9b4fa9a11/setup.py
exts.append( Extension('pyexpat', ['pyexpat.c'], libraries = ['expat']) )
defs = None if find_file(inc_dirs, 'expat.h'): defs = [('HAVE_EXPAT_H', 1)] elif find_file(inc_dirs, 'xmlparse.h'): defs = [] if defs is not None: exts.append( Extension('pyexpat', ['pyexpat.c'], define_macros = defs, libraries = ['expat']) )
def detect_modules(self): # XXX this always gets an empty list -- hardwiring to # a fixed list lib_dirs = self.compiler.library_dirs[:] lib_dirs += ['/lib', '/usr/lib', '/usr/local/lib'] exts = []
a99202a017b69f176c27a4f2cee222a9b4fa9a11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a99202a017b69f176c27a4f2cee222a9b4fa9a11/setup.py
s.bind(hostname, PORT)
s.bind((hostname, PORT))
def missing_ok(str): try: getattr(socket, str) except AttributeError: pass
7e57bc4a5b4a05329c4bbdacd7552e2e4f898e04 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e57bc4a5b4a05329c4bbdacd7552e2e4f898e04/test_socket.py
s.connect(hostname, PORT)
s.connect((hostname, PORT))
def missing_ok(str): try: getattr(socket, str) except AttributeError: pass
7e57bc4a5b4a05329c4bbdacd7552e2e4f898e04 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e57bc4a5b4a05329c4bbdacd7552e2e4f898e04/test_socket.py
vars, lasttoken, parent, prefix = [], None, None, ''
vars, lasttoken, parent, prefix, value = [], None, None, '', __UNDEF__
def scanvars(reader, frame, locals): """Scan one logical line of Python and look up values of variables used.""" import tokenize, keyword vars, lasttoken, parent, prefix = [], None, None, '' for ttype, token, start, end, line in tokenize.generate_tokens(reader): if ttype == tokenize.NEWLINE: break if ttype == tokenize.NAME and token not in keyword.kwlist: if lasttoken == '.': if parent is not __UNDEF__: value = getattr(parent, token, __UNDEF__) vars.append((prefix + token, prefix, value)) else: where, value = lookup(token, frame, locals) vars.append((token, where, value)) elif token == '.': prefix += lasttoken + '.' parent = value else: parent, prefix = None, '' lasttoken = token return vars
26f6bdf4f19336c125e3fac7aacaf55b312f474b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/26f6bdf4f19336c125e3fac7aacaf55b312f474b/cgitb.py
print """q(uit) Quit from the debugger.
print """q(uit) or exit - Quit from the debugger.
def help_q(self): print """q(uit) Quit from the debugger.
d1c08f33f2915d101c75c8937806bc27496b3463 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d1c08f33f2915d101c75c8937806bc27496b3463/pdb.py
def createMessage(self, dir):
def createMessage(self, dir, mbox=False):
def createMessage(self, dir): t = int(time.time() % 1000000) pid = self._counter self._counter += 1 filename = os.extsep.join((str(t), str(pid), "myhostname", "mydomain")) tmpname = os.path.join(self._dir, "tmp", filename) newname = os.path.join(self._dir, dir, filename) fp = open(tmpname, "w") self._msgfiles.append(tmpname) fp.write(DUMMY_MESSAGE) fp.close() if hasattr(os, "link"): os.link(tmpname, newname) else: fp = open(newname, "w") fp.write(DUMMY_MESSAGE) fp.close() self._msgfiles.append(newname)
5253da163c8faf789567ab0a709a176addb8d73d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5253da163c8faf789567ab0a709a176addb8d73d/test_mailbox.py
doc = getattr(value, "__doc__", None)
if callable(value): doc = getattr(value, "__doc__", None) else: doc = None
def spilldata(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: base = self.docother(getattr(object, name), name, mod) doc = getattr(value, "__doc__", None) if doc is None: push('<dl><dt>%s</dl>\n' % base) else: doc = self.markup(getdoc(value), self.preformat, funcs, classes, mdict) doc = '<dd><tt>%s</tt>' % doc push('<dl><dt>%s%s</dl>\n' % (base, doc)) push('\n') return attrs
5e355b244ff5b76e736a949d6ee5ec4f01f0b9a0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5e355b244ff5b76e736a949d6ee5ec4f01f0b9a0/pydoc.py
doc = getattr(value, "__doc__", None)
if callable(value): doc = getattr(value, "__doc__", None) else: doc = None
def spilldata(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: doc = getattr(value, "__doc__", None) push(self.docother(getattr(object, name), name, mod, 70, doc) + '\n') return attrs
5e355b244ff5b76e736a949d6ee5ec4f01f0b9a0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5e355b244ff5b76e736a949d6ee5ec4f01f0b9a0/pydoc.py
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
3cbdbfbf9c07577b624d660c30bfa5a8e1e69419 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3cbdbfbf9c07577b624d660c30bfa5a8e1e69419/setup.py
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
3cbdbfbf9c07577b624d660c30bfa5a8e1e69419 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3cbdbfbf9c07577b624d660c30bfa5a8e1e69419/setup.py
self.assertTrue(data.endswith('\n'))
self.assertTrue(data == '' or data.endswith('\n'))
def verify_valid_flag(self, cmd_line): data = self.start_python(cmd_line) self.assertTrue(data.endswith('\n')) self.assertTrue('Traceback' not in data)
c252c5964c076071bfc20f8c4dfe70a79dba57aa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c252c5964c076071bfc20f8c4dfe70a79dba57aa/test_cmd_line.py
return 1
def test_expat_entityresolver(): return 1 # disabling this until pyexpat.c has been fixed parser = create_parser() parser.setEntityResolver(TestEntityResolver()) result = StringIO() parser.setContentHandler(XMLGenerator(result)) parser.feed('<!DOCTYPE doc [\n') parser.feed(' <!ENTITY test SYSTEM "whatever">\n') parser.feed(']>\n') parser.feed('<doc>&test;</doc>') parser.close() return result.getvalue() == start + "<doc><entity></entity></doc>"
424980fd4df1b706208b06d2afe6a0e7626c4c0f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/424980fd4df1b706208b06d2afe6a0e7626c4c0f/test_sax.py
print 'Start element:\n\t', name, attrs
print 'Start element:\n\t', name, attrs
def StartElementHandler(self, name, attrs):
e188d52a7ec912c9752fdb1e9c1b97c5848f0889 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e188d52a7ec912c9752fdb1e9c1b97c5848f0889/test_pyexpat.py
print 'End element:\n\t', name
print 'End element:\n\t', name
def EndElementHandler(self, name):
e188d52a7ec912c9752fdb1e9c1b97c5848f0889 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e188d52a7ec912c9752fdb1e9c1b97c5848f0889/test_pyexpat.py
print 'PI:\n\t', target, data
print 'PI:\n\t', target, data
def ProcessingInstructionHandler(self, target, data):
e188d52a7ec912c9752fdb1e9c1b97c5848f0889 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e188d52a7ec912c9752fdb1e9c1b97c5848f0889/test_pyexpat.py
print 'NS decl:\n\t', prefix, uri
print 'NS decl:\n\t', prefix, uri
def StartNamespaceDeclHandler(self, prefix, uri):
e188d52a7ec912c9752fdb1e9c1b97c5848f0889 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e188d52a7ec912c9752fdb1e9c1b97c5848f0889/test_pyexpat.py
print 'End of NS decl:\n\t', prefix
print 'End of NS decl:\n\t', prefix
def EndNamespaceDeclHandler(self, prefix):
e188d52a7ec912c9752fdb1e9c1b97c5848f0889 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e188d52a7ec912c9752fdb1e9c1b97c5848f0889/test_pyexpat.py
print 'Start of CDATA section'
print 'Start of CDATA section'
def StartCdataSectionHandler(self):
e188d52a7ec912c9752fdb1e9c1b97c5848f0889 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e188d52a7ec912c9752fdb1e9c1b97c5848f0889/test_pyexpat.py
print 'End of CDATA section'
print 'End of CDATA section'
def EndCdataSectionHandler(self):
e188d52a7ec912c9752fdb1e9c1b97c5848f0889 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e188d52a7ec912c9752fdb1e9c1b97c5848f0889/test_pyexpat.py
print 'Comment:\n\t', repr(text)
print 'Comment:\n\t', repr(text)
def CommentHandler(self, text):
e188d52a7ec912c9752fdb1e9c1b97c5848f0889 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e188d52a7ec912c9752fdb1e9c1b97c5848f0889/test_pyexpat.py
print 'Notation declared:', args
print 'Notation declared:', args
def NotationDeclHandler(self, *args): name, base, sysid, pubid = args
e188d52a7ec912c9752fdb1e9c1b97c5848f0889 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e188d52a7ec912c9752fdb1e9c1b97c5848f0889/test_pyexpat.py
'CharacterDataHandler', 'ProcessingInstructionHandler', 'UnparsedEntityDeclHandler', 'NotationDeclHandler', 'StartNamespaceDeclHandler', 'EndNamespaceDeclHandler', 'CommentHandler', 'StartCdataSectionHandler', 'EndCdataSectionHandler',
'CharacterDataHandler', 'ProcessingInstructionHandler', 'UnparsedEntityDeclHandler', 'NotationDeclHandler', 'StartNamespaceDeclHandler', 'EndNamespaceDeclHandler', 'CommentHandler', 'StartCdataSectionHandler', 'EndCdataSectionHandler',
def DefaultHandlerExpand(self, userData): pass
e188d52a7ec912c9752fdb1e9c1b97c5848f0889 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e188d52a7ec912c9752fdb1e9c1b97c5848f0889/test_pyexpat.py
'ExternalEntityRefHandler'
'ExternalEntityRefHandler'
def DefaultHandlerExpand(self, userData): pass
e188d52a7ec912c9752fdb1e9c1b97c5848f0889 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e188d52a7ec912c9752fdb1e9c1b97c5848f0889/test_pyexpat.py
try: if os.isatty(sys.stdin.fileno()): NO_ARG_FUNCTIONS.append("getlogin") except: pass
def testNoArgFunctions(self): # test posix functions which take no arguments and have # no side-effects which we need to cleanup (e.g., fork, wait, abort) NO_ARG_FUNCTIONS = [ "ctermid", "getcwd", "getcwdu", "uname", "times", "getloadavg", "tmpnam", "getegid", "geteuid", "getgid", "getgroups", "getpid", "getpgrp", "getppid", "getuid", ] # getlogin() only works when run from a tty (terminal) try: if os.isatty(sys.stdin.fileno()): NO_ARG_FUNCTIONS.append("getlogin") except: pass
6e54f579a68c1c8e567a49464afda8599a03b7a7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6e54f579a68c1c8e567a49464afda8599a03b7a7/test_posix.py
t = test()
t = Test()
def str(self): return str(self)
de6024872abe4fd95972036db63d0a57cf557f94 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/de6024872abe4fd95972036db63d0a57cf557f94/test_scope.py
assert u"%c" % (u"abc",) == u'a' assert u"%c" % ("abc",) == u'a'
assert u"%c" % (u"a",) == u'a' assert u"%c" % ("a",) == u'a'
test('capwords', u'abc\t def \nghi', u'Abc Def Ghi')
59a044b7d2c831e4e6f002808096318c741dec19 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/59a044b7d2c831e4e6f002808096318c741dec19/test_unicode.py
'.mid': 'audio/midi', '.midi': 'audio/midi',
def read_mime_types(file): try: f = open(file) except IOError: return None db = MimeTypes() db.readfp(f) return db.types_map
a3689fe78675c89d5979c0c5acdb1c173cc75ed6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a3689fe78675c89d5979c0c5acdb1c173cc75ed6/mimetypes.py
'.rtf': 'application/rtf',
def read_mime_types(file): try: f = open(file) except IOError: return None db = MimeTypes() db.readfp(f) return db.types_map
a3689fe78675c89d5979c0c5acdb1c173cc75ed6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a3689fe78675c89d5979c0c5acdb1c173cc75ed6/mimetypes.py
self.assertRaises(ValueError, u"%c".__mod__, (sys.maxunicode+1,))
self.assertRaises(OverflowError, u"%c".__mod__, (sys.maxunicode+1,))
def test_formatting(self): string_tests.MixinStrUnicodeUserStringTest.test_formatting(self) # Testing Unicode formatting strings... self.assertEqual(u"%s, %s" % (u"abc", "abc"), u'abc, abc') self.assertEqual(u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", 1, 2, 3), u'abc, abc, 1, 2.000000, 3.00') self.assertEqual(u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", 1, -2, 3), u'abc, abc, 1, -2.000000, 3.00') self.assertEqual(u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 3.5), u'abc, abc, -1, -2.000000, 3.50') self.assertEqual(u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 3.57), u'abc, abc, -1, -2.000000, 3.57') self.assertEqual(u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 1003.57), u'abc, abc, -1, -2.000000, 1003.57') if not sys.platform.startswith('java'): self.assertEqual(u"%r, %r" % (u"abc", "abc"), u"u'abc', 'abc'") self.assertEqual(u"%(x)s, %(y)s" % {'x':u"abc", 'y':"def"}, u'abc, def') self.assertEqual(u"%(x)s, %(\xfc)s" % {'x':u"abc", u'\xfc':"def"}, u'abc, def')
44f527fea4c73038322c7c6647e20e47c2ccdd88 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/44f527fea4c73038322c7c6647e20e47c2ccdd88/test_unicode.py
'Header', 'Iterators', 'MIMEAudio', 'MIMEBase', 'MIMEImage', 'MIMEMessage', 'MIMEText', 'Message', 'Parser', 'Utils', 'base64MIME',
'Header', 'Iterators', 'MIMEAudio', 'MIMEBase', 'MIMEImage', 'MIMEMessage', 'MIMEMultipart', 'MIMENonMultipart', 'MIMEText', 'Message', 'Parser', 'Utils', 'base64MIME',
def test__all__(self): module = __import__('email') all = module.__all__ all.sort() self.assertEqual(all, ['Charset', 'Encoders', 'Errors', 'Generator', 'Header', 'Iterators', 'MIMEAudio', 'MIMEBase', 'MIMEImage', 'MIMEMessage', 'MIMEText', 'Message', 'Parser', 'Utils', 'base64MIME', 'message_from_file', 'message_from_string', 'quopriMIME'])
0ac885e8216436fb000da97702a9cf4c53b710f2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0ac885e8216436fb000da97702a9cf4c53b710f2/test_email.py
items = map(lambda (k, v), type = type, simp = SIMPLE_TYPES, indent = indent: (k, v, not type(v) in simp, indent), items)
items = [(k, v, not isinstance(v, SIMPLE_TYPES), indent) for k, v in items]
def pack_items(items, indent = 0): items = map(lambda (k, v), type = type, simp = SIMPLE_TYPES, indent = indent: (k, v, not type(v) in simp, indent), items) return tuple_caselesssort(items)
feddf77ad200ebf2f67b5c4f2fa670a58814229a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/feddf77ad200ebf2f67b5c4f2fa670a58814229a/PyBrowser.py
s = madstring("\x00" * 5) verify(str(s) == "\x00" * 5)
base = "\x00" * 5 s = madstring(base) verify(str(s) == base)
def rev(self): if self._rev is not None: return self._rev L = list(self) L.reverse() self._rev = self.__class__("".join(L)) return self._rev
8fa5dd0601ed48c534be96e6f1f3fe54d023d0a0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8fa5dd0601ed48c534be96e6f1f3fe54d023d0a0/test_descr.py
return self.reader.next()
data = self.reader.next() data, bytesencoded = self.encode(data, self.errors) return data
def next(self):
c5238b82887c9f0507632aec206739c3bb7a1caf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c5238b82887c9f0507632aec206739c3bb7a1caf/codecs.py
def circle(self, radius, extent=None):
def circle(self, radius, extent = None):
def circle(self, radius, extent=None): """ Draw a circle with given radius. The center is radius units left of the turtle; extent determines which part of the circle is drawn. If not given, the entire circle is drawn.
4c4300de4e0f7d598da8769bbd7523748167249e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4c4300de4e0f7d598da8769bbd7523748167249e/turtle.py
extent = self._fullcircle x0, y0 = self._position xc = x0 - radius * sin(self._angle * self._invradian) yc = y0 - radius * cos(self._angle * self._invradian) if radius >= 0.0: start = self._angle - (self._fullcircle / 4.0) else: start = self._angle + (self._fullcircle / 4.0) extent = -extent if self._filling: if abs(extent) >= self._fullcircle: item = self._canvas.create_oval(xc-radius, yc-radius, xc+radius, yc+radius, width=self._width, outline="") self._tofill.append(item) item = self._canvas.create_arc(xc-radius, yc-radius, xc+radius, yc+radius, style="chord", start=start, extent=extent, width=self._width, outline="") self._tofill.append(item) if self._drawing: if abs(extent) >= self._fullcircle: item = self._canvas.create_oval(xc-radius, yc-radius, xc+radius, yc+radius, width=self._width, outline=self._color) self._items.append(item) item = self._canvas.create_arc(xc-radius, yc-radius, xc+radius, yc+radius, style="arc", start=start, extent=extent, width=self._width, outline=self._color) self._items.append(item) angle = start + extent x1 = xc + abs(radius) * cos(angle * self._invradian) y1 = yc - abs(radius) * sin(angle * self._invradian) self._angle = (self._angle + extent) % self._fullcircle self._position = x1, y1 if self._filling: self._path.append(self._position) self._draw_turtle()
extent = self._fullcircle frac = abs(extent)/self._fullcircle steps = 1+int(min(11+abs(radius)/6.0, 59.0)*frac) w = 1.0 * extent / steps w2 = 0.5 * w l = 2.0 * radius * sin(w2*self._invradian) if radius < 0: l, w, w2 = -l, -w, -w2 self.left(w2) for i in range(steps): self.forward(l) self.left(w) self.right(w2)
def circle(self, radius, extent=None): """ Draw a circle with given radius. The center is radius units left of the turtle; extent determines which part of the circle is drawn. If not given, the entire circle is drawn.
4c4300de4e0f7d598da8769bbd7523748167249e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4c4300de4e0f7d598da8769bbd7523748167249e/turtle.py
for h in root.handlers:
for h in root.handlers[:]:
def fileConfig(fname, defaults=None): """ Read the logging configuration from a ConfigParser-format file. This can be called several times from an application, allowing an end user the ability to select from various pre-canned configurations (if the developer provides a mechanism to present the choices and load the chosen configuration). In versions of ConfigParser which have the readfp method [typically shipped in 2.x versions of Python], you can pass in a file-like object rather than a filename, in which case the file-like object will be read using readfp. """ import ConfigParser cp = ConfigParser.ConfigParser(defaults) if hasattr(cp, 'readfp') and hasattr(fname, 'readline'): cp.readfp(fname) else: cp.read(fname) #first, do the formatters... flist = cp.get("formatters", "keys") if len(flist): flist = string.split(flist, ",") formatters = {} for form in flist: sectname = "formatter_%s" % form opts = cp.options(sectname) if "format" in opts: fs = cp.get(sectname, "format", 1) else: fs = None if "datefmt" in opts: dfs = cp.get(sectname, "datefmt", 1) else: dfs = None f = logging.Formatter(fs, dfs) formatters[form] = f #next, do the handlers... #critical section... logging._acquireLock() try: try: #first, lose the existing handlers... logging._handlers.clear() #now set up the new ones... hlist = cp.get("handlers", "keys") if len(hlist): hlist = string.split(hlist, ",") handlers = {} fixups = [] #for inter-handler references for hand in hlist: sectname = "handler_%s" % hand klass = cp.get(sectname, "class") opts = cp.options(sectname) if "formatter" in opts: fmt = cp.get(sectname, "formatter") else: fmt = "" klass = eval(klass, vars(logging)) args = cp.get(sectname, "args") args = eval(args, vars(logging)) h = apply(klass, args) if "level" in opts: level = cp.get(sectname, "level") h.setLevel(logging._levelNames[level]) if len(fmt): h.setFormatter(formatters[fmt]) #temporary hack for FileHandler and MemoryHandler. if klass == logging.handlers.MemoryHandler: if "target" in opts: target = cp.get(sectname,"target") else: target = "" if len(target): #the target handler may not be loaded yet, so keep for later... fixups.append((h, target)) handlers[hand] = h #now all handlers are loaded, fixup inter-handler references... for fixup in fixups: h = fixup[0] t = fixup[1] h.setTarget(handlers[t]) #at last, the loggers...first the root... llist = cp.get("loggers", "keys") llist = string.split(llist, ",") llist.remove("root") sectname = "logger_root" root = logging.root log = root opts = cp.options(sectname) if "level" in opts: level = cp.get(sectname, "level") log.setLevel(logging._levelNames[level]) for h in root.handlers: root.removeHandler(h) hlist = cp.get(sectname, "handlers") if len(hlist): hlist = string.split(hlist, ",") for hand in hlist: log.addHandler(handlers[hand]) #and now the others... #we don't want to lose the existing loggers, #since other threads may have pointers to them. #existing is set to contain all existing loggers, #and as we go through the new configuration we #remove any which are configured. At the end, #what's left in existing is the set of loggers #which were in the previous configuration but #which are not in the new configuration. existing = root.manager.loggerDict.keys() #now set up the new ones... for log in llist: sectname = "logger_%s" % log qn = cp.get(sectname, "qualname") opts = cp.options(sectname) if "propagate" in opts: propagate = cp.getint(sectname, "propagate") else: propagate = 1 logger = logging.getLogger(qn) if qn in existing: existing.remove(qn) if "level" in opts: level = cp.get(sectname, "level") logger.setLevel(logging._levelNames[level]) for h in logger.handlers: logger.removeHandler(h) logger.propagate = propagate logger.disabled = 0 hlist = cp.get(sectname, "handlers") if len(hlist): hlist = string.split(hlist, ",") for hand in hlist: logger.addHandler(handlers[hand]) #Disable any old loggers. There's no point deleting #them as other threads may continue to hold references #and by disabling them, you stop them doing any logging. for log in existing: root.manager.loggerDict[log].disabled = 1 except: import traceback ei = sys.exc_info() traceback.print_exception(ei[0], ei[1], ei[2], None, sys.stderr) del ei finally: logging._releaseLock()
24475896dd7c80695cb1b632fba37afd99d3b71b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/24475896dd7c80695cb1b632fba37afd99d3b71b/config.py
for h in logger.handlers:
for h in logger.handlers[:]:
def fileConfig(fname, defaults=None): """ Read the logging configuration from a ConfigParser-format file. This can be called several times from an application, allowing an end user the ability to select from various pre-canned configurations (if the developer provides a mechanism to present the choices and load the chosen configuration). In versions of ConfigParser which have the readfp method [typically shipped in 2.x versions of Python], you can pass in a file-like object rather than a filename, in which case the file-like object will be read using readfp. """ import ConfigParser cp = ConfigParser.ConfigParser(defaults) if hasattr(cp, 'readfp') and hasattr(fname, 'readline'): cp.readfp(fname) else: cp.read(fname) #first, do the formatters... flist = cp.get("formatters", "keys") if len(flist): flist = string.split(flist, ",") formatters = {} for form in flist: sectname = "formatter_%s" % form opts = cp.options(sectname) if "format" in opts: fs = cp.get(sectname, "format", 1) else: fs = None if "datefmt" in opts: dfs = cp.get(sectname, "datefmt", 1) else: dfs = None f = logging.Formatter(fs, dfs) formatters[form] = f #next, do the handlers... #critical section... logging._acquireLock() try: try: #first, lose the existing handlers... logging._handlers.clear() #now set up the new ones... hlist = cp.get("handlers", "keys") if len(hlist): hlist = string.split(hlist, ",") handlers = {} fixups = [] #for inter-handler references for hand in hlist: sectname = "handler_%s" % hand klass = cp.get(sectname, "class") opts = cp.options(sectname) if "formatter" in opts: fmt = cp.get(sectname, "formatter") else: fmt = "" klass = eval(klass, vars(logging)) args = cp.get(sectname, "args") args = eval(args, vars(logging)) h = apply(klass, args) if "level" in opts: level = cp.get(sectname, "level") h.setLevel(logging._levelNames[level]) if len(fmt): h.setFormatter(formatters[fmt]) #temporary hack for FileHandler and MemoryHandler. if klass == logging.handlers.MemoryHandler: if "target" in opts: target = cp.get(sectname,"target") else: target = "" if len(target): #the target handler may not be loaded yet, so keep for later... fixups.append((h, target)) handlers[hand] = h #now all handlers are loaded, fixup inter-handler references... for fixup in fixups: h = fixup[0] t = fixup[1] h.setTarget(handlers[t]) #at last, the loggers...first the root... llist = cp.get("loggers", "keys") llist = string.split(llist, ",") llist.remove("root") sectname = "logger_root" root = logging.root log = root opts = cp.options(sectname) if "level" in opts: level = cp.get(sectname, "level") log.setLevel(logging._levelNames[level]) for h in root.handlers: root.removeHandler(h) hlist = cp.get(sectname, "handlers") if len(hlist): hlist = string.split(hlist, ",") for hand in hlist: log.addHandler(handlers[hand]) #and now the others... #we don't want to lose the existing loggers, #since other threads may have pointers to them. #existing is set to contain all existing loggers, #and as we go through the new configuration we #remove any which are configured. At the end, #what's left in existing is the set of loggers #which were in the previous configuration but #which are not in the new configuration. existing = root.manager.loggerDict.keys() #now set up the new ones... for log in llist: sectname = "logger_%s" % log qn = cp.get(sectname, "qualname") opts = cp.options(sectname) if "propagate" in opts: propagate = cp.getint(sectname, "propagate") else: propagate = 1 logger = logging.getLogger(qn) if qn in existing: existing.remove(qn) if "level" in opts: level = cp.get(sectname, "level") logger.setLevel(logging._levelNames[level]) for h in logger.handlers: logger.removeHandler(h) logger.propagate = propagate logger.disabled = 0 hlist = cp.get(sectname, "handlers") if len(hlist): hlist = string.split(hlist, ",") for hand in hlist: logger.addHandler(handlers[hand]) #Disable any old loggers. There's no point deleting #them as other threads may continue to hold references #and by disabling them, you stop them doing any logging. for log in existing: root.manager.loggerDict[log].disabled = 1 except: import traceback ei = sys.exc_info() traceback.print_exception(ei[0], ei[1], ei[2], None, sys.stderr) del ei finally: logging._releaseLock()
24475896dd7c80695cb1b632fba37afd99d3b71b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/24475896dd7c80695cb1b632fba37afd99d3b71b/config.py
'_topdir %s/%s' % (os.getcwd(), self.rpm_base),])
'_topdir %s' % os.path.abspath(self.rpm_base)])
def run (self):
57a6a41e54c132a317b80dd47df1598df3fb4cdf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/57a6a41e54c132a317b80dd47df1598df3fb4cdf/bdist_rpm.py
def get(self, section, option, raw=0):
def get(self, section, option, raw=0, vars=None):
def get(self, section, option, raw=0): """Get an option value for a given section.
e6506e753bd3c1fc5c32271d30db46fb41f8486f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6506e753bd3c1fc5c32271d30db46fb41f8486f/ConfigParser.py
argument `raw' is true.
argument `raw' is true. Additional substitutions may be provided using the vars keyword argument, which override any pre-existing defaults.
def get(self, section, option, raw=0): """Get an option value for a given section.
e6506e753bd3c1fc5c32271d30db46fb41f8486f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6506e753bd3c1fc5c32271d30db46fb41f8486f/ConfigParser.py
try: return rawval % d except KeyError, key: raise InterpolationError(key, option, section, rawval)
value = rawval while 1: if not string.find(value, "%("): try: value = value % d except KeyError, key: raise InterpolationError(key, option, section, rawval) else: return value
def get(self, section, option, raw=0): """Get an option value for a given section.
e6506e753bd3c1fc5c32271d30db46fb41f8486f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6506e753bd3c1fc5c32271d30db46fb41f8486f/ConfigParser.py
raise TestFailed, 'zip() - no args, expected TypeError, got', e
raise TestFailed, 'zip() - no args, expected TypeError, got %s' % e
def __getitem__(self, i): if i < 0 or i > 2: raise IndexError return i + 4
715812667366cc747ac78598d462dd7ff75d4bb2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/715812667366cc747ac78598d462dd7ff75d4bb2/test_b2.py
raise TestFailed, 'zip(None) - expected TypeError, got', e
raise TestFailed, 'zip(None) - expected TypeError, got %s' % e
def __getitem__(self, i): if i < 0 or i > 2: raise IndexError return i + 4
715812667366cc747ac78598d462dd7ff75d4bb2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/715812667366cc747ac78598d462dd7ff75d4bb2/test_b2.py
print "path =", `path` if "/arse" in path: import pdb; pdb.set_trace()
def write_results_file(self, path, lines, lnotab, lines_hit): """Return a coverage results file in path."""
80bd5ca722875a685c7595358ec4d9173d777ece /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/80bd5ca722875a685c7595358ec4d9173d777ece/trace.py
while cursel > 0 and selstart[:i] <= self.completions[cursel-1]:
previous_completion = self.completions[cursel - 1] while cursel > 0 and selstart[:i] <= previous_completion:
def _selection_changed(self): """Should be called when the selection of the Listbox has changed. Updates the Listbox display and calls _change_start.""" cursel = int(self.listbox.curselection()[0])
c3200b97d6f7dff43c094ab7dd6cd91da879e5d8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c3200b97d6f7dff43c094ab7dd6cd91da879e5d8/AutoCompleteWindow.py
def __init__(self, sock=None): dispatcher.__init__(self, sock)
def __init__(self, sock=None, map=None): dispatcher.__init__(self, sock, map)
def __init__(self, sock=None): dispatcher.__init__(self, sock) self.out_buffer = ''
67867eaf8ceca3d061194b7819832aae05202c8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/67867eaf8ceca3d061194b7819832aae05202c8c/asyncore.py
def __init__(self, fd): dispatcher.__init__(self)
def __init__(self, fd, map=None): dispatcher.__init__(self, None, map)
def __init__(self, fd): dispatcher.__init__(self) self.connected = True # set it to non-blocking mode flags = fcntl.fcntl(fd, fcntl.F_GETFL, 0) flags = flags | os.O_NONBLOCK fcntl.fcntl(fd, fcntl.F_SETFL, flags) self.set_file(fd)
67867eaf8ceca3d061194b7819832aae05202c8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/67867eaf8ceca3d061194b7819832aae05202c8c/asyncore.py
host, XXX = splithost(r_type) if '@' in host: user_pass, host = host.split('@', 1) if ':' in user_pass: user, password = user_pass.split(':', 1) user_pass = base64.encodestring('%s:%s' % (unquote(user), unquote(password))).strip() req.add_header('Proxy-authorization', 'Basic ' + user_pass)
if not type or r_type.isdigit(): type = orig_type host = proxy else: host, r_host = splithost(r_type) user_pass, host = splituser(host) user, password = splitpasswd(user_pass) if user and password: user, password = user_pass.split(':', 1) user_pass = base64.encodestring('%s:%s' % (unquote(user), unquote(password))).strip() req.add_header('Proxy-authorization', 'Basic ' + user_pass)
def proxy_open(self, req, proxy, type): orig_type = req.get_type() type, r_type = splittype(proxy) host, XXX = splithost(r_type) if '@' in host: user_pass, host = host.split('@', 1) if ':' in user_pass: user, password = user_pass.split(':', 1) user_pass = base64.encodestring('%s:%s' % (unquote(user), unquote(password))).strip() req.add_header('Proxy-authorization', 'Basic ' + user_pass) host = unquote(host) req.set_proxy(host, type) if orig_type == type: # let other handlers take care of it # XXX this only makes sense if the proxy is before the # other handlers return None else: # need to start over, because the other handlers don't # grok the proxy's URL type return self.parent.open(req)
531cebad4c815f8fcf7abaf680ceb88c014d7d3f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/531cebad4c815f8fcf7abaf680ceb88c014d7d3f/urllib2.py
if r.status in (200, 206): resp = addinfourl(r.fp, r.msg, req.get_full_url()) resp.code = r.status resp.msg = r.reason return resp else: return self.parent.error("http", req, r.fp, r.status, r.msg, r.msg.dict)
resp = addinfourl(r.fp, r.msg, req.get_full_url()) resp.code = r.status resp.msg = r.reason return resp
def do_open(self, http_class, req): """Return an addinfourl object for the request, using http_class.
f9ea7c067a5278d02b28e567a99f850a136d29c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f9ea7c067a5278d02b28e567a99f850a136d29c8/urllib2.py
test_support.run_unittest( TrivialTests, OpenerDirectorTests, HandlerTests, MiscTests, )
tests = (TrivialTests, OpenerDirectorTests, HandlerTests, MiscTests) if test_support.is_resource_enabled('network'): tests += (NetworkTests,) test_support.run_unittest(*tests)
def test_main(verbose=None): from test import test_sets test_support.run_unittest( TrivialTests, OpenerDirectorTests, HandlerTests, MiscTests, )
bd3200fa2bfa8a73d56de16b68d33d2e25583875 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bd3200fa2bfa8a73d56de16b68d33d2e25583875/test_urllib2.py
def putrequest(self, method, url, skip_host=0):
def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0):
def putrequest(self, method, url, skip_host=0): """Send a request to the server.
af7dc8d8b86de39a16c6cf7bdba263ea1cedf26b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/af7dc8d8b86de39a16c6cf7bdba263ea1cedf26b/httplib.py
def putrequest(self, method, url, skip_host=0): """Send a request to the server.
af7dc8d8b86de39a16c6cf7bdba263ea1cedf26b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/af7dc8d8b86de39a16c6cf7bdba263ea1cedf26b/httplib.py
self.putheader('Accept-Encoding', 'identity')
if not skip_accept_encoding: self.putheader('Accept-Encoding', 'identity')
def putrequest(self, method, url, skip_host=0): """Send a request to the server.
af7dc8d8b86de39a16c6cf7bdba263ea1cedf26b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/af7dc8d8b86de39a16c6cf7bdba263ea1cedf26b/httplib.py
pass return '?'
if not self.lseen: if not self.rseen: return '0' else: return 'N' else: if not self.rseen: return '?' if self.lsum == self.rsum: return 'c' else: return 'C' else: if not self.lseen: if self.eremoved: if self.rseen: return 'R' else: return 'r' else: if self.rseen: print "warning:", print self.file, print "was lost" return 'U' else: return 'r' else: if not self.rseen: if self.enew: return 'A' else: return 'D' else: if self.enew: if self.lsum == self.rsum: return 'u' else: return 'C' if self.lsum == self.esum: if self.esum == self.rsum: return '=' else: return 'U' elif self.esum == self.rsum: return 'M' elif self.lsum == self.rsum: return 'u' else: return 'C'
def action(self): """Return a code indicating the update status of this file.
6bb4a51daacef23a08dc0e4df60f1c48d778041a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6bb4a51daacef23a08dc0e4df60f1c48d778041a/rcvs.py
self.cvs.report()
for file in files: print self.cvs.entries[file].action(), file
def default(self): files = [] if self.cvs.checkfiles(files): return 1 self.cvs.report()
6bb4a51daacef23a08dc0e4df60f1c48d778041a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6bb4a51daacef23a08dc0e4df60f1c48d778041a/rcvs.py
if not self.entries[file].commitcheck():
if not self.cvs.entries[file].commitcheck():
def do_commit(self, opts, files): """commit [file] ...""" if self.cvs.checkfiles(files): return 1 sts = 0 for file in files: if not self.entries[file].commitcheck(): sts = 1 if sts: return sts message = raw_input("One-liner: ") for file in files: self.entries[file].commit(message)
6bb4a51daacef23a08dc0e4df60f1c48d778041a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6bb4a51daacef23a08dc0e4df60f1c48d778041a/rcvs.py
self.entries[file].commit(message)
self.cvs.entries[file].commit(message) self.cvs.putentries()
def do_commit(self, opts, files): """commit [file] ...""" if self.cvs.checkfiles(files): return 1 sts = 0 for file in files: if not self.entries[file].commitcheck(): sts = 1 if sts: return sts message = raw_input("One-liner: ") for file in files: self.entries[file].commit(message)
6bb4a51daacef23a08dc0e4df60f1c48d778041a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6bb4a51daacef23a08dc0e4df60f1c48d778041a/rcvs.py
print x return x
def __del__(self): x = self.ref() print x return x
bb1861a996f659621a3d9de875027679ce1926eb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bb1861a996f659621a3d9de875027679ce1926eb/test_descr.py
if type(klass) != types.ClassType: raise TypeError, "setLoggerClass is expecting a class"
def setLoggerClass(klass): """ Set the class to be used when instantiating a logger. The class should define __init__() such that only a name argument is required, and the __init__() should call Logger.__init__() """ if klass != Logger: if type(klass) != types.ClassType: raise TypeError, "setLoggerClass is expecting a class" if not issubclass(klass, Logger): raise TypeError, "logger not derived from logging.Logger: " + \ klass.__name__ global _loggerClass _loggerClass = klass
a256f7d36f0fda36f7ff02cd0c6a5d43990f9572 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a256f7d36f0fda36f7ff02cd0c6a5d43990f9572/__init__.py
self.curNode.appendChild(node) self.curNode = node
def startElementNS(self, name, tagName , attrs): uri, localname = name if uri: # When using namespaces, the reader may or may not # provide us with the original name. If not, create # *a* valid tagName from the current context. if tagName is None: tagName = self._current_context[uri] + ":" + localname node = self.document.createElementNS(uri, tagName) else: # When the tagname is not prefixed, it just appears as # localname node = self.document.createElement(localname)
04a1a542cbaa88136693cf26f3ee1d5d921afe14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/04a1a542cbaa88136693cf26f3ee1d5d921afe14/pulldom.py
self.push(node)
def startElementNS(self, name, tagName , attrs): uri, localname = name if uri: # When using namespaces, the reader may or may not # provide us with the original name. If not, create # *a* valid tagName from the current context. if tagName is None: tagName = self._current_context[uri] + ":" + localname node = self.document.createElementNS(uri, tagName) else: # When the tagname is not prefixed, it just appears as # localname node = self.document.createElement(localname)
04a1a542cbaa88136693cf26f3ee1d5d921afe14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/04a1a542cbaa88136693cf26f3ee1d5d921afe14/pulldom.py
node = self.curNode self.lastEvent[1] = [(END_ELEMENT, node), None] self.lastEvent = self.lastEvent[1] self.curNode = self.curNode.parentNode
self.lastEvent[1] = [(END_ELEMENT, self.pop()), None] self.lastEvent = self.lastEvent[1]
def endElementNS(self, name, tagName): node = self.curNode self.lastEvent[1] = [(END_ELEMENT, node), None] self.lastEvent = self.lastEvent[1] #self.events.append((END_ELEMENT, node)) self.curNode = self.curNode.parentNode
04a1a542cbaa88136693cf26f3ee1d5d921afe14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/04a1a542cbaa88136693cf26f3ee1d5d921afe14/pulldom.py
self.curNode.appendChild(node) self.curNode = node
def startElement(self, name, attrs): node = self.document.createElement(name)
04a1a542cbaa88136693cf26f3ee1d5d921afe14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/04a1a542cbaa88136693cf26f3ee1d5d921afe14/pulldom.py
self.push(node)
def startElement(self, name, attrs): node = self.document.createElement(name)
04a1a542cbaa88136693cf26f3ee1d5d921afe14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/04a1a542cbaa88136693cf26f3ee1d5d921afe14/pulldom.py
node = self.curNode self.lastEvent[1] = [(END_ELEMENT, node), None] self.lastEvent = self.lastEvent[1] self.curNode = node.parentNode
self.lastEvent[1] = [(END_ELEMENT, self.pop()), None] self.lastEvent = self.lastEvent[1]
def endElement(self, name): node = self.curNode self.lastEvent[1] = [(END_ELEMENT, node), None] self.lastEvent = self.lastEvent[1] #self.events.append((END_ELEMENT, node)) self.curNode = node.parentNode
04a1a542cbaa88136693cf26f3ee1d5d921afe14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/04a1a542cbaa88136693cf26f3ee1d5d921afe14/pulldom.py
self.curNode.appendChild(node)
def comment(self, s): node = self.document.createComment(s) self.curNode.appendChild(node)
04a1a542cbaa88136693cf26f3ee1d5d921afe14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/04a1a542cbaa88136693cf26f3ee1d5d921afe14/pulldom.py
def comment(self, s): node = self.document.createComment(s) self.curNode.appendChild(node)
04a1a542cbaa88136693cf26f3ee1d5d921afe14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/04a1a542cbaa88136693cf26f3ee1d5d921afe14/pulldom.py
self.curNode.appendChild(node)
def processingInstruction(self, target, data): node = self.document.createProcessingInstruction(target, data)
04a1a542cbaa88136693cf26f3ee1d5d921afe14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/04a1a542cbaa88136693cf26f3ee1d5d921afe14/pulldom.py
def processingInstruction(self, target, data): node = self.document.createProcessingInstruction(target, data)
04a1a542cbaa88136693cf26f3ee1d5d921afe14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/04a1a542cbaa88136693cf26f3ee1d5d921afe14/pulldom.py
self.curNode.appendChild(node)
def ignorableWhitespace(self, chars): node = self.document.createTextNode(chars) self.curNode.appendChild(node)
04a1a542cbaa88136693cf26f3ee1d5d921afe14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/04a1a542cbaa88136693cf26f3ee1d5d921afe14/pulldom.py
def ignorableWhitespace(self, chars): node = self.document.createTextNode(chars) self.curNode.appendChild(node)
04a1a542cbaa88136693cf26f3ee1d5d921afe14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/04a1a542cbaa88136693cf26f3ee1d5d921afe14/pulldom.py
self.curNode.appendChild(node)
def characters(self, chars): node = self.document.createTextNode(chars) self.curNode.appendChild(node)
04a1a542cbaa88136693cf26f3ee1d5d921afe14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/04a1a542cbaa88136693cf26f3ee1d5d921afe14/pulldom.py
self.curNode = self.document = node
self.document = node
def startDocument(self): publicId = systemId = None if self._locator: publicId = self._locator.getPublicId() systemId = self._locator.getSystemId() if self.documentFactory is None: import xml.dom.minidom self.documentFactory = xml.dom.minidom.Document.implementation node = self.documentFactory.createDocument(None, publicId, systemId) self.curNode = self.document = node self.lastEvent[1] = [(START_DOCUMENT, node), None] self.lastEvent = self.lastEvent[1] #self.events.append((START_DOCUMENT, node))
04a1a542cbaa88136693cf26f3ee1d5d921afe14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/04a1a542cbaa88136693cf26f3ee1d5d921afe14/pulldom.py
self.push(node)
def startDocument(self): publicId = systemId = None if self._locator: publicId = self._locator.getPublicId() systemId = self._locator.getSystemId() if self.documentFactory is None: import xml.dom.minidom self.documentFactory = xml.dom.minidom.Document.implementation node = self.documentFactory.createDocument(None, publicId, systemId) self.curNode = self.document = node self.lastEvent[1] = [(START_DOCUMENT, node), None] self.lastEvent = self.lastEvent[1] #self.events.append((START_DOCUMENT, node))
04a1a542cbaa88136693cf26f3ee1d5d921afe14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/04a1a542cbaa88136693cf26f3ee1d5d921afe14/pulldom.py
assert self.curNode.parentNode is None, \ "not all elements have been properly closed" assert self.curNode.documentElement is not None, \ "document does not contain a root element" node = self.curNode.documentElement self.lastEvent[1] = [(END_DOCUMENT, node), None]
self.lastEvent[1] = [(END_DOCUMENT, self.document), None] self.pop()
def endDocument(self): assert self.curNode.parentNode is None, \ "not all elements have been properly closed" assert self.curNode.documentElement is not None, \ "document does not contain a root element" node = self.curNode.documentElement self.lastEvent[1] = [(END_DOCUMENT, node), None] #self.events.append((END_DOCUMENT, self.curNode))
04a1a542cbaa88136693cf26f3ee1d5d921afe14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/04a1a542cbaa88136693cf26f3ee1d5d921afe14/pulldom.py
cur_node.parentNode.appendChild(cur_node)
parents[-1].appendChild(cur_node) if token == START_ELEMENT: parents.append(cur_node) elif token == END_ELEMENT: del parents[-1]
def expandNode(self, node): event = self.getEvent() while event: token, cur_node = event if cur_node is node: return if token != END_ELEMENT: cur_node.parentNode.appendChild(cur_node) event = self.getEvent()
04a1a542cbaa88136693cf26f3ee1d5d921afe14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/04a1a542cbaa88136693cf26f3ee1d5d921afe14/pulldom.py
self.curNode.parentNode.appendChild(self.curNode)
curNode = self.elementStack[-1] parentNode = self.elementStack[-2] parentNode.appendChild(curNode)
def startElementNS(self, name, tagName , attrs): PullDOM.startElementNS(self, name, tagName, attrs) self.curNode.parentNode.appendChild(self.curNode)
04a1a542cbaa88136693cf26f3ee1d5d921afe14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/04a1a542cbaa88136693cf26f3ee1d5d921afe14/pulldom.py
self.curNode.parentNode.appendChild(self.curNode)
curNode = self.elementStack[-1] parentNode = self.elementStack[-2] parentNode.appendChild(curNode)
def startElement(self, name, attrs): PullDOM.startElement(self, name, attrs) self.curNode.parentNode.appendChild(self.curNode)
04a1a542cbaa88136693cf26f3ee1d5d921afe14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/04a1a542cbaa88136693cf26f3ee1d5d921afe14/pulldom.py
node.parentNode.appendChild(node)
parentNode = self.elementStack[-1] parentNode.appendChild(node)
def processingInstruction(self, target, data): PullDOM.processingInstruction(self, target, data) node = self.lastEvent[0][1] node.parentNode.appendChild(node)
04a1a542cbaa88136693cf26f3ee1d5d921afe14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/04a1a542cbaa88136693cf26f3ee1d5d921afe14/pulldom.py
node.parentNode.appendChild(node)
parentNode = self.elementStack[-1] parentNode.appendChild(node)
def ignorableWhitespace(self, chars): PullDOM.ignorableWhitespace(self, chars) node = self.lastEvent[0][1] node.parentNode.appendChild(node)
04a1a542cbaa88136693cf26f3ee1d5d921afe14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/04a1a542cbaa88136693cf26f3ee1d5d921afe14/pulldom.py
node.parentNode.appendChild(node)
parentNode = self.elementStack[-1] parentNode.appendChild(node)
def characters(self, chars): PullDOM.characters(self, chars) node = self.lastEvent[0][1] node.parentNode.appendChild(node)
04a1a542cbaa88136693cf26f3ee1d5d921afe14 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/04a1a542cbaa88136693cf26f3ee1d5d921afe14/pulldom.py
The request should be stored in self.raw_request; the results
The request should be stored in self.raw_requestline; the results
def parse_request(self): """Parse a request (internal).
bf68c78a6fc00de1682428eef4488d757dd2f17b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bf68c78a6fc00de1682428eef4488d757dd2f17b/BaseHTTPServer.py