rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
try:
for thisType in [int, long, float, complex]:
def seval(item): """ Strips parens from item prior to calling eval in an attempt to make it safer """ return eval(item.replace('(', '').replace(')', ''))
5cf26e5184cafd0f87ad4cafc52ed5b635df0d4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5cf26e5184cafd0f87ad4cafc52ed5b635df0d4a/csv.py
thisType = type(seval(row[col])) except OverflowError: thisType = type(seval(row[col] + 'L')) thisType = type(0) except:
thisType(row[col]) break except ValueError, OverflowError: pass else:
def seval(item): """ Strips parens from item prior to calling eval in an attempt to make it safer """ return eval(item.replace('(', '').replace(')', ''))
5cf26e5184cafd0f87ad4cafc52ed5b635df0d4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5cf26e5184cafd0f87ad4cafc52ed5b635df0d4a/csv.py
eval("%s(%s)" % (colType.__name__, header[col])) except:
colType(header[col]) except ValueError, TypeError:
def seval(item): """ Strips parens from item prior to calling eval in an attempt to make it safer """ return eval(item.replace('(', '').replace(')', ''))
5cf26e5184cafd0f87ad4cafc52ed5b635df0d4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5cf26e5184cafd0f87ad4cafc52ed5b635df0d4a/csv.py
return s.split(NUL, 1)[0]
return s.rstrip(NUL)
def nts(s): """Convert a null-terminated string buffer to a python string. """ return s.split(NUL, 1)[0]
a74b881a4cd6de08399203b7b9fd0fb368fe774c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a74b881a4cd6de08399203b7b9fd0fb368fe774c/tarfile.py
parts.append(value + (fieldsize - l) * NUL)
parts.append(value[:fieldsize] + (fieldsize - l) * NUL)
def tobuf(self): """Return a tar header block as a 512 byte string. """ name = self.name
a74b881a4cd6de08399203b7b9fd0fb368fe774c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a74b881a4cd6de08399203b7b9fd0fb368fe774c/tarfile.py
self.chunks = [0]
def __init__(self, name=None, mode="r", fileobj=None): """Open an (uncompressed) tar archive `name'. `mode' is either 'r' to read from an existing archive, 'a' to append data to an existing file or 'w' to create a new file overwriting an existing one. `mode' defaults to 'r'. If `fileobj' is given, it is used for reading or writing data. If it can be determined, `mode' is overridden by `fileobj's mode. `fileobj' is not closed, when TarFile is closed. """ self.name = name
a74b881a4cd6de08399203b7b9fd0fb368fe774c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a74b881a4cd6de08399203b7b9fd0fb368fe774c/tarfile.py
self.members.append(tarinfo) self.membernames.append(tarinfo.name) self.chunks.append(self.offset)
self._record_member(tarinfo)
def addfile(self, tarinfo, fileobj=None): """Add the TarInfo object `tarinfo' to the archive. If `fileobj' is given, tarinfo.size bytes are read from it and added to the archive. You can create TarInfo objects using gettarinfo(). On Windows platforms, `fileobj' should always be opened with mode 'rb' to avoid irritation about the file size. """ self._check("aw")
a74b881a4cd6de08399203b7b9fd0fb368fe774c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a74b881a4cd6de08399203b7b9fd0fb368fe774c/tarfile.py
self.fileobj.seek(self.chunks[-1])
self.fileobj.seek(self.offset)
def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m
a74b881a4cd6de08399203b7b9fd0fb368fe774c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a74b881a4cd6de08399203b7b9fd0fb368fe774c/tarfile.py
if self.chunks[-1] == 0:
if self.offset == 0:
def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m
a74b881a4cd6de08399203b7b9fd0fb368fe774c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a74b881a4cd6de08399203b7b9fd0fb368fe774c/tarfile.py
tarinfo = self.TYPE_METH[tarinfo.type](self, tarinfo) else: tarinfo.offset_data = self.offset if tarinfo.isreg() or tarinfo.type not in SUPPORTED_TYPES: self.offset += self._block(tarinfo.size)
return self.TYPE_METH[tarinfo.type](self, tarinfo) tarinfo.offset_data = self.offset if tarinfo.isreg() or tarinfo.type not in SUPPORTED_TYPES: self.offset += self._block(tarinfo.size)
def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m
a74b881a4cd6de08399203b7b9fd0fb368fe774c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a74b881a4cd6de08399203b7b9fd0fb368fe774c/tarfile.py
self.members.append(tarinfo) self.membernames.append(tarinfo.name) self.chunks.append(self.offset)
self._record_member(tarinfo)
def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m
a74b881a4cd6de08399203b7b9fd0fb368fe774c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a74b881a4cd6de08399203b7b9fd0fb368fe774c/tarfile.py
def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m
a74b881a4cd6de08399203b7b9fd0fb368fe774c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a74b881a4cd6de08399203b7b9fd0fb368fe774c/tarfile.py
name = nts(buf) if tarinfo.type == GNUTYPE_LONGLINK: linkname = nts(buf) buf = self.fileobj.read(BLOCKSIZE) tarinfo = TarInfo.frombuf(buf) tarinfo.offset = self.offset self.offset += BLOCKSIZE tarinfo.offset_data = self.offset tarinfo.name = name or tarinfo.name tarinfo.linkname = linkname or tarinfo.linkname if tarinfo.isreg() or tarinfo.type not in SUPPORTED_TYPES: self.offset += self._block(tarinfo.size) return tarinfo
next.name = nts(buf) elif tarinfo.type == GNUTYPE_LONGLINK: next.linkname = nts(buf) return next
def proc_gnulong(self, tarinfo): """Evaluate the blocks that hold a GNU longname or longlink member. """ buf = "" name = None linkname = None count = tarinfo.size while count > 0: block = self.fileobj.read(BLOCKSIZE) buf += block self.offset += BLOCKSIZE count -= BLOCKSIZE
a74b881a4cd6de08399203b7b9fd0fb368fe774c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a74b881a4cd6de08399203b7b9fd0fb368fe774c/tarfile.py
"""Yield submodule names+loaders recursively, for path or sys.path"""
"""Yields (module_loader, name, ispkg) for all modules recursively on path, or, if path is None, all accessible modules. 'path' should be either None or a list of paths to look for modules in. 'prefix' is a string to output on the front of every module name on output. Note that this function must import all *packages* (NOT all modules!) on the given path, in order to access the __path__ attribute to find submodules. 'onerror' is a function which gets called with one argument (the name of the package which was being imported) if an ImportError occurs trying to import a package. By default the ImportError is caught and ignored. Examples: walk_packages() : list all modules python can access walk_packages(ctypes.__path__, ctypes.__name__+'.') : list all submodules of ctypes """
def walk_packages(path=None, prefix='', onerror=None): """Yield submodule names+loaders recursively, for path or sys.path""" def seen(p, m={}): if p in m: return True m[p] = True for importer, name, ispkg in iter_modules(path, prefix): yield importer, name, ispkg if ispkg: try: __import__(name) except ImportError: if onerror is not None: onerror() else: path = getattr(sys.modules[name], '__path__', None) or [] # don't traverse path items we've seen before path = [p for p in path if not seen(p)] for item in walk_packages(path, name+'.'): yield item
0c794a0bf1c69eb314aed94c3d45da6e72559fd7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0c794a0bf1c69eb314aed94c3d45da6e72559fd7/pkgutil.py
onerror()
onerror(name)
def seen(p, m={}): if p in m: return True m[p] = True
0c794a0bf1c69eb314aed94c3d45da6e72559fd7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0c794a0bf1c69eb314aed94c3d45da6e72559fd7/pkgutil.py
for item in walk_packages(path, name+'.'):
for item in walk_packages(path, name+'.', onerror):
def seen(p, m={}): if p in m: return True m[p] = True
0c794a0bf1c69eb314aed94c3d45da6e72559fd7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0c794a0bf1c69eb314aed94c3d45da6e72559fd7/pkgutil.py
"""Yield submodule names+loaders for path or sys.path"""
"""Yields (module_loader, name, ispkg) for all submodules on path, or, if path is None, all top-level modules on sys.path. 'path' should be either None or a list of paths to look for modules in. 'prefix' is a string to output on the front of every module name on output. """
def iter_modules(path=None, prefix=''): """Yield submodule names+loaders for path or sys.path""" if path is None: importers = iter_importers() else: importers = map(get_importer, path) yielded = {} for i in importers: for name, ispkg in iter_importer_modules(i, prefix): if name not in yielded: yielded[name] = 1 yield i, name, ispkg
0c794a0bf1c69eb314aed94c3d45da6e72559fd7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0c794a0bf1c69eb314aed94c3d45da6e72559fd7/pkgutil.py
return self.fp.tell() - self.start
return self.fp.tell() - len(self.readahead) - self.start
def tell(self): if self.level > 0: return self.lastpos return self.fp.tell() - self.start
ab4ae4454020df9de19a9140e63a4e15d2ca3894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ab4ae4454020df9de19a9140e63a4e15d2ca3894/multifile.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, )
9c67491428947547268c4c7dda4519074204753d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9c67491428947547268c4c7dda4519074204753d/test_urllib2.py
assert output_dir is not None
if output_dir is None: output_dir = ''
def object_filenames(self, source_filenames, strip_dir=0, output_dir=''): assert output_dir is not None obj_names = [] for src_name in source_filenames: base, ext = os.path.splitext(src_name) if ext not in self.src_extensions: raise UnknownFileError, \ "unknown file type '%s' (from '%s')" % (ext, src_name) if strip_dir: base = os.path.basename(base) obj_names.append(os.path.join(output_dir, base + self.obj_extension)) return obj_names
3c0ed8d236bba953a3dfeb5469a2a1cf4dc760a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3c0ed8d236bba953a3dfeb5469a2a1cf4dc760a6/ccompiler.py
ext_modules=[Extension('struct', ['structmodule.c'])],
ext_modules=[Extension('_struct', ['_struct.c'])],
def main(): # turn off warnings when deprecated modules are imported import warnings warnings.filterwarnings("ignore",category=DeprecationWarning) setup(# PyPI Metadata (PEP 301) name = "Python", version = sys.version.split()[0], url = "http://www.python.org/%s" % sys.version[:3], maintainer = "Guido van Rossum and the Python community", maintainer_email = "[email protected]", description = "A high-level object-oriented programming language", long_description = SUMMARY.strip(), license = "PSF license", classifiers = filter(None, CLASSIFIERS.split("\n")), platforms = ["Many"], # Build info cmdclass = {'build_ext':PyBuildExt, 'install':PyBuildInstall, 'install_lib':PyBuildInstallLib}, # The struct module is defined here, because build_ext won't be # called unless there's at least one extension module defined. ext_modules=[Extension('struct', ['structmodule.c'])], # Scripts to install scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle', 'Lib/smtpd.py'] )
90e097f9c40b9d045ade31d21a17bb553a15c9d4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/90e097f9c40b9d045ade31d21a17bb553a15c9d4/setup.py
regexp=None, nocase=None, count=None):
regexp=None, nocase=None, count=None, elide=None):
def search(self, pattern, index, stopindex=None, forwards=None, backwards=None, exact=None, regexp=None, nocase=None, count=None): """Search PATTERN beginning from INDEX until STOPINDEX. Return the index of the first character of a match or an empty string.""" args = [self._w, 'search'] if forwards: args.append('-forwards') if backwards: args.append('-backwards') if exact: args.append('-exact') if regexp: args.append('-regexp') if nocase: args.append('-nocase') if count: args.append('-count'); args.append(count) if pattern[0] == '-': args.append('--') args.append(pattern) args.append(index) if stopindex: args.append(stopindex) return self.tk.call(tuple(args))
f2f3cd8b7effa6d4a9a75890d721c02adf808fe0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f2f3cd8b7effa6d4a9a75890d721c02adf808fe0/Tkinter.py
def checkSetMinor(self):
def test_checkSetMinor(self):
def checkSetMinor(self): au = MIMEAudio(self._audiodata, 'fish') self.assertEqual(im.get_type(), 'audio/fish')
904c1d02e084eedcc12cee56bfca3579d050abf2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/904c1d02e084eedcc12cee56bfca3579d050abf2/test_email.py
self.assertEqual(im.get_type(), 'audio/fish')
self.assertEqual(au.get_type(), 'audio/fish')
def checkSetMinor(self): au = MIMEAudio(self._audiodata, 'fish') self.assertEqual(im.get_type(), 'audio/fish')
904c1d02e084eedcc12cee56bfca3579d050abf2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/904c1d02e084eedcc12cee56bfca3579d050abf2/test_email.py
def checkSetMinor(self):
def test_checkSetMinor(self):
def checkSetMinor(self): im = MIMEImage(self._imgdata, 'fish') self.assertEqual(im.get_type(), 'image/fish')
904c1d02e084eedcc12cee56bfca3579d050abf2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/904c1d02e084eedcc12cee56bfca3579d050abf2/test_email.py
def redirect_request(self, req, fp, code, msg, headers): """Return a Request or None in response to a redirect.
ac6817c3c65ca5ef8a6c7c75fe2b53cf5f35344a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ac6817c3c65ca5ef8a6c7c75fe2b53cf5f35344a/urllib2.py
if (code in (301, 302, 303, 307) and req.method() in ("GET", "HEAD") or code in (302, 303) and req.method() == "POST"):
if "location" in headers: newurl = headers["location"] elif "uri" in headers: newurl = headers["uri"] else: return newurl = urlparse.urljoin(req.get_full_url(), newurl) m = req.get_method() if (code in (301, 302, 303, 307) and m in ("GET", "HEAD") or code in (302, 303) and m == "POST"):
def redirect_request(self, req, fp, code, msg, headers): """Return a Request or None in response to a redirect.
ac6817c3c65ca5ef8a6c7c75fe2b53cf5f35344a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ac6817c3c65ca5ef8a6c7c75fe2b53cf5f35344a/urllib2.py
try: h = http_class(host) if req.has_data(): data = req.get_data() h.putrequest('POST', req.get_selector()) if not 'Content-type' in req.headers: h.putheader('Content-type', 'application/x-www-form-urlencoded') if not 'Content-length' in req.headers: h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', req.get_selector()) except socket.error, err: raise URLError(err)
h = http_class(host) if req.has_data(): data = req.get_data() h.putrequest('POST', req.get_selector()) if not 'Content-type' in req.headers: h.putheader('Content-type', 'application/x-www-form-urlencoded') if not 'Content-length' in req.headers: h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', req.get_selector())
def do_open(self, http_class, req): host = req.get_host() if not host: raise URLError('no host given')
ac6817c3c65ca5ef8a6c7c75fe2b53cf5f35344a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ac6817c3c65ca5ef8a6c7c75fe2b53cf5f35344a/urllib2.py
h.endheaders()
try: h.endheaders() except socket.error, err: raise URLError(err)
def do_open(self, http_class, req): host = req.get_host() if not host: raise URLError('no host given')
ac6817c3c65ca5ef8a6c7c75fe2b53cf5f35344a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ac6817c3c65ca5ef8a6c7c75fe2b53cf5f35344a/urllib2.py
timestamp = 1000000000 utc = FixedOffset(0, "utc", 0) expected = datetime(2001, 9, 9, 1, 46, 40) got = datetime.utcfromtimestamp(timestamp) self.failUnless(abs(got - expected) < timedelta(minutes=1)) est = FixedOffset(-5*60, "est", 0) expected -= timedelta(hours=5) got = datetime.fromtimestamp(timestamp, est).replace(tzinfo=None) self.failUnless(abs(got - expected) < timedelta(minutes=1))
timestamp = 1000000000 utcdatetime = datetime.utcfromtimestamp(timestamp) utcoffset = timedelta(hours=-15, minutes=39) tz = FixedOffset(utcoffset, "tz", 0) expected = utcdatetime + utcoffset got = datetime.fromtimestamp(timestamp, tz) self.assertEqual(expected, got.replace(tzinfo=None))
def test_tzinfo_fromtimestamp(self): import time meth = self.theclass.fromtimestamp ts = time.time() # Ensure it doesn't require tzinfo (i.e., that this doesn't blow up). base = meth(ts) # Try with and without naming the keyword. off42 = FixedOffset(42, "42") another = meth(ts, off42) again = meth(ts, tz=off42) self.failUnless(another.tzinfo is again.tzinfo) self.assertEqual(another.utcoffset(), timedelta(minutes=42)) # Bad argument with and w/o naming the keyword. self.assertRaises(TypeError, meth, ts, 16) self.assertRaises(TypeError, meth, ts, tzinfo=16) # Bad keyword name. self.assertRaises(TypeError, meth, ts, tinfo=off42) # Too many args. self.assertRaises(TypeError, meth, ts, off42, off42) # Too few args. self.assertRaises(TypeError, meth)
36153d9d6e39233f15bf54c9d8c14f3c7c82df93 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/36153d9d6e39233f15bf54c9d8c14f3c7c82df93/test_datetime.py
self._arrow = _canvas.create_line(x-dx,y+dy,x,y,
self._arrow = self._canvas.create_line(x-dx,y+dy,x,y,
def _draw_turtle(self,position=[]): if not self._tracing: return if position == []: position = self._position x,y = position distance = 8 dx = distance * cos(self._angle*self._invradian) dy = distance * sin(self._angle*self._invradian) self._delete_turtle() self._arrow = _canvas.create_line(x-dx,y+dy,x,y, width=self._width, arrow="last", capstyle="round", fill=self._color) self._canvas.update()
7efadd55c31efe5a169943d66cef80ba98056ea0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7efadd55c31efe5a169943d66cef80ba98056ea0/turtle.py
print 'DBG interaction'
def edit_applet(name): pref_handle = openpreffile(READ) app_handle = openapplet(name) notfound = '' l, sr = getprefpath(OVERRIDE_PATH_STRINGS_ID) if l == None: notfound = 'path' l, dummy = getprefpath(PATH_STRINGS_ID) if l == None: message('Cannot find any sys.path resource! (Old python?)') sys.exit(0) fss, dr, fss_changed = getprefdir(OVERRIDE_DIRECTORY_ID) if fss == None: if notfound: notfound = notfound + ', directory' else: notfound = 'directory' fss, dummy, dummy2 = getprefdir(DIRECTORY_ID) if fss == None: fss = macfs.FSSpec(os.getcwd()) fss_changed = 1 options, opr = getoptions(OVERRIDE_OPTIONS_ID) if not opr: if notfound: notfound = notfound + ', options' else: notfound = 'options' options, dummy = getoptions(OPTIONS_ID) saved_options = options[:] creator, type, delaycons, gusi_opr = getgusioptions(OVERRIDE_GUSI_ID) if not gusi_opr: if notfound: notfound = notfound + ', GUSI options' else: notfound = 'GUSI options' creator, type, delaycons, gusi_opr = getgusioptions(GUSI_ID) saved_gusi_options = creator, type, delaycons dummy = dummy2 = None # Discard them. if notfound: message('Warning: initial %s taken from system-wide defaults'%notfound) # Let the user play away print 'DBG interaction' result = interact(l, fss, (options, creator, type, delaycons), name) # See what we have to update, and how if result == None: sys.exit(0) pathlist, nfss, (options, creator, type, delaycons) = result if nfss != fss: fss_changed = 1 if fss_changed: alias = nfss.NewAlias() if dr: dr.data = alias.data dr.ChangedResource() else: dr = Resource(alias.data) dr.AddResource('alis', OVERRIDE_DIRECTORY_ID, '') if pathlist != l: if pathlist == []: if sr.HomeResFile() == app_handle: sr.RemoveResource() elif sr and sr.HomeResFile() == app_handle: sr.data = listtores(pathlist) sr.ChangedResource() else: sr = Resource(listtores(pathlist)) sr.AddResource('STR#', OVERRIDE_PATH_STRINGS_ID, '') if options != saved_options: newdata = reduce(lambda x, y: x+chr(y), options, '') if opr and opr.HomeResFile() == app_handle: opr.data = newdata opr.ChangedResource() else: opr = Resource(newdata) opr.AddResource('Popt', OVERRIDE_OPTIONS_ID, '') if (creator, type, delaycons) != saved_gusi_options: newdata = setgusioptions(gusi_opr, creator, type, delaycons) id, type, name = gusi_opr.GetResInfo() if gusi_opr.HomeResFile() == app_handle and id == OVERRIDE_GUSI_ID: gusi_opr.data = newdata gusi_opr.ChangedResource() else: ngusi_opr = Resource(newdata) ngusi_opr.AddResource('GU\267I', OVERRIDE_GUSI_ID, '') CloseResFile(app_handle)
de76f6cb606861769dfd55c64c6113e1068f193f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/de76f6cb606861769dfd55c64c6113e1068f193f/EditPythonPrefs.py
def _read(self, size=1024): if self.fileobj is None: raise EOFError, "Reached EOF"
db6b7a680bb447f5c6ea14edab0696d340732c70 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/db6b7a680bb447f5c6ea14edab0696d340732c70/gzip.py
def readline(self):
def readline(self, size=-1): if size < 0: size = sys.maxint
def readline(self): bufs = [] readsize = 100 while 1: c = self.read(readsize) i = string.find(c, '\n') if i >= 0 or c == '': bufs.append(c[:i+1]) self._unread(c[i+1:]) return string.join(bufs, '') bufs.append(c) readsize = readsize * 2
db6b7a680bb447f5c6ea14edab0696d340732c70 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/db6b7a680bb447f5c6ea14edab0696d340732c70/gzip.py
readsize = 100
orig_size = size readsize = min(100, size)
def readline(self): bufs = [] readsize = 100 while 1: c = self.read(readsize) i = string.find(c, '\n') if i >= 0 or c == '': bufs.append(c[:i+1]) self._unread(c[i+1:]) return string.join(bufs, '') bufs.append(c) readsize = readsize * 2
db6b7a680bb447f5c6ea14edab0696d340732c70 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/db6b7a680bb447f5c6ea14edab0696d340732c70/gzip.py
bufs.append(c[:i+1]) self._unread(c[i+1:]) return string.join(bufs, '')
bufs.append(c[:i+1]) self._unread(c[i+1:]) return string.join(bufs, '')
def readline(self): bufs = [] readsize = 100 while 1: c = self.read(readsize) i = string.find(c, '\n') if i >= 0 or c == '': bufs.append(c[:i+1]) self._unread(c[i+1:]) return string.join(bufs, '') bufs.append(c) readsize = readsize * 2
db6b7a680bb447f5c6ea14edab0696d340732c70 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/db6b7a680bb447f5c6ea14edab0696d340732c70/gzip.py
readsize = readsize * 2 def readlines(self, ignored=None): buf = self.read() lines = string.split(buf, '\n') for i in range(len(lines)-1): lines[i] = lines[i] + '\n' if lines and not lines[-1]: del lines[-1] return lines
size = size - len(c) readsize = min(size, readsize * 2) def readlines(self, sizehint=0): if sizehint <= 0: sizehint = sys.maxint L = [] while sizehint > 0: line = self.readline() if line == "": break L.append( line ) sizehint = sizehint - len(line) return L
def readline(self): bufs = [] readsize = 100 while 1: c = self.read(readsize) i = string.find(c, '\n') if i >= 0 or c == '': bufs.append(c[:i+1]) self._unread(c[i+1:]) return string.join(bufs, '') bufs.append(c) readsize = readsize * 2
db6b7a680bb447f5c6ea14edab0696d340732c70 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/db6b7a680bb447f5c6ea14edab0696d340732c70/gzip.py
retval = os.spawnl(os.P_WAIT, sys.executable, sys.executable, tester, v, fd)
if sys.platform in ('win32'): decorated = '"%s"' % sys.executable tester = '"%s"' % tester else: decorated = sys.executable retval = os.spawnl(os.P_WAIT, sys.executable, decorated, tester, v, fd)
def test_noinherit(self): # _mkstemp_inner file handles are not inherited by child processes if not has_spawnl: return # ugh, can't use TestSkipped.
94f4b784a42fe9ac9ba58081ab733886848c976b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/94f4b784a42fe9ac9ba58081ab733886848c976b/test_tempfile.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)
0137f49977b7885b2612af7b535b2dc7e15dc946 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0137f49977b7885b2612af7b535b2dc7e15dc946/test_mailbox.py
t>>11, (t>>5)&0x3F, t&0x1F * 2 )
t>>11, (t>>5)&0x3F, (t&0x1F) * 2 )
def _GetContents(self): "Read in the table of contents for the zip file" fp = self.fp fp.seek(-22, 2) # Start of end-of-archive record filesize = fp.tell() + 22 # Get file size endrec = fp.read(22) # Archive must not end with a comment! if endrec[0:4] != stringEndArchive or endrec[-2:] != "\000\000": raise BadZipfile, "File is not a zip file, or ends with a comment" endrec = struct.unpack(structEndArchive, endrec) if self.debug > 1: print endrec size_cd = endrec[5] # bytes in central directory offset_cd = endrec[6] # offset of central directory x = filesize - 22 - size_cd # "concat" is zero, unless zip was concatenated to another file concat = x - offset_cd if self.debug > 2: print "given, inferred, offset", offset_cd, x, concat # self.start_dir: Position of start of central directory self.start_dir = offset_cd + concat fp.seek(self.start_dir, 0) total = 0 while total < size_cd: centdir = fp.read(46) total = total + 46 if centdir[0:4] != stringCentralDir: raise BadZipfile, "Bad magic number for central directory" centdir = struct.unpack(structCentralDir, centdir) if self.debug > 2: print centdir filename = fp.read(centdir[12]) # Create ZipInfo instance to store file information x = ZipInfo(filename) x.extra = fp.read(centdir[13]) x.comment = fp.read(centdir[14]) total = total + centdir[12] + centdir[13] + centdir[14] x.header_offset = centdir[18] + concat x.file_offset = x.header_offset + 30 + centdir[12] + centdir[13] (x.create_version, x.create_system, x.extract_version, x.reserved, x.flag_bits, x.compress_type, t, d, x.CRC, x.compress_size, x.file_size) = centdir[1:12] x.volume, x.internal_attr, x.external_attr = centdir[15:18] # Convert date/time code to (year, month, day, hour, min, sec) x.date_time = ( (d>>9)+1980, (d>>5)&0xF, d&0x1F, t>>11, (t>>5)&0x3F, t&0x1F * 2 ) self.filelist.append(x) self.NameToInfo[x.filename] = x if self.debug > 2: print "total", total for data in self.filelist: fp.seek(data.header_offset, 0) fheader = fp.read(30) if fheader[0:4] != stringFileHeader: raise BadZipfile, "Bad magic number for file header" fheader = struct.unpack(structFileHeader, fheader) fname = fp.read(fheader[10]) if fname != data.filename: raise RuntimeError, \
816c8922523c43fcc2e056ae33d4839ab177d09c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/816c8922523c43fcc2e056ae33d4839ab177d09c/zipfile.py
def AS_TYPE_64BIT(as_): return \
def AS_TYPE_64BIT(as): return \
def AS_TYPE_64BIT(as_): return \
d46994584fb6a7ccebbab184c589cf5476b30a44 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46994584fb6a7ccebbab184c589cf5476b30a44/STROPTS.py
if request.command in ('post', 'put'):
if request.command.lower() in ('post', 'put'):
def handle_request (self, request): [path, params, query, fragment] = request.split_uri()
2f0b99704ba9383906c1e977e097c4be684f3eed /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2f0b99704ba9383906c1e977e097c4be684f3eed/xmlrpc_handler.py
def wait(self, timeout=None): self.__cond.acquire() if not self.__flag: self.__cond.wait(timeout) self.__cond.release()
9aa768fae6f87cd7b6c65bbd6548ea779ce8732d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9aa768fae6f87cd7b6c65bbd6548ea779ce8732d/threading.py
res[i] = '%%%02x' % ord(c)
res[i] = '%%%02X' % ord(c)
def _fast_quote(s): global _fast_safe if _fast_safe is None: _fast_safe = {} for c in _fast_safe_test: _fast_safe[c] = c res = list(s) for i in range(len(res)): c = res[i] if not _fast_safe.has_key(c): res[i] = '%%%02x' % ord(c) return ''.join(res)
b0446de497a682b7c63979906f548c3861022e95 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b0446de497a682b7c63979906f548c3861022e95/urllib.py
res[i] = '%%%02x' % ord(c)
res[i] = '%%%02X' % ord(c)
def quote(s, safe = '/'): """quote('abc def') -> 'abc%20def' Each part of a URL, e.g. the path info, the query, etc., has a different set of reserved characters that must be quoted. RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax lists the following reserved characters. reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | "," Each of these characters is reserved in some component of a URL, but not necessarily in all of them. By default, the quote function is intended for quoting the path section of a URL. Thus, it will not encode '/'. This character is reserved, but in typical usage the quote function is being called on a path where the existing slash characters are used as reserved characters. """ safe = always_safe + safe if _fast_safe_test == safe: return _fast_quote(s) res = list(s) for i in range(len(res)): c = res[i] if c not in safe: res[i] = '%%%02x' % ord(c) return ''.join(res)
b0446de497a682b7c63979906f548c3861022e95 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b0446de497a682b7c63979906f548c3861022e95/urllib.py
else: p = "%s-ast.h" % mod.name f = open(p, "wb") print >> f, auto_gen_msg print >> f, ' c = ChainOfVisitors(TypeDefVisitor(f), StructVisitor(f), PrototypeVisitor(f), ) c.visit(mod) print >>f, "PyObject* PyAST_mod2obj(mod_ty t);" f.close()
f = open(p, "wb") print >> f, auto_gen_msg print >> f, ' c = ChainOfVisitors(TypeDefVisitor(f), StructVisitor(f), PrototypeVisitor(f), ) c.visit(mod) print >>f, "PyObject* PyAST_mod2obj(mod_ty t);" f.close()
def main(srcfile): argv0 = sys.argv[0] components = argv0.split(os.sep) argv0 = os.sep.join(components[-2:]) auto_gen_msg = '/* File automatically generated by %s */\n' % argv0 mod = asdl.parse(srcfile) if not asdl.check(mod): sys.exit(1) if INC_DIR: p = "%s/%s-ast.h" % (INC_DIR, mod.name) else: p = "%s-ast.h" % mod.name f = open(p, "wb") print >> f, auto_gen_msg print >> f, '#include "asdl.h"\n' c = ChainOfVisitors(TypeDefVisitor(f), StructVisitor(f), PrototypeVisitor(f), ) c.visit(mod) print >>f, "PyObject* PyAST_mod2obj(mod_ty t);" f.close() if SRC_DIR: p = os.path.join(SRC_DIR, str(mod.name) + "-ast.c") else: p = "%s-ast.c" % mod.name f = open(p, "wb") print >> f, auto_gen_msg print >> f, '#include "Python.h"' print >> f, '#include "%s-ast.h"' % mod.name print >> f print >>f, "static PyTypeObject* AST_type;" v = ChainOfVisitors( PyTypesDeclareVisitor(f), PyTypesVisitor(f), FunctionVisitor(f), ObjVisitor(f), ASTModuleVisitor(f), PartingShots(f), ) v.visit(mod) f.close()
107d08463a26492fd36ed134f09409a1547b0540 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/107d08463a26492fd36ed134f09409a1547b0540/asdl_c.py
else: p = "%s-ast.c" % mod.name f = open(p, "wb") print >> f, auto_gen_msg print >> f, ' print >> f, ' print >> f print >>f, "static PyTypeObject* AST_type;" v = ChainOfVisitors( PyTypesDeclareVisitor(f), PyTypesVisitor(f), FunctionVisitor(f), ObjVisitor(f), ASTModuleVisitor(f), PartingShots(f), ) v.visit(mod) f.close()
f = open(p, "wb") print >> f, auto_gen_msg print >> f, ' print >> f, ' print >> f print >>f, "static PyTypeObject* AST_type;" v = ChainOfVisitors( PyTypesDeclareVisitor(f), PyTypesVisitor(f), FunctionVisitor(f), ObjVisitor(f), ASTModuleVisitor(f), PartingShots(f), ) v.visit(mod) f.close()
def main(srcfile): argv0 = sys.argv[0] components = argv0.split(os.sep) argv0 = os.sep.join(components[-2:]) auto_gen_msg = '/* File automatically generated by %s */\n' % argv0 mod = asdl.parse(srcfile) if not asdl.check(mod): sys.exit(1) if INC_DIR: p = "%s/%s-ast.h" % (INC_DIR, mod.name) else: p = "%s-ast.h" % mod.name f = open(p, "wb") print >> f, auto_gen_msg print >> f, '#include "asdl.h"\n' c = ChainOfVisitors(TypeDefVisitor(f), StructVisitor(f), PrototypeVisitor(f), ) c.visit(mod) print >>f, "PyObject* PyAST_mod2obj(mod_ty t);" f.close() if SRC_DIR: p = os.path.join(SRC_DIR, str(mod.name) + "-ast.c") else: p = "%s-ast.c" % mod.name f = open(p, "wb") print >> f, auto_gen_msg print >> f, '#include "Python.h"' print >> f, '#include "%s-ast.h"' % mod.name print >> f print >>f, "static PyTypeObject* AST_type;" v = ChainOfVisitors( PyTypesDeclareVisitor(f), PyTypesVisitor(f), FunctionVisitor(f), ObjVisitor(f), ASTModuleVisitor(f), PartingShots(f), ) v.visit(mod) f.close()
107d08463a26492fd36ed134f09409a1547b0540 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/107d08463a26492fd36ed134f09409a1547b0540/asdl_c.py
exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) )
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')
497a84bc876f4170963c7b9a867b15f5b56338c3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/497a84bc876f4170963c7b9a867b15f5b56338c3/setup.py
if len(a) < len(b): a, b = b, a res = a[:] for i in range(len(b)): res[i] = res[i] - b[i] return normalize(res)
neg_b = map(lambda x: -x, b[:]) return plus(a, neg_b)
def minus(a, b): if len(a) < len(b): a, b = b, a # make sure a is the longest res = a[:] # make a copy for i in range(len(b)): res[i] = res[i] - b[i] return normalize(res)
ec0831f744ad5a2eb816d0d17e37c46c9c71c71a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ec0831f744ad5a2eb816d0d17e37c46c9c71c71a/poly.py
if type (package) is StringType: path = string.split (package, '.') elif type (package) in (TupleType, ListType): path = list (package) else: raise TypeError, "'package' must be a string, list, or tuple"
path = string.split (package, '.')
def get_package_dir (self, package): """Return the directory, relative to the top of the source distribution, where package 'package' should be found (at least according to the 'package_dir' option, if any)."""
3d9bb778ccc0824f7d97c06b70a7acdb7f51e70b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3d9bb778ccc0824f7d97c06b70a7acdb7f51e70b/build_py.py
package = tuple (path[0:-1])
package = string.join(path[0:-1], '.')
def find_modules (self): """Finds individually-specified Python modules, ie. those listed by module name in 'self.py_modules'. Returns a list of tuples (package, module_base, filename): 'package' is a tuple of the path through package-space to the module; 'module_base' is the bare (no packages, no dots) module name, and 'filename' is the path to the ".py" file (relative to the distribution root) that implements the module. """
3d9bb778ccc0824f7d97c06b70a7acdb7f51e70b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3d9bb778ccc0824f7d97c06b70a7acdb7f51e70b/build_py.py
newurl = basejoin("http:" + url, newurl)
newurl = basejoin(self.type + ":" + url, newurl)
def redirect_internal(self, url, fp, errcode, errmsg, headers, data): if headers.has_key('location'): newurl = headers['location'] elif headers.has_key('uri'): newurl = headers['uri'] else: return void = fp.read() fp.close() # In case the server sent a relative URL, join with original: newurl = basejoin("http:" + url, newurl) if data is None: return self.open(newurl) else: return self.open(newurl, data)
729bdef1d05d468ff158ca3741762a42e6fb26b3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/729bdef1d05d468ff158ca3741762a42e6fb26b3/urllib.py
if sys.argv[-1] == "Release":
if sys.argv[1] == "Release":
def main(): build_all = "-a" in sys.argv if sys.argv[-1] == "Release": arch = "x86" debug = False configure = "VC-WIN32" makefile = "32.mak" elif sys.argv[-1] == "Debug": arch = "x86" debug = True configure = "VC-WIN32" makefile="d32.mak" elif sys.argv[-1] == "ReleaseItanium": arch = "ia64" debug = False configure = "VC-WIN64I" do_script = "ms\\do_win64i" makefile = "ms\\nt.mak" os.environ["VSEXTCOMP_USECL"] = "MS_ITANIUM" elif sys.argv[-1] == "ReleaseAMD64": arch="amd64" debug=False configure = "VC-WIN64A" do_script = "ms\\do_win64a" makefile = "ms\\nt.mak" os.environ["VSEXTCOMP_USECL"] = "MS_OPTERON" make_flags = "" if build_all: make_flags = "-a" # perl should be on the path, but we also look in "\perl" and "c:\\perl" # as "well known" locations perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"]) perl = find_working_perl(perls) if perl is None: sys.exit(1) print "Found a working perl at '%s'" % (perl,) # Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live. ssl_dir = find_best_ssl_dir(("../..",)) if ssl_dir is None: sys.exit(1) old_cd = os.getcwd() try: os.chdir(ssl_dir) # If the ssl makefiles do not exist, we invoke Perl to generate them. if not os.path.isfile(makefile): print "Creating the makefiles..." # Put our working Perl at the front of our path os.environ["PATH"] = os.path.split(perl)[0] + \ os.pathsep + \ os.environ["PATH"] if arch=="x86": run_32all_py() else: run_configure(configure, do_script) # Now run make. print "Executing nmake over the ssl makefiles..." rc = os.system("nmake /nologo -f "+makefile) if rc: print "Executing d32.mak failed" print rc sys.exit(rc) finally: os.chdir(old_cd) # And finally, we can build the _ssl module itself for Python. defs = "SSL_DIR=%s" % (ssl_dir,) if debug: defs = defs + " " + "DEBUG=1" rc = os.system('nmake /nologo -f _ssl.mak ' + defs + " " + make_flags) sys.exit(rc)
40128621657218c77c0b1ab6c79261f4d757a774 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/40128621657218c77c0b1ab6c79261f4d757a774/build_ssl.py
elif sys.argv[-1] == "Debug":
elif sys.argv[1] == "Debug":
def main(): build_all = "-a" in sys.argv if sys.argv[-1] == "Release": arch = "x86" debug = False configure = "VC-WIN32" makefile = "32.mak" elif sys.argv[-1] == "Debug": arch = "x86" debug = True configure = "VC-WIN32" makefile="d32.mak" elif sys.argv[-1] == "ReleaseItanium": arch = "ia64" debug = False configure = "VC-WIN64I" do_script = "ms\\do_win64i" makefile = "ms\\nt.mak" os.environ["VSEXTCOMP_USECL"] = "MS_ITANIUM" elif sys.argv[-1] == "ReleaseAMD64": arch="amd64" debug=False configure = "VC-WIN64A" do_script = "ms\\do_win64a" makefile = "ms\\nt.mak" os.environ["VSEXTCOMP_USECL"] = "MS_OPTERON" make_flags = "" if build_all: make_flags = "-a" # perl should be on the path, but we also look in "\perl" and "c:\\perl" # as "well known" locations perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"]) perl = find_working_perl(perls) if perl is None: sys.exit(1) print "Found a working perl at '%s'" % (perl,) # Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live. ssl_dir = find_best_ssl_dir(("../..",)) if ssl_dir is None: sys.exit(1) old_cd = os.getcwd() try: os.chdir(ssl_dir) # If the ssl makefiles do not exist, we invoke Perl to generate them. if not os.path.isfile(makefile): print "Creating the makefiles..." # Put our working Perl at the front of our path os.environ["PATH"] = os.path.split(perl)[0] + \ os.pathsep + \ os.environ["PATH"] if arch=="x86": run_32all_py() else: run_configure(configure, do_script) # Now run make. print "Executing nmake over the ssl makefiles..." rc = os.system("nmake /nologo -f "+makefile) if rc: print "Executing d32.mak failed" print rc sys.exit(rc) finally: os.chdir(old_cd) # And finally, we can build the _ssl module itself for Python. defs = "SSL_DIR=%s" % (ssl_dir,) if debug: defs = defs + " " + "DEBUG=1" rc = os.system('nmake /nologo -f _ssl.mak ' + defs + " " + make_flags) sys.exit(rc)
40128621657218c77c0b1ab6c79261f4d757a774 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/40128621657218c77c0b1ab6c79261f4d757a774/build_ssl.py
elif sys.argv[-1] == "ReleaseItanium":
elif sys.argv[1] == "ReleaseItanium":
def main(): build_all = "-a" in sys.argv if sys.argv[-1] == "Release": arch = "x86" debug = False configure = "VC-WIN32" makefile = "32.mak" elif sys.argv[-1] == "Debug": arch = "x86" debug = True configure = "VC-WIN32" makefile="d32.mak" elif sys.argv[-1] == "ReleaseItanium": arch = "ia64" debug = False configure = "VC-WIN64I" do_script = "ms\\do_win64i" makefile = "ms\\nt.mak" os.environ["VSEXTCOMP_USECL"] = "MS_ITANIUM" elif sys.argv[-1] == "ReleaseAMD64": arch="amd64" debug=False configure = "VC-WIN64A" do_script = "ms\\do_win64a" makefile = "ms\\nt.mak" os.environ["VSEXTCOMP_USECL"] = "MS_OPTERON" make_flags = "" if build_all: make_flags = "-a" # perl should be on the path, but we also look in "\perl" and "c:\\perl" # as "well known" locations perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"]) perl = find_working_perl(perls) if perl is None: sys.exit(1) print "Found a working perl at '%s'" % (perl,) # Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live. ssl_dir = find_best_ssl_dir(("../..",)) if ssl_dir is None: sys.exit(1) old_cd = os.getcwd() try: os.chdir(ssl_dir) # If the ssl makefiles do not exist, we invoke Perl to generate them. if not os.path.isfile(makefile): print "Creating the makefiles..." # Put our working Perl at the front of our path os.environ["PATH"] = os.path.split(perl)[0] + \ os.pathsep + \ os.environ["PATH"] if arch=="x86": run_32all_py() else: run_configure(configure, do_script) # Now run make. print "Executing nmake over the ssl makefiles..." rc = os.system("nmake /nologo -f "+makefile) if rc: print "Executing d32.mak failed" print rc sys.exit(rc) finally: os.chdir(old_cd) # And finally, we can build the _ssl module itself for Python. defs = "SSL_DIR=%s" % (ssl_dir,) if debug: defs = defs + " " + "DEBUG=1" rc = os.system('nmake /nologo -f _ssl.mak ' + defs + " " + make_flags) sys.exit(rc)
40128621657218c77c0b1ab6c79261f4d757a774 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/40128621657218c77c0b1ab6c79261f4d757a774/build_ssl.py
elif sys.argv[-1] == "ReleaseAMD64":
elif sys.argv[1] == "ReleaseAMD64":
def main(): build_all = "-a" in sys.argv if sys.argv[-1] == "Release": arch = "x86" debug = False configure = "VC-WIN32" makefile = "32.mak" elif sys.argv[-1] == "Debug": arch = "x86" debug = True configure = "VC-WIN32" makefile="d32.mak" elif sys.argv[-1] == "ReleaseItanium": arch = "ia64" debug = False configure = "VC-WIN64I" do_script = "ms\\do_win64i" makefile = "ms\\nt.mak" os.environ["VSEXTCOMP_USECL"] = "MS_ITANIUM" elif sys.argv[-1] == "ReleaseAMD64": arch="amd64" debug=False configure = "VC-WIN64A" do_script = "ms\\do_win64a" makefile = "ms\\nt.mak" os.environ["VSEXTCOMP_USECL"] = "MS_OPTERON" make_flags = "" if build_all: make_flags = "-a" # perl should be on the path, but we also look in "\perl" and "c:\\perl" # as "well known" locations perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"]) perl = find_working_perl(perls) if perl is None: sys.exit(1) print "Found a working perl at '%s'" % (perl,) # Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live. ssl_dir = find_best_ssl_dir(("../..",)) if ssl_dir is None: sys.exit(1) old_cd = os.getcwd() try: os.chdir(ssl_dir) # If the ssl makefiles do not exist, we invoke Perl to generate them. if not os.path.isfile(makefile): print "Creating the makefiles..." # Put our working Perl at the front of our path os.environ["PATH"] = os.path.split(perl)[0] + \ os.pathsep + \ os.environ["PATH"] if arch=="x86": run_32all_py() else: run_configure(configure, do_script) # Now run make. print "Executing nmake over the ssl makefiles..." rc = os.system("nmake /nologo -f "+makefile) if rc: print "Executing d32.mak failed" print rc sys.exit(rc) finally: os.chdir(old_cd) # And finally, we can build the _ssl module itself for Python. defs = "SSL_DIR=%s" % (ssl_dir,) if debug: defs = defs + " " + "DEBUG=1" rc = os.system('nmake /nologo -f _ssl.mak ' + defs + " " + make_flags) sys.exit(rc)
40128621657218c77c0b1ab6c79261f4d757a774 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/40128621657218c77c0b1ab6c79261f4d757a774/build_ssl.py
self.plist.CFBundleExecutable = self.name
def setup(self): if self.mainprogram is None and self.executable is None: raise TypeError, ("must specify either or both of " "'executable' and 'mainprogram'")
9ad693d92fd6efd9d232473808eabc0df23e0b8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9ad693d92fd6efd9d232473808eabc0df23e0b8c/bundlebuilder.py
try: fp = open(file) except: return None
fp = open(file)
def __init__(self, file=None): if not file: file = os.path.join(os.environ['HOME'], ".netrc") try: fp = open(file) except: return None self.hosts = {} self.macros = {} lexer = shlex.shlex(fp)
94386c09a599b72a60117b78821688716b60139b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/94386c09a599b72a60117b78821688716b60139b/netrc.py
emit(LOGHEADER, self.ui, os.environ, date=date, _file=tfn)
emit(LOGHEADER, self.ui, os.environ, date=date, _file=tf)
def commit(self, entry): file = entry.file # Normalize line endings in body if '\r' in self.ui.body: self.ui.body = re.sub('\r\n?', '\n', self.ui.body) # Normalize whitespace in title self.ui.title = ' '.join(self.ui.title.split()) # Check that there were any changes if self.ui.body == entry.body and self.ui.title == entry.title: self.error("You didn't make any changes!") return
9ffc1d6c116ea48a64d97c9b25c1d352ee0b0094 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9ffc1d6c116ea48a64d97c9b25c1d352ee0b0094/faqwiz.py
os.unlink(tfn)
os.unlink(tf.name)
def commit(self, entry): file = entry.file # Normalize line endings in body if '\r' in self.ui.body: self.ui.body = re.sub('\r\n?', '\n', self.ui.body) # Normalize whitespace in title self.ui.title = ' '.join(self.ui.title.split()) # Check that there were any changes if self.ui.body == entry.body and self.ui.title == entry.title: self.error("You didn't make any changes!") return
9ffc1d6c116ea48a64d97c9b25c1d352ee0b0094 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9ffc1d6c116ea48a64d97c9b25c1d352ee0b0094/faqwiz.py
traceback.print_exc()
traceback.print_exc(file=sys.stdout)
def runtest(hier, code): root = tempfile.mktemp() mkhier(root, hier) savepath = sys.path[:] codefile = tempfile.mktemp() f = open(codefile, "w") f.write(code) f.close() try: sys.path.insert(0, root) if verbose: print "sys.path =", sys.path try: execfile(codefile, globals(), {}) except: traceback.print_exc() finally: sys.path[:] = savepath try: cleanout(root) except (os.error, IOError): pass os.remove(codefile)
d259d86dd9f563d3b98ea8b4cbe9dc4ac70f51e3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d259d86dd9f563d3b98ea8b4cbe9dc4ac70f51e3/test_pkg.py
("t1", [("t1", None)], "import ni"),
("t1", [("t1", None)], "import t1"),
def runtest(hier, code): root = tempfile.mktemp() mkhier(root, hier) savepath = sys.path[:] codefile = tempfile.mktemp() f = open(codefile, "w") f.write(code) f.close() try: sys.path.insert(0, root) if verbose: print "sys.path =", sys.path try: execfile(codefile, globals(), {}) except: traceback.print_exc() finally: sys.path[:] = savepath try: cleanout(root) except (os.error, IOError): pass os.remove(codefile)
d259d86dd9f563d3b98ea8b4cbe9dc4ac70f51e3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d259d86dd9f563d3b98ea8b4cbe9dc4ac70f51e3/test_pkg.py
test('replace', 'one!two!three!', 'one!two!three!', '!', '@', 0)
test('replace', 'one!two!three!', 'one@two@three@', '!', '@', 0)
def __getitem__(self, i): return self.seq[i]
8c071f192bcaf45cb7f621baab2e5bc2d1b4f1e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8c071f192bcaf45cb7f621baab2e5bc2d1b4f1e0/test_strop.py
osname = string.lower(osname)
osname = string.lower(osname) osname = string.replace(osname, '/', '')
def get_platform (): """Return a string that identifies the current platform. This is used mainly to distinguish platform-specific build directories and platform-specific built distributions. Typically includes the OS name and version and the architecture (as supplied by 'os.uname()'), although the exact information included depends on the OS; eg. for IRIX the architecture isn't particularly important (IRIX only runs on SGI hardware), but for Linux the kernel version isn't particularly important. Examples of returned values: linux-i586 linux-alpha (?) solaris-2.6-sun4u irix-5.3 irix64-6.2 For non-POSIX platforms, currently just returns 'sys.platform'. """ if os.name != "posix" or not hasattr(os, 'uname'): # XXX what about the architecture? NT is Intel or Alpha, # Mac OS is M68k or PPC, etc. return sys.platform # Try to distinguish various flavours of Unix (osname, host, release, version, machine) = os.uname() osname = string.lower(osname) if osname[:5] == "linux": # At least on Linux/Intel, 'machine' is the processor -- # i386, etc. # XXX what about Alpha, SPARC, etc? return "%s-%s" % (osname, machine) elif osname[:5] == "sunos": if release[0] >= "5": # SunOS 5 == Solaris 2 osname = "solaris" release = "%d.%s" % (int(release[0]) - 3, release[2:]) # fall through to standard osname-release-machine representation elif osname[:4] == "irix": # could be "irix64"! return "%s-%s" % (osname, release) elif osname[:3] == "aix": return "%s-%s.%s" % (osname, version, release) elif osname[:6] == "cygwin": rel_re = re.compile (r'[\d.]+') m = rel_re.match(release) if m: release = m.group() return "%s-%s-%s" % (osname, release, machine)
1454626dff145ef9f655be82194558bb34327409 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1454626dff145ef9f655be82194558bb34327409/util.py
if isinstance(fullurl, (types.StringType, types.UnicodeType)):
if isinstance(fullurl, types.StringTypes):
def open(self, fullurl, data=None): # accept a URL or a Request object if isinstance(fullurl, (types.StringType, types.UnicodeType)): req = Request(fullurl, data) else: req = fullurl if data is not None: req.add_data(data) assert isinstance(req, Request) # really only care about interface
7cc432f73152ac06245ea869392b44fb88d4c2f8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7cc432f73152ac06245ea869392b44fb88d4c2f8/urllib2.py
if isinstance(uri, (types.StringType, types.UnicodeType)):
if isinstance(uri, types.StringTypes):
def add_password(self, realm, uri, user, passwd): # uri could be a single URI or a sequence if isinstance(uri, (types.StringType, types.UnicodeType)): uri = [uri] uri = tuple(map(self.reduce_uri, uri)) if not self.passwd.has_key(realm): self.passwd[realm] = {} self.passwd[realm][uri] = (user, passwd)
7cc432f73152ac06245ea869392b44fb88d4c2f8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7cc432f73152ac06245ea869392b44fb88d4c2f8/urllib2.py
debian_tcl_include = ( '/usr/include/tcl' + version ) debian_tk_include = ( '/usr/include/tk' + version ) tcl_includes = find_file('tcl.h', inc_dirs, [debian_tcl_include] ) tk_includes = find_file('tk.h', inc_dirs, [debian_tk_include] )
debian_tcl_include = [ '/usr/include/tcl' + version ] debian_tk_include = [ '/usr/include/tk' + version ] + debian_tcl_include tcl_includes = find_file('tcl.h', inc_dirs, debian_tcl_include) tk_includes = find_file('tk.h', inc_dirs, debian_tk_include)
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. # # The command for _tkinter is long and site specific. Please # uncomment and/or edit those parts as indicated. If you don't have a # specific extension (e.g. Tix or BLT), leave the corresponding line # commented out. (Leave the trailing backslashes in! If you # experience strange errors, you may want to join all uncommented # lines and remove the backslashes -- the backslash interpretation is # done by the shell's "read" command and it may not be implemented on # every system.
0ddea030f955e4ee9c7f9a2e86065ab127e41833 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0ddea030f955e4ee9c7f9a2e86065ab127e41833/setup.py
lexer.whitepace = ' \t'
lexer.whitespace = ' \t'
# Look for a machine, default, or macdef top-level keyword
dc3bebe91f60391266d4c5651032cfadf1964725 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/dc3bebe91f60391266d4c5651032cfadf1964725/netrc.py
if not line or line == '\012' and tt == '\012': lexer.whitepace = ' \t\r\n'
if not line or line == '\012': lexer.whitespace = ' \t\r\n'
# Look for a machine, default, or macdef top-level keyword
dc3bebe91f60391266d4c5651032cfadf1964725 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/dc3bebe91f60391266d4c5651032cfadf1964725/netrc.py
tt = line
# Look for a machine, default, or macdef top-level keyword
dc3bebe91f60391266d4c5651032cfadf1964725 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/dc3bebe91f60391266d4c5651032cfadf1964725/netrc.py
if toplevel == 'machine': login = account = password = None self.hosts[entryname] = {}
login = account = password = None self.hosts[entryname] = {}
# Look for a machine, default, or macdef top-level keyword
dc3bebe91f60391266d4c5651032cfadf1964725 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/dc3bebe91f60391266d4c5651032cfadf1964725/netrc.py
if tt=='' or tt == 'machine' or tt == 'default' or tt == 'macdef': if toplevel == 'macdef': break elif login and password:
if (tt=='' or tt == 'machine' or tt == 'default' or tt =='macdef'): if login and password:
# Look for a machine, default, or macdef top-level keyword
dc3bebe91f60391266d4c5651032cfadf1964725 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/dc3bebe91f60391266d4c5651032cfadf1964725/netrc.py
Assume y1 <= y2 and no funny (non-leap century) years.""" return (y2+3)/4 - (y1+3)/4
Assume y1 <= y2.""" y1 -= 1 y2 -= 1 return (y2/4 - y1/4) - (y2/100 - y1/100) + (y2/400 - y1/400)
def leapdays(y1, y2): """Return number of leap years in range [y1, y2). Assume y1 <= y2 and no funny (non-leap century) years.""" return (y2+3)/4 - (y1+3)/4
48b8aa7e6b152d8b75c853dd164c3322a85afa63 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/48b8aa7e6b152d8b75c853dd164c3322a85afa63/calendar.py
def test_basic_pty(): try: debug("Calling master_open()") master_fd, slave_name = pty.master_open() debug("Got master_fd '%d', slave_name '%s'"%(master_fd, slave_name)) debug("Calling slave_open(%r)"%(slave_name,)) slave_fd = pty.slave_open(slave_name) debug("Got slave_fd '%d'"%slave_fd) except OSError: # " An optional feature could not be imported " ... ? raise TestSkipped, "Pseudo-terminals (seemingly) not functional." if not os.isatty(slave_fd) and sys.platform not in fickle_isatty: raise TestFailed, "slave_fd is not a tty" # IRIX apparently turns \n into \r\n. Allow that, but avoid allowing other # differences (like extra whitespace, trailing garbage, etc.) debug("Writing to slave_fd") os.write(slave_fd, TEST_STRING_1) s1 = os.read(master_fd, 1024) sys.stdout.write(s1.replace("\r\n", "\n")) debug("Writing chunked output") os.write(slave_fd, TEST_STRING_2[:5]) os.write(slave_fd, TEST_STRING_2[5:]) s2 = os.read(master_fd, 1024) sys.stdout.write(s2.replace("\r\n", "\n")) os.close(slave_fd) os.close(master_fd)
70c47f9f59fde40322448090d8d59323175b7d85 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/70c47f9f59fde40322448090d8d59323175b7d85/test_pty.py
sys.stdout.write(s1.replace("\r\n", "\n"))
sys.stdout.write(normalize_output(s1))
def test_basic_pty(): try: debug("Calling master_open()") master_fd, slave_name = pty.master_open() debug("Got master_fd '%d', slave_name '%s'"%(master_fd, slave_name)) debug("Calling slave_open(%r)"%(slave_name,)) slave_fd = pty.slave_open(slave_name) debug("Got slave_fd '%d'"%slave_fd) except OSError: # " An optional feature could not be imported " ... ? raise TestSkipped, "Pseudo-terminals (seemingly) not functional." if not os.isatty(slave_fd) and sys.platform not in fickle_isatty: raise TestFailed, "slave_fd is not a tty" # IRIX apparently turns \n into \r\n. Allow that, but avoid allowing other # differences (like extra whitespace, trailing garbage, etc.) debug("Writing to slave_fd") os.write(slave_fd, TEST_STRING_1) s1 = os.read(master_fd, 1024) sys.stdout.write(s1.replace("\r\n", "\n")) debug("Writing chunked output") os.write(slave_fd, TEST_STRING_2[:5]) os.write(slave_fd, TEST_STRING_2[5:]) s2 = os.read(master_fd, 1024) sys.stdout.write(s2.replace("\r\n", "\n")) os.close(slave_fd) os.close(master_fd)
70c47f9f59fde40322448090d8d59323175b7d85 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/70c47f9f59fde40322448090d8d59323175b7d85/test_pty.py
sys.stdout.write(s2.replace("\r\n", "\n"))
sys.stdout.write(normalize_output(s2))
def test_basic_pty(): try: debug("Calling master_open()") master_fd, slave_name = pty.master_open() debug("Got master_fd '%d', slave_name '%s'"%(master_fd, slave_name)) debug("Calling slave_open(%r)"%(slave_name,)) slave_fd = pty.slave_open(slave_name) debug("Got slave_fd '%d'"%slave_fd) except OSError: # " An optional feature could not be imported " ... ? raise TestSkipped, "Pseudo-terminals (seemingly) not functional." if not os.isatty(slave_fd) and sys.platform not in fickle_isatty: raise TestFailed, "slave_fd is not a tty" # IRIX apparently turns \n into \r\n. Allow that, but avoid allowing other # differences (like extra whitespace, trailing garbage, etc.) debug("Writing to slave_fd") os.write(slave_fd, TEST_STRING_1) s1 = os.read(master_fd, 1024) sys.stdout.write(s1.replace("\r\n", "\n")) debug("Writing chunked output") os.write(slave_fd, TEST_STRING_2[:5]) os.write(slave_fd, TEST_STRING_2[5:]) s2 = os.read(master_fd, 1024) sys.stdout.write(s2.replace("\r\n", "\n")) os.close(slave_fd) os.close(master_fd)
70c47f9f59fde40322448090d8d59323175b7d85 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/70c47f9f59fde40322448090d8d59323175b7d85/test_pty.py
compiler = self.compiler
def build_libraries (self, libraries):
32ce1142bd0be81f26415db6d5f9205e8acac57d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/32ce1142bd0be81f26415db6d5f9205e8acac57d/build_clib.py
self.info = list(self.interesting_lines(1))
self.info = [(0, -1, "", False)]
def __init__(self, editwin): self.editwin = editwin self.text = editwin.text self.textfont = self.text["font"] self.label = None # Dummy line, which starts the "block" of the whole document: self.info = list(self.interesting_lines(1)) self.lastfirstline = 1 visible = idleConf.GetOption("extensions", "CodeContext", "visible", type="bool", default=False) if visible: self.toggle_code_context_event() self.editwin.setvar('<<toggle-code-context>>', True) # Start two update cycles, one for context lines, one for font changes. self.text.after(UPDATEINTERVAL, self.timer_event) self.text.after(FONTUPDATEINTERVAL, self.font_timer_event)
98f9ff7223406f0c344f530e77fc866a67894c35 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/98f9ff7223406f0c344f530e77fc866a67894c35/CodeContext.py
There is a dummy block start, with indentation -1 and text "". Return the indent level, text (including leading whitespace), and the block opening keyword.
def get_line_info(self, linenum): """Get the line indent value, text, and any block start keyword
98f9ff7223406f0c344f530e77fc866a67894c35 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/98f9ff7223406f0c344f530e77fc866a67894c35/CodeContext.py
if linenum == 0: return -1, "", True
def get_line_info(self, linenum): """Get the line indent value, text, and any block start keyword
98f9ff7223406f0c344f530e77fc866a67894c35 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/98f9ff7223406f0c344f530e77fc866a67894c35/CodeContext.py
def interesting_lines(self, firstline): """Generator which yields context lines, starting at firstline."""
def interesting_lines(self, firstline, stopline=1, stopindent=0): """ Find the context lines, starting at firstline. Will not return lines whose index is smaller than stopline or whose indentation is smaller than stopindent. stopline should always be >= 1, so the dummy block start will never be returned (This function doesn't know what to do about it.) Returns a list with the context lines, starting from the first (top), and a number which all context lines above the inspected region should have a smaller indentation than it. """ lines = []
def interesting_lines(self, firstline): """Generator which yields context lines, starting at firstline.""" # The indentation level we are currently in: lastindent = INFINITY # For a line to be interesting, it must begin with a block opening # keyword, and have less indentation than lastindent. for line_index in xrange(firstline, -1, -1): indent, text, opener = self.get_line_info(line_index) if indent < lastindent: lastindent = indent if opener in ("else", "elif"): # We also show the if statement lastindent += 1 if opener and line_index < firstline: yield line_index, text
98f9ff7223406f0c344f530e77fc866a67894c35 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/98f9ff7223406f0c344f530e77fc866a67894c35/CodeContext.py
for line_index in xrange(firstline, -1, -1):
for line_index in xrange(firstline, stopline-1, -1):
def interesting_lines(self, firstline): """Generator which yields context lines, starting at firstline.""" # The indentation level we are currently in: lastindent = INFINITY # For a line to be interesting, it must begin with a block opening # keyword, and have less indentation than lastindent. for line_index in xrange(firstline, -1, -1): indent, text, opener = self.get_line_info(line_index) if indent < lastindent: lastindent = indent if opener in ("else", "elif"): # We also show the if statement lastindent += 1 if opener and line_index < firstline: yield line_index, text
98f9ff7223406f0c344f530e77fc866a67894c35 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/98f9ff7223406f0c344f530e77fc866a67894c35/CodeContext.py
if opener and line_index < firstline: yield line_index, text
if opener and line_index < firstline and indent >= stopindent: lines.append((line_index, indent, text, opener)) if lastindent <= stopindent: break lines.reverse() return lines, lastindent
def interesting_lines(self, firstline): """Generator which yields context lines, starting at firstline.""" # The indentation level we are currently in: lastindent = INFINITY # For a line to be interesting, it must begin with a block opening # keyword, and have less indentation than lastindent. for line_index in xrange(firstline, -1, -1): indent, text, opener = self.get_line_info(line_index) if indent < lastindent: lastindent = indent if opener in ("else", "elif"): # We also show the if statement lastindent += 1 if opener and line_index < firstline: yield line_index, text
98f9ff7223406f0c344f530e77fc866a67894c35 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/98f9ff7223406f0c344f530e77fc866a67894c35/CodeContext.py
tmpstack = [] for line_index, text in self.interesting_lines(firstline): while self.info[-1][0] > line_index: del self.info[-1] if self.info[-1][0] == line_index: break tmpstack.append((line_index, text)) while tmpstack: self.info.append(tmpstack.pop())
def update_label(self): firstline = int(self.text.index("@0,0").split('.')[0]) if self.lastfirstline == firstline: return self.lastfirstline = firstline tmpstack = [] for line_index, text in self.interesting_lines(firstline): # Remove irrelevant self.info items, and when we reach a relevant # item (which must happen because of the dummy element), break. while self.info[-1][0] > line_index: del self.info[-1] if self.info[-1][0] == line_index: break tmpstack.append((line_index, text)) while tmpstack: self.info.append(tmpstack.pop()) lines = [""] * max(0, self.numlines - len(self.info)) + \ [x[1] for x in self.info[-self.numlines:]] self.label["text"] = '\n'.join(lines)
98f9ff7223406f0c344f530e77fc866a67894c35 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/98f9ff7223406f0c344f530e77fc866a67894c35/CodeContext.py
[x[1] for x in self.info[-self.numlines:]]
[x[2] for x in self.info[-self.numlines:]]
def update_label(self): firstline = int(self.text.index("@0,0").split('.')[0]) if self.lastfirstline == firstline: return self.lastfirstline = firstline tmpstack = [] for line_index, text in self.interesting_lines(firstline): # Remove irrelevant self.info items, and when we reach a relevant # item (which must happen because of the dummy element), break. while self.info[-1][0] > line_index: del self.info[-1] if self.info[-1][0] == line_index: break tmpstack.append((line_index, text)) while tmpstack: self.info.append(tmpstack.pop()) lines = [""] * max(0, self.numlines - len(self.info)) + \ [x[1] for x in self.info[-self.numlines:]] self.label["text"] = '\n'.join(lines)
98f9ff7223406f0c344f530e77fc866a67894c35 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/98f9ff7223406f0c344f530e77fc866a67894c35/CodeContext.py
self.assertEqual(sys.stdout.getvalue().splitlines(), ['0', '0.5', '0'])
if 1/2 == 0: expected = ['0', '0.5', '0'] else: expected = ['0.5', '0.5', '0.5'] self.assertEqual(sys.stdout.getvalue().splitlines(), expected)
def test_input_and_raw_input(self): self.write_testfile() fp = open(TESTFN, 'r') savestdin = sys.stdin savestdout = sys.stdout # Eats the echo try: sys.stdin = fp sys.stdout = BitBucket() self.assertEqual(input(), 2) self.assertEqual(input('testing\n'), 2) self.assertEqual(raw_input(), 'The quick brown fox jumps over the lazy dog.') self.assertEqual(raw_input('testing\n'), 'Dear John') sys.stdin = cStringIO.StringIO("NULL\0") self.assertRaises(TypeError, input, 42, 42) sys.stdin = cStringIO.StringIO(" 'whitespace'") self.assertEqual(input(), 'whitespace') sys.stdin = cStringIO.StringIO() self.assertRaises(EOFError, input)
0511c932b9e77c4f163f9d3504aad92394d648c3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0511c932b9e77c4f163f9d3504aad92394d648c3/test_builtin.py
def message_from_string(s, _class=_Message): return _Parser(_class).parsestr(s)
def message_from_string(s, _class=_Message, strict=1): return _Parser(_class, strict=strict).parsestr(s)
def message_from_string(s, _class=_Message): return _Parser(_class).parsestr(s)
e638faba21d423d2f75faa859194d87fb80befad /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e638faba21d423d2f75faa859194d87fb80befad/__init__.py
attrname = string.lower(attrname)
def parse_starttag(self, i):
49eb8822fe10574e9e4e4392194d57c8292d0a8f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/49eb8822fe10574e9e4e4392194d57c8292d0a8f/xmllib.py
def test(args = None): import sys if not args: args = sys.argv[1:] if args and args[0] == '-s': args = args[1:] klass = XMLParser else: klass = TestXMLParser if args: file = args[0] else: file = 'test.xml' if file == '-': f = sys.stdin else: try: f = open(file, 'r') except IOError, msg: print file, ":", msg sys.exit(1) data = f.read() if f is not sys.stdin: f.close() x = klass() for c in data: x.feed(c) x.close()
49eb8822fe10574e9e4e4392194d57c8292d0a8f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/49eb8822fe10574e9e4e4392194d57c8292d0a8f/xmllib.py
def askopenfilenames(**options): """Ask for multiple filenames to open Returns a list of filenames or empty list if cancel button selected """ options["multiple"]=1 files=Open(**options).show() return files.split()
def asksaveasfilename(**options): "Ask for a filename to save as" return SaveAs(**options).show()
e6f33f710a772d32e6ba44f223aa3fa01cca4cc3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e6f33f710a772d32e6ba44f223aa3fa01cca4cc3/tkFileDialog.py
n_lines += 1
def write_results_file(self, path, lines, lnotab, lines_hit): """Return a coverage results file in path."""
eae3b77ba7e028343b1ce13411320c4f2ac4dd6f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/eae3b77ba7e028343b1ce13411320c4f2ac4dd6f/trace.py
params, method = xmlrpclib.loads(data)
def _marshaled_dispatch(self, data, dispatch_method = None): """Dispatches an XML-RPC method from marshalled (XML) data.
d5d8a78cd81f8fed88448d7b2e9e6e10fe5496b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d5d8a78cd81f8fed88448d7b2e9e6e10fe5496b9/SimpleXMLRPCServer.py
print self.debug
def sendsms(self):#{{{ baseURLSSL='https://www.orange.pl' baseURL='http://www.orange.pl' length = 634 - len(self.message) cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) # orange index#{{{ request = urllib2.Request(baseURLSSL) request.add_header('User-Agent', 'Opera/8.00 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'Connecting with',baseURLSSL except IOError: print 'Connection with %s failed.' % baseURLSSL#}}} # orange map#{{{ request = urllib2.Request(baseURLSSL + '/portal/map/map/') request.add_header('User-Agent', 'Opera/8.00 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'Connecting with www.orange.pl/portal/map/map' except IOError: print 'Connection with https://www.orange.pl/portal/map/map failed.'#}}} # orange login#{{{ parmdicta = {'_dyncharset': 'UTF-8', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginErrorURL': '/portal/map/map/signin', '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginErrorURL': ' ', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginSuccessURL': 'http://www.orange.pl/portal/map/map/pim', '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginSuccessURL': ' ', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login': self.login, '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login': ' ', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password': self.password, '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password': ' ', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.x': '0', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.y': '0', '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login': ' ', '_DARGS': '/gear/static/login.jsp'} request = urllib2.Request(baseURLSSL + '/portal/map/map/home?_DARGS=/gear/static/login.jsp') postdata = urllib.unquote(urllib.urlencode(parmdicta)) request.add_data(postdata) request.add_header('User-Agent', 'Opera/8.00 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'Logged' except IOError: print 'Not logged'#}}} # orange SMS form#{{{ request = urllib2.Request(baseURL + '/portal/map/map/message_box?mbox_view=newsms&mbox_edit=new') request.add_header('User-Agent', 'Opera/8.00 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'Opening SMS form' except IOError: print 'Open SMS form failed.'#}}} # Send SMS#{{{ parmdictb = {'_dyncharset': 'UTF-8', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.type': 'sms', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.type' : ' ', 'enabled': 'true', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.errorURL': '/portal/map/map/message_box?mbox_view=newsms', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.errorURL': ' ', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.successURL': '/portal/map/map/message_box?mbox_view=messageslist', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.successURL': ' ', 'smscounter' : '1', 'counter': length, '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to': self.number, '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to': ' ', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body': ' ', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body': self.sender+' : '+self.message, '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create.x': '0', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create.y': '0', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create': ' ', '_DARGS': '/gear/mapmessagebox/smsform.jsp'} request = urllib2.Request(baseURL + '/portal/map/map/message_box?_DARGS=/gear/mapmessagebox/smsform.jsp') postdata = urllib.unquote(urllib.urlencode(parmdictb)) request.add_data(postdata) request.add_header('User-Agent', 'Opera/8.00 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'SMS sended.' except IOError: print 'SMS not send.' smsy = self.zostalo(result.read()) smsy_darmowe = 0 if len(smsy) == 1: smsy_darmowe = smsy[0] smsy_doladowane = 0 if len(smsy) == 2: smsy_darmowe = smsy[0] smsy_doladowane = smsy[1]; if smsy_darmowe and self.debug: print 'Orange -> Zostalo: %s+%s SMS' % (smsy_darmowe, smsy_doladowane) #}}}
d27f4c53e24bf8591d5093449ed8c32346f61ad6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/2325/d27f4c53e24bf8591d5093449ed8c32346f61ad6/orange.py
print postdata
def sendsms(self):#{{{ baseURLSSL='https://www.orange.pl' baseURL='http://www.orange.pl' length = 634 - len(self.message) cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) # orange index#{{{ request = urllib2.Request(baseURLSSL) request.add_header('User-Agent', 'Opera/9.00 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'Connecting with',baseURLSSL except IOError: print 'Connection with %s failed.' % baseURLSSL#}}} # orange map#{{{ request = urllib2.Request(baseURLSSL + '/portal/map/map/') request.add_header('User-Agent', 'Opera/8.00 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'Connecting with www.orange.pl/portal/map/map' except IOError: print 'Connection with https://www.orange.pl/portal/map/map failed.'#}}} # orange login#{{{ parmdicta = { '_dyncharset' : 'UTF-8', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginErrorURL' : '/portal/map/map/signin', '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginErrorURL' : ' ', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginSuccessURL' : 'http://www.orange.pl/portal/map/map/pim', '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginSuccessURL' : ' ', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login' : self.login, '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login' : ' ', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password' : self.password, '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password' : ' ', '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login' : ' ', '_DARGS' : '/gear/static/home/login.jsp.loginFormId', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login' : ' ', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.x' : '5', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.y' : '5'} request = urllib2.Request(baseURLSSL + '/portal/map/map/homeo?_DARGS=/gear/static/home/login.jsp.loginFormId') postdata = urllib.unquote(urllib.urlencode(parmdicta)) request.add_data(postdata) print postdata request.add_header('User-Agent', 'Opera/8.10 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'Logged' except IOError: print 'Not logged'#}}} # orange SMS form#{{{ request = urllib2.Request(baseURL + '/portal/map/map/message_box?mbox_view=newsms&mbox_edit=new') request.add_header('User-Agent', 'Opera/8.00 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'Opening SMS form' except IOError: print 'Open SMS form failed.'#}}} # Send SMS#{{{ parmdictb = {'_dyncharset': 'UTF-8', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.type': 'sms', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.type' : ' ', 'enabled': 'true', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.errorURL': '/portal/map/map/message_box?mbox_view=newsms', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.errorURL': ' ', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.successURL': '/portal/map/map/message_box?mbox_view=messageslist', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.successURL': ' ', 'smscounter' : '1', 'counter': '630', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to': self.number, '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to': ' ', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body': ' ', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body': self.sender+' : '+self.message, '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create': ' ', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create': 'Wylij', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create.x': '5', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create.y': '5', '_DARGS': '/gear/mapmessagebox/smsform.jsp'} request = urllib2.Request(baseURL + '/portal/map/map/message_box?_DARGS=/gear/mapmessagebox/smsform.jsp') postdata = urllib.unquote(urllib.urlencode(parmdictb)) request.add_data(postdata) request.add_header('User-Agent', 'Opera/8.00 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'SMS sended.' except IOError: print 'SMS not send.' smsy = self.zostalo(result.read()) smsy_darmowe = 0 if len(smsy) == 1: smsy_darmowe = smsy[0] smsy_doladowane = 0 if len(smsy) == 2: smsy_darmowe = smsy[0] smsy_doladowane = smsy[1]; if smsy_darmowe and self.debug: print 'Orange -> Zostalo: %s+%s SMS' % (smsy_darmowe, smsy_doladowane) #}}}
d738da0586f43d406e7b3cd584e863708de73b21 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/2325/d738da0586f43d406e7b3cd584e863708de73b21/orange.py
print postdata
def sendsms(self):#{{{ baseURL='http://www.eraomnix.pl' cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj), moj_redirect_handler) request = urllib2.Request(baseURL + '/msg/api/do/tinker/sponsored') parametry = { 'failure' : baseURL, 'success' : baseURL, 'message' : self.message, 'login' : self.login, 'password' : self.password, 'number' : '48' + self.number, 'mms' : 'false'}
b06d8d784cec632efda7fdf326a22c337b2c048d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/2325/b06d8d784cec632efda7fdf326a22c337b2c048d/eraomnix.py
print blad
def sendsms(self):#{{{ baseURL='http://www.eraomnix.pl' cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj), moj_redirect_handler) request = urllib2.Request(baseURL + '/msg/api/do/tinker/sponsored') parametry = { 'failure' : baseURL, 'success' : baseURL, 'message' : self.message, 'login' : self.login, 'password' : self.password, 'number' : '48' + self.number, 'mms' : 'false'}
b06d8d784cec632efda7fdf326a22c337b2c048d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/2325/b06d8d784cec632efda7fdf326a22c337b2c048d/eraomnix.py
print "change desc: ``%s''" % changedesc
def parse_change_desc(changedesc, result_dict): summary = "" description = "" files = [] changedesc_keys = { 'QA Notes': "", 'Testing Done': "", 'Documentation Notes': "", 'Bug Number': "", 'Reviewed by': "", 'Approved by': "", 'Breaks vmcore compatibility': "", 'Breaks vmkernel compatibility': "", 'Breaks vmkdrivers compatibility': "", 'Mailto': "", } process_summary = False process_description = False process_files = False cur_key = None print "change desc: ``%s''" % changedesc for line in changedesc.split("\n"): print ">> `%s'" % line if line == "Description:": process_summary = True continue elif line == "Files:": process_files = True continue elif line == "" or line == "\t": if process_summary: process_summary = False process_description = True continue line = "" elif line.startswith("\t"): line = line[1:] if process_files: files.append(line) elif line.find(':') != -1: key, value = line.split(':', 2) if changedesc_keys.has_key(key): process_description = False cur_key = key changedesc_keys[key] = value.lstrip() + "\n" continue line += "\n" if process_summary: summary += line elif process_description: description += line elif cur_key != None: changedesc_keys[cur_key] += line result_dict['summary'] = summary result_dict['description'] = description result_dict['testing_done'] = changedesc_keys['Testing Done'] # TODO: Normalize bug number result_dict['bugs_closed'] = changedesc_keys['Bug Number'] # This is gross. if len(files) > 0: parts = files[0].split('/') if parts[2] == "depot": result_dict['branch'] = parts[4]
945dddff971630c6744b0d920a4e4b0e4d8061ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/1600/945dddff971630c6744b0d920a4e4b0e4d8061ab/views.py
print ">> `%s'" % line
def parse_change_desc(changedesc, result_dict): summary = "" description = "" files = [] changedesc_keys = { 'QA Notes': "", 'Testing Done': "", 'Documentation Notes': "", 'Bug Number': "", 'Reviewed by': "", 'Approved by': "", 'Breaks vmcore compatibility': "", 'Breaks vmkernel compatibility': "", 'Breaks vmkdrivers compatibility': "", 'Mailto': "", } process_summary = False process_description = False process_files = False cur_key = None print "change desc: ``%s''" % changedesc for line in changedesc.split("\n"): print ">> `%s'" % line if line == "Description:": process_summary = True continue elif line == "Files:": process_files = True continue elif line == "" or line == "\t": if process_summary: process_summary = False process_description = True continue line = "" elif line.startswith("\t"): line = line[1:] if process_files: files.append(line) elif line.find(':') != -1: key, value = line.split(':', 2) if changedesc_keys.has_key(key): process_description = False cur_key = key changedesc_keys[key] = value.lstrip() + "\n" continue line += "\n" if process_summary: summary += line elif process_description: description += line elif cur_key != None: changedesc_keys[cur_key] += line result_dict['summary'] = summary result_dict['description'] = description result_dict['testing_done'] = changedesc_keys['Testing Done'] # TODO: Normalize bug number result_dict['bugs_closed'] = changedesc_keys['Bug Number'] # This is gross. if len(files) > 0: parts = files[0].split('/') if parts[2] == "depot": result_dict['branch'] = parts[4]
945dddff971630c6744b0d920a4e4b0e4d8061ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/1600/945dddff971630c6744b0d920a4e4b0e4d8061ab/views.py
result_dict['bugs_closed'] = changedesc_keys['Bug Number']
result_dict['bugs_closed'] = \ ", ".join(re.split(r"[, ]+", changedesc_keys['Bug Number']))
def parse_change_desc(changedesc, result_dict): summary = "" description = "" files = [] changedesc_keys = { 'QA Notes': "", 'Testing Done': "", 'Documentation Notes': "", 'Bug Number': "", 'Reviewed by': "", 'Approved by': "", 'Breaks vmcore compatibility': "", 'Breaks vmkernel compatibility': "", 'Breaks vmkdrivers compatibility': "", 'Mailto': "", } process_summary = False process_description = False process_files = False cur_key = None print "change desc: ``%s''" % changedesc for line in changedesc.split("\n"): print ">> `%s'" % line if line == "Description:": process_summary = True continue elif line == "Files:": process_files = True continue elif line == "" or line == "\t": if process_summary: process_summary = False process_description = True continue line = "" elif line.startswith("\t"): line = line[1:] if process_files: files.append(line) elif line.find(':') != -1: key, value = line.split(':', 2) if changedesc_keys.has_key(key): process_description = False cur_key = key changedesc_keys[key] = value.lstrip() + "\n" continue line += "\n" if process_summary: summary += line elif process_description: description += line elif cur_key != None: changedesc_keys[cur_key] += line result_dict['summary'] = summary result_dict['description'] = description result_dict['testing_done'] = changedesc_keys['Testing Done'] # TODO: Normalize bug number result_dict['bugs_closed'] = changedesc_keys['Bug Number'] # This is gross. if len(files) > 0: parts = files[0].split('/') if parts[2] == "depot": result_dict['branch'] = parts[4]
945dddff971630c6744b0d920a4e4b0e4d8061ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/1600/945dddff971630c6744b0d920a4e4b0e4d8061ab/views.py
Bug Number: 456123\n\
Bug Number: 456123, 12873 1298371\n\
def new_review_request(request, template_name='reviews/new.html', changenum_path='changenum'): changedesc = "\
945dddff971630c6744b0d920a4e4b0e4d8061ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/1600/945dddff971630c6744b0d920a4e4b0e4d8061ab/views.py