rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
"""Return a 2-tuple containing (new_string, number). new_string is the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in the source string by the replacement repl. number is the number of substitutions that were made."""
"""subn(repl, string[, count=0]) -> tuple Perform the same operation as sub(), but return a tuple (new_string, number_of_subs_made). """
def subn(self, repl, source, count=0): """Return a 2-tuple containing (new_string, number). new_string is the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in the source string by the replacement repl. number is the number of substitutions that were made.""" if count < 0: raise error, "negative substitution count" if count == 0: count = sys.maxint n = 0 # Number of matches pos = 0 # Where to start searching lastmatch = -1 # End of last match results = [] # Substrings making up the result end = len(source)
6ebb387a087b1a64437856da4b286694396e663c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6ebb387a087b1a64437856da4b286694396e663c/re.py
"""Split the source string by the occurrences of the pattern, returning a list containing the resulting substrings."""
"""split(source[, maxsplit=0]) -> list of strings Split string by the occurrences of the compiled pattern. If capturing parentheses are used in the pattern, then the text of all groups in the pattern are also returned as part of the resulting list. If maxsplit is nonzero, at most maxsplit splits occur, and the remainder of the string is returned as the final element of the list. """
def split(self, source, maxsplit=0): """Split the source string by the occurrences of the pattern, returning a list containing the resulting substrings."""
6ebb387a087b1a64437856da4b286694396e663c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6ebb387a087b1a64437856da4b286694396e663c/re.py
"""Return a list of all non-overlapping matches in the string. If one or more groups are present in the pattern, return a list of groups; this will be a list of tuples if the pattern has more than one group. Empty matches are included in the result.
"""findall(source) -> list Return a list of all non-overlapping matches of the compiled pattern in string. If one or more groups are present in the pattern, return a list of groups; this will be a list of tuples if the pattern has more than one group. Empty matches are included in the result.
def findall(self, source): """Return a list of all non-overlapping matches in the string.
6ebb387a087b1a64437856da4b286694396e663c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6ebb387a087b1a64437856da4b286694396e663c/re.py
"Return the start of the substring matched by group g"
"""start([group=0]) -> int or None Return the index of the start of the substring matched by group; group defaults to zero (meaning the whole matched substring). Return None if group exists but did not contribute to the match. """
def start(self, g = 0): "Return the start of the substring matched by group g" if type(g) == type(''): try: g = self.re.groupindex[g] except (KeyError, TypeError): raise IndexError, 'group %s is undefined' % `g` return self.regs[g][0]
6ebb387a087b1a64437856da4b286694396e663c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6ebb387a087b1a64437856da4b286694396e663c/re.py
"Return the end of the substring matched by group g"
"""end([group=0]) -> int or None Return the indices of the end of the substring matched by group; group defaults to zero (meaning the whole matched substring). Return None if group exists but did not contribute to the match. """
def end(self, g = 0): "Return the end of the substring matched by group g" if type(g) == type(''): try: g = self.re.groupindex[g] except (KeyError, TypeError): raise IndexError, 'group %s is undefined' % `g` return self.regs[g][1]
6ebb387a087b1a64437856da4b286694396e663c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6ebb387a087b1a64437856da4b286694396e663c/re.py
"Return (start, end) of the substring matched by group g"
"""span([group=0]) -> tuple Return the 2-tuple (m.start(group), m.end(group)). Note that if group did not contribute to the match, this is (None, None). Group defaults to zero (meaning the whole matched substring). """
def span(self, g = 0): "Return (start, end) of the substring matched by group g" if type(g) == type(''): try: g = self.re.groupindex[g] except (KeyError, TypeError): raise IndexError, 'group %s is undefined' % `g` return self.regs[g]
6ebb387a087b1a64437856da4b286694396e663c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6ebb387a087b1a64437856da4b286694396e663c/re.py
"Return a tuple containing all subgroups of the match object"
"""groups([default=None]) -> tuple Return a tuple containing all the subgroups of the match, from 1 up to however many groups are in the pattern. The default argument is used for groups that did not participate in the match. """
def groups(self, default=None): "Return a tuple containing all subgroups of the match object" result = [] for g in range(1, self.re._num_regs): a, b = self.regs[g] if a == -1 or b == -1: result.append(default) else: result.append(self.string[a:b]) return tuple(result)
6ebb387a087b1a64437856da4b286694396e663c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6ebb387a087b1a64437856da4b286694396e663c/re.py
"Return one or more groups of the match"
"""group([group1, group2, ...]) -> string or tuple Return one or more subgroups of the match. If there is a single argument, the result is a single string; if there are multiple arguments, the result is a tuple with one item per argument. Without arguments, group1 defaults to zero (i.e. the whole match is returned). If a groupN argument is zero, the corresponding return value is the entire matching string; if it is in the inclusive range [1..99], it is the string matching the the corresponding parenthesized group. If a group number is negative or larger than the number of groups defined in the pattern, an IndexError exception is raised. If a group is contained in a part of the pattern that did not match, the corresponding result is None. If a group is contained in a part of the pattern that matched multiple times, the last match is returned. If the regular expression uses the (?P<name>...) syntax, the groupN arguments may also be strings identifying groups by their group name. If a string argument is not used as a group name in the pattern, an IndexError exception is raised. """
def group(self, *groups): "Return one or more groups of the match" if len(groups) == 0: groups = (0,) result = [] for g in groups: if type(g) == type(''): try: g = self.re.groupindex[g] except (KeyError, TypeError): raise IndexError, 'group %s is undefined' % `g` if g >= len(self.regs): raise IndexError, 'group %s is undefined' % `g` a, b = self.regs[g] if a == -1 or b == -1: result.append(None) else: result.append(self.string[a:b]) if len(result) > 1: return tuple(result) elif len(result) == 1: return result[0] else: return ()
6ebb387a087b1a64437856da4b286694396e663c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6ebb387a087b1a64437856da4b286694396e663c/re.py
self.filename = filename
self.filename = _normpath(filename)
def __init__(self, filename="NoName", date_time=(1980,1,1,0,0,0)): self.filename = filename # Name of the file in the archive self.date_time = date_time # year, month, day, hour, min, sec # Standard values: self.compress_type = ZIP_STORED # Type of compression for the file self.comment = "" # Comment for each file self.extra = "" # ZIP extra data self.create_system = 0 # System which created ZIP archive self.create_version = 20 # Version which created ZIP archive self.extract_version = 20 # Version needed to extract archive self.reserved = 0 # Must be zero self.flag_bits = 0 # ZIP flag bits self.volume = 0 # Volume number of file header self.internal_attr = 0 # Internal attributes self.external_attr = 0 # External file attributes # Other attributes are set by class ZipFile: # header_offset Byte offset to the file header # file_offset Byte offset to the start of the file data # CRC CRC-32 of the uncompressed file # compress_size Size of the compressed file # file_size Size of the uncompressed file
a58947f60098b07471ad6771b185557081d14a4c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a58947f60098b07471ad6771b185557081d14a4c/zipfile.py
for i in ['_exit']: try: exec "from nt import " + i except ImportError: pass
try: from nt import _exit except ImportError: pass
def _get_exports_list(module): try: return list(module.__all__) except AttributeError: return [n for n in dir(module) if n[0] != '_']
6757c1e8565262cdc234de3370c4747927a72f72 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6757c1e8565262cdc234de3370c4747927a72f72/os.py
for i in ['_exit']: try: exec "from ce import " + i except ImportError: pass
try: from ce import _exit except ImportError: pass
def _get_exports_list(module): try: return list(module.__all__) except AttributeError: return [n for n in dir(module) if n[0] != '_']
6757c1e8565262cdc234de3370c4747927a72f72 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6757c1e8565262cdc234de3370c4747927a72f72/os.py
except IOError, msg:
except (OSError, IOError), msg:
def addrobot(self, root): root = urlparse.urljoin(root, "/") if self.robots.has_key(root): return url = urlparse.urljoin(root, "/robots.txt") self.robots[root] = rp = robotparser.RobotFileParser() self.note(2, "Parsing %s", url) rp.debug = self.verbose > 3 rp.set_url(url) try: rp.read() except IOError, msg: self.note(1, "I/O error parsing %s: %s", url, msg)
f0953b9dff9a0cc08b6dcfe206047c0490e1d38a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f0953b9dff9a0cc08b6dcfe206047c0490e1d38a/webchecker.py
except IOError, msg:
except (OSError, IOError), msg:
def openpage(self, url_pair): url, fragment = url_pair try: return self.urlopener.open(url) except IOError, msg: msg = self.sanitize(msg) self.note(0, "Error %s", msg) if self.verbose > 0: self.show(" HREF ", url, " from", self.todo[url_pair]) self.setbad(url_pair, msg) return None
f0953b9dff9a0cc08b6dcfe206047c0490e1d38a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f0953b9dff9a0cc08b6dcfe206047c0490e1d38a/webchecker.py
(sys.platform.startswith('linux') and
((sys.platform.startswith('linux') or sys.platform.startswith('gnu')) and
def finalize_options (self): from distutils import sysconfig
d149d0c76a7fa8c90140342dad3e1c220c63c054 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d149d0c76a7fa8c90140342dad3e1c220c63c054/build_ext.py
self.assertRaises(TypeError, islice, xrange(10))
self.assertEqual(list(islice(xrange(10))), range(10)) self.assertEqual(list(islice(xrange(10), None)), range(10)) self.assertEqual(list(islice(xrange(10), 2, None)), range(2, 10)) self.assertEqual(list(islice(xrange(10), 1, None, 2)), range(1, 10, 2))
def test_islice(self): for args in [ # islice(args) should agree with range(args) (10, 20, 3), (10, 3, 20), (10, 20), (10, 3), (20,) ]: self.assertEqual(list(islice(xrange(100), *args)), range(*args))
14ef54cd833c7ccfa0b3d03e2b45074d54a8ac87 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/14ef54cd833c7ccfa0b3d03e2b45074d54a8ac87/test_itertools.py
import test_itertools
def test_main(verbose=None): import test_itertools suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestBasicOps)) test_support.run_suite(suite) test_support.run_doctest(test_itertools, verbose) # verify reference counting import sys if verbose and hasattr(sys, "gettotalrefcount"): counts = [] for i in xrange(5): test_support.run_suite(suite) counts.append(sys.gettotalrefcount()-i) print counts
14ef54cd833c7ccfa0b3d03e2b45074d54a8ac87 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/14ef54cd833c7ccfa0b3d03e2b45074d54a8ac87/test_itertools.py
test_support.run_doctest(test_itertools, verbose)
def test_main(verbose=None): import test_itertools suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestBasicOps)) test_support.run_suite(suite) test_support.run_doctest(test_itertools, verbose) # verify reference counting import sys if verbose and hasattr(sys, "gettotalrefcount"): counts = [] for i in xrange(5): test_support.run_suite(suite) counts.append(sys.gettotalrefcount()-i) print counts
14ef54cd833c7ccfa0b3d03e2b45074d54a8ac87 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/14ef54cd833c7ccfa0b3d03e2b45074d54a8ac87/test_itertools.py
pass
def __getitem__(self, index): return 2*tuple.__getitem__(self, index)
def test_filter_subclasses(self): # test, that filter() never returns tuple, str or unicode subclasses funcs = (None, lambda x: True) class tuple2(tuple): pass class str2(str): pass inputs = { tuple2: [(), (1,2,3)], str2: ["", "123"] } if have_unicode: class unicode2(unicode): pass inputs[unicode2] = [unicode(), unicode("123")]
1918f7755e03900224c5a53cca9fc0088c3186d3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1918f7755e03900224c5a53cca9fc0088c3186d3/test_builtin.py
pass
def __getitem__(self, index): return 2*str.__getitem__(self, index)
def test_filter_subclasses(self): # test, that filter() never returns tuple, str or unicode subclasses funcs = (None, lambda x: True) class tuple2(tuple): pass class str2(str): pass inputs = { tuple2: [(), (1,2,3)], str2: ["", "123"] } if have_unicode: class unicode2(unicode): pass inputs[unicode2] = [unicode(), unicode("123")]
1918f7755e03900224c5a53cca9fc0088c3186d3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1918f7755e03900224c5a53cca9fc0088c3186d3/test_builtin.py
tuple2: [(), (1,2,3)], str2: ["", "123"]
tuple2: {(): (), (1, 2, 3): (1, 2, 3)}, str2: {"": "", "123": "112233"}
def test_filter_subclasses(self): # test, that filter() never returns tuple, str or unicode subclasses funcs = (None, lambda x: True) class tuple2(tuple): pass class str2(str): pass inputs = { tuple2: [(), (1,2,3)], str2: ["", "123"] } if have_unicode: class unicode2(unicode): pass inputs[unicode2] = [unicode(), unicode("123")]
1918f7755e03900224c5a53cca9fc0088c3186d3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1918f7755e03900224c5a53cca9fc0088c3186d3/test_builtin.py
pass inputs[unicode2] = [unicode(), unicode("123")] for func in funcs: for (cls, inps) in inputs.iteritems(): for inp in inps: out = filter(func, cls(inp)) self.assertEqual(inp, out) self.assert_(not isinstance(out, cls))
def __getitem__(self, index): return 2*unicode.__getitem__(self, index) inputs[unicode2] = { unicode(): unicode(), unicode("123"): unicode("112233") } for (cls, inps) in inputs.iteritems(): for (inp, exp) in inps.iteritems(): self.assertEqual( filter(funcs[0], cls(inp)), filter(funcs[1], cls(inp)) ) for func in funcs: outp = filter(func, cls(inp)) self.assertEqual(outp, exp) self.assert_(not isinstance(outp, cls))
def test_filter_subclasses(self): # test, that filter() never returns tuple, str or unicode subclasses funcs = (None, lambda x: True) class tuple2(tuple): pass class str2(str): pass inputs = { tuple2: [(), (1,2,3)], str2: ["", "123"] } if have_unicode: class unicode2(unicode): pass inputs[unicode2] = [unicode(), unicode("123")]
1918f7755e03900224c5a53cca9fc0088c3186d3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1918f7755e03900224c5a53cca9fc0088c3186d3/test_builtin.py
TypeError: iteration over non-sequence
TypeError: 'int' object is not iterable
>>> def f(n):
ccff78525889fe2fa1a3512c4084a407994f9ce3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ccff78525889fe2fa1a3512c4084a407994f9ce3/test_genexps.py
e.set_lk_detect(db.DB_LOCK_DEFAULT)
def _openDBEnv(cachesize): e = db.DBEnv() if cachesize is not None: if cachesize >= 20480: e.set_cachesize(0, cachesize) else: raise error, "cachesize must be >= 20480" e.open('.', db.DB_PRIVATE | db.DB_CREATE | db.DB_THREAD | db.DB_INIT_LOCK | db.DB_INIT_MPOOL) e.set_lk_detect(db.DB_LOCK_DEFAULT) return e
996710fd44426f43d54034ebf3ee2355fca18f6a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/996710fd44426f43d54034ebf3ee2355fca18f6a/__init__.py
def __imull__(self, n): self.data += n
def __imul__(self, n): self.data *= n
def __imull__(self, n): self.data += n return self
add8d8632528d104a3a1e653ec815ed2e2c75b7a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/add8d8632528d104a3a1e653ec815ed2e2c75b7a/UserString.py
self._tk.deletecommand(cbname)
self._master.deletecommand(cbname)
def trace_vdelete(self, mode, cbname): self._tk.call("trace", "vdelete", self._name, mode, cbname) self._tk.deletecommand(cbname)
0001a11986a17a94f1bf16df92b57df358d56958 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0001a11986a17a94f1bf16df92b57df358d56958/Tkinter.py
if time.strftime(directive, time_tuple).find('00'):
if '00' in time.strftime(directive, time_tuple):
def __calc_date_time(self): # Set self.date_time, self.date, & self.time by using # time.strftime().
6e372d1422dfaf5b1cd2ab2f48a42ee609cc119c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6e372d1422dfaf5b1cd2ab2f48a42ee609cc119c/_strptime.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]
1ee77d9b71dab3b42b3c00760216cc4955a3cfeb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1ee77d9b71dab3b42b3c00760216cc4955a3cfeb/test_strop.py
if self.force or output_file is None or newer(source, output_file)):
if self.force or output_file is None or newer(source, output_file):
def preprocess (self, source, output_file=None, macros=None, include_dirs=None, extra_preargs=None, extra_postargs=None):
63a47402b354e76255d4a629ee3e1950d843af25 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/63a47402b354e76255d4a629ee3e1950d843af25/unixccompiler.py
install = self.distribution.get_command_obj('install')
install = self.reinitialize_command('install')
def run (self):
edc6a519dc7801d22b3105f25327606476f4cc46 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/edc6a519dc7801d22b3105f25327606476f4cc46/bdist_dumb.py
def __init__(self, allow_none):
def __init__(self, allow_none, encoding):
def __init__(self, allow_none): self.funcs = {} self.instance = None self.allow_none = allow_none
427aedbbd436a3daa27176b2a57b8e402d1ff0e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/427aedbbd436a3daa27176b2a57b8e402d1ff0e0/SimpleXMLRPCServer.py
allow_none = self.allow_none)
allow_none=self.allow_none, encoding=self.encoding)
def _marshaled_dispatch(self, data, dispatch_method = None): """Dispatches an XML-RPC method from marshalled (XML) data.
427aedbbd436a3daa27176b2a57b8e402d1ff0e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/427aedbbd436a3daa27176b2a57b8e402d1ff0e0/SimpleXMLRPCServer.py
response = xmlrpclib.dumps(fault)
response = xmlrpclib.dumps(fault, allow_none=self.allow_none, encoding=self.encoding)
def _marshaled_dispatch(self, data, dispatch_method = None): """Dispatches an XML-RPC method from marshalled (XML) data.
427aedbbd436a3daa27176b2a57b8e402d1ff0e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/427aedbbd436a3daa27176b2a57b8e402d1ff0e0/SimpleXMLRPCServer.py
xmlrpclib.Fault(1, "%s:%s" % (sys.exc_type, sys.exc_value))
xmlrpclib.Fault(1, "%s:%s" % (sys.exc_type, sys.exc_value)), encoding=self.encoding, allow_none=self.allow_none,
def _marshaled_dispatch(self, data, dispatch_method = None): """Dispatches an XML-RPC method from marshalled (XML) data.
427aedbbd436a3daa27176b2a57b8e402d1ff0e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/427aedbbd436a3daa27176b2a57b8e402d1ff0e0/SimpleXMLRPCServer.py
logRequests=True, allow_none=False):
logRequests=True, allow_none=False, encoding=None):
def __init__(self, addr, requestHandler=SimpleXMLRPCRequestHandler, logRequests=True, allow_none=False): self.logRequests = logRequests
427aedbbd436a3daa27176b2a57b8e402d1ff0e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/427aedbbd436a3daa27176b2a57b8e402d1ff0e0/SimpleXMLRPCServer.py
SimpleXMLRPCDispatcher.__init__(self, allow_none)
SimpleXMLRPCDispatcher.__init__(self, allow_none, encoding)
def __init__(self, addr, requestHandler=SimpleXMLRPCRequestHandler, logRequests=True, allow_none=False): self.logRequests = logRequests
427aedbbd436a3daa27176b2a57b8e402d1ff0e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/427aedbbd436a3daa27176b2a57b8e402d1ff0e0/SimpleXMLRPCServer.py
def __init__(self, allow_none=False): SimpleXMLRPCDispatcher.__init__(self, allow_none)
def __init__(self, allow_none=False, encoding=None): SimpleXMLRPCDispatcher.__init__(self, allow_none, encoding)
def __init__(self, allow_none=False): SimpleXMLRPCDispatcher.__init__(self, allow_none)
427aedbbd436a3daa27176b2a57b8e402d1ff0e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/427aedbbd436a3daa27176b2a57b8e402d1ff0e0/SimpleXMLRPCServer.py
return Falso
return False
def ignored(self, file): if os.path.isdir(file): return True for pat in self.IgnoreList: if fnmatch.fnmatch(file, pat): return True return Falso
72118e5bc7fff604058b821ac8fca6587eedf735 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/72118e5bc7fff604058b821ac8fca6587eedf735/cvslib.py
def addwork(self, job): if not job: raise TypeError, 'cannot add null job'
def addwork(self, func, args): job = (func, args)
def addwork(self, job): if not job: raise TypeError, 'cannot add null job' self.mutex.acquire() self.work.append(job) self.mutex.release() if len(self.work) == 1: self.todo.release()
3ac5b00d4091e2c06bafe5fc5fb18798d3fa701b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ac5b00d4091e2c06bafe5fc5fb18798d3fa701b/find.py
if '\n' in text: if string.find(text, '\r\n') >= 0: self._eoln = '\r\n' else: self._eoln = '\n' text = string.replace(text, self._eoln, '\r') change = 0 else: change = 0 self._eoln = '\r'
def __init__(self, path = "", title = ""): defaultfontsettings, defaulttabsettings, defaultwindowsize = geteditorprefs() global _scriptuntitledcounter if not path: if title: self.title = title else: self.title = "Untitled Script " + `_scriptuntitledcounter` _scriptuntitledcounter = _scriptuntitledcounter + 1 text = "" self._creator = W._signature self._eoln = os.linesep elif os.path.exists(path): path = resolvealiases(path) dir, name = os.path.split(path) self.title = name f = open(path, "rb") text = f.read() f.close() self._creator, filetype = MacOS.GetCreatorAndType(path) self.addrecentfile(path) else: raise IOError, "file '%s' does not exist" % path self.path = path if '\n' in text: if string.find(text, '\r\n') >= 0: self._eoln = '\r\n' else: self._eoln = '\n' text = string.replace(text, self._eoln, '\r') change = 0 else: change = 0 self._eoln = '\r' self.settings = {} if self.path: self.readwindowsettings() if self.settings.has_key("windowbounds"): bounds = self.settings["windowbounds"] else: bounds = defaultwindowsize if self.settings.has_key("fontsettings"): self.fontsettings = self.settings["fontsettings"] else: self.fontsettings = defaultfontsettings if self.settings.has_key("tabsize"): try: self.tabsettings = (tabsize, tabmode) = self.settings["tabsize"] except: self.tabsettings = defaulttabsettings else: self.tabsettings = defaulttabsettings W.Window.__init__(self, bounds, self.title, minsize = (330, 120), tabbable = 0) self.setupwidgets(text) if change > 0: self.editgroup.editor.textchanged() if self.settings.has_key("selection"): selstart, selend = self.settings["selection"] self.setselection(selstart, selend) self.open() self.setinfotext() self.globals = {} self._buf = "" # for write method self.debugging = 0 self.profiling = 0 self.run_as_main = self.settings.get("run_as_main", 0) self.run_with_interpreter = self.settings.get("run_with_interpreter", 0) self.run_with_cl_interpreter = self.settings.get("run_with_cl_interpreter", 0)
4e6b3c55d0a045e37725a0eb6c7a0dfcd4d4084b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4e6b3c55d0a045e37725a0eb6c7a0dfcd4d4084b/PyEdit.py
if change > 0: self.editgroup.editor.textchanged()
def __init__(self, path = "", title = ""): defaultfontsettings, defaulttabsettings, defaultwindowsize = geteditorprefs() global _scriptuntitledcounter if not path: if title: self.title = title else: self.title = "Untitled Script " + `_scriptuntitledcounter` _scriptuntitledcounter = _scriptuntitledcounter + 1 text = "" self._creator = W._signature self._eoln = os.linesep elif os.path.exists(path): path = resolvealiases(path) dir, name = os.path.split(path) self.title = name f = open(path, "rb") text = f.read() f.close() self._creator, filetype = MacOS.GetCreatorAndType(path) self.addrecentfile(path) else: raise IOError, "file '%s' does not exist" % path self.path = path if '\n' in text: if string.find(text, '\r\n') >= 0: self._eoln = '\r\n' else: self._eoln = '\n' text = string.replace(text, self._eoln, '\r') change = 0 else: change = 0 self._eoln = '\r' self.settings = {} if self.path: self.readwindowsettings() if self.settings.has_key("windowbounds"): bounds = self.settings["windowbounds"] else: bounds = defaultwindowsize if self.settings.has_key("fontsettings"): self.fontsettings = self.settings["fontsettings"] else: self.fontsettings = defaultfontsettings if self.settings.has_key("tabsize"): try: self.tabsettings = (tabsize, tabmode) = self.settings["tabsize"] except: self.tabsettings = defaulttabsettings else: self.tabsettings = defaulttabsettings W.Window.__init__(self, bounds, self.title, minsize = (330, 120), tabbable = 0) self.setupwidgets(text) if change > 0: self.editgroup.editor.textchanged() if self.settings.has_key("selection"): selstart, selend = self.settings["selection"] self.setselection(selstart, selend) self.open() self.setinfotext() self.globals = {} self._buf = "" # for write method self.debugging = 0 self.profiling = 0 self.run_as_main = self.settings.get("run_as_main", 0) self.run_with_interpreter = self.settings.get("run_with_interpreter", 0) self.run_with_cl_interpreter = self.settings.get("run_with_cl_interpreter", 0)
4e6b3c55d0a045e37725a0eb6c7a0dfcd4d4084b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4e6b3c55d0a045e37725a0eb6c7a0dfcd4d4084b/PyEdit.py
"http://www.unicode.org/Public/UNIDATA/" + TESTDATAFILE)
"http://www.unicode.org/Public/3.2-Update/" + TESTDATAFILE)
def test_main(): if skip_expected: raise TestSkipped(TESTDATAFILE + " not found, download from " + "http://www.unicode.org/Public/UNIDATA/" + TESTDATAFILE) part1_data = {} for line in open(TESTDATAFILE): if '#' in line: line = line.split('#')[0] line = line.strip() if not line: continue if line.startswith("@Part"): part = line continue try: c1,c2,c3,c4,c5 = [unistr(x) for x in line.split(';')[:-1]] except RangeError: # Skip unsupported characters continue if verbose: print line # Perform tests verify(c2 == NFC(c1) == NFC(c2) == NFC(c3), line) verify(c4 == NFC(c4) == NFC(c5), line) verify(c3 == NFD(c1) == NFD(c2) == NFD(c3), line) verify(c5 == NFD(c4) == NFD(c5), line) verify(c4 == NFKC(c1) == NFKC(c2) == NFKC(c3) == NFKC(c4) == NFKC(c5), line) verify(c5 == NFKD(c1) == NFKD(c2) == NFKD(c3) == NFKD(c4) == NFKD(c5), line) # Record part 1 data if part == "@Part1": part1_data[c1] = 1 # Perform tests for all other data for c in range(sys.maxunicode+1): X = unichr(c) if X in part1_data: continue assert X == NFC(X) == NFD(X) == NFKC(X) == NFKD(X), c
8db4403a768b711bbda1857ab4f38ed4be726e4b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8db4403a768b711bbda1857ab4f38ed4be726e4b/test_normalization.py
for checkArgName in expected.keys():
s = str(e) for checkArgName in expected:
def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e
38d4d4a35b9f5ba10d0343d458dd97a2a2432dae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/38d4d4a35b9f5ba10d0343d458dd97a2a2432dae/test_exceptions.py
for checkArgName in expected.keys():
for checkArgName in expected:
def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e
38d4d4a35b9f5ba10d0343d458dd97a2a2432dae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/38d4d4a35b9f5ba10d0343d458dd97a2a2432dae/test_exceptions.py
raise DistutilsOptionsError, \
raise DistutilsOptionError, \
def finalize_options (self): self.set_undefined_options('bdist', ('bdist_base', 'bdist_base')) if self.rpm_base is None: if not self.rpm3_mode: raise DistutilsOptionError, \ "you must specify --rpm-base in RPM 2 mode" self.rpm_base = os.path.join(self.bdist_base, "rpm")
5079fe07fe990e6db9b7c3b2d8702cad06cf2be0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5079fe07fe990e6db9b7c3b2d8702cad06cf2be0/bdist_rpm.py
fn = os.path.join(fn, os.pardir, os.pardir, "Doc", "index.html")
fn = os.path.join(fn, os.pardir, os.pardir, "pythlp.chm")
def help_dialog(self, event=None): try: helpfile = os.path.join(os.path.dirname(__file__), self.helpfile) except NameError: helpfile = self.helpfile if self.flist: self.flist.open(helpfile) else: self.io.loadfile(helpfile)
dcd2dc2fffce8614c5d2b8d303a303a599b88a23 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dcd2dc2fffce8614c5d2b8d303a303a599b88a23/EditorWindow.py
def python_docs(self, event=None): webbrowser.open(self.help_url)
def python_docs(self, event=None): os.startfile(self.help_url) else: def python_docs(self, event=None): webbrowser.open(self.help_url)
def python_docs(self, event=None): webbrowser.open(self.help_url)
dcd2dc2fffce8614c5d2b8d303a303a599b88a23 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dcd2dc2fffce8614c5d2b8d303a303a599b88a23/EditorWindow.py
opt_name = string.translate(opt_name, longopt_xlate) val = getattr(self, opt_name)
if self.negative_opt.has_key(opt_name): opt_name = string.translate(self.negative_opt[opt_name], longopt_xlate) val = not getattr(self, opt_name) else: opt_name = string.translate(opt_name, longopt_xlate) val = getattr(self, opt_name)
def dump_dirs (self, msg): if DEBUG: from distutils.fancy_getopt import longopt_xlate print msg + ":" for opt in self.user_options: opt_name = opt[0] if opt_name[-1] == "=": opt_name = opt_name[0:-1] opt_name = string.translate(opt_name, longopt_xlate) val = getattr(self, opt_name) print " %s: %s" % (opt_name, val)
1d1eac3ce895e29cdd5bb1d9b1f39dd60621e841 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1d1eac3ce895e29cdd5bb1d9b1f39dd60621e841/install.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()
7580149bde28532ef16924328af0f0543411c3b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7580149bde28532ef16924328af0f0543411c3b4/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()
7580149bde28532ef16924328af0f0543411c3b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7580149bde28532ef16924328af0f0543411c3b4/asdl_c.py
def __init__(self, format):
def __init__(self, format, len):
def __init__(self, format): self.format = format
4c8349592d508df26b9a8023f7a78d6874eedb08 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4c8349592d508df26b9a8023f7a78d6874eedb08/calendar.py
day_name = _localized_name('%A') day_abbr = _localized_name('%a')
day_name = _localized_name('%A', 7) day_abbr = _localized_name('%a', 7)
def __getitem__(self, item): return strftime(self.format, (item,)*9).capitalize()
4c8349592d508df26b9a8023f7a78d6874eedb08 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4c8349592d508df26b9a8023f7a78d6874eedb08/calendar.py
month_name = _localized_name('%B') month_abbr = _localized_name('%b')
month_name = _localized_name('%B', 12) month_abbr = _localized_name('%b', 12)
def __getitem__(self, item): return strftime(self.format, (item,)*9).capitalize()
4c8349592d508df26b9a8023f7a78d6874eedb08 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4c8349592d508df26b9a8023f7a78d6874eedb08/calendar.py
def __init__(self, sock, debuglevel=0):
def __init__(self, sock, debuglevel=0, strict=0):
def __init__(self, sock, debuglevel=0): self.fp = sock.makefile('rb', 0) self.debuglevel = debuglevel
d46aa37d35811a37397104f02074c8a44e7dbec1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d46aa37d35811a37397104f02074c8a44e7dbec1/httplib.py
version = "HTTP/0.9" status = "200" reason = "" if version[:5] != 'HTTP/': self.close() raise BadStatusLine(line)
version = "" if not version.startswith('HTTP/'): if self.strict: self.close() raise BadStatusLine(line) else: self.fp = LineAndFileWrapper(line, self.fp) return "HTTP/0.9", 200, ""
def _read_status(self): line = self.fp.readline() if self.debuglevel > 0: print "reply:", repr(line) try: [version, status, reason] = line.split(None, 2) except ValueError: try: [version, status] = line.split(None, 1) reason = "" except ValueError: version = "HTTP/0.9" status = "200" reason = "" if version[:5] != 'HTTP/': self.close() raise BadStatusLine(line)
d46aa37d35811a37397104f02074c8a44e7dbec1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d46aa37d35811a37397104f02074c8a44e7dbec1/httplib.py
def __init__(self, host, port=None):
strict = 0 def __init__(self, host, port=None, strict=None):
def getheader(self, name, default=None): if self.msg is None: raise ResponseNotReady() return self.msg.getheader(name, default)
d46aa37d35811a37397104f02074c8a44e7dbec1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d46aa37d35811a37397104f02074c8a44e7dbec1/httplib.py
def __init__(self, host, port=None): self.sock = None self.__response = None self.__state = _CS_IDLE
d46aa37d35811a37397104f02074c8a44e7dbec1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d46aa37d35811a37397104f02074c8a44e7dbec1/httplib.py
response = self.response_class(self.sock, self.debuglevel) else: response = self.response_class(self.sock)
response = self.response_class(self.sock, self.debuglevel, strict=self.strict) else: response = self.response_class(self.sock, strict=self.strict)
def getresponse(self): "Get the response from the server."
d46aa37d35811a37397104f02074c8a44e7dbec1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d46aa37d35811a37397104f02074c8a44e7dbec1/httplib.py
def __init__(self, host, port=None, key_file=None, cert_file=None): HTTPConnection.__init__(self, host, port)
def __init__(self, host, port=None, key_file=None, cert_file=None, strict=None): HTTPConnection.__init__(self, host, port, strict)
def __init__(self, host, port=None, key_file=None, cert_file=None): HTTPConnection.__init__(self, host, port) self.key_file = key_file self.cert_file = cert_file
d46aa37d35811a37397104f02074c8a44e7dbec1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d46aa37d35811a37397104f02074c8a44e7dbec1/httplib.py
def __init__(self, host='', port=None):
def __init__(self, host='', port=None, strict=None):
def __init__(self, host='', port=None): "Provide a default host, since the superclass requires one."
d46aa37d35811a37397104f02074c8a44e7dbec1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d46aa37d35811a37397104f02074c8a44e7dbec1/httplib.py
self._setup(self._connection_class(host, port))
self._setup(self._connection_class(host, port, strict))
def __init__(self, host='', port=None): "Provide a default host, since the superclass requires one."
d46aa37d35811a37397104f02074c8a44e7dbec1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d46aa37d35811a37397104f02074c8a44e7dbec1/httplib.py
def __init__(self, host='', port=None, **x509):
def __init__(self, host='', port=None, key_file=None, cert_file=None, strict=None):
def __init__(self, host='', port=None, **x509): # provide a default host, pass the X509 cert info
d46aa37d35811a37397104f02074c8a44e7dbec1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d46aa37d35811a37397104f02074c8a44e7dbec1/httplib.py
self._setup(self._connection_class(host, port, **x509))
self._setup(self._connection_class(host, port, key_file, cert_file, strict))
def __init__(self, host='', port=None, **x509): # provide a default host, pass the X509 cert info
d46aa37d35811a37397104f02074c8a44e7dbec1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d46aa37d35811a37397104f02074c8a44e7dbec1/httplib.py
self.key_file = x509.get('key_file') self.cert_file = x509.get('cert_file')
self.key_file = key_file self.cert_file = cert_file
def __init__(self, host='', port=None, **x509): # provide a default host, pass the X509 cert info
d46aa37d35811a37397104f02074c8a44e7dbec1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d46aa37d35811a37397104f02074c8a44e7dbec1/httplib.py
int i;
int i, result;
def visitModule(self, mod): self.emit("""
19379f18a6ba7f8baf695f9340eb1ab21a85771e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/19379f18a6ba7f8baf695f9340eb1ab21a85771e/asdl_c.py
for(i=0; i < num_fields; i++) {
for(i = 0; i < num_fields; i++) {
def visitModule(self, mod): self.emit("""
19379f18a6ba7f8baf695f9340eb1ab21a85771e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/19379f18a6ba7f8baf695f9340eb1ab21a85771e/asdl_c.py
return PyObject_SetAttrString((PyObject*)type, "_attributes", l) >=0;
result = PyObject_SetAttrString((PyObject*)type, "_attributes", l) >= 0; Py_DECREF(l); return result;
def visitModule(self, mod): self.emit("""
19379f18a6ba7f8baf695f9340eb1ab21a85771e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/19379f18a6ba7f8baf695f9340eb1ab21a85771e/asdl_c.py
self.emit("static int initialized;", 0)
def visitModule(self, mod): self.emit("""
19379f18a6ba7f8baf695f9340eb1ab21a85771e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/19379f18a6ba7f8baf695f9340eb1ab21a85771e/asdl_c.py
self.emit('if(PyDict_SetItemString(d, "%s", (PyObject*)%s_type) < 0) return;' % (name, name), 1)
self.emit('if (PyDict_SetItemString(d, "%s", (PyObject*)%s_type) < 0) return;' % (name, name), 1)
def addObj(self, name): self.emit('if(PyDict_SetItemString(d, "%s", (PyObject*)%s_type) < 0) return;' % (name, name), 1)
19379f18a6ba7f8baf695f9340eb1ab21a85771e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/19379f18a6ba7f8baf695f9340eb1ab21a85771e/asdl_c.py
self.chunksize = struct.unpack(strflag+'l', file.read(4))[0]
self.chunksize = struct.unpack(strflag+'L', file.read(4))[0]
def __init__(self, file, align=True, bigendian=True, inclheader=False): import struct self.closed = False self.align = align # whether to align to word (2-byte) boundaries if bigendian: strflag = '>' else: strflag = '<' self.file = file self.chunkname = file.read(4) if len(self.chunkname) < 4: raise EOFError try: self.chunksize = struct.unpack(strflag+'l', file.read(4))[0] except struct.error: raise EOFError if inclheader: self.chunksize = self.chunksize - 8 # subtract header self.size_read = 0 try: self.offset = self.file.tell() except (AttributeError, IOError): self.seekable = False else: self.seekable = True
7b4e7c24df974b2590d5ef332910a020db355546 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7b4e7c24df974b2590d5ef332910a020db355546/chunk.py
>>> def m235():
b6c3ceae79f193e4361651fea61dfb2528bc2746 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b6c3ceae79f193e4361651fea61dfb2528bc2746/test_generators.py
__test__ = {"tut": tutorial_tests, "pep": pep_tests, "email": email_tests, "fun": fun_tests, "syntax": syntax_tests}
x_tests = """ >>> def firstn(g, n): ... return [g.next() for i in range(n)] >>> def times(n, g): ... for i in g: ... yield n * i >>> def merge(g, h): ... ng = g.next() ... nh = h.next() ... while 1: ... if ng < nh: ... yield ng ... ng = g.next() ... elif ng > nh: ... yield nh ... nh = h.next() ... else: ... yield ng ... ng = g.next() ... nh = h.next() >>> class LazyList: ... def __init__(self, g): ... self.sofar = [] ... self.fetch = g.next ... ... def __getitem__(self, i): ... sofar, fetch = self.sofar, self.fetch ... while i >= len(sofar): ... sofar.append(fetch()) ... return sofar[i] >>> def m235(): ... yield 1 ... ... me_times2 = times(2, m235) ... me_times3 = times(3, m235) ... me_times5 = times(5, m235) ... for i in merge(merge(me_times2, ... me_times3), ... me_times5): ... yield i >>> m235 = LazyList(m235()) >>> for i in range(5): ... x = [m235[j] for j in range(15*i, 15*(i+1))] [1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24] [25, 27, 30, 32, 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80] [81, 90, 96, 100, 108, 120, 125, 128, 135, 144, 150, 160, 162, 180, 192] [200, 216, 225, 240, 243, 250, 256, 270, 288, 300, 320, 324, 360, 375, 384] [400, 405, 432, 450, 480, 486, 500, 512, 540, 576, 600, 625, 640, 648, 675] """ __test__ = {"tut": tutorial_tests, "pep": pep_tests, "email": email_tests, "fun": fun_tests, "syntax": syntax_tests }
>>> def f():
b6c3ceae79f193e4361651fea61dfb2528bc2746 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b6c3ceae79f193e4361651fea61dfb2528bc2746/test_generators.py
for i in range(1000):
for i in range(5000):
def test_main(): import doctest, test_generators if 0: # Temporary block to help track down leaks. So far, the blame # has fallen mostly on doctest. for i in range(1000): doctest.master = None doctest.testmod(test_generators) else: doctest.testmod(test_generators)
b6c3ceae79f193e4361651fea61dfb2528bc2746 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b6c3ceae79f193e4361651fea61dfb2528bc2746/test_generators.py
try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e try: unicode('\xff') except Exception, e: sampleUnicodeDecodeError = e
def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e
ecab623e1315cd0cfbe01e046e618001fe315490 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ecab623e1315cd0cfbe01e046e618001fe315490/test_exceptions.py
(sampleUnicodeEncodeError, {'message' : '', 'args' : ('ascii', u'Hello \xe1', 6, 7, 'ordinal not in range(128)'), 'encoding' : 'ascii', 'object' : u'Hello \xe1', 'start' : 6, 'reason' : 'ordinal not in range(128)'}), (sampleUnicodeDecodeError,
(UnicodeEncodeError, ('ascii', u'a', 0, 1, 'ordinal not in range'), {'message' : '', 'args' : ('ascii', u'a', 0, 1, 'ordinal not in range'), 'encoding' : 'ascii', 'object' : u'a', 'start' : 0, 'reason' : 'ordinal not in range'}), (UnicodeDecodeError, ('ascii', '\xff', 0, 1, 'ordinal not in range'),
def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e
ecab623e1315cd0cfbe01e046e618001fe315490 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ecab623e1315cd0cfbe01e046e618001fe315490/test_exceptions.py
'ordinal not in range(128)'),
'ordinal not in range'),
def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e
ecab623e1315cd0cfbe01e046e618001fe315490 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ecab623e1315cd0cfbe01e046e618001fe315490/test_exceptions.py
'start' : 0, 'reason' : 'ordinal not in range(128)'}),
'start' : 0, 'reason' : 'ordinal not in range'}),
def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e
ecab623e1315cd0cfbe01e046e618001fe315490 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ecab623e1315cd0cfbe01e046e618001fe315490/test_exceptions.py
for args in exceptionList: expected = args[-1] try: exc = args[0] if len(args) == 2: raise exc else: raise exc(*args[1])
for exc, args, expected in exceptionList: try: raise exc(*args)
def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e
ecab623e1315cd0cfbe01e046e618001fe315490 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ecab623e1315cd0cfbe01e046e618001fe315490/test_exceptions.py
if (e is not exc and type(e) is not exc):
if type(e) is not exc:
def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e
ecab623e1315cd0cfbe01e046e618001fe315490 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ecab623e1315cd0cfbe01e046e618001fe315490/test_exceptions.py
The QUESTION strign ca be at most 255 characters.
The QUESTION string can be at most 255 characters.
def AskYesNoCancel(question, default = 0, yes=None, no=None, cancel=None, id=262): """Display a QUESTION string which can be answered with Yes or No. Return 1 when the user clicks the Yes button. Return 0 when the user clicks the No button. Return -1 when the user clicks the Cancel button. When the user presses Return, the DEFAULT value is returned. If omitted, this is 0 (No). The QUESTION strign ca be at most 255 characters. """ d = GetNewDialog(id, -1) if not d: print "Can't get DLOG resource with id =", id return # Button assignments: # 1 = default (invisible) # 2 = Yes # 3 = No # 4 = Cancel # The question string is item 5 h = d.GetDialogItemAsControl(5) SetDialogItemText(h, lf2cr(question)) if yes != None: if yes == '': d.HideDialogItem(2) else: h = d.GetDialogItemAsControl(2) h.SetControlTitle(yes) if no != None: if no == '': d.HideDialogItem(3) else: h = d.GetDialogItemAsControl(3) h.SetControlTitle(no) if cancel != None: if cancel == '': d.HideDialogItem(4) else: h = d.GetDialogItemAsControl(4) h.SetControlTitle(cancel) d.SetDialogCancelItem(4) if default == 1: d.SetDialogDefaultItem(2) elif default == 0: d.SetDialogDefaultItem(3) elif default == -1: d.SetDialogDefaultItem(4) d.AutoSizeDialog() d.GetDialogWindow().ShowWindow() while 1: n = ModalDialog(None) if n == 1: return default if n == 2: return 1 if n == 3: return 0 if n == 4: return -1
639a740e50c12400586b2dad429e357365c16822 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/639a740e50c12400586b2dad429e357365c16822/EasyDialogs.py
st = os.stat(src) mode = stat.S_IMODE(st[stat.ST_MODE]) os.chmod(dst, mode)
if hasattr(os, 'chmod'): st = os.stat(src) mode = stat.S_IMODE(st[stat.ST_MODE]) os.chmod(dst, mode)
def copymode(src, dst): """Copy mode bits from src to dst""" st = os.stat(src) mode = stat.S_IMODE(st[stat.ST_MODE]) os.chmod(dst, mode)
0c94724cc77a004973fb0105417c084234c2da73 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0c94724cc77a004973fb0105417c084234c2da73/shutil.py
os.utime(dst, (st[stat.ST_ATIME], st[stat.ST_MTIME])) os.chmod(dst, mode)
if hasattr(os, 'utime'): os.utime(dst, (st[stat.ST_ATIME], st[stat.ST_MTIME])) if hasattr(os, 'chmod'): os.chmod(dst, mode)
def copystat(src, dst): """Copy all stat info (mode bits, atime and mtime) from src to dst""" st = os.stat(src) mode = stat.S_IMODE(st[stat.ST_MODE]) os.utime(dst, (st[stat.ST_ATIME], st[stat.ST_MTIME])) os.chmod(dst, mode)
0c94724cc77a004973fb0105417c084234c2da73 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0c94724cc77a004973fb0105417c084234c2da73/shutil.py
if (rframe is frame) and rcur:
if (rframe is not frame) and rcur:
def trace_dispatch_exception(self, frame, t): rt, rtt, rct, rfn, rframe, rcur = self.cur if (rframe is frame) and rcur: return self.trace_dispatch_return(rframe, t) return 0
a0bc9993e77afc32660082a392f9af7fef428648 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a0bc9993e77afc32660082a392f9af7fef428648/profile.py
hdrfields = string.split(hdr)
hdrfields = hdr.split(" ", 2)
def decode(in_file, out_file=None, mode=None): """Decode uuencoded file""" # # Open the input file, if needed. # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): in_file = open(in_file) # # Read until a begin is encountered or we've exhausted the file # while 1: hdr = in_file.readline() if not hdr: raise Error, 'No valid begin line found in input file' if hdr[:5] != 'begin': continue hdrfields = string.split(hdr) if len(hdrfields) == 3 and hdrfields[0] == 'begin': try: string.atoi(hdrfields[1], 8) break except ValueError: pass if out_file is None: out_file = hdrfields[2] if mode is None: mode = string.atoi(hdrfields[1], 8) # # Open the output file # if out_file == '-': out_file = sys.stdout elif type(out_file) == type(''): fp = open(out_file, 'wb') try: os.path.chmod(out_file, mode) except AttributeError: pass out_file = fp # # Main decoding loop # s = in_file.readline() while s and s != 'end\n': try: data = binascii.a2b_uu(s) except binascii.Error, v: # Workaround for broken uuencoders by /Fredrik Lundh nbytes = (((ord(s[0])-32) & 63) * 4 + 5) / 3 data = binascii.a2b_uu(s[:nbytes]) sys.stderr.write("Warning: %s\n" % str(v)) out_file.write(data) s = in_file.readline() if not str: raise Error, 'Truncated input file'
62c11155eb13e950e10d660b8f5150e04efb3a5e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/62c11155eb13e950e10d660b8f5150e04efb3a5e/uu.py
string.atoi(hdrfields[1], 8)
int(hdrfields[1], 8)
def decode(in_file, out_file=None, mode=None): """Decode uuencoded file""" # # Open the input file, if needed. # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): in_file = open(in_file) # # Read until a begin is encountered or we've exhausted the file # while 1: hdr = in_file.readline() if not hdr: raise Error, 'No valid begin line found in input file' if hdr[:5] != 'begin': continue hdrfields = string.split(hdr) if len(hdrfields) == 3 and hdrfields[0] == 'begin': try: string.atoi(hdrfields[1], 8) break except ValueError: pass if out_file is None: out_file = hdrfields[2] if mode is None: mode = string.atoi(hdrfields[1], 8) # # Open the output file # if out_file == '-': out_file = sys.stdout elif type(out_file) == type(''): fp = open(out_file, 'wb') try: os.path.chmod(out_file, mode) except AttributeError: pass out_file = fp # # Main decoding loop # s = in_file.readline() while s and s != 'end\n': try: data = binascii.a2b_uu(s) except binascii.Error, v: # Workaround for broken uuencoders by /Fredrik Lundh nbytes = (((ord(s[0])-32) & 63) * 4 + 5) / 3 data = binascii.a2b_uu(s[:nbytes]) sys.stderr.write("Warning: %s\n" % str(v)) out_file.write(data) s = in_file.readline() if not str: raise Error, 'Truncated input file'
62c11155eb13e950e10d660b8f5150e04efb3a5e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/62c11155eb13e950e10d660b8f5150e04efb3a5e/uu.py
out_file = hdrfields[2]
out_file = hdrfields[2].rstrip()
def decode(in_file, out_file=None, mode=None): """Decode uuencoded file""" # # Open the input file, if needed. # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): in_file = open(in_file) # # Read until a begin is encountered or we've exhausted the file # while 1: hdr = in_file.readline() if not hdr: raise Error, 'No valid begin line found in input file' if hdr[:5] != 'begin': continue hdrfields = string.split(hdr) if len(hdrfields) == 3 and hdrfields[0] == 'begin': try: string.atoi(hdrfields[1], 8) break except ValueError: pass if out_file is None: out_file = hdrfields[2] if mode is None: mode = string.atoi(hdrfields[1], 8) # # Open the output file # if out_file == '-': out_file = sys.stdout elif type(out_file) == type(''): fp = open(out_file, 'wb') try: os.path.chmod(out_file, mode) except AttributeError: pass out_file = fp # # Main decoding loop # s = in_file.readline() while s and s != 'end\n': try: data = binascii.a2b_uu(s) except binascii.Error, v: # Workaround for broken uuencoders by /Fredrik Lundh nbytes = (((ord(s[0])-32) & 63) * 4 + 5) / 3 data = binascii.a2b_uu(s[:nbytes]) sys.stderr.write("Warning: %s\n" % str(v)) out_file.write(data) s = in_file.readline() if not str: raise Error, 'Truncated input file'
62c11155eb13e950e10d660b8f5150e04efb3a5e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/62c11155eb13e950e10d660b8f5150e04efb3a5e/uu.py
mode = string.atoi(hdrfields[1], 8)
mode = int(hdrfields[1], 8)
def decode(in_file, out_file=None, mode=None): """Decode uuencoded file""" # # Open the input file, if needed. # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): in_file = open(in_file) # # Read until a begin is encountered or we've exhausted the file # while 1: hdr = in_file.readline() if not hdr: raise Error, 'No valid begin line found in input file' if hdr[:5] != 'begin': continue hdrfields = string.split(hdr) if len(hdrfields) == 3 and hdrfields[0] == 'begin': try: string.atoi(hdrfields[1], 8) break except ValueError: pass if out_file is None: out_file = hdrfields[2] if mode is None: mode = string.atoi(hdrfields[1], 8) # # Open the output file # if out_file == '-': out_file = sys.stdout elif type(out_file) == type(''): fp = open(out_file, 'wb') try: os.path.chmod(out_file, mode) except AttributeError: pass out_file = fp # # Main decoding loop # s = in_file.readline() while s and s != 'end\n': try: data = binascii.a2b_uu(s) except binascii.Error, v: # Workaround for broken uuencoders by /Fredrik Lundh nbytes = (((ord(s[0])-32) & 63) * 4 + 5) / 3 data = binascii.a2b_uu(s[:nbytes]) sys.stderr.write("Warning: %s\n" % str(v)) out_file.write(data) s = in_file.readline() if not str: raise Error, 'Truncated input file'
62c11155eb13e950e10d660b8f5150e04efb3a5e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/62c11155eb13e950e10d660b8f5150e04efb3a5e/uu.py
self.sock.send(str)
sendptr = 0 while sendptr < len(str): sendptr = sendptr + self.sock.send(str[sendptr:])
def send(self, str): """Send `str' to the server.""" if self.debuglevel > 0: print 'send:', `str` if self.sock: try: self.sock.send(str) except socket.error: raise SMTPServerDisconnected('Server not connected') else: raise SMTPServerDisconnected('please run connect() first')
5bf94a0b772276548781ec6c29c3bd1cc96115d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5bf94a0b772276548781ec6c29c3bd1cc96115d7/smtplib.py
except SyntaxWarning, msg: print "got SyntaxWarning as expected"
except SyntaxError, msg: print "got SyntaxError as expected"
def compile_and_catch_warning(text): try: compile(text, "<test code>", "exec") except SyntaxWarning, msg: print "got SyntaxWarning as expected" else: print "expected SyntaxWarning"
150a6640f5f63d2dd32e823b619b6afdf3d1b8c1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/150a6640f5f63d2dd32e823b619b6afdf3d1b8c1/test_global.py
print "expected SyntaxWarning"
print "expected SyntaxError"
def compile_and_catch_warning(text): try: compile(text, "<test code>", "exec") except SyntaxWarning, msg: print "got SyntaxWarning as expected" else: print "expected SyntaxWarning"
150a6640f5f63d2dd32e823b619b6afdf3d1b8c1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/150a6640f5f63d2dd32e823b619b6afdf3d1b8c1/test_global.py
if os.name == "posix": check_environ() sys_dir = os.path.dirname(sys.modules['distutils'].__file__) sys_file = os.path.join(sys_dir, "pydistutils.cfg") if os.path.isfile(sys_file): files.append(sys_file) user_file = os.path.join(os.environ.get('HOME'), ".pydistutils.cfg")
check_environ() if os.name=='posix': sys_dir = os.path.dirname(sys.modules['distutils'].__file__) user_filename = ".pydistutils.cfg" else: sys_dir = sysconfig.PREFIX user_filename = "pydistutils.cfg" sys_file = os.path.join(sys_dir, "pydistutils.cfg") if os.path.isfile(sys_file): files.append(sys_file) if os.environ.has_key('HOME'): user_file = os.path.join(os.environ.get('HOME'), user_filename)
def find_config_files (self): """Find as many configuration files as should be processed for this platform, and return a list of filenames in the order in which they should be parsed. The filenames returned are guaranteed to exist (modulo nasty race conditions).
acf3f6a7000eaed43f8c4e5df249967b06dfc474 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/acf3f6a7000eaed43f8c4e5df249967b06dfc474/dist.py
else: sys_file = os.path.join (sysconfig.PREFIX, "pydistutils.cfg") if os.path.isfile(sys_file): files.append(sys_file)
def find_config_files (self): """Find as many configuration files as should be processed for this platform, and return a list of filenames in the order in which they should be parsed. The filenames returned are guaranteed to exist (modulo nasty race conditions).
acf3f6a7000eaed43f8c4e5df249967b06dfc474 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/acf3f6a7000eaed43f8c4e5df249967b06dfc474/dist.py
exc_type, exc_val, exc_tb = sys.exc_info()
exc_type, exc_val = sys.exc_info()[:2]
def _run_examples_inner(out, fakeout, examples, globs, verbose, name): import sys, traceback OK, BOOM, FAIL = range(3) NADA = "nothing" stderr = _SpoofOut() failures = 0 for source, want, lineno in examples: if verbose: _tag_out(out, ("Trying", source), ("Expecting", want or NADA)) fakeout.clear() try: exec compile(source, "<string>", "single") in globs got = fakeout.get() state = OK except: # See whether the exception was expected. if want.find("Traceback (innermost last):\n") == 0 or \ want.find("Traceback (most recent call last):\n") == 0: # Only compare exception type and value - the rest of # the traceback isn't necessary. want = want.split('\n')[-2] + '\n' exc_type, exc_val, exc_tb = sys.exc_info() got = traceback.format_exception_only(exc_type, exc_val)[-1] state = OK else: # unexpected exception stderr.clear() traceback.print_exc(file=stderr) state = BOOM if state == OK: if got == want: if verbose: out("ok\n") continue state = FAIL assert state in (FAIL, BOOM) failures = failures + 1 out("*" * 65 + "\n") _tag_out(out, ("Failure in example", source)) out("from line #" + `lineno` + " of " + name + "\n") if state == FAIL: _tag_out(out, ("Expected", want or NADA), ("Got", got)) else: assert state == BOOM _tag_out(out, ("Exception raised", stderr.get())) return failures, len(examples)
77f2d504c3891ff7f75d1e50d12b4cdb30e89767 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77f2d504c3891ff7f75d1e50d12b4cdb30e89767/doctest.py
pid, sts = os.wait(G.busy, options)
pid, sts = os.waitpid(G.busy, options)
def waitchild(options): pid, sts = os.wait(G.busy, options) if pid == G.busy: G.busy = 0 G.stop.enable(0)
3dc44aba71305cd9be8cba7703a96b6528f34169 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3dc44aba71305cd9be8cba7703a96b6528f34169/jukebox.py
"could not extract parameter group: " + `line`)
"could not extract parameter %s for %s: %s" % (attrname, macroname, `line[:100]`))
def subconvert(line, ofp, table, discards, autoclosing, knownempty, endchar=None): stack = [] while line: if line[0] == endchar and not stack: return line[1:] m = _comment_rx.match(line) if m: text = m.group(1) if text: ofp.write("(COMMENT\n") ofp.write("- %s \n" % encode(text)) ofp.write(")COMMENT\n") ofp.write("-\\n\n") else: ofp.write("-\\n\n") line = line[m.end():] continue m = _begin_env_rx.match(line) if m: # re-write to use the macro handler line = r"\%s %s" % (m.group(1), line[m.end():]) continue m =_end_env_rx.match(line) if m: # end of environment envname = m.group(1) if envname == "document": # special magic for n in stack[1:]: if n not in autoclosing: raise LaTeXFormatError("open element on stack: " + `n`) # should be more careful, but this is easier to code: stack = [] ofp.write(")document\n") elif envname == stack[-1]: ofp.write(")%s\n" % envname) del stack[-1] else: raise LaTeXFormatError("environment close doesn't match") line = line[m.end():] continue m = _begin_macro_rx.match(line) if m: # start of macro macroname = m.group(1) if macroname == "verbatim": # really magic case! pos = string.find(line, "\\end{verbatim}") text = line[m.end(1):pos] ofp.write("(verbatim\n") ofp.write("-%s\n" % encode(text)) ofp.write(")verbatim\n") line = line[pos + len("\\end{verbatim}"):] continue numbered = 1 if macroname[-1] == "*": macroname = macroname[:-1] numbered = 0 if macroname in autoclosing and macroname in stack: while stack[-1] != macroname: if stack[-1] and stack[-1] not in discards: ofp.write(")%s\n-\\n\n" % stack[-1]) del stack[-1] if macroname not in discards: ofp.write("-\\n\n)%s\n-\\n\n" % macroname) del stack[-1] real_ofp = ofp if macroname in discards: ofp = StringIO.StringIO() # conversion = table.get(macroname, ([], 0, 0)) params, optional, empty = conversion empty = empty or knownempty(macroname) if empty: ofp.write("e\n") if not numbered: ofp.write("Anumbered TOKEN no\n") # rip off the macroname if params: if optional and len(params) == 1: line = line = line[m.end():] else: line = line[m.end(1):] elif empty: line = line[m.end(1):] else: line = line[m.end():] # # Very ugly special case to deal with \item[]. The catch is that # this needs to occur outside the for loop that handles attribute # parsing so we can 'continue' the outer loop. # if optional and type(params[0]) is type(()): # the attribute name isn't used in this special case stack.append(macroname) ofp.write("(%s\n" % macroname) m = _start_optional_rx.match(line) if m: line = line[m.end():] line = subconvert(line, ofp, table, discards, autoclosing, knownempty, endchar="]") line = "}" + line continue # handle attribute mappings here: for attrname in params: if optional: optional = 0 if type(attrname) is type(""): m = _optional_rx.match(line) if m: line = line[m.end():] ofp.write("A%s TOKEN %s\n" % (attrname, encode(m.group(1)))) elif type(attrname) is type(()): # This is a sub-element; but don't place the # element we found on the stack (\section-like) stack.append(macroname) ofp.write("(%s\n" % macroname) macroname = attrname[0] m = _start_group_rx.match(line) if m: line = line[m.end():] elif type(attrname) is type([]): # A normal subelement. attrname = attrname[0] stack.append(macroname) stack.append(attrname) ofp.write("(%s\n" % macroname) macroname = attrname else: m = _parameter_rx.match(line) if not m: raise LaTeXFormatError( "could not extract parameter group: " + `line`) value = m.group(1) if _token_rx.match(value): dtype = "TOKEN" else: dtype = "CDATA" ofp.write("A%s %s %s\n" % (attrname, dtype, encode(value))) line = line[m.end():] stack.append(macroname) ofp.write("(%s\n" % macroname) if empty: line = "}" + line ofp = real_ofp continue if line[0] == "}": # end of macro macroname = stack[-1] conversion = table.get(macroname) if macroname \ and macroname not in discards \ and type(conversion) is not type(""): # otherwise, it was just a bare group ofp.write(")%s\n" % stack[-1]) del stack[-1] line = line[1:] continue if line[0] == "{": stack.append("") line = line[1:] continue if line[0] == "\\" and line[1] in ESCAPED_CHARS: ofp.write("-%s\n" % encode(line[1])) line = line[2:] continue if line[:2] == r"\\": ofp.write("(BREAK\n)BREAK\n") line = line[2:] continue m = _text_rx.match(line) if m: text = encode(m.group()) ofp.write("-%s\n" % text) line = line[m.end():] continue # special case because of \item[] if line[0] == "]": ofp.write("-]\n") line = line[1:] continue # avoid infinite loops extra = "" if len(line) > 100: extra = "..." raise LaTeXFormatError("could not identify markup: %s%s" % (`line[:100]`, extra))
bbd7509dbe6865e8f74d155c6f149b27828361d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bbd7509dbe6865e8f74d155c6f149b27828361d7/latex2esis.py
if not callable(callback): callback = print_line
if callback is None: callback = print_line
def retrlines(self, cmd, callback = None): '''Retrieve data in line mode. The argument is a RETR or LIST command. The callback function (2nd argument) is called for each line, with trailing CRLF stripped. This creates a new port for you. print_line() is the default callback.''' if not callable(callback): callback = print_line resp = self.sendcmd('TYPE A') conn = self.transfercmd(cmd) fp = conn.makefile('rb') while 1: line = fp.readline() if self.debugging > 2: print '*retr*', `line` if not line: break if line[-2:] == CRLF: line = line[:-2] elif line[-1:] == '\n': line = line[:-1] callback(line) fp.close() conn.close() return self.voidresp()
e874fc304e0ea29fc9608023b3f153b566e0acef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e874fc304e0ea29fc9608023b3f153b566e0acef/ftplib.py
self.packageRootFolder = root
self.sourceFolder = root
def build(self, root, resources=None, **options): """Create a package for some given root folder.
997429a5f47037de601ff9bd7d4bd4b538927106 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/997429a5f47037de601ff9bd7d4bd4b538927106/buildpkg.py
self.packageResourceFolder = root
self.resourceFolder = root else: self.resourceFolder = resources
def build(self, root, resources=None, **options): """Create a package for some given root folder.
997429a5f47037de601ff9bd7d4bd4b538927106 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/997429a5f47037de601ff9bd7d4bd4b538927106/buildpkg.py
elif not k in ["OutputDir"]: raise Error, "Unknown package option: %s" % k outputdir = options.get("OutputDir", os.getcwd()) packageName = self.packageInfo["Title"] self.PackageRootFolder = os.path.join(outputdir, packageName + ".pkg")
def build(self, root, resources=None, **options): """Create a package for some given root folder.
997429a5f47037de601ff9bd7d4bd4b538927106 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/997429a5f47037de601ff9bd7d4bd4b538927106/buildpkg.py
packageName = self.packageInfo["Title"] rootFolder = packageName + ".pkg" contFolder = join(rootFolder, "Contents") resourceFolder = join(contFolder, "Resources") os.mkdir(rootFolder)
contFolder = join(self.PackageRootFolder, "Contents") self.packageResourceFolder = join(contFolder, "Resources") os.mkdir(self.PackageRootFolder)
def _makeFolders(self): "Create package folder structure."
997429a5f47037de601ff9bd7d4bd4b538927106 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/997429a5f47037de601ff9bd7d4bd4b538927106/buildpkg.py
os.mkdir(resourceFolder) self.resourceFolder = resourceFolder
os.mkdir(self.packageResourceFolder)
def _makeFolders(self): "Create package folder structure."
997429a5f47037de601ff9bd7d4bd4b538927106 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/997429a5f47037de601ff9bd7d4bd4b538927106/buildpkg.py