rem
stringlengths 1
322k
| add
stringlengths 0
2.05M
| context
stringlengths 4
228k
| meta
stringlengths 156
215
|
---|---|---|---|
def write(self, s): # Override base class write self.tkconsole.console.write(s) | da7b9c92feedbd56478e5ce885bb5ba812478f4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/da7b9c92feedbd56478e5ce885bb5ba812478f4a/PyShell.py |
||
self.fileobj.write(struct.pack("<L", self.pos)) | self.fileobj.write(struct.pack("<L", self.pos & 0xffffFFFFL)) | def close(self): """Close the _Stream object. No operation should be done on it afterwards. """ if self.closed: return | fa94ed634bdb3105cc30589284474c78315d2069 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fa94ed634bdb3105cc30589284474c78315d2069/tarfile.py |
"""bsdTableDB.open(filename, dbhome, create=0, truncate=0, mode=0600) | """bsdTableDB(filename, dbhome, create=0, truncate=0, mode=0600) | def __init__(self, filename, dbhome, create=0, truncate=0, mode=0600, recover=0, dbflags=0): """bsdTableDB.open(filename, dbhome, create=0, truncate=0, mode=0600) Open database name in the dbhome BerkeleyDB directory. Use keyword arguments when calling this constructor. """ self.db = None myflags = DB_THREAD if create: myflags |= DB_CREATE flagsforenv = (DB_INIT_MPOOL | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN | dbflags) # DB_AUTO_COMMIT isn't a valid flag for env.open() try: dbflags |= DB_AUTO_COMMIT except AttributeError: pass if recover: flagsforenv = flagsforenv | DB_RECOVER self.env = DBEnv() # enable auto deadlock avoidance self.env.set_lk_detect(DB_LOCK_DEFAULT) self.env.open(dbhome, myflags | flagsforenv) if truncate: myflags |= DB_TRUNCATE self.db = DB(self.env) # this code relies on DBCursor.set* methods to raise exceptions # rather than returning None self.db.set_get_returns_none(1) # allow duplicate entries [warning: be careful w/ metadata] self.db.set_flags(DB_DUP) self.db.open(filename, DB_BTREE, dbflags | myflags, mode) self.dbfilename = filename # Initialize the table names list if this is a new database txn = self.env.txn_begin() try: if not self.db.has_key(_table_names_key, txn): self.db.put(_table_names_key, pickle.dumps([], 1), txn=txn) # Yes, bare except except: txn.abort() raise else: txn.commit() # TODO verify more of the database's metadata? self.__tablecolumns = {} | 1953a7405024a0548dde1705171b2008920216d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1953a7405024a0548dde1705171b2008920216d7/dbtables.py |
"""CreateTable(table, columns) - Create a new table in the database | """CreateTable(table, columns) - Create a new table in the database. | def CreateTable(self, table, columns): """CreateTable(table, columns) - Create a new table in the database raises TableDBError if it already exists or for other DB errors. """ assert isinstance(columns, ListType) txn = None try: # checking sanity of the table and column names here on # table creation will prevent problems elsewhere. if contains_metastrings(table): raise ValueError( "bad table name: contains reserved metastrings") for column in columns : if contains_metastrings(column): raise ValueError( "bad column name: contains reserved metastrings") | 1953a7405024a0548dde1705171b2008920216d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1953a7405024a0548dde1705171b2008920216d7/dbtables.py |
- Create a new table in the database. | Create a new table in the database. | def CreateOrExtendTable(self, table, columns): """CreateOrExtendTable(table, columns) | 1953a7405024a0548dde1705171b2008920216d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1953a7405024a0548dde1705171b2008920216d7/dbtables.py |
"""Modify(table, conditions) - Modify in rows matching 'conditions' using mapping functions in 'mappings' * conditions is a dictionary keyed on column names containing condition functions expecting the data string as an argument and returning a boolean. * mappings is a dictionary keyed on column names containint condition functions expecting the data string as an argument and returning the new string for that column. | """Modify(table, conditions={}, mappings={}) - Modify items in rows matching 'conditions' using mapping functions in 'mappings' * table - the table name * conditions - a dictionary keyed on column names containing a condition callable expecting the data string as an argument and returning a boolean. * mappings - a dictionary keyed on column names containing a condition callable expecting the data string as an argument and returning the new string for that column. | def Modify(self, table, conditions={}, mappings={}): """Modify(table, conditions) - Modify in rows matching 'conditions' using mapping functions in 'mappings' * conditions is a dictionary keyed on column names containing condition functions expecting the data string as an argument and returning a boolean. * mappings is a dictionary keyed on column names containint condition functions expecting the data string as an argument and returning the new string for that column. """ try: matching_rowids = self.__Select(table, [], conditions) | 1953a7405024a0548dde1705171b2008920216d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1953a7405024a0548dde1705171b2008920216d7/dbtables.py |
except DBError, dberror: | except: | def Modify(self, table, conditions={}, mappings={}): """Modify(table, conditions) - Modify in rows matching 'conditions' using mapping functions in 'mappings' * conditions is a dictionary keyed on column names containing condition functions expecting the data string as an argument and returning a boolean. * mappings is a dictionary keyed on column names containint condition functions expecting the data string as an argument and returning the new string for that column. """ try: matching_rowids = self.__Select(table, [], conditions) | 1953a7405024a0548dde1705171b2008920216d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1953a7405024a0548dde1705171b2008920216d7/dbtables.py |
* conditions is a dictionary keyed on column names containing condition functions expecting the data string as an argument and returning a boolean. | * conditions - a dictionary keyed on column names containing condition functions expecting the data string as an argument and returning a boolean. | def Delete(self, table, conditions={}): """Delete(table, conditions) - Delete items matching the given conditions from the table. * conditions is a dictionary keyed on column names containing condition functions expecting the data string as an argument and returning a boolean. """ try: matching_rowids = self.__Select(table, [], conditions) | 1953a7405024a0548dde1705171b2008920216d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1953a7405024a0548dde1705171b2008920216d7/dbtables.py |
"""Select(table, conditions) - retrieve specific row data | """Select(table, columns, conditions) - retrieve specific row data | def Select(self, table, columns, conditions={}): """Select(table, conditions) - retrieve specific row data Returns a list of row column->value mapping dictionaries. * columns is a list of which column data to return. If columns is None, all columns will be returned. * conditions is a dictionary keyed on column names containing callable conditions expecting the data string as an argument and returning a boolean. """ try: if not self.__tablecolumns.has_key(table): self.__load_column_info(table) if columns is None: columns = self.__tablecolumns[table] matching_rowids = self.__Select(table, columns, conditions) except DBError, dberror: raise TableDBError, dberror[1] # return the matches as a list of dictionaries return matching_rowids.values() | 1953a7405024a0548dde1705171b2008920216d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1953a7405024a0548dde1705171b2008920216d7/dbtables.py |
* columns is a list of which column data to return. If | * columns - a list of which column data to return. If | def Select(self, table, columns, conditions={}): """Select(table, conditions) - retrieve specific row data Returns a list of row column->value mapping dictionaries. * columns is a list of which column data to return. If columns is None, all columns will be returned. * conditions is a dictionary keyed on column names containing callable conditions expecting the data string as an argument and returning a boolean. """ try: if not self.__tablecolumns.has_key(table): self.__load_column_info(table) if columns is None: columns = self.__tablecolumns[table] matching_rowids = self.__Select(table, columns, conditions) except DBError, dberror: raise TableDBError, dberror[1] # return the matches as a list of dictionaries return matching_rowids.values() | 1953a7405024a0548dde1705171b2008920216d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1953a7405024a0548dde1705171b2008920216d7/dbtables.py |
* conditions is a dictionary keyed on column names | * conditions - a dictionary keyed on column names | def Select(self, table, columns, conditions={}): """Select(table, conditions) - retrieve specific row data Returns a list of row column->value mapping dictionaries. * columns is a list of which column data to return. If columns is None, all columns will be returned. * conditions is a dictionary keyed on column names containing callable conditions expecting the data string as an argument and returning a boolean. """ try: if not self.__tablecolumns.has_key(table): self.__load_column_info(table) if columns is None: columns = self.__tablecolumns[table] matching_rowids = self.__Select(table, columns, conditions) except DBError, dberror: raise TableDBError, dberror[1] # return the matches as a list of dictionaries return matching_rowids.values() | 1953a7405024a0548dde1705171b2008920216d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1953a7405024a0548dde1705171b2008920216d7/dbtables.py |
try: printable = value is None or not str(value) except: printable = False if printable: | valuestr = _some_str(value) if value is None or not valuestr: | def _format_final_exc_line(etype, value): """Return a list of a single line -- normal case for format_exception_only""" try: printable = value is None or not str(value) except: printable = False if printable: line = "%s\n" % etype else: line = "%s: %s\n" % (etype, _some_str(value)) return line | 988b47b6fb342b4e3f79391d570f190e595a2836 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/988b47b6fb342b4e3f79391d570f190e595a2836/traceback.py |
line = "%s: %s\n" % (etype, _some_str(value)) | line = "%s: %s\n" % (etype, valuestr) | def _format_final_exc_line(etype, value): """Return a list of a single line -- normal case for format_exception_only""" try: printable = value is None or not str(value) except: printable = False if printable: line = "%s\n" % etype else: line = "%s: %s\n" % (etype, _some_str(value)) return line | 988b47b6fb342b4e3f79391d570f190e595a2836 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/988b47b6fb342b4e3f79391d570f190e595a2836/traceback.py |
class _Environ(UserDict.UserDict): | class _Environ(UserDict.IterableUserDict): | def unsetenv(key): putenv(key, "") | e74c5ff780c10cd35cd29d5a58d799c8ea85b31c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e74c5ff780c10cd35cd29d5a58d799c8ea85b31c/os.py |
uchunks = [unicode(s, str(charset)) for s, charset in self._chunks] return u''.join(uchunks) | uchunks = [] lastcs = None for s, charset in self._chunks: nextcs = charset if uchunks: if lastcs is not None: if nextcs is None or nextcs == 'us-ascii': uchunks.append(USPACE) nextcs = None elif nextcs is not None and nextcs <> 'us-ascii': uchunks.append(USPACE) lastcs = nextcs uchunks.append(unicode(s, str(charset))) return UEMPTYSTRING.join(uchunks) | def __unicode__(self): """Helper for the built-in unicode function.""" # charset item is a Charset instance so we need to stringify it. uchunks = [unicode(s, str(charset)) for s, charset in self._chunks] return u''.join(uchunks) | c1ab8b3d8649d387bad4c5de5932f2afde14216b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c1ab8b3d8649d387bad4c5de5932f2afde14216b/Header.py |
def test_main(): test.test_support.run_unittest(BuiltinTest, TestSorted) | def test_main(verbose=None): test_classes = (BuiltinTest, TestSorted) run_unittest(*test_classes) if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in xrange(len(counts)): run_unittest(*test_classes) gc.collect() counts[i] = sys.gettotalrefcount() print counts | def test_main(): test.test_support.run_unittest(BuiltinTest, TestSorted) | 89c6ad986d7fe61560d046dee0a270b93466b02b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/89c6ad986d7fe61560d046dee0a270b93466b02b/test_builtin.py |
test_main() | test_main(verbose=True) | def test_main(): test.test_support.run_unittest(BuiltinTest, TestSorted) | 89c6ad986d7fe61560d046dee0a270b93466b02b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/89c6ad986d7fe61560d046dee0a270b93466b02b/test_builtin.py |
self._color = color | self._set_color(color) | def color(self, *args): if not args: raise Error, "no color arguments" if len(args) == 1: color = args[0] if type(color) == type(""): # Test the color first try: id = self._canvas.create_line(0, 0, 0, 0, fill=color) except Tkinter.TclError: raise Error, "bad color string: %s" % `color` self._color = color return try: r, g, b = color except: raise Error, "bad color sequence: %s" % `color` else: try: r, g, b = args except: raise Error, "bad color arguments: %s" % `args` assert 0 <= r <= 1 assert 0 <= g <= 1 assert 0 <= b <= 1 x = 255.0 y = 0.5 self._color = "#%02x%02x%02x" % (int(r*x+y), int(g*x+y), int(b*x+y)) | 1171524d5e42a034eb78910abbcfc78ee00546d6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1171524d5e42a034eb78910abbcfc78ee00546d6/turtle.py |
self._color = " | self._set_color(" def _set_color(self,color): self._color = color self._draw_turtle() | def color(self, *args): if not args: raise Error, "no color arguments" if len(args) == 1: color = args[0] if type(color) == type(""): # Test the color first try: id = self._canvas.create_line(0, 0, 0, 0, fill=color) except Tkinter.TclError: raise Error, "bad color string: %s" % `color` self._color = color return try: r, g, b = color except: raise Error, "bad color sequence: %s" % `color` else: try: r, g, b = args except: raise Error, "bad color arguments: %s" % `args` assert 0 <= r <= 1 assert 0 <= g <= 1 assert 0 <= b <= 1 x = 255.0 y = 0.5 self._color = "#%02x%02x%02x" % (int(r*x+y), int(g*x+y), int(b*x+y)) | 1171524d5e42a034eb78910abbcfc78ee00546d6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1171524d5e42a034eb78910abbcfc78ee00546d6/turtle.py |
if self._tracing: | if self._tracing: | def _goto(self, x1, y1): x0, y0 = start = self._position self._position = map(float, (x1, y1)) if self._filling: self._path.append(self._position) if self._drawing: if self._tracing: dx = float(x1 - x0) dy = float(y1 - y0) distance = hypot(dx, dy) nhops = int(distance) item = self._canvas.create_line(x0, y0, x0, y0, width=self._width, arrow="last", capstyle="round", fill=self._color) try: for i in range(1, 1+nhops): x, y = x0 + dx*i/nhops, y0 + dy*i/nhops self._canvas.coords(item, x0, y0, x, y) self._canvas.update() self._canvas.after(10) # in case nhops==0 self._canvas.coords(item, x0, y0, x1, y1) self._canvas.itemconfigure(item, arrow="none") except Tkinter.TclError: # Probably the window was closed! return else: item = self._canvas.create_line(x0, y0, x1, y1, width=self._width, capstyle="round", fill=self._color) self._items.append(item) | 1171524d5e42a034eb78910abbcfc78ee00546d6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1171524d5e42a034eb78910abbcfc78ee00546d6/turtle.py |
arrow="last", | def _goto(self, x1, y1): x0, y0 = start = self._position self._position = map(float, (x1, y1)) if self._filling: self._path.append(self._position) if self._drawing: if self._tracing: dx = float(x1 - x0) dy = float(y1 - y0) distance = hypot(dx, dy) nhops = int(distance) item = self._canvas.create_line(x0, y0, x0, y0, width=self._width, arrow="last", capstyle="round", fill=self._color) try: for i in range(1, 1+nhops): x, y = x0 + dx*i/nhops, y0 + dy*i/nhops self._canvas.coords(item, x0, y0, x, y) self._canvas.update() self._canvas.after(10) # in case nhops==0 self._canvas.coords(item, x0, y0, x1, y1) self._canvas.itemconfigure(item, arrow="none") except Tkinter.TclError: # Probably the window was closed! return else: item = self._canvas.create_line(x0, y0, x1, y1, width=self._width, capstyle="round", fill=self._color) self._items.append(item) | 1171524d5e42a034eb78910abbcfc78ee00546d6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1171524d5e42a034eb78910abbcfc78ee00546d6/turtle.py |
|
sys.stderr = StringIO() self.assertRaises(self.parser.parse_args, (cmdline_args,), None, SystemExit, expected_output, self.redirected_stderr) sys.stderr = sys.__stderr__ | save_stderr = sys.stderr try: sys.stderr = StringIO() self.assertRaises(self.parser.parse_args, (cmdline_args,), None, SystemExit, expected_output, self.redirected_stderr) finally: sys.stderr = save_stderr | def assertParseFail(self, cmdline_args, expected_output): """Assert the parser fails with the expected message.""" sys.stderr = StringIO() self.assertRaises(self.parser.parse_args, (cmdline_args,), None, SystemExit, expected_output, self.redirected_stderr) sys.stderr = sys.__stderr__ | 54b934e963d7972f62c3625b723cb51a21647124 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/54b934e963d7972f62c3625b723cb51a21647124/test_optparse.py |
sys.stdout = StringIO() self.assertRaises(self.parser.parse_args, (cmdline_args,), None, SystemExit, expected_output, self.redirected_stdout) sys.stdout = sys.__stdout__ | save_stdout = sys.stdout try: sys.stdout = StringIO() self.assertRaises(self.parser.parse_args, (cmdline_args,), None, SystemExit, expected_output, self.redirected_stdout) finally: sys.stdout = save_stdout | def assertStdoutEquals(self, cmdline_args, expected_output): """Assert the parser prints the expected output on stdout.""" sys.stdout = StringIO() self.assertRaises(self.parser.parse_args, (cmdline_args,), None, SystemExit, expected_output, self.redirected_stdout) sys.stdout = sys.__stdout__ | 54b934e963d7972f62c3625b723cb51a21647124 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/54b934e963d7972f62c3625b723cb51a21647124/test_optparse.py |
sys.argv[0] = "/foo/bar/baz.py" parser = OptionParser("usage: %prog ...", version="%prog 1.2") expected_usage = "usage: baz.py ...\n" self.assertUsage(parser, expected_usage) self.assertVersion(parser, "baz.py 1.2") self.assertHelp(parser, expected_usage + "\n" + "options:\n" " --version show program's version number and exit\n" " -h, --help show this help message and exit\n") | save_argv = sys.argv[:] try: sys.argv[0] = "/foo/bar/baz.py" parser = OptionParser("usage: %prog ...", version="%prog 1.2") expected_usage = "usage: baz.py ...\n" self.assertUsage(parser, expected_usage) self.assertVersion(parser, "baz.py 1.2") self.assertHelp(parser, expected_usage + "\n" + "options:\n" " --version show program's version number and exit\n" " -h, --help show this help message and exit\n") finally: sys.argv[:] = save_argv | def test_default_progname(self): # Make sure that program name taken from sys.argv[0] by default. sys.argv[0] = "/foo/bar/baz.py" parser = OptionParser("usage: %prog ...", version="%prog 1.2") expected_usage = "usage: baz.py ...\n" self.assertUsage(parser, expected_usage) self.assertVersion(parser, "baz.py 1.2") self.assertHelp(parser, expected_usage + "\n" + "options:\n" " --version show program's version number and exit\n" " -h, --help show this help message and exit\n") | 54b934e963d7972f62c3625b723cb51a21647124 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/54b934e963d7972f62c3625b723cb51a21647124/test_optparse.py |
updated is a tuple naming the attributes off the wrapper that | updated is a tuple naming the attributes of the wrapper that | def update_wrapper(wrapper, wrapped, assigned = WRAPPER_ASSIGNMENTS, updated = WRAPPER_UPDATES): """Update a wrapper function to look like the wrapped function wrapper is the function to be updated wrapped is the original function assigned is a tuple naming the attributes assigned directly from the wrapped function to the wrapper function (defaults to functools.WRAPPER_ASSIGNMENTS) updated is a tuple naming the attributes off the wrapper that are updated with the corresponding attribute from the wrapped function (defaults to functools.WRAPPER_UPDATES) """ for attr in assigned: setattr(wrapper, attr, getattr(wrapped, attr)) for attr in updated: getattr(wrapper, attr).update(getattr(wrapped, attr)) # Return the wrapper so this can be used as a decorator via partial() return wrapper | a58611c7583aa7a5f8d1db54b30006e4d7d9deec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a58611c7583aa7a5f8d1db54b30006e4d7d9deec/functools.py |
bp = bdb.Breakpoint.bpbynumber[int(i)] | try: i = int(i) except ValueError: print 'Breakpoint index %r is not a number' % i continue if not (0 <= i < len(bdb.Breakpoint.bpbynumber)): print 'No breakpoint numbered', i continue bp = bdb.Breakpoint.bpbynumber[i] | def do_enable(self, arg): args = arg.split() for i in args: bp = bdb.Breakpoint.bpbynumber[int(i)] if bp: bp.enable() | 6308d0d9da083ab2f10fc25b6acfb01043c04ae5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6308d0d9da083ab2f10fc25b6acfb01043c04ae5/pdb.py |
bp = bdb.Breakpoint.bpbynumber[int(i)] | try: i = int(i) except ValueError: print 'Breakpoint index %r is not a number' % i continue if not (0 <= i < len(bdb.Breakpoint.bpbynumber)): print 'No breakpoint numbered', i continue bp = bdb.Breakpoint.bpbynumber[i] | def do_disable(self, arg): args = arg.split() for i in args: bp = bdb.Breakpoint.bpbynumber[int(i)] if bp: bp.disable() | 6308d0d9da083ab2f10fc25b6acfb01043c04ae5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6308d0d9da083ab2f10fc25b6acfb01043c04ae5/pdb.py |
path = [module.__filename__] | head, tail = os.path.split(module.__filename__) path = [head] | def reload(self, module, path=None): if path is None and hasattr(module, '__filename__'): path = [module.__filename__] return ihooks.ModuleImporter.reload(self, module, path) | 47331cb9c86c5b11d386486dc4e95efa775b235a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/47331cb9c86c5b11d386486dc4e95efa775b235a/rexec.py |
suffix = ['.html', '.txt'][self.format=="html"] | suffix = ['.txt', '.html'][self.format=="html"] | def handle(self, info=None): info = info or sys.exc_info() if self.format == "html": self.file.write(reset()) | d97b9c8ad3940fcb543d8cd4d99687b5d311fc87 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d97b9c8ad3940fcb543d8cd4d99687b5d311fc87/cgitb.py |
def start_a(self, attributes): self.link_attr(attributes, 'href') | def check_name_id( self, attributes ): """ Check the name or id attributes on an element. """ | def start_a(self, attributes): self.link_attr(attributes, 'href') | 2afe5246f2a2897da6602dbcf286b67c150d0f2a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2afe5246f2a2897da6602dbcf286b67c150d0f2a/webchecker.py |
if name == "name": | if name == "name" or name == "id": | def start_a(self, attributes): self.link_attr(attributes, 'href') | 2afe5246f2a2897da6602dbcf286b67c150d0f2a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2afe5246f2a2897da6602dbcf286b67c150d0f2a/webchecker.py |
self.checker.message("WARNING: duplicate name %s in %s", | self.checker.message("WARNING: duplicate ID name %s in %s", | def start_a(self, attributes): self.link_attr(attributes, 'href') | 2afe5246f2a2897da6602dbcf286b67c150d0f2a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2afe5246f2a2897da6602dbcf286b67c150d0f2a/webchecker.py |
(S_IFLNK, "l", S_IFREG, "-", S_IFBLK, "b", S_IFDIR, "d", S_IFCHR, "c", S_IFIFO, "p"), (TUREAD, "r"), (TUWRITE, "w"), (TUEXEC, "x", TSUID, "S", TUEXEC|TSUID, "s"), (TGREAD, "r"), (TGWRITE, "w"), (TGEXEC, "x", TSGID, "S", TGEXEC|TSGID, "s"), (TOREAD, "r"), (TOWRITE, "w"), (TOEXEC, "x", TSVTX, "T", TOEXEC|TSVTX, "t")) | ((S_IFLNK, "l"), (S_IFREG, "-"), (S_IFBLK, "b"), (S_IFDIR, "d"), (S_IFCHR, "c"), (S_IFIFO, "p")), ((TUREAD, "r"),), ((TUWRITE, "w"),), ((TUEXEC|TSUID, "s"), (TSUID, "S"), (TUEXEC, "x")), ((TGREAD, "r"),), ((TGWRITE, "w"),), ((TGEXEC|TSGID, "s"), (TSGID, "S"), (TGEXEC, "x")), ((TOREAD, "r"),), ((TOWRITE, "w"),), ((TOEXEC|TSVTX, "t"), (TSVTX, "T"), (TOEXEC, "x")) ) | def copyfileobj(src, dst, length=None): """Copy length bytes from fileobj src to fileobj dst. If length is None, copy the entire content. """ if length == 0: return if length is None: shutil.copyfileobj(src, dst) return BUFSIZE = 16 * 1024 blocks, remainder = divmod(length, BUFSIZE) for b in xrange(blocks): buf = src.read(BUFSIZE) if len(buf) < BUFSIZE: raise IOError, "end of file reached" dst.write(buf) if remainder != 0: buf = src.read(remainder) if len(buf) < remainder: raise IOError, "end of file reached" dst.write(buf) return | c5ffa82ed17230e5ba7c9259db606ac64bbb4806 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c5ffa82ed17230e5ba7c9259db606ac64bbb4806/tarfile.py |
s = "" for t in filemode_table: while True: if mode & t[0] == t[0]: s += t[1] elif len(t) > 2: t = t[2:] continue else: s += "-" break return s | perm = [] for table in filemode_table: for bit, char in table: if mode & bit == bit: perm.append(char) break else: perm.append("-") return "".join(perm) | def filemode(mode): """Convert a file's mode to a string of the form -rwxrwxrwx. Used by TarFile.list() """ s = "" for t in filemode_table: while True: if mode & t[0] == t[0]: s += t[1] elif len(t) > 2: t = t[2:] continue else: s += "-" break return s | c5ffa82ed17230e5ba7c9259db606ac64bbb4806 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c5ffa82ed17230e5ba7c9259db606ac64bbb4806/tarfile.py |
assert u"%r, %r" % (u"abc", "abc") == u"u'abc', 'abc'" | value = u"%r, %r" % (u"abc", "abc") if value != u"u'abc', 'abc'": print '*** formatting failed for "%s"' % 'u"%r, %r" % (u"abc", "abc")' | test('capwords', u'abc\t def \nghi', u'Abc Def Ghi') | 6b096315daae01cf10bf6b6f3074de1bb0c20fec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6b096315daae01cf10bf6b6f3074de1bb0c20fec/test_unicode.py |
assert u"%(x)s, %()s" % {'x':u"abc", u''.encode('utf-8'):"def"} == u'abc, def' | try: value = u"%(x)s, %()s" % {'x':u"abc", u''.encode('utf-8'):"def"} except KeyError: print '*** formatting failed for "%s"' % "u'abc, def'" else: assert value == u'abc, def' | test('capwords', u'abc\t def \nghi', u'Abc Def Ghi') | 6b096315daae01cf10bf6b6f3074de1bb0c20fec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6b096315daae01cf10bf6b6f3074de1bb0c20fec/test_unicode.py |
raise AssertionError, "'...%s......' % u'abc' failed to raise an exception" | print "*** formatting failed ...%s......' % u'abc' failed to raise an exception" | test('capwords', u'abc\t def \nghi', u'Abc Def Ghi') | 6b096315daae01cf10bf6b6f3074de1bb0c20fec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6b096315daae01cf10bf6b6f3074de1bb0c20fec/test_unicode.py |
def checkit(source, opts, morecmds=[]): """Check the LaTeX formatting in a sequence of lines. Opts is a mapping of options to option values if any: -m munge parenthesis and brackets -f forward slash warnings to be skipped -d delimiters only checking -v verbose listing on delimiters -s lineno: linenumber to start scan (default is 1). Morecmds is a sequence of LaTeX commands (without backslashes) that are to be considered valid in the scan. """ texcmd = re.compile(r'\\[A-Za-z]+') validcmds = sets.Set(cmdstr.split()) for cmd in morecmds: validcmds.add('\\' + cmd) openers = [] # Stack of pending open delimiters if '-m' in opts: pairmap = {']':'[(', ')':'(['} # Munged openers else: pairmap = {']':'[', ')':'('} # Normal opener for a given closer openpunct = sets.Set('([') # Set of valid openers delimiters = re.compile(r'\\(begin|end){([_a-zA-Z]+)}|([()\[\]])') tablestart = re.compile(r'\\begin{(?:long)?table([iv]+)}') tableline = re.compile(r'\\line([iv]+){') tableend = re.compile(r'\\end{(?:long)?table([iv]+)}') tablelevel = '' tablestartline = 0 startline = int(opts.get('-s', '1')) lineno = 0 for lineno, line in izip(count(startline), islice(source, startline-1, None)): line = line.rstrip() if '-f' not in opts and '/' in line: # Warn whenever forward slashes encountered line = line.rstrip() print 'Warning, forward slash on line %d: %s' % (lineno, line) if '-d' not in opts: # Validate commands nc = line.find(r'\newcommand') if nc != -1: start = line.find('{', nc) end = line.find('}', start) validcmds.add(line[start+1:end]) for cmd in texcmd.findall(line): if cmd not in validcmds: print r'Warning, unknown tex cmd on line %d: \%s' % (lineno, cmd) # Check balancing of open/close markers (parens, brackets, etc) for begend, name, punct in delimiters.findall(line): if '-v' in opts: print lineno, '|', begend, name, punct, if begend == 'begin' and '-d' not in opts: openers.append((lineno, name)) elif punct in openpunct: openers.append((lineno, punct)) elif begend == 'end' and '-d' not in opts: matchclose(lineno, name, openers, pairmap) elif punct in pairmap: matchclose(lineno, punct, openers, pairmap) if '-v' in opts: print ' --> ', openers # Check table levels (make sure lineii only inside lineiii) m = tablestart.search(line) if m: tablelevel = m.group(1) tablestartline = lineno m = tableline.search(line) if m and m.group(1) != tablelevel: print r'Warning, \line%s on line %d does not match \table%s on line %d' % (m.group(1), lineno, tablelevel, tablestartline) if tableend.search(line): tablelevel = '' for lineno, symbol in openers: print "Unmatched open delimiter '%s' on line %d" % (symbol, lineno) print 'Done checking %d lines.' % (lineno,) return 0 | 2895447fca2aef1afccba7ad2a4ca58238b78043 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2895447fca2aef1afccba7ad2a4ca58238b78043/texcheck.py |
||
print 'Done checking %d lines.' % (lineno,) | print 'Done checking %d lines.' % (lastline,) | def checkit(source, opts, morecmds=[]): """Check the LaTeX formatting in a sequence of lines. Opts is a mapping of options to option values if any: -m munge parenthesis and brackets -f forward slash warnings to be skipped -d delimiters only checking -v verbose listing on delimiters -s lineno: linenumber to start scan (default is 1). Morecmds is a sequence of LaTeX commands (without backslashes) that are to be considered valid in the scan. """ texcmd = re.compile(r'\\[A-Za-z]+') validcmds = sets.Set(cmdstr.split()) for cmd in morecmds: validcmds.add('\\' + cmd) openers = [] # Stack of pending open delimiters if '-m' in opts: pairmap = {']':'[(', ')':'(['} # Munged openers else: pairmap = {']':'[', ')':'('} # Normal opener for a given closer openpunct = sets.Set('([') # Set of valid openers delimiters = re.compile(r'\\(begin|end){([_a-zA-Z]+)}|([()\[\]])') tablestart = re.compile(r'\\begin{(?:long)?table([iv]+)}') tableline = re.compile(r'\\line([iv]+){') tableend = re.compile(r'\\end{(?:long)?table([iv]+)}') tablelevel = '' tablestartline = 0 startline = int(opts.get('-s', '1')) lineno = 0 for lineno, line in izip(count(startline), islice(source, startline-1, None)): line = line.rstrip() if '-f' not in opts and '/' in line: # Warn whenever forward slashes encountered line = line.rstrip() print 'Warning, forward slash on line %d: %s' % (lineno, line) if '-d' not in opts: # Validate commands nc = line.find(r'\newcommand') if nc != -1: start = line.find('{', nc) end = line.find('}', start) validcmds.add(line[start+1:end]) for cmd in texcmd.findall(line): if cmd not in validcmds: print r'Warning, unknown tex cmd on line %d: \%s' % (lineno, cmd) # Check balancing of open/close markers (parens, brackets, etc) for begend, name, punct in delimiters.findall(line): if '-v' in opts: print lineno, '|', begend, name, punct, if begend == 'begin' and '-d' not in opts: openers.append((lineno, name)) elif punct in openpunct: openers.append((lineno, punct)) elif begend == 'end' and '-d' not in opts: matchclose(lineno, name, openers, pairmap) elif punct in pairmap: matchclose(lineno, punct, openers, pairmap) if '-v' in opts: print ' --> ', openers # Check table levels (make sure lineii only inside lineiii) m = tablestart.search(line) if m: tablelevel = m.group(1) tablestartline = lineno m = tableline.search(line) if m and m.group(1) != tablelevel: print r'Warning, \line%s on line %d does not match \table%s on line %d' % (m.group(1), lineno, tablelevel, tablestartline) if tableend.search(line): tablelevel = '' for lineno, symbol in openers: print "Unmatched open delimiter '%s' on line %d" % (symbol, lineno) print 'Done checking %d lines.' % (lineno,) return 0 | 2895447fca2aef1afccba7ad2a4ca58238b78043 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2895447fca2aef1afccba7ad2a4ca58238b78043/texcheck.py |
_cleanup() | for inst in _active[:]: inst.wait() | def _test(): teststr = "abc\n" print "testing popen2..." r, w = popen2('cat') w.write(teststr) w.close() assert r.read() == teststr print "testing popen3..." r, w, e = popen3(['cat']) w.write(teststr) w.close() assert r.read() == teststr assert e.read() == "" _cleanup() assert not _active print "All OK" | 0fc4a406432343eafbe88ca5ad132112e7bb1559 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0fc4a406432343eafbe88ca5ad132112e7bb1559/popen2.py |
saved_dist_files = self.distributuion.dist_files[:] | saved_dist_files = self.distribution.dist_files[:] | def run (self): | a6e7ef2744130450543d0189a51bfd9f89038050 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a6e7ef2744130450543d0189a51bfd9f89038050/bdist_rpm.py |
if data[0][-1] in (',', '.') or data[0].lower() in _daynames: | if data[0].endswith(',') or data[0].lower() in _daynames: | def parsedate_tz(data): """Convert a date string to a time tuple. Accounts for military timezones. """ data = data.split() if data[0][-1] in (',', '.') or data[0].lower() in _daynames: # There's a dayname here. Skip it del data[0] if len(data) == 3: # RFC 850 date, deprecated stuff = data[0].split('-') if len(stuff) == 3: data = stuff + data[1:] if len(data) == 4: s = data[3] i = s.find('+') if i > 0: data[3:] = [s[:i], s[i+1:]] else: data.append('') # Dummy tz if len(data) < 5: return None data = data[:5] [dd, mm, yy, tm, tz] = data mm = mm.lower() if mm not in _monthnames: dd, mm = mm, dd.lower() if mm not in _monthnames: return None mm = _monthnames.index(mm) + 1 if mm > 12: mm -= 12 if dd[-1] == ',': dd = dd[:-1] i = yy.find(':') if i > 0: yy, tm = tm, yy if yy[-1] == ',': yy = yy[:-1] if not yy[0].isdigit(): yy, tz = tz, yy if tm[-1] == ',': tm = tm[:-1] tm = tm.split(':') if len(tm) == 2: [thh, tmm] = tm tss = '0' elif len(tm) == 3: [thh, tmm, tss] = tm else: return None try: yy = int(yy) dd = int(dd) thh = int(thh) tmm = int(tmm) tss = int(tss) except ValueError: return None tzoffset = None tz = tz.upper() if _timezones.has_key(tz): tzoffset = _timezones[tz] else: try: tzoffset = int(tz) except ValueError: pass # Convert a timezone offset into seconds ; -0500 -> -18000 if tzoffset: if tzoffset < 0: tzsign = -1 tzoffset = -tzoffset else: tzsign = 1 tzoffset = tzsign * ( (tzoffset/100)*3600 + (tzoffset % 100)*60) tuple = (yy, mm, dd, thh, tmm, tss, 0, 0, 0, tzoffset) return tuple | f8f431d3443fe9e5d94fc6c1b9aeb75b1d2d6b65 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f8f431d3443fe9e5d94fc6c1b9aeb75b1d2d6b65/_parseaddr.py |
if inst.poll(_deadstate=sys.maxint) >= 0: | res = inst.poll(_deadstate=sys.maxint) if res is not None and res >= 0: | def _cleanup(): for inst in _active[:]: if inst.poll(_deadstate=sys.maxint) >= 0: try: _active.remove(inst) except ValueError: # This can happen if two threads create a new Popen instance. # It's harmless that it was already removed, so ignore. pass | fa26ce2dc62c8f19c06bb9e5ec244a34fe28c6cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fa26ce2dc62c8f19c06bb9e5ec244a34fe28c6cd/subprocess.py |
self._dkeys = self._dict.keys() self._dkeys.sort() | def __init__(self, *args): unittest.TestCase.__init__(self, *args) self._dkeys = self._dict.keys() self._dkeys.sort() | e77de0e1a5b6f2edbb35d3ba3573344546f33727 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e77de0e1a5b6f2edbb35d3ba3573344546f33727/test_dumbdbm.py |
|
_delete_files() | def test_dumbdbm_creation(self): _delete_files() f = dumbdbm.open(_fname, 'c') self.assertEqual(f.keys(), []) for key in self._dict: f[key] = self._dict[key] self.read_helper(f) f.close() | e77de0e1a5b6f2edbb35d3ba3573344546f33727 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e77de0e1a5b6f2edbb35d3ba3573344546f33727/test_dumbdbm.py |
|
self.assertEqual(keys, self._dkeys) | dkeys = self._dict.keys() dkeys.sort() self.assertEqual(keys, dkeys) | def keys_helper(self, f): keys = f.keys() keys.sort() self.assertEqual(keys, self._dkeys) return keys | e77de0e1a5b6f2edbb35d3ba3573344546f33727 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e77de0e1a5b6f2edbb35d3ba3573344546f33727/test_dumbdbm.py |
if stdin == None and stdout == None and stderr == None: | if stdin is None and stdout is None and stderr is None: | def _get_handles(self, stdin, stdout, stderr): """Construct and return tupel with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ if stdin == None and stdout == None and stderr == None: return (None, None, None, None, None, None) | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
if stdin == None: | if stdin is None: | def _get_handles(self, stdin, stdout, stderr): """Construct and return tupel with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ if stdin == None and stdout == None and stderr == None: return (None, None, None, None, None, None) | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
elif type(stdin) == int: | elif isinstance(stdin, int): | def _get_handles(self, stdin, stdout, stderr): """Construct and return tupel with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ if stdin == None and stdout == None and stderr == None: return (None, None, None, None, None, None) | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
if stdout == None: | if stdout is None: | def _get_handles(self, stdin, stdout, stderr): """Construct and return tupel with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ if stdin == None and stdout == None and stderr == None: return (None, None, None, None, None, None) | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
elif type(stdout) == int: | elif isinstance(stdout, int): | def _get_handles(self, stdin, stdout, stderr): """Construct and return tupel with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ if stdin == None and stdout == None and stderr == None: return (None, None, None, None, None, None) | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
if stderr == None: | if stderr is None: | def _get_handles(self, stdin, stdout, stderr): """Construct and return tupel with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ if stdin == None and stdout == None and stderr == None: return (None, None, None, None, None, None) | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
elif type(stderr) == int: | elif isinstance(stderr, int): | def _get_handles(self, stdin, stdout, stderr): """Construct and return tupel with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ if stdin == None and stdout == None and stderr == None: return (None, None, None, None, None, None) | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
if startupinfo == None: | if startupinfo is None: | def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite): """Execute program (MS Windows version)""" | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
if p2cread != None: | if p2cread is not None: | def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite): """Execute program (MS Windows version)""" | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
if c2pwrite != None: | if c2pwrite is not None: | def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite): """Execute program (MS Windows version)""" | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
if errwrite != None: | if errwrite is not None: | def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite): """Execute program (MS Windows version)""" | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
if self.returncode == None: | if self.returncode is None: | def poll(self): """Check if child process has terminated. Returns returncode attribute.""" if self.returncode == None: if WaitForSingleObject(self._handle, 0) == WAIT_OBJECT_0: self.returncode = GetExitCodeProcess(self._handle) _active.remove(self) return self.returncode | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
if self.returncode == None: | if self.returncode is None: | def wait(self): """Wait for child process to terminate. Returns returncode attribute.""" if self.returncode == None: obj = WaitForSingleObject(self._handle, INFINITE) self.returncode = GetExitCodeProcess(self._handle) _active.remove(self) return self.returncode | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
if input != None: | if input is not None: | def communicate(self, input=None): """Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to terminate. The optional input argument should be a string to be sent to the child process, or None, if no data should be sent to the child. | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
if stdout != None: | if stdout is not None: | def communicate(self, input=None): """Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to terminate. The optional input argument should be a string to be sent to the child process, or None, if no data should be sent to the child. | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
if stderr != None: | if stderr is not None: | def communicate(self, input=None): """Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to terminate. The optional input argument should be a string to be sent to the child process, or None, if no data should be sent to the child. | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
if stdin == None: | if stdin is None: | def _get_handles(self, stdin, stdout, stderr): """Construct and return tupel with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ p2cread, p2cwrite = None, None c2pread, c2pwrite = None, None errread, errwrite = None, None | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
elif type(stdin) == int: | elif isinstance(stdin, int): | def _get_handles(self, stdin, stdout, stderr): """Construct and return tupel with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ p2cread, p2cwrite = None, None c2pread, c2pwrite = None, None errread, errwrite = None, None | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
if stdout == None: | if stdout is None: | def _get_handles(self, stdin, stdout, stderr): """Construct and return tupel with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ p2cread, p2cwrite = None, None c2pread, c2pwrite = None, None errread, errwrite = None, None | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
elif type(stdout) == int: | elif isinstance(stdout, int): | def _get_handles(self, stdin, stdout, stderr): """Construct and return tupel with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ p2cread, p2cwrite = None, None c2pread, c2pwrite = None, None errread, errwrite = None, None | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
if stderr == None: | if stderr is None: | def _get_handles(self, stdin, stdout, stderr): """Construct and return tupel with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ p2cread, p2cwrite = None, None c2pread, c2pwrite = None, None errread, errwrite = None, None | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
elif type(stderr) == int: | elif isinstance(stderr, int): | def _get_handles(self, stdin, stdout, stderr): """Construct and return tupel with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ p2cread, p2cwrite = None, None c2pread, c2pwrite = None, None errread, errwrite = None, None | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
if executable == None: | if executable is None: | def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite): """Execute program (POSIX version)""" | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
if cwd != None: | if cwd is not None: | def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite): """Execute program (POSIX version)""" | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
if env == None: | if env is None: | def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite): """Execute program (POSIX version)""" | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
if self.returncode == None: | if self.returncode is None: | def poll(self): """Check if child process has terminated. Returns returncode attribute.""" if self.returncode == None: try: pid, sts = os.waitpid(self.pid, os.WNOHANG) if pid == self.pid: self._handle_exitstatus(sts) except os.error: pass return self.returncode | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
if self.returncode == None: | if self.returncode is None: | def wait(self): """Wait for child process to terminate. Returns returncode attribute.""" if self.returncode == None: pid, sts = os.waitpid(self.pid, 0) self._handle_exitstatus(sts) return self.returncode | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
if stdout != None: | if stdout is not None: | def communicate(self, input=None): """Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to terminate. The optional input argument should be a string to be sent to the child process, or None, if no data should be sent to the child. | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
if stderr != None: | if stderr is not None: | def communicate(self, input=None): """Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to terminate. The optional input argument should be a string to be sent to the child process, or None, if no data should be sent to the child. | d9d8e95d201f8665ecddddf49cd22a62908564ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9d8e95d201f8665ecddddf49cd22a62908564ee/subprocess.py |
while True: | while self.pos < len(self.field): | def getaddrlist(self): """Parse all addresses. | 9918d0f2e74673e04e9e9f53bde21cb70cf8ed9a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9918d0f2e74673e04e9e9f53bde21cb70cf8ed9a/_parseaddr.py |
break | result.append(('', '')) | def getaddrlist(self): """Parse all addresses. | 9918d0f2e74673e04e9e9f53bde21cb70cf8ed9a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9918d0f2e74673e04e9e9f53bde21cb70cf8ed9a/_parseaddr.py |
exts.append( Extension('gestalt', ['gestaltmodule.c']) ) | exts.append( Extension('gestalt', ['gestaltmodule.c'], extra_link_args=['-framework', 'Carbon']) ) | 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') | 499f43632dbd218075c4f07047e5f4bd10a9dd3c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/499f43632dbd218075c4f07047e5f4bd10a9dd3c/setup.py |
exts.append( Extension('_CF', ['cf/_CFmodule.c']) ) exts.append( Extension('_Res', ['res/_Resmodule.c']) ) | exts.append( Extension('_CF', ['cf/_CFmodule.c'], extra_link_args=['-framework', 'CoreFoundation']) ) exts.append( Extension('_Res', ['res/_Resmodule.c'], extra_link_args=['-framework', 'Carbon']) ) | 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') | 499f43632dbd218075c4f07047e5f4bd10a9dd3c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/499f43632dbd218075c4f07047e5f4bd10a9dd3c/setup.py |
print time.strftime(LAST_CHANGED, time.localtime(now)) | print time.strftime(LAST_CHANGED, time.localtime(latest)) | def last_changed(self, files): | 62d7cc8895b1602d168334edb8a615f0c13f60cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/62d7cc8895b1602d168334edb8a615f0c13f60cd/faqwiz.py |
code, modname = compilesuite(suite, major, minor, language, script, fname, basepackage) if modname: suitelist.append((code, modname)) | code, suite, fss, modname, precompinfo = precompilesuite(suite, basepackage) if not code: continue allprecompinfo = allprecompinfo + precompinfo suiteinfo = suite, fss, modname suitelist.append((code, modname)) allsuites.append(suiteinfo) for suiteinfo in allsuites: compilesuite(suiteinfo, major, minor, language, script, fname, basepackage, allprecompinfo) | def compileaete(aete, resinfo, fname): """Generate code for a full aete resource. fname passed for doc purposes""" [version, language, script, suites] = aete major, minor = divmod(version, 256) fss = macfs.FSSpec(fname) creatorsignature, dummy = fss.GetCreatorType() packagename = identify(os.path.basename(fname)) if language: packagename = packagename+'_lang%d'%language if script: packagename = packagename+'_script%d'%script if len(packagename) > 27: packagename = packagename[:27] macfs.SetFolder(os.path.join(sys.prefix, ':Mac:Lib:lib-scriptpackages')) fss, ok = macfs.GetDirectory('Package folder for %s'%packagename) if not ok: return pathname = fss.as_pathname() packagename = os.path.split(os.path.normpath(pathname))[1] fss, ok = macfs.GetDirectory('Package folder for base suite (usually StdSuites)') if ok: dirname, basepkgname = os.path.split(os.path.normpath(fss.as_pathname())) if not dirname in sys.path: sys.path.insert(0, dirname) basepackage = __import__(basepkgname) else: basepackage = None macfs.SetFolder(pathname) suitelist = [] for suite in suites: code, modname = compilesuite(suite, major, minor, language, script, fname, basepackage) if modname: suitelist.append((code, modname)) fss, ok = macfs.StandardPutFile('Package module', '__init__.py') if not ok: return fp = open(fss.as_pathname(), 'w') fss.SetCreatorType('Pyth', 'TEXT') fp.write('"""\n') fp.write("Package generated from %s\n"%fname) fp.write("Resource %s resid %d %s\n"%(resinfo[1], resinfo[0], resinfo[2])) fp.write('"""\n') fp.write('import aetools\n') for code, modname in suitelist: fp.write("import %s\n" % modname) fp.write("\n\n_code_to_module = {\n") for code, modname in suitelist: fp.write("\t'%s' : %s,\n"%(code, modname)) fp.write("}\n\n") fp.write("\n\n_code_to_fullname = {\n") for code, modname in suitelist: fp.write("\t'%s' : '%s.%s',\n"%(code, packagename, modname)) fp.write("}\n\n") for code, modname in suitelist: fp.write("from %s import *\n"%modname) if suitelist: fp.write("\n\nclass %s(%s_Events"%(packagename, suitelist[0][1])) for code, modname in suitelist[1:]: fp.write(",\n\t%s_Events"%modname) fp.write(",\n\taetools.TalkTo):\n") fp.write("\t_signature = '%s'\n\n"%creatorsignature) fp.close() | b18e37723e6f3e7fe6bae03f14e954721df23eaf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b18e37723e6f3e7fe6bae03f14e954721df23eaf/gensuitemodule.py |
fp.write("\t'%s' : '%s.%s',\n"%(code, packagename, modname)) | fp.write("\t'%s' : ('%s.%s', '%s'),\n"%(code, packagename, modname, modname)) | def compileaete(aete, resinfo, fname): """Generate code for a full aete resource. fname passed for doc purposes""" [version, language, script, suites] = aete major, minor = divmod(version, 256) fss = macfs.FSSpec(fname) creatorsignature, dummy = fss.GetCreatorType() packagename = identify(os.path.basename(fname)) if language: packagename = packagename+'_lang%d'%language if script: packagename = packagename+'_script%d'%script if len(packagename) > 27: packagename = packagename[:27] macfs.SetFolder(os.path.join(sys.prefix, ':Mac:Lib:lib-scriptpackages')) fss, ok = macfs.GetDirectory('Package folder for %s'%packagename) if not ok: return pathname = fss.as_pathname() packagename = os.path.split(os.path.normpath(pathname))[1] fss, ok = macfs.GetDirectory('Package folder for base suite (usually StdSuites)') if ok: dirname, basepkgname = os.path.split(os.path.normpath(fss.as_pathname())) if not dirname in sys.path: sys.path.insert(0, dirname) basepackage = __import__(basepkgname) else: basepackage = None macfs.SetFolder(pathname) suitelist = [] for suite in suites: code, modname = compilesuite(suite, major, minor, language, script, fname, basepackage) if modname: suitelist.append((code, modname)) fss, ok = macfs.StandardPutFile('Package module', '__init__.py') if not ok: return fp = open(fss.as_pathname(), 'w') fss.SetCreatorType('Pyth', 'TEXT') fp.write('"""\n') fp.write("Package generated from %s\n"%fname) fp.write("Resource %s resid %d %s\n"%(resinfo[1], resinfo[0], resinfo[2])) fp.write('"""\n') fp.write('import aetools\n') for code, modname in suitelist: fp.write("import %s\n" % modname) fp.write("\n\n_code_to_module = {\n") for code, modname in suitelist: fp.write("\t'%s' : %s,\n"%(code, modname)) fp.write("}\n\n") fp.write("\n\n_code_to_fullname = {\n") for code, modname in suitelist: fp.write("\t'%s' : '%s.%s',\n"%(code, packagename, modname)) fp.write("}\n\n") for code, modname in suitelist: fp.write("from %s import *\n"%modname) if suitelist: fp.write("\n\nclass %s(%s_Events"%(packagename, suitelist[0][1])) for code, modname in suitelist[1:]: fp.write(",\n\t%s_Events"%modname) fp.write(",\n\taetools.TalkTo):\n") fp.write("\t_signature = '%s'\n\n"%creatorsignature) fp.close() | b18e37723e6f3e7fe6bae03f14e954721df23eaf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b18e37723e6f3e7fe6bae03f14e954721df23eaf/gensuitemodule.py |
fp.write(",\n\t%s_Events"%modname) fp.write(",\n\taetools.TalkTo):\n") | fp.write(",\n\t\t%s_Events"%modname) fp.write(",\n\t\taetools.TalkTo):\n") | def compileaete(aete, resinfo, fname): """Generate code for a full aete resource. fname passed for doc purposes""" [version, language, script, suites] = aete major, minor = divmod(version, 256) fss = macfs.FSSpec(fname) creatorsignature, dummy = fss.GetCreatorType() packagename = identify(os.path.basename(fname)) if language: packagename = packagename+'_lang%d'%language if script: packagename = packagename+'_script%d'%script if len(packagename) > 27: packagename = packagename[:27] macfs.SetFolder(os.path.join(sys.prefix, ':Mac:Lib:lib-scriptpackages')) fss, ok = macfs.GetDirectory('Package folder for %s'%packagename) if not ok: return pathname = fss.as_pathname() packagename = os.path.split(os.path.normpath(pathname))[1] fss, ok = macfs.GetDirectory('Package folder for base suite (usually StdSuites)') if ok: dirname, basepkgname = os.path.split(os.path.normpath(fss.as_pathname())) if not dirname in sys.path: sys.path.insert(0, dirname) basepackage = __import__(basepkgname) else: basepackage = None macfs.SetFolder(pathname) suitelist = [] for suite in suites: code, modname = compilesuite(suite, major, minor, language, script, fname, basepackage) if modname: suitelist.append((code, modname)) fss, ok = macfs.StandardPutFile('Package module', '__init__.py') if not ok: return fp = open(fss.as_pathname(), 'w') fss.SetCreatorType('Pyth', 'TEXT') fp.write('"""\n') fp.write("Package generated from %s\n"%fname) fp.write("Resource %s resid %d %s\n"%(resinfo[1], resinfo[0], resinfo[2])) fp.write('"""\n') fp.write('import aetools\n') for code, modname in suitelist: fp.write("import %s\n" % modname) fp.write("\n\n_code_to_module = {\n") for code, modname in suitelist: fp.write("\t'%s' : %s,\n"%(code, modname)) fp.write("}\n\n") fp.write("\n\n_code_to_fullname = {\n") for code, modname in suitelist: fp.write("\t'%s' : '%s.%s',\n"%(code, packagename, modname)) fp.write("}\n\n") for code, modname in suitelist: fp.write("from %s import *\n"%modname) if suitelist: fp.write("\n\nclass %s(%s_Events"%(packagename, suitelist[0][1])) for code, modname in suitelist[1:]: fp.write(",\n\t%s_Events"%modname) fp.write(",\n\taetools.TalkTo):\n") fp.write("\t_signature = '%s'\n\n"%creatorsignature) fp.close() | b18e37723e6f3e7fe6bae03f14e954721df23eaf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b18e37723e6f3e7fe6bae03f14e954721df23eaf/gensuitemodule.py |
def compilesuite(suite, major, minor, language, script, fname, basepackage=None): """Generate code for a single suite""" | def precompilesuite(suite, basepackage=None): """Parse a single suite without generating the output. This step is needed so we can resolve recursive references by suites to enums/comps/etc declared in other suites""" | def compileaete(aete, resinfo, fname): """Generate code for a full aete resource. fname passed for doc purposes""" [version, language, script, suites] = aete major, minor = divmod(version, 256) fss = macfs.FSSpec(fname) creatorsignature, dummy = fss.GetCreatorType() packagename = identify(os.path.basename(fname)) if language: packagename = packagename+'_lang%d'%language if script: packagename = packagename+'_script%d'%script if len(packagename) > 27: packagename = packagename[:27] macfs.SetFolder(os.path.join(sys.prefix, ':Mac:Lib:lib-scriptpackages')) fss, ok = macfs.GetDirectory('Package folder for %s'%packagename) if not ok: return pathname = fss.as_pathname() packagename = os.path.split(os.path.normpath(pathname))[1] fss, ok = macfs.GetDirectory('Package folder for base suite (usually StdSuites)') if ok: dirname, basepkgname = os.path.split(os.path.normpath(fss.as_pathname())) if not dirname in sys.path: sys.path.insert(0, dirname) basepackage = __import__(basepkgname) else: basepackage = None macfs.SetFolder(pathname) suitelist = [] for suite in suites: code, modname = compilesuite(suite, major, minor, language, script, fname, basepackage) if modname: suitelist.append((code, modname)) fss, ok = macfs.StandardPutFile('Package module', '__init__.py') if not ok: return fp = open(fss.as_pathname(), 'w') fss.SetCreatorType('Pyth', 'TEXT') fp.write('"""\n') fp.write("Package generated from %s\n"%fname) fp.write("Resource %s resid %d %s\n"%(resinfo[1], resinfo[0], resinfo[2])) fp.write('"""\n') fp.write('import aetools\n') for code, modname in suitelist: fp.write("import %s\n" % modname) fp.write("\n\n_code_to_module = {\n") for code, modname in suitelist: fp.write("\t'%s' : %s,\n"%(code, modname)) fp.write("}\n\n") fp.write("\n\n_code_to_fullname = {\n") for code, modname in suitelist: fp.write("\t'%s' : '%s.%s',\n"%(code, packagename, modname)) fp.write("}\n\n") for code, modname in suitelist: fp.write("from %s import *\n"%modname) if suitelist: fp.write("\n\nclass %s(%s_Events"%(packagename, suitelist[0][1])) for code, modname in suitelist[1:]: fp.write(",\n\t%s_Events"%modname) fp.write(",\n\taetools.TalkTo):\n") fp.write("\t_signature = '%s'\n\n"%creatorsignature) fp.close() | b18e37723e6f3e7fe6bae03f14e954721df23eaf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b18e37723e6f3e7fe6bae03f14e954721df23eaf/gensuitemodule.py |
return None, None | return None, None, None, None, None | def compilesuite(suite, major, minor, language, script, fname, basepackage=None): """Generate code for a single suite""" [name, desc, code, level, version, events, classes, comps, enums] = suite modname = identify(name) if len(modname) > 28: modname = modname[:27] fss, ok = macfs.StandardPutFile('Python output file', modname+'.py') if not ok: return None, None pathname = fss.as_pathname() modname = os.path.splitext(os.path.split(pathname)[1])[0] fp = open(fss.as_pathname(), 'w') fss.SetCreatorType('Pyth', 'TEXT') fp.write('"""Suite %s: %s\n' % (name, desc)) fp.write("Level %d, version %d\n\n" % (level, version)) fp.write("Generated from %s\n"%fname) fp.write("AETE/AEUT resource version %d/%d, language %d, script %d\n" % \ (major, minor, language, script)) fp.write('"""\n\n') fp.write('import aetools\n') fp.write('import MacOS\n\n') fp.write("_code = %s\n\n"% `code`) if basepackage and basepackage._code_to_module.has_key(code): # We are an extension of a baseclass (usually an application extending # Standard_Suite or so). Import everything from our base module fp.write('from %s import *\n'%basepackage._code_to_fullname[code]) basemodule = basepackage._code_to_module[code] else: # We are not an extension. basemodule = None compileclassheader(fp, modname, basemodule) enumsneeded = {} if events: for event in events: compileevent(fp, event, enumsneeded) else: fp.write("\tpass\n\n") objc = ObjectCompiler(fp, basemodule) for cls in classes: objc.compileclass(cls) for cls in classes: objc.fillclasspropsandelems(cls) for comp in comps: objc.compilecomparison(comp) for enum in enums: objc.compileenumeration(enum) for enum in enumsneeded.keys(): objc.checkforenum(enum) objc.dumpindex() return code, modname | b18e37723e6f3e7fe6bae03f14e954721df23eaf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b18e37723e6f3e7fe6bae03f14e954721df23eaf/gensuitemodule.py |
fp = open(fss.as_pathname(), 'w') fss.SetCreatorType('Pyth', 'TEXT') fp.write('"""Suite %s: %s\n' % (name, desc)) fp.write("Level %d, version %d\n\n" % (level, version)) fp.write("Generated from %s\n"%fname) fp.write("AETE/AEUT resource version %d/%d, language %d, script %d\n" % \ (major, minor, language, script)) fp.write('"""\n\n') fp.write('import aetools\n') fp.write('import MacOS\n\n') fp.write("_code = %s\n\n"% `code`) | def compilesuite(suite, major, minor, language, script, fname, basepackage=None): """Generate code for a single suite""" [name, desc, code, level, version, events, classes, comps, enums] = suite modname = identify(name) if len(modname) > 28: modname = modname[:27] fss, ok = macfs.StandardPutFile('Python output file', modname+'.py') if not ok: return None, None pathname = fss.as_pathname() modname = os.path.splitext(os.path.split(pathname)[1])[0] fp = open(fss.as_pathname(), 'w') fss.SetCreatorType('Pyth', 'TEXT') fp.write('"""Suite %s: %s\n' % (name, desc)) fp.write("Level %d, version %d\n\n" % (level, version)) fp.write("Generated from %s\n"%fname) fp.write("AETE/AEUT resource version %d/%d, language %d, script %d\n" % \ (major, minor, language, script)) fp.write('"""\n\n') fp.write('import aetools\n') fp.write('import MacOS\n\n') fp.write("_code = %s\n\n"% `code`) if basepackage and basepackage._code_to_module.has_key(code): # We are an extension of a baseclass (usually an application extending # Standard_Suite or so). Import everything from our base module fp.write('from %s import *\n'%basepackage._code_to_fullname[code]) basemodule = basepackage._code_to_module[code] else: # We are not an extension. basemodule = None compileclassheader(fp, modname, basemodule) enumsneeded = {} if events: for event in events: compileevent(fp, event, enumsneeded) else: fp.write("\tpass\n\n") objc = ObjectCompiler(fp, basemodule) for cls in classes: objc.compileclass(cls) for cls in classes: objc.fillclasspropsandelems(cls) for comp in comps: objc.compilecomparison(comp) for enum in enums: objc.compileenumeration(enum) for enum in enumsneeded.keys(): objc.checkforenum(enum) objc.dumpindex() return code, modname | b18e37723e6f3e7fe6bae03f14e954721df23eaf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b18e37723e6f3e7fe6bae03f14e954721df23eaf/gensuitemodule.py |
|
fp.write('from %s import *\n'%basepackage._code_to_fullname[code]) | def compilesuite(suite, major, minor, language, script, fname, basepackage=None): """Generate code for a single suite""" [name, desc, code, level, version, events, classes, comps, enums] = suite modname = identify(name) if len(modname) > 28: modname = modname[:27] fss, ok = macfs.StandardPutFile('Python output file', modname+'.py') if not ok: return None, None pathname = fss.as_pathname() modname = os.path.splitext(os.path.split(pathname)[1])[0] fp = open(fss.as_pathname(), 'w') fss.SetCreatorType('Pyth', 'TEXT') fp.write('"""Suite %s: %s\n' % (name, desc)) fp.write("Level %d, version %d\n\n" % (level, version)) fp.write("Generated from %s\n"%fname) fp.write("AETE/AEUT resource version %d/%d, language %d, script %d\n" % \ (major, minor, language, script)) fp.write('"""\n\n') fp.write('import aetools\n') fp.write('import MacOS\n\n') fp.write("_code = %s\n\n"% `code`) if basepackage and basepackage._code_to_module.has_key(code): # We are an extension of a baseclass (usually an application extending # Standard_Suite or so). Import everything from our base module fp.write('from %s import *\n'%basepackage._code_to_fullname[code]) basemodule = basepackage._code_to_module[code] else: # We are not an extension. basemodule = None compileclassheader(fp, modname, basemodule) enumsneeded = {} if events: for event in events: compileevent(fp, event, enumsneeded) else: fp.write("\tpass\n\n") objc = ObjectCompiler(fp, basemodule) for cls in classes: objc.compileclass(cls) for cls in classes: objc.fillclasspropsandelems(cls) for comp in comps: objc.compilecomparison(comp) for enum in enums: objc.compileenumeration(enum) for enum in enumsneeded.keys(): objc.checkforenum(enum) objc.dumpindex() return code, modname | b18e37723e6f3e7fe6bae03f14e954721df23eaf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b18e37723e6f3e7fe6bae03f14e954721df23eaf/gensuitemodule.py |
|
compileclassheader(fp, modname, basemodule) | def compilesuite(suite, major, minor, language, script, fname, basepackage=None): """Generate code for a single suite""" [name, desc, code, level, version, events, classes, comps, enums] = suite modname = identify(name) if len(modname) > 28: modname = modname[:27] fss, ok = macfs.StandardPutFile('Python output file', modname+'.py') if not ok: return None, None pathname = fss.as_pathname() modname = os.path.splitext(os.path.split(pathname)[1])[0] fp = open(fss.as_pathname(), 'w') fss.SetCreatorType('Pyth', 'TEXT') fp.write('"""Suite %s: %s\n' % (name, desc)) fp.write("Level %d, version %d\n\n" % (level, version)) fp.write("Generated from %s\n"%fname) fp.write("AETE/AEUT resource version %d/%d, language %d, script %d\n" % \ (major, minor, language, script)) fp.write('"""\n\n') fp.write('import aetools\n') fp.write('import MacOS\n\n') fp.write("_code = %s\n\n"% `code`) if basepackage and basepackage._code_to_module.has_key(code): # We are an extension of a baseclass (usually an application extending # Standard_Suite or so). Import everything from our base module fp.write('from %s import *\n'%basepackage._code_to_fullname[code]) basemodule = basepackage._code_to_module[code] else: # We are not an extension. basemodule = None compileclassheader(fp, modname, basemodule) enumsneeded = {} if events: for event in events: compileevent(fp, event, enumsneeded) else: fp.write("\tpass\n\n") objc = ObjectCompiler(fp, basemodule) for cls in classes: objc.compileclass(cls) for cls in classes: objc.fillclasspropsandelems(cls) for comp in comps: objc.compilecomparison(comp) for enum in enums: objc.compileenumeration(enum) for enum in enumsneeded.keys(): objc.checkforenum(enum) objc.dumpindex() return code, modname | b18e37723e6f3e7fe6bae03f14e954721df23eaf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b18e37723e6f3e7fe6bae03f14e954721df23eaf/gensuitemodule.py |
|
if events: for event in events: compileevent(fp, event, enumsneeded) else: fp.write("\tpass\n\n") objc = ObjectCompiler(fp, basemodule) | for event in events: findenumsinevent(event, enumsneeded) objc = ObjectCompiler(None, basemodule) | def compilesuite(suite, major, minor, language, script, fname, basepackage=None): """Generate code for a single suite""" [name, desc, code, level, version, events, classes, comps, enums] = suite modname = identify(name) if len(modname) > 28: modname = modname[:27] fss, ok = macfs.StandardPutFile('Python output file', modname+'.py') if not ok: return None, None pathname = fss.as_pathname() modname = os.path.splitext(os.path.split(pathname)[1])[0] fp = open(fss.as_pathname(), 'w') fss.SetCreatorType('Pyth', 'TEXT') fp.write('"""Suite %s: %s\n' % (name, desc)) fp.write("Level %d, version %d\n\n" % (level, version)) fp.write("Generated from %s\n"%fname) fp.write("AETE/AEUT resource version %d/%d, language %d, script %d\n" % \ (major, minor, language, script)) fp.write('"""\n\n') fp.write('import aetools\n') fp.write('import MacOS\n\n') fp.write("_code = %s\n\n"% `code`) if basepackage and basepackage._code_to_module.has_key(code): # We are an extension of a baseclass (usually an application extending # Standard_Suite or so). Import everything from our base module fp.write('from %s import *\n'%basepackage._code_to_fullname[code]) basemodule = basepackage._code_to_module[code] else: # We are not an extension. basemodule = None compileclassheader(fp, modname, basemodule) enumsneeded = {} if events: for event in events: compileevent(fp, event, enumsneeded) else: fp.write("\tpass\n\n") objc = ObjectCompiler(fp, basemodule) for cls in classes: objc.compileclass(cls) for cls in classes: objc.fillclasspropsandelems(cls) for comp in comps: objc.compilecomparison(comp) for enum in enums: objc.compileenumeration(enum) for enum in enumsneeded.keys(): objc.checkforenum(enum) objc.dumpindex() return code, modname | b18e37723e6f3e7fe6bae03f14e954721df23eaf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b18e37723e6f3e7fe6bae03f14e954721df23eaf/gensuitemodule.py |
if module and hasattr(module, classname): fp.write("class %s(%s):\n\n"%(classname, classname)) | if module: modshortname = string.split(module.__name__, '.')[-1] baseclassname = '%s_Events'%modshortname fp.write("class %s(%s):\n\n"%(classname, baseclassname)) | def compileclassheader(fp, name, module=None): """Generate class boilerplate""" classname = '%s_Events'%name if module and hasattr(module, classname): fp.write("class %s(%s):\n\n"%(classname, classname)) else: fp.write("class %s:\n\n"%classname) | b18e37723e6f3e7fe6bae03f14e954721df23eaf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b18e37723e6f3e7fe6bae03f14e954721df23eaf/gensuitemodule.py |
def __init__(self, fp, basesuite=None): | def __init__(self, fp, basesuite=None, othernamemappers=None): | def __init__(self, fp, basesuite=None): self.fp = fp self.propnames = {} self.classnames = {} self.propcodes = {} self.classcodes = {} self.compcodes = {} self.enumcodes = {} self.othersuites = [] self.basesuite = basesuite | b18e37723e6f3e7fe6bae03f14e954721df23eaf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b18e37723e6f3e7fe6bae03f14e954721df23eaf/gensuitemodule.py |
self.propnames = {} self.classnames = {} self.propcodes = {} self.classcodes = {} self.compcodes = {} self.enumcodes = {} self.othersuites = [] | def __init__(self, fp, basesuite=None): self.fp = fp self.propnames = {} self.classnames = {} self.propcodes = {} self.classcodes = {} self.compcodes = {} self.enumcodes = {} self.othersuites = [] self.basesuite = basesuite | b18e37723e6f3e7fe6bae03f14e954721df23eaf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b18e37723e6f3e7fe6bae03f14e954721df23eaf/gensuitemodule.py |
|
if type == 'property': if self.propcodes.has_key(code): return self.propcodes[code], self.propcodes[code], None if self.basesuite and self.basesuite._propdeclarations.has_key(code): name = self.basesuite._propdeclarations[code].__name__ return name, name, None for s in self.othersuites: if s._propdeclarations.has_key(code): name = s._propdeclarations[code].__name__ return name, '%s.%s' % (s.__name__, name), s.__name__ if type == 'class': if self.classcodes.has_key(code): return self.classcodes[code], self.classcodes[code], None if self.basesuite and self.basesuite._classdeclarations.has_key(code): name = self.basesuite._classdeclarations[code].__name__ return name, name, None for s in self.othersuites: if s._classdeclarations.has_key(code): name = s._classdeclarations[code].__name__ return name, '%s.%s' % (s.__name__, name), s.__name__ if type == 'enum': if self.enumcodes.has_key(code): return self.enumcodes[code], self.enumcodes[code], None if self.basesuite and self.basesuite._enumdeclarations.has_key(code): name = '_Enum_' + identify(code) return name, name, None for s in self.othersuites: if s._enumdeclarations.has_key(code): name = '_Enum_' + identify(code) return name, '%s.%s' % (s.__name__, name), s.__name__ if type == 'comparison': if self.compcodes.has_key(code): return self.compcodes[code], self.compcodes[code], None if self.basesuite and self.basesuite._compdeclarations.has_key(code): name = self.basesuite._compdeclarations[code].__name__ return name, name, None for s in self.othersuites: if s._compdeclarations.has_key(code): name = s._compdeclarations[code].__name__ return name, '%s.%s' % (s.__name__, name), s.__name__ m = self.askdefinitionmodule(type, code) if not m: return None, None, None self.othersuites.append(m) | for mapper in self.namemappers: if mapper.hascode(type, code): return mapper.findcodename(type, code) for mapper in self.othernamemappers: if mapper.hascode(type, code): self.othernamemappers.remove(mapper) self.namemappers.append(mapper) if self.fp: self.fp.write("import %s\n"%mapper.modulename) break else: if self.fp: m = self.askdefinitionmodule(type, code) else: m = None if not m: return None, None, None mapper = CodeNameMapper() mapper.addmodule(m, m.__name__, 0) self.namemappers.append(mapper) | def findcodename(self, type, code): while 1: if type == 'property': # First we check whether we ourselves have defined it if self.propcodes.has_key(code): return self.propcodes[code], self.propcodes[code], None # Next we check whether our base suite module has defined it if self.basesuite and self.basesuite._propdeclarations.has_key(code): name = self.basesuite._propdeclarations[code].__name__ return name, name, None # Finally we test whether one of the other suites we know about has defined # it. for s in self.othersuites: if s._propdeclarations.has_key(code): name = s._propdeclarations[code].__name__ return name, '%s.%s' % (s.__name__, name), s.__name__ if type == 'class': if self.classcodes.has_key(code): return self.classcodes[code], self.classcodes[code], None if self.basesuite and self.basesuite._classdeclarations.has_key(code): name = self.basesuite._classdeclarations[code].__name__ return name, name, None for s in self.othersuites: if s._classdeclarations.has_key(code): name = s._classdeclarations[code].__name__ return name, '%s.%s' % (s.__name__, name), s.__name__ if type == 'enum': if self.enumcodes.has_key(code): return self.enumcodes[code], self.enumcodes[code], None if self.basesuite and self.basesuite._enumdeclarations.has_key(code): name = '_Enum_' + identify(code) return name, name, None for s in self.othersuites: if s._enumdeclarations.has_key(code): name = '_Enum_' + identify(code) return name, '%s.%s' % (s.__name__, name), s.__name__ if type == 'comparison': if self.compcodes.has_key(code): return self.compcodes[code], self.compcodes[code], None if self.basesuite and self.basesuite._compdeclarations.has_key(code): name = self.basesuite._compdeclarations[code].__name__ return name, name, None for s in self.othersuites: if s._compdeclarations.has_key(code): name = s._compdeclarations[code].__name__ return name, '%s.%s' % (s.__name__, name), s.__name__ # If all this has failed we ask the user for a guess on where it could # be and retry. m = self.askdefinitionmodule(type, code) if not m: return None, None, None self.othersuites.append(m) | b18e37723e6f3e7fe6bae03f14e954721df23eaf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b18e37723e6f3e7fe6bae03f14e954721df23eaf/gensuitemodule.py |
if self.classcodes.has_key(code): | if self.namemappers[0].hascode('class', code): | def compileclass(self, cls): [name, code, desc, properties, elements] = cls pname = identify(name) if self.classcodes.has_key(code): # plural forms and such self.fp.write("\n%s = %s\n"%(pname, self.classcodes[code])) self.classnames[pname] = code else: self.fp.write('\nclass %s(aetools.ComponentItem):\n' % pname) self.fp.write('\t"""%s - %s """\n' % (name, desc)) self.fp.write('\twant = %s\n' % `code`) self.classnames[pname] = code self.classcodes[code] = pname for prop in properties: self.compileproperty(prop) for elem in elements: self.compileelement(elem) | b18e37723e6f3e7fe6bae03f14e954721df23eaf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b18e37723e6f3e7fe6bae03f14e954721df23eaf/gensuitemodule.py |
self.fp.write("\n%s = %s\n"%(pname, self.classcodes[code])) self.classnames[pname] = code | othername, dummy, dummy = self.namemappers[0].findcodename('class', code) if self.fp: self.fp.write("\n%s = %s\n"%(pname, othername)) | def compileclass(self, cls): [name, code, desc, properties, elements] = cls pname = identify(name) if self.classcodes.has_key(code): # plural forms and such self.fp.write("\n%s = %s\n"%(pname, self.classcodes[code])) self.classnames[pname] = code else: self.fp.write('\nclass %s(aetools.ComponentItem):\n' % pname) self.fp.write('\t"""%s - %s """\n' % (name, desc)) self.fp.write('\twant = %s\n' % `code`) self.classnames[pname] = code self.classcodes[code] = pname for prop in properties: self.compileproperty(prop) for elem in elements: self.compileelement(elem) | b18e37723e6f3e7fe6bae03f14e954721df23eaf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b18e37723e6f3e7fe6bae03f14e954721df23eaf/gensuitemodule.py |
self.fp.write('\nclass %s(aetools.ComponentItem):\n' % pname) self.fp.write('\t"""%s - %s """\n' % (name, desc)) self.fp.write('\twant = %s\n' % `code`) self.classnames[pname] = code self.classcodes[code] = pname | if self.fp: self.fp.write('\nclass %s(aetools.ComponentItem):\n' % pname) self.fp.write('\t"""%s - %s """\n' % (name, desc)) self.fp.write('\twant = %s\n' % `code`) self.namemappers[0].addnamecode('class', pname, code) | def compileclass(self, cls): [name, code, desc, properties, elements] = cls pname = identify(name) if self.classcodes.has_key(code): # plural forms and such self.fp.write("\n%s = %s\n"%(pname, self.classcodes[code])) self.classnames[pname] = code else: self.fp.write('\nclass %s(aetools.ComponentItem):\n' % pname) self.fp.write('\t"""%s - %s """\n' % (name, desc)) self.fp.write('\twant = %s\n' % `code`) self.classnames[pname] = code self.classcodes[code] = pname for prop in properties: self.compileproperty(prop) for elem in elements: self.compileelement(elem) | b18e37723e6f3e7fe6bae03f14e954721df23eaf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b18e37723e6f3e7fe6bae03f14e954721df23eaf/gensuitemodule.py |
if self.propcodes.has_key(code): self.fp.write(" | if self.namemappers[0].hascode('property', code): if self.fp: self.fp.write(" | def compileproperty(self, prop): [name, code, what] = prop if code == 'c@#!': # Something silly with plurals. Skip it. return pname = identify(name) if self.propcodes.has_key(code): self.fp.write("# repeated property %s %s\n"%(pname, what[1])) else: self.fp.write("class %s(aetools.NProperty):\n" % pname) self.fp.write('\t"""%s - %s """\n' % (name, what[1])) self.fp.write("\twhich = %s\n" % `code`) self.fp.write("\twant = %s\n" % `what[0]`) self.propnames[pname] = code self.propcodes[code] = pname | b18e37723e6f3e7fe6bae03f14e954721df23eaf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b18e37723e6f3e7fe6bae03f14e954721df23eaf/gensuitemodule.py |
self.fp.write("class %s(aetools.NProperty):\n" % pname) self.fp.write('\t"""%s - %s """\n' % (name, what[1])) self.fp.write("\twhich = %s\n" % `code`) self.fp.write("\twant = %s\n" % `what[0]`) self.propnames[pname] = code self.propcodes[code] = pname | if self.fp: self.fp.write("class %s(aetools.NProperty):\n" % pname) self.fp.write('\t"""%s - %s """\n' % (name, what[1])) self.fp.write("\twhich = %s\n" % `code`) self.fp.write("\twant = %s\n" % `what[0]`) self.namemappers[0].addnamecode('property', pname, code) | def compileproperty(self, prop): [name, code, what] = prop if code == 'c@#!': # Something silly with plurals. Skip it. return pname = identify(name) if self.propcodes.has_key(code): self.fp.write("# repeated property %s %s\n"%(pname, what[1])) else: self.fp.write("class %s(aetools.NProperty):\n" % pname) self.fp.write('\t"""%s - %s """\n' % (name, what[1])) self.fp.write("\twhich = %s\n" % `code`) self.fp.write("\twant = %s\n" % `what[0]`) self.propnames[pname] = code self.propcodes[code] = pname | b18e37723e6f3e7fe6bae03f14e954721df23eaf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b18e37723e6f3e7fe6bae03f14e954721df23eaf/gensuitemodule.py |
self.fp.write(" | if self.fp: self.fp.write(" | def compileelement(self, elem): [code, keyform] = elem self.fp.write("# element %s as %s\n" % (`code`, keyform)) | b18e37723e6f3e7fe6bae03f14e954721df23eaf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b18e37723e6f3e7fe6bae03f14e954721df23eaf/gensuitemodule.py |
if self.classcodes[code] != cname: | if self.namemappers[0].hascode('class', code) and \ self.namemappers[0].findcodename('class', code)[0] != cname: | def fillclasspropsandelems(self, cls): [name, code, desc, properties, elements] = cls cname = identify(name) if self.classcodes[code] != cname: # This is an other name (plural or so) for something else. Skip. return plist = [] elist = [] for prop in properties: [pname, pcode, what] = prop if pcode == 'c@#!': continue pname = identify(pname) plist.append(pname) for elem in elements: [ecode, keyform] = elem if ecode == 'c@#!': continue name, ename, module = self.findcodename('class', ecode) if not name: self.fp.write("# XXXX %s element %s not found!!\n"%(cname, `ecode`)) else: elist.append((name, ename)) self.fp.write("%s._propdict = {\n"%cname) for n in plist: self.fp.write("\t'%s' : %s,\n"%(n, n)) self.fp.write("}\n") self.fp.write("%s._elemdict = {\n"%cname) for n, fulln in elist: self.fp.write("\t'%s' : %s,\n"%(n, fulln)) self.fp.write("}\n") | b18e37723e6f3e7fe6bae03f14e954721df23eaf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b18e37723e6f3e7fe6bae03f14e954721df23eaf/gensuitemodule.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.