bugged
stringlengths 4
228k
| fixed
stringlengths 0
96.3M
| __index_level_0__
int64 0
481k
|
|---|---|---|
def write(self, s): # Override base class write self.tkconsole.console.write(s)
|
def write(self, s): # Override base class write self.tkconsole.console.write(s)
| 11,300
|
def close(self): """Close the _Stream object. No operation should be done on it afterwards. """ if self.closed: return
|
def close(self): """Close the _Stream object. No operation should be done on it afterwards. """ if self.closed: return
| 11,301
|
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 = {}
|
def __init__(self, filename, dbhome, create=0, truncate=0, mode=0600, recover=0, dbflags=0): """bsdTableDB(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 = {}
| 11,302
|
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")
|
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")
| 11,303
|
def CreateOrExtendTable(self, table, columns): """CreateOrExtendTable(table, columns)
|
def CreateOrExtendTable(self, table, columns): """CreateOrExtendTable(table, columns)
| 11,304
|
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)
|
def Modify(self, table, conditions={}, mappings={}): """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. """ try: matching_rowids = self.__Select(table, [], conditions)
| 11,305
|
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)
|
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)
| 11,306
|
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)
|
def Delete(self, table, conditions={}): """Delete(table, conditions) - Delete items matching the given conditions from the table. * conditions - 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)
| 11,307
|
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()
|
def Select(self, table, columns, conditions={}): """Select(table, columns, 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()
| 11,308
|
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()
|
def Select(self, table, columns, conditions={}): """Select(table, conditions) - retrieve specific row data Returns a list of row column->value mapping dictionaries. * columns - 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()
| 11,309
|
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()
|
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 - 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()
| 11,310
|
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
|
def _format_final_exc_line(etype, value): """Return a list of a single line -- normal case for format_exception_only""" valuestr = _some_str(value) if value is None or not valuestr: line = "%s\n" % etype else: line = "%s: %s\n" % (etype, _some_str(value)) return line
| 11,311
|
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
|
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, valuestr) return line
| 11,312
|
def unsetenv(key): putenv(key, "")
|
def unsetenv(key): putenv(key, "")
| 11,313
|
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)
|
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)
| 11,314
|
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
| 11,315
|
def test_main(): test.test_support.run_unittest(BuiltinTest, TestSorted)
|
def test_main(): test.test_support.run_unittest(BuiltinTest, TestSorted)
| 11,316
|
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))
|
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._set_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))
| 11,317
|
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))
|
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))
| 11,318
|
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)
|
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)
| 11,319
|
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)
|
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, 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)
| 11,320
|
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__
|
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__
| 11,321
|
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__
|
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__
| 11,322
|
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")
|
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")
| 11,323
|
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
|
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 of 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
| 11,324
|
def do_enable(self, arg): args = arg.split() for i in args: bp = bdb.Breakpoint.bpbynumber[int(i)] if bp: bp.enable()
|
def do_enable(self, arg): args = arg.split() for i in args: 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] if bp: bp.enable()
| 11,325
|
def do_disable(self, arg): args = arg.split() for i in args: bp = bdb.Breakpoint.bpbynumber[int(i)] if bp: bp.disable()
|
def do_disable(self, arg): args = arg.split() for i in args: 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] if bp: bp.disable()
| 11,326
|
def reload(self, module, path=None): if path is None and hasattr(module, '__filename__'): path = [module.__filename__] return ihooks.ModuleImporter.reload(self, module, path)
|
def reload(self, module, path=None): if path is None and hasattr(module, '__filename__'): head, tail = os.path.split(module.__filename__) path = [head] return ihooks.ModuleImporter.reload(self, module, path)
| 11,327
|
def handle(self, info=None): info = info or sys.exc_info() if self.format == "html": self.file.write(reset())
|
def handle(self, info=None): info = info or sys.exc_info() if self.format == "html": self.file.write(reset())
| 11,328
|
def start_a(self, attributes): self.link_attr(attributes, 'href')
|
def start_a(self, attributes): self.link_attr(attributes, 'href')
| 11,329
|
def start_a(self, attributes): self.link_attr(attributes, 'href')
|
def start_a(self, attributes): self.link_attr(attributes, 'href')
| 11,330
|
def start_a(self, attributes): self.link_attr(attributes, 'href')
|
def start_a(self, attributes): self.link_attr(attributes, 'href')
| 11,331
|
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
|
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
| 11,332
|
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
|
def filemode(mode): """Convert a file's mode to a string of the form -rwxrwxrwx. Used by TarFile.list() """ 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)
| 11,333
|
test('capwords', u'abc\t def \nghi', u'Abc Def Ghi')
|
test('capwords', u'abc\t def \nghi', u'Abc Def Ghi')
| 11,334
|
test('capwords', u'abc\t def \nghi', u'Abc Def Ghi')
|
test('capwords', u'abc\t def \nghi', u'Abc Def Ghi')
| 11,335
|
test('capwords', u'abc\t def \nghi', u'Abc Def Ghi')
|
test('capwords', u'abc\t def \nghi', u'Abc Def Ghi')
| 11,336
|
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
|
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
| 11,337
|
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
|
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.' % (lastline,) return 0
| 11,338
|
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"
|
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() == "" for inst in _active[:]: inst.wait() assert not _active print "All OK"
| 11,339
|
def run (self):
|
def run (self):
| 11,340
|
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
|
def parsedate_tz(data): """Convert a date string to a time tuple. Accounts for military timezones. """ data = data.split() if data[0].endswith(',') 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
| 11,341
|
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
|
def _cleanup(): for inst in _active[:]: res = inst.poll(_deadstate=sys.maxint) if res is not None and res >= 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
| 11,342
|
def __init__(self, *args): unittest.TestCase.__init__(self, *args) 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()
| 11,343
|
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()
|
def test_dumbdbm_creation(self): 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()
| 11,344
|
def keys_helper(self, f): keys = f.keys() keys.sort() self.assertEqual(keys, self._dkeys) return keys
|
def keys_helper(self, f): keys = f.keys() keys.sort() dkeys = self._dict.keys() dkeys.sort() self.assertEqual(keys, dkeys) return keys
| 11,345
|
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)
|
def _get_handles(self, stdin, stdout, stderr): """Construct and return tupel with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ if stdin is None and stdout is None and stderr is None: return (None, None, None, None, None, None)
| 11,346
|
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)
|
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)
| 11,347
|
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)
|
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)
| 11,348
|
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)
|
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)
| 11,349
|
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)
|
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)
| 11,350
|
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)
|
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)
| 11,351
|
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)
|
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)
| 11,352
|
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)"""
|
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)"""
| 11,353
|
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)"""
|
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)"""
| 11,354
|
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)"""
|
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)"""
| 11,355
|
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)"""
|
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)"""
| 11,356
|
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
|
def poll(self): """Check if child process has terminated. Returns returncode attribute.""" if self.returncode is None: if WaitForSingleObject(self._handle, 0) == WAIT_OBJECT_0: self.returncode = GetExitCodeProcess(self._handle) _active.remove(self) return self.returncode
| 11,357
|
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
|
def wait(self): """Wait for child process to terminate. Returns returncode attribute.""" if self.returncode is None: obj = WaitForSingleObject(self._handle, INFINITE) self.returncode = GetExitCodeProcess(self._handle) _active.remove(self) return self.returncode
| 11,358
|
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.
|
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.
| 11,359
|
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.
|
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.
| 11,360
|
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.
|
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.
| 11,361
|
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
|
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
| 11,362
|
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
|
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
| 11,363
|
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
|
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
| 11,364
|
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
|
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
| 11,365
|
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
|
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
| 11,366
|
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
|
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
| 11,367
|
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)"""
|
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)"""
| 11,368
|
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)"""
|
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)"""
| 11,369
|
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)"""
|
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)"""
| 11,370
|
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
|
def poll(self): """Check if child process has terminated. Returns returncode attribute.""" if self.returncode is 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
| 11,371
|
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
|
def wait(self): """Wait for child process to terminate. Returns returncode attribute.""" if self.returncode is None: pid, sts = os.waitpid(self.pid, 0) self._handle_exitstatus(sts) return self.returncode
| 11,372
|
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.
|
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.
| 11,373
|
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.
|
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.
| 11,374
|
def getaddrlist(self): """Parse all addresses.
|
def getaddrlist(self): """Parse all addresses.
| 11,375
|
def getaddrlist(self): """Parse all addresses.
|
def getaddrlist(self): """Parse all addresses.
| 11,376
|
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')
|
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')
| 11,377
|
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')
|
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')
| 11,378
|
def last_changed(self, files):
|
def last_changed(self, files):
| 11,379
|
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()
|
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, 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) 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()
| 11,380
|
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()
|
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', '%s'),\n"%(code, packagename, modname, 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()
| 11,381
|
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()
|
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\t%s_Events"%modname) fp.write(",\n\t\taetools.TalkTo):\n") fp.write("\t_signature = '%s'\n\n"%creatorsignature) fp.close()
| 11,382
|
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()
|
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()
| 11,383
|
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
|
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, None, 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
| 11,384
|
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
|
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] 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
| 11,385
|
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
|
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 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
| 11,386
|
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
|
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 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
| 11,387
|
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
|
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 = {} for event in events: findenumsinevent(event, enumsneeded) objc = ObjectCompiler(None, 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
| 11,388
|
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)
|
def compileclassheader(fp, name, module=None): """Generate class boilerplate""" classname = '%s_Events'%name if module: modshortname = string.split(module.__name__, '.')[-1] baseclassname = '%s_Events'%modshortname fp.write("class %s(%s):\n\n"%(classname, baseclassname)) else: fp.write("class %s:\n\n"%classname)
| 11,389
|
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
|
def __init__(self, fp, basesuite=None, othernamemappers=None): self.fp = fp self.propnames = {} self.classnames = {} self.propcodes = {} self.classcodes = {} self.compcodes = {} self.enumcodes = {} self.othersuites = [] self.basesuite = basesuite
| 11,390
|
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
|
def __init__(self, fp, basesuite=None): self.fp = fp self.basesuite = basesuite
| 11,391
|
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)
|
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)
| 11,392
|
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)
|
def compileclass(self, cls): [name, code, desc, properties, elements] = cls pname = identify(name) if self.namemappers[0].hascode('class', 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)
| 11,393
|
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)
|
def compileclass(self, cls): [name, code, desc, properties, elements] = cls pname = identify(name) if self.classcodes.has_key(code): # plural forms and such othername, dummy, dummy = self.namemappers[0].findcodename('class', code) if self.fp: self.fp.write("\n%s = %s\n"%(pname, othername)) 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)
| 11,394
|
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)
|
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: 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) for prop in properties: self.compileproperty(prop) for elem in elements: self.compileelement(elem)
| 11,395
|
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
|
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
| 11,396
|
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
|
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: 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)
| 11,397
|
def compileelement(self, elem): [code, keyform] = elem self.fp.write("# element %s as %s\n" % (`code`, keyform))
|
def compileelement(self, elem): [code, keyform] = elem self.fp.write("# element %s as %s\n" % (`code`, keyform))
| 11,398
|
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")
|
def fillclasspropsandelems(self, cls): [name, code, desc, properties, elements] = cls cname = identify(name) if self.namemappers[0].hascode('class', code) and \ self.namemappers[0].findcodename('class', code)[0] != 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")
| 11,399
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.