rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
if container_class or self._create_mount_points:
if self._create_mount_points:
def _traverseToMountedRoot(self, root, mount_parent): """Hook for getting the object to be mounted. """ params = self._v_mount_params if params is None: params = self._loadMountParams() real_root, real_path, container_class = params if real_root is None: real_root = 'Application' try: obj = root[real_root] except KeyEr...
if container_class or self._create_mount_points:
if container_class and self._create_mount_points:
def _traverseToMountedRoot(self, root, mount_parent): """Hook for getting the object to be mounted. """ params = self._v_mount_params if params is None: params = self._loadMountParams() real_root, real_path, container_class = params if real_root is None: real_root = 'Application' try: obj = root[real_root] except KeyEr...
def get_refcounts(self, n=100, t=(type(Fake), type(Acquisition.Implicit))):
_v_rcs=None _v_rst=None def refcount(self, n=None, t=(type(Fake), type(Acquisition.Implicit))):
def get_refcounts(self, n=100, t=(type(Fake), type(Acquisition.Implicit))): # get class refcount info
pairs = map(lambda x: (x[1], '%s' % x[0].__name__), dict.items())
pairs=[] append=pairs.append for ob, v in dict.items(): if hasattr(ob, '__module__'): name='%s.%s' % (ob.__module__, ob.__name__) else: name='%s' % ob.__name__ append((v, name))
def get_refcounts(self, n=100, t=(type(Fake), type(Acquisition.Implicit))): # get class refcount info
pairs=pairs[:n]
if n is not None: pairs=pairs[:n]
def get_refcounts(self, n=100, t=(type(Fake), type(Acquisition.Implicit))): # get class refcount info
def refdict(self): rc=self.refcount() dict={} for v, n in rc: dict[n]=v return dict def rcsnapshot(self): self._v_rcs=self.refdict() self._v_rst=DateTime() def rcdate(self): return self._v_rst def rcdeltas(self): if self._v_rcs is None: self.rcsnapshot() nc=self.refdict() rc=self._v_rcs rd=[] for n, c in nc.items():...
def get_refcounts(self, n=100, t=(type(Fake), type(Acquisition.Implicit))): # get class refcount info
if type(result) is type(''): result=RDB.File(StringIO(result),brain,self)
if type(result) is type(''): f=StringIO() f.write(result) result=RDB.File(f,brain,self)
def __call__(self, REQUEST=None, __ick__=None, src__=0, **kw):
if missing: raise self.MissingArgumentError, \ "The following arguments were omitted " \ " from the ZSQL method call: %s" % str(missing)
def _argdata(self, REQUEST):
if REQUEST.get('raw'):
if REQUEST is not None and REQUEST.get('raw'):
def document_src(self, REQUEST=None, RESPONSE=None): """Return expanded document source."""
code = None, opt_args = [], *extras):
code = None, opt_args = [], extras = {}):
def __init__(self, mnem, class_name, base_class = '', code = None, opt_args = [], *extras): self.mnemonic = mnem self.class_name = class_name self.base_class = base_class if code: #If the user already made a CodeBlock, pick the parts from it if isinstance(code, CodeBlock): origCode = code.orig_code codeBlock = code els...
compositeCode = '\n'.join([origCode] + [pair[1] for pair in extras])
stringExtras = {} otherExtras = {} for (k, v) in extras.items(): if type(v) == str: stringExtras[k] = v else: otherExtras[k] = v compositeCode = "\n".join([origCode] + stringExtras.values())
def __init__(self, mnem, class_name, base_class = '', code = None, opt_args = [], *extras): self.mnemonic = mnem self.class_name = class_name self.base_class = base_class if code: #If the user already made a CodeBlock, pick the parts from it if isinstance(code, CodeBlock): origCode = code.orig_code codeBlock = code els...
for (key, snippet) in extras:
for (key, snippet) in stringExtras.items():
def __init__(self, mnem, class_name, base_class = '', code = None, opt_args = [], *extras): self.mnemonic = mnem self.class_name = class_name self.base_class = base_class if code: #If the user already made a CodeBlock, pick the parts from it if isinstance(code, CodeBlock): origCode = code.orig_code codeBlock = code els...
if value == Nxone:
if value == None:
def _convert(cls, value): if value == Nxone: return
sob = [ base for base in bases \ if issubclass(base, ParamType) and base != ParamType ] if len(sob) == 1:
cnbase = [ base for base in bases if isConfigNode(base) ] if len(cnbase) == 1:
def __init__(cls, name, bases, dict): super(MetaConfigNode, cls).__init__(name, bases, dict)
for key,val in sob[0]._values.iteritems():
for key,val in cnbase[0]._values.iteritems():
def __init__(cls, name, bases, dict): super(MetaConfigNode, cls).__init__(name, bases, dict)
cls._params.parent = sob[0]._params cls._values.parent = sob[0]._values elif len(sob) > 1:
cls._params.parent = cnbase[0]._params cls._values.parent = cnbase[0]._values elif len(cnbase) > 1:
def __init__(cls, name, bases, dict): super(MetaConfigNode, cls).__init__(name, bases, dict)
%s""" % str(sob))
%s""" % str(cnbase))
def __init__(cls, name, bases, dict): super(MetaConfigNode, cls).__init__(name, bases, dict)
sim_seconds = source['sim_seconds']
def disp(*args): print "%-35s %12s %12s %4s %5s %5s %5s %10s" % args
bps = etherdev.rxBandwidth + etherdev.txBandwidth
def disp(*args): print "%-35s %12s %12s %4s %5s %5s %5s %10s" % args
output.stat = packets / sim_seconds
output.stat = packets / source['sim_seconds']
def display(): if options.graph: output.graph(command, options.graphdir, proxy) else: output.display(command, options.binned, options.printmode)
output.stat = bps / 1e9
output.stat = (etherdev.rxBandwidth + etherdev.txBandwidth) / 1e9
def display(): if options.graph: output.graph(command, options.graphdir, proxy) else: output.display(command, options.binned, options.printmode)
self.inner_axes.set_ylim(self.ylim)
inner_axes.set_ylim(self.ylim)
def graph(self): if self.chartdata is None: raise AttributeError, "Data not set for bar chart!"
self.xsubticks.append('') inner_axes.set_xticklabels(self.xsubticks * cshape[2], fontsize=7, rotation=90)
xsubticks = list(self.xsubticks) + [ '' ] inner_axes.set_xticklabels(xsubticks * cshape[2], fontsize=7, rotation=30)
def graph(self): if self.chartdata is None: raise AttributeError, "Data not set for bar chart!"
disk.dir = joinpath('/n/zamp/z/ktlim/local/clean/linux', 'disks')
disk.dir = joinpath(system.dir, 'disks')
def system(): if not system.dir: try: path = env['M5_PATH'].split(':') except KeyError: path = [ '/dist/m5/system', '/n/poolfs/z/dist/m5/system' ] for system.dir in path: if os.path.isdir(system.dir): break else: raise ImportError, "Can't find a path to system files." if not binary.dir: binary.dir = joinpath(system.d...
scope = { '__file__' : sys.argv[0] }
def main(): import cc_main parse_args() done = False if options.copyright: done = True print info.LICENSE print if options.authors: done = True print 'Author information:' print print info.AUTHORS print if options.readme: done = True print 'Readme:' print print info.README print if options.release_notes: done = Tr...
system = info.source.__dict__[options.system]
def commands(options, command, args): if command == 'database': if len(args) == 0: raise CommandException import dbinit mydb = dbinit.MyDB(options) if args[0] == 'drop': if len(args) > 2: raise CommandException mydb.admin() mydb.drop() if len(args) == 2 and args[1] == 'init': mydb.create() mydb.connect() mydb.populat...
if isinstance(obj, BaseProxy):
if isinstance(obj, (BaseProxy, EthernetAddr)):
def isproxy(obj): if isinstance(obj, BaseProxy): return True elif isinstance(obj, (list, tuple)): for v in obj: if isproxy(v): return True return False
__metaclass__ = Singleton
def IncEthernetAddr(addr, val = 1): bytes = map(lambda x: int(x, 16), addr.split(':')) bytes[5] += val for i in (5, 4, 3, 2, 1): val,rem = divmod(bytes[i], 256) bytes[i] = rem if val == 0: break bytes[i - 1] += val assert(bytes[0] <= 255) return ':'.join(map(lambda x: '%02x' % x, bytes))
self.value = self.addr self.addr = IncEthernetAddr(self.addr, inc)
self.value = NextEthernetAddr.addr NextEthernetAddr.addr = IncEthernetAddr(NextEthernetAddr.addr, inc)
def __init__(self, inc = 1): self.value = self.addr self.addr = IncEthernetAddr(self.addr, inc)
self.value = self.value().value return self.value
return self.addr else: return self.value
def __str__(self): if self.value == NextEthernetAddr: self.value = self.value().value return self.value
if self.isMem(): self.is_src = '' self.is_dest = ''
def finalize(self): self.flags = self.getFlags() self.constructor = self.makeConstructor() self.op_decl = self.makeDecl()
if system is None and hasattr('system', job):
if system is None and hasattr(job, 'system'):
def get(self, job, stat, system=None): run = self.allRunNames.get(str(job), None) if run is None: return None
(obj.path, child.path)
(found_obj.path, child.path)
def find_any(self, ptype): if isinstance(self, ptype): return self, True
self.children.sort(lambda x,y: cmp(x.name, y.name))
def display(self): print '[' + self.path + ']' # .ini section header
def parse_isa_desc(isa_desc_file, output_dir, include_path):
def parse_isa_desc(isa_desc_file, output_dir):
def parse_isa_desc(isa_desc_file, output_dir, include_path): # set a global var for the input filename... used in error messages global input_filename input_filename = isa_desc_file global fileNameStack fileNameStack = [(input_filename, 1)] # Suck the ISA description file in. input = open(isa_desc_file) isa_desc = inp...
parse_isa_desc(sys.argv[1], sys.argv[2], sys.argv[3])
parse_isa_desc(sys.argv[1], sys.argv[2])
def parse_isa_desc(isa_desc_file, output_dir, include_path): # set a global var for the input filename... used in error messages global input_filename input_filename = isa_desc_file global fileNameStack fileNameStack = [(input_filename, 1)] # Suck the ISA description file in. input = open(isa_desc_file) isa_desc = inp...
def clearPCSymbol(option, opt_str, value, parser): objects.ExecutionTrace.pc_symbol = False def clearPrintCycle(option, opt_str, value, parser): objects.ExecutionTrace.print_cycle = False
def setTraceFile(option, opt_str, value, parser): objects.Trace.file = value def usePCSymbol(option, opt_str, value, parser): objects.ExecutionTrace.pc_symbol = value def printCycle(option, opt_str, value, parser): objects.ExecutionTrace.print_cycle = value def printOp(option, opt_str, value, parser): objects.Execut...
def clearPCSymbol(option, opt_str, value, parser): objects.ExecutionTrace.pc_symbol = False
optparse.make_option("--nopcsymbol", action="callback", callback=clearPCSymbol, help="Turn off printing PC symbols in trace output"), optparse.make_option("--noprintcycle", action="callback", callback=clearPrintCycle, help="Turn off printing cycles in trace output"),
optparse.make_option("--tracefile", type="string", action="callback", callback=setTraceFile), optparse.make_option("--pcsymbol", type="choice", choices=TrueOrFalse, default="True", metavar=TorF, action="callback", callback=usePCSymbol, help="Use PC symbols in trace output"), optparse.make_option("--printcycle", type="c...
def statsTextFile(option, opt_str, value, parser): objects.Statistics.text_file = value
if isinstance(self, System):
if isinstance(self, m5.objects.System):
def changeTiming(self, mode): if isinstance(self, System): self._ccObject.setMemoryMode(mode) for child in self._children.itervalues(): child.changeTiming(mode)
def m5execfile(f, global_dict): oldpath = sys.path[:] sys.path.insert(0, os.path.abspath(os.path.dirname(f))) execfile(f, global_dict) sys.path = oldpath
def panic(string): print >>sys.stderr, 'panic:', string sys.exit(1)
if os.path.isdir(path) and path not in sys.path: sys.path.append(path)
sys.path.insert(1, path)
def AddToPath(path): path = os.path.realpath(path) if os.path.isdir(path) and path not in sys.path: sys.path.append(path)
eval("%s = %s" % (var, repr(val)))
exec "%s = %s" % (var, repr(val))
def AddToPath(path): # if it's a relative path and we know what directory the current # python script is in, make the path relative to that directory. if not os.path.isabs(path) and sys.path[0]: path = os.path.join(sys.path[0], path) path = os.path.realpath(path) # sys.path[0] should always refer to the current script'...
fname = '/n/ziff/z/binkertn/graph/data.ibm/%s.%s.dat' % (tag, base)
fname = '/n/ziff/z/binkertn/graph/test0/data/%s.%s.dat' % (tag, base)
def graphdata(runs, tag, label, value): import info configs = ['std', 'csa', 'ht1', 'ht4', 'htx', 'ocm', 'occ', 'ocp' ] benchmarks = [ 'm', 's' ] dmas = [ 'x', 'd', 'b' ] caches = [ '1', '2', '3', '4', '5' ] systems = [ 'M' ] checkpoints = [ '1' ] names = [] for bench in benchmarks: for dma in dmas: for cache in cache...
if graph:
if options.graph:
def commands(options, command, args): if command == 'database': if len(args) == 0: raise CommandException import dbinit mydb = dbinit.MyDB(options) if args[0] == 'drop': if len(args) > 2: raise CommandException mydb.admin() mydb.drop() if len(args) == 2 and args[1] == 'init': mydb.create() mydb.connect() mydb.populat...
if binned:
if options.binned:
def commands(options, command, args): if command == 'database': if len(args) == 0: raise CommandException import dbinit mydb = dbinit.MyDB(options) if args[0] == 'drop': if len(args) > 2: raise CommandException mydb.admin() mydb.drop() if len(args) == 2 and args[1] == 'init': mydb.create() mydb.connect() mydb.populat...
graph = False binned = False
def commands(options, command, args): if command == 'database': if len(args) == 0: raise CommandException import dbinit mydb = dbinit.MyDB(options) if args[0] == 'drop': if len(args) > 2: raise CommandException mydb.admin() mydb.drop() if len(args) == 2 and args[1] == 'init': mydb.create() mydb.connect() mydb.populat...
sys.exit(*args, **kwargs)
print >>sys.stderr, 'panic:', string sys.exit(1)
def panic(*args, **kwargs): sys.exit(*args, **kwargs)
if os.path.isdir(path):
if os.path.isdir(path) and path not in sys.path:
def AddToPath(path): path = os.path.realpath(path) if os.path.isdir(path): sys.path.append(path)
maxtick = -1
from m5 import MaxTick maxtick = MaxTick
def binpath(app, file=None): # executable has same name as app unless specified otherwise if not file: file = app return os.path.join(test_progs, app, 'bin', isa, opsys, file)
exportContextSymbols = ('InstObjParams', 'CodeBlock', 'makeList', 're', 'string')
exportContextSymbols = ('InstObjParams', 'makeList', 're', 'string')
def wrap_decode_block(self, pre, post = ''): self.decode_block = pre + indent(self.decode_block) + post
myDict = templateMap.copy() if isinstance(d, dict): myDict.update(d) elif hasattr(d, '__dict__'): myDict.update(d.__dict__) else: raise TypeError, "Template.subst() arg must be or have dictionary"
myDict = None
def subst(self, d): # Start with the template namespace. Make a copy since we're # going to modify it. myDict = templateMap.copy() # if the argument is a dictionary, we just use it. if isinstance(d, dict): myDict.update(d) # if the argument is an object, we use its attribute map. elif hasattr(d, '__dict__'): myDict.up...
c += '\n\t_srcRegIdx[%d] = %s;' % \
c += '\n\t_srcRegIdx[%d] = %s + Ctrl_Base_DepTag;' % \
def makeConstructor(self): c = '' if self.is_src: c += '\n\t_srcRegIdx[%d] = %s;' % \ (self.src_reg_idx, self.reg_spec) if self.is_dest: c += '\n\t_destRegIdx[%d] = %s;' % \ (self.dest_reg_idx, self.reg_spec) return c
c += '\n\t_destRegIdx[%d] = %s;' % \
c += '\n\t_destRegIdx[%d] = %s + Ctrl_Base_DepTag;' % \
def makeConstructor(self): c = '' if self.is_src: c += '\n\t_srcRegIdx[%d] = %s;' % \ (self.src_reg_idx, self.reg_spec) if self.is_dest: c += '\n\t_destRegIdx[%d] = %s;' % \ (self.dest_reg_idx, self.reg_spec) return c
base = 'xc->readMiscReg(%s)' % self.reg_spec
base = 'xc->readMiscRegOperand(this, %s)' % self.src_reg_idx
def makeRead(self): bit_select = 0 if (self.ctype == 'float' or self.ctype == 'double'): error(0, 'Attempt to read control register as FP') base = 'xc->readMiscReg(%s)' % self.reg_spec if self.size == self.dflt_size: return '%s = %s;\n' % (self.base_name, base) else: return '%s = bits(%s, %d, 0);\n' % \ (self.base_name...
wb = 'xc->setMiscRegWithEffect(%s, %s);\n' % (self.reg_spec, self.base_name)
wb = 'xc->setMiscRegOperandWithEffect(this, %s, %s);\n' % \ (self.dest_reg_idx, self.base_name)
def makeWrite(self): if (self.ctype == 'float' or self.ctype == 'double'): error(0, 'Attempt to write control register as FP') wb = 'xc->setMiscRegWithEffect(%s, %s);\n' % (self.reg_spec, self.base_name) wb += 'if (traceData) { traceData->setData(%s); }' % \ self.base_name return wb
class CodeBlock: def __init__(self, code): self.orig_code = code self.operands = OperandList(code) self.code = substMungedOpNames(substBitOps(code))
instFlagRE = re.compile(r'Is.*') opClassRE = re.compile(r'.*Op|No_OpClass') class InstObjParams: def __init__(self, mnem, class_name, base_class = '', snippets = None, opt_args = []): self.mnemonic = mnem self.class_name = class_name self.base_class = base_class compositeCode = '' if snippets: if not isinstance(snip...
def makeFlagConstructor(flag_list): if len(flag_list) == 0: return '' # filter out repeated flags flag_list.sort() i = 1 while i < len(flag_list): if flag_list[i] == flag_list[i-1]: del flag_list[i] else: i += 1 pre = '\n\tflags[' post = '] = true;' code = pre + string.join(flag_list, post + pre) + post return code
self.op_decl = self.operands.concatAttrStrings('op_decl') is_src = lambda op: op.is_src is_dest = lambda op: op.is_dest self.op_src_decl = \ self.operands.concatSomeAttrStrings(is_src, 'op_src_decl') self.op_dest_decl = \ self.operands.concatSomeAttrStrings(is_dest, 'op_dest_decl') self.op_rd = self.operands.concatA...
def __init__(self, code): self.orig_code = code self.operands = OperandList(code) self.code = substMungedOpNames(substBitOps(code)) self.constructor = self.operands.concatAttrStrings('constructor') self.constructor += \ '\n\t_numSrcRegs = %d;' % self.operands.numSrcRegs self.constructor += \ '\n\t_numDestRegs = %d;' % ...
if self.operands.memOperand: self.mem_acc_size = self.operands.memOperand.mem_acc_size self.mem_acc_type = self.operands.memOperand.mem_acc_type
def __init__(self, code): self.orig_code = code self.operands = OperandList(code) self.code = substMungedOpNames(substBitOps(code)) self.constructor = self.operands.concatAttrStrings('constructor') self.constructor += \ '\n\t_numSrcRegs = %d;' % self.operands.numSrcRegs self.constructor += \ '\n\t_numDestRegs = %d;' % ...
instFlagRE = re.compile(r'Is.*') opClassRE = re.compile(r'.*Op|No_OpClass') class InstObjParams: def __init__(self, mnem, class_name, base_class = '', code = None, opt_args = [], extras = {}): self.mnemonic = mnem self.class_name = class_name self.base_class = base_class if code: if isinstance(code, CodeBlock): ori...
def __init__(self, code): self.orig_code = code self.operands = OperandList(code) self.code = substMungedOpNames(substBitOps(code)) self.constructor = self.operands.concatAttrStrings('constructor') self.constructor += \ '\n\t_numSrcRegs = %d;' % self.operands.numSrcRegs self.constructor += \ '\n\t_numDestRegs = %d;' % ...
print parser.help
parser.print_help()
def usage(exitcode=None): print parser.help if exitcode is not None: sys.exit(exitcode)
global fileNameStack fileNameStack.append((t.value[11:-1], t.lineno))
fileNameStack.push((t.value[11:-1], t.lineno))
def t_NEWFILE(t): r'^\#\#newfile\s+"[\w/.-]*"' global fileNameStack fileNameStack.append((t.value[11:-1], t.lineno)) t.lineno = 0
(filename, t.lineno) = fileNameStack.pop()
(old_filename, t.lineno) = fileNameStack.pop()
def t_ENDFILE(t): r'^\#\#endfile' (filename, t.lineno) = fileNameStack.pop()
error_bt(0, "unknown syntax error")
error(0, "unknown syntax error", True)
def p_error(t): if t: error(t.lineno, "syntax error at '%s'" % t.value) else: error_bt(0, "unknown syntax error")
def error(lineno, string):
def error(lineno, string, print_traceback = False):
def fixPythonIndentation(s): # get rid of blank lines first s = re.sub(r'(?m)^\s*\n', '', s); if (s != '' and re.match(r'[ \t]', s[0])): s = 'if 1:\n' + s return s
print spaces + "In file included from " + filename
print spaces + "In file included from " + filename + ":"
def error(lineno, string): spaces = "" for (filename, line) in fileNameStack[0:-1]: print spaces + "In file included from " + filename spaces += " " # Uncomment the following line to get a Python stack backtrace for # these errors too. Can be handy when trying to debug the parser. # traceback.print_exc() sys.exit(spa...
sys.exit(spaces + "%s:%d: %s" % (fileNameStack[-1][0], lineno, string)) def error_bt(lineno, string): traceback.print_exc() print >> sys.stderr, "%s:%d: %s" % (input_filename, lineno, string) sys.exit(1)
if (print_traceback): traceback.print_exc() if lineno != 0: line_str = "%d:" % lineno else: line_str = "" sys.exit(spaces + "%s:%s %s" % (fileNameStack[-1][0], line_str, string))
def error(lineno, string): spaces = "" for (filename, line) in fileNameStack[0:-1]: print spaces + "In file included from " + filename spaces += " " # Uncomment the following line to get a Python stack backtrace for # these errors too. Can be handy when trying to debug the parser. # traceback.print_exc() sys.exit(spa...
error(0, 'Unrecognized type description "%s" in userDict')
error(lineno, 'Unrecognized type description "%s" in userDict')
def buildOperandTypeMap(userDict, lineno): global operandTypeMap operandTypeMap = {} for (ext, (desc, size)) in userDict.iteritems(): if desc == 'signed int': ctype = 'int%d_t' % size is_signed = 1 elif desc == 'unsigned int': ctype = 'uint%d_t' % size is_signed = 0 elif desc == 'float': is_signed = 1 # shouldn't reall...
def preprocess_isa_desc(isa_desc):
def replace_include(matchobj, dirname): fname = matchobj.group('filename') full_fname = os.path.normpath(os.path.join(dirname, fname)) contents = ' (full_fname, read_and_flatten(full_fname)) return contents def read_and_flatten(filename): current_dir = os.path.dirname(filename) try: contents = open(filename).read() e...
def preprocess_isa_desc(isa_desc): # Find any includes and include them pos = 0 while 1: m = includeRE.search(isa_desc, pos) if not m: break filename = m.group('filename') print 'Including file "%s"' % filename try: isa_desc = isa_desc[:m.start()] + \ '##newfile "' + filename + '"\n' + \ open(filename).read() + \ '##en...
pos = 0 while 1: m = includeRE.search(isa_desc, pos) if not m: break filename = m.group('filename') print 'Including file "%s"' % filename try: isa_desc = isa_desc[:m.start()] + \ ' open(filename).read() + \ ' isa_desc[m.end():] except IOError: error(0, 'Error including file "%s"' % (filename)) pos = m.start() return i...
contents = includeRE.sub(lambda m: replace_include(m, current_dir), contents) fileNameStack.pop() return contents
def preprocess_isa_desc(isa_desc): # Find any includes and include them pos = 0 while 1: m = includeRE.search(isa_desc, pos) if not m: break filename = m.group('filename') print 'Including file "%s"' % filename try: isa_desc = isa_desc[:m.start()] + \ '##newfile "' + filename + '"\n' + \ open(filename).read() + \ '##en...
global input_filename input_filename = isa_desc_file global fileNameStack fileNameStack = [(input_filename, 1)] input = open(isa_desc_file) isa_desc = input.read() input.close() isa_desc = preprocess_isa_desc(isa_desc)
isa_desc = read_and_flatten(isa_desc_file) fileNameStack.push((isa_desc_file, 0))
def parse_isa_desc(isa_desc_file, output_dir): # set a global var for the input filename... used in error messages global input_filename input_filename = isa_desc_file global fileNameStack fileNameStack = [(input_filename, 1)] # Suck the ISA description file in. input = open(isa_desc_file) isa_desc = input.read() inpu...
s = re.sub(r'%(?!\()', '%%', s)
s = protect_non_subst_percents(s)
def process_output(s): # protect any non-substitution '%'s (not followed by '(') s = re.sub(r'%(?!\()', '%%', s) # protects cpu-specific symbols too s = protect_cpu_symbols(s) return substBitOps(s % templateMap)
return protect_cpu_symbols(self.template) % myDict
template = protect_cpu_symbols(template) return template % myDict
def subst(self, d): # Start with the template namespace. Make a copy since we're # going to modify it. myDict = templateMap.copy() # if the argument is a dictionary, we just use it. if isinstance(d, dict): myDict.update(d) # if the argument is an object, we use its attribute map. elif hasattr(d, '__dict__'): myDict.up...
def panic(*args, **kwargs):
def panic(string):
def panic(*args, **kwargs): print >>sys.stderr, 'panic:', string sys.exit(1)
path = [ '/dist/m5/system' ]
path = [ '/dist/m5/system', '/n/poolfs/z/dist/m5/system' ]
def load_defaults(): global systemdir, bindir, diskdir, scriptdir if not systemdir: try: path = env['M5_PATH'].split(':') except KeyError: path = [ '/dist/m5/system' ] for systemdir in path: if os.path.isdir(systemdir): break else: raise ImportError, "Can't find a path to system files." if not bindir: bindir = joinpa...
__all__ = ['env', 'issequence',
__all__ = ['env', 'issequence', 'panic',
def instantiate(root): instance = root.instantiate('root') instance.fixup() instance.display() if not noDot: dot = pydot.Dot() instance.outputDot(dot) dot.orientation = "portrait" dot.size = "8.5,11" dot.ranksep="equally" dot.rank="samerank" dot.write("config.dot") dot.write_ps("config.ps")
eval(args_left.pop(0))
exec args_left.pop(0)
def AddToPath(path): # if it's a relative path and we know what directory the current # python script is in, make the path relative to that directory. if not os.path.isabs(path) and sys.path[0]: path = os.path.join(sys.path[0], path) path = os.path.realpath(path) # sys.path[0] should always refer to the current script'...
return float(value[:-3]) * tera
return float(value[:-4]) * tera
def toNetworkBandwidth(value): if not isinstance(value, str): raise TypeError, "wrong type '%s' should be str" % type(value) if value.endswith('Tbps'): return float(value[:-3]) * tera elif value.endswith('Gbps'): return float(value[:-3]) * giga elif value.endswith('Mbps'): return float(value[:-3]) * mega elif value.en...
return float(value[:-3]) * giga
return float(value[:-4]) * giga
def toNetworkBandwidth(value): if not isinstance(value, str): raise TypeError, "wrong type '%s' should be str" % type(value) if value.endswith('Tbps'): return float(value[:-3]) * tera elif value.endswith('Gbps'): return float(value[:-3]) * giga elif value.endswith('Mbps'): return float(value[:-3]) * mega elif value.en...
return float(value[:-3]) * mega
return float(value[:-4]) * mega
def toNetworkBandwidth(value): if not isinstance(value, str): raise TypeError, "wrong type '%s' should be str" % type(value) if value.endswith('Tbps'): return float(value[:-3]) * tera elif value.endswith('Gbps'): return float(value[:-3]) * giga elif value.endswith('Mbps'): return float(value[:-3]) * mega elif value.en...
return float(value[:-3]) * kilo
return float(value[:-4]) * kilo
def toNetworkBandwidth(value): if not isinstance(value, str): raise TypeError, "wrong type '%s' should be str" % type(value) if value.endswith('Tbps'): return float(value[:-3]) * tera elif value.endswith('Gbps'): return float(value[:-3]) * giga elif value.endswith('Mbps'): return float(value[:-3]) * mega elif value.en...
return float(value[:-2])
return float(value[:-3])
def toNetworkBandwidth(value): if not isinstance(value, str): raise TypeError, "wrong type '%s' should be str" % type(value) if value.endswith('Tbps'): return float(value[:-3]) * tera elif value.endswith('Gbps'): return float(value[:-3]) * giga elif value.endswith('Mbps'): return float(value[:-3]) * mega elif value.en...
print 'type =', self.type
print 'type=%s' % self.type
def print_ini(self): print '[' + self.path() + ']' # .ini section header
print 'children =', ' '.join(np_child_names)
print 'children=%s' % ' '.join(np_child_names)
def print_ini(self): print '[' + self.path() + ']' # .ini section header
print param, '=', self._values[param].ini_str()
print '%s=%s' % (param, self._values[param].ini_str())
def print_ini(self): print '[' + self.path() + ']' # .ini section header
'Enum', 'Bool', 'String',
'Enum', 'Bool', 'String', 'Float',
def instantiate(root): global ticks_per_sec ticks_per_sec = float(root.clock.frequency) root.print_ini() noDot = True # temporary until we fix dot if not noDot: dot = pydot.Dot() instance.outputDot(dot) dot.orientation = "portrait" dot.size = "8.5,11" dot.ranksep="equally" dot.rank="samerank" dot.write("config.dot") do...
self.cmd.append('-Wdepend=afterok:%s' % self.after)
self.cmd.append('-Wdepend=afterok:%s' % self.afterok)
def build(self, script, args = []): self.cmd = [ self.qsub ]
raise TypeError, "%s is not of type BaseCPU", cpu
raise TypeError, "%s is not of type BaseCPU" % cpu
def switchCpus(cpuList): print "switching cpus" if not isinstance(cpuList, list): raise RuntimeError, "Must pass a list to this function" for i in cpuList: if not isinstance(i, tuple): raise RuntimeError, "List must have tuples of (oldCPU,newCPU)" [old_cpus, new_cpus] = zip(*cpuList) for cpu in old_cpus: if not isins...
xfn = os.normcase(os.normpath(x)) if fn[-len(xfn):]==xfn: return 1
xfn = os.path.normcase(os.path.normpath(x)) if makeabs(fn)[-len(xfn):]==xfn: return 1
def is_exceptional(fn,exceptions): for x in exceptions: xfn = os.normcase(os.normpath(x)) if fn[-len(xfn):]==xfn: return 1 return 0
dir = os.path.normcase(os.path.normpath(dir)) if not os.path.isabs(dir): dir = os.path.join(os.getcwd(),dir)
dir = makeabs(dir)
def usage(code=0, msg=''): f = code and sys.stderr or sys.stdout if msg is not None: f.write(msg+'\n') f.write(\
outdir = outputfile('')
outDir = outputfile('')
def test0(self): "Test if pythonpoint.pdf can be created from pythonpoint.xml."
outDir = join(rlDir, 'test')
def test0(self): "Test if pythonpoint.pdf can be created from pythonpoint.xml."
os.remove(pdf)
def test0(self): "Test if pythonpoint.pdf can be created from pythonpoint.xml."
formName = getFormName(pdfFileName, pageNo)
formName = self.getFormName(pdfFileName, pageNo)
def processPDF(self, pdfFileName, pageNo): formName = getFormName(pdfFileName, pageNo) storeForms(pdfFileName, formName + '.frm', prefix= formName + '_', pagenumbers=[pageNo]) print 'stored %s.frm' % formName return formName + '.frm'
A[j[0]] = (func is None) and val or apply(func,(v,))
A[j[0]] = (func is None) and v or apply(func,(v,))
def getAttributes(self,attr,attrMap): A = {} for k, v in attr.items(): k = string.lower(k) if k in attrMap.keys(): j = attrMap[k] func = j[1] try: A[j[0]] = (func is None) and val or apply(func,(v,)) except: self.syntax_error('%s: invalid value %s'%(k,v)) else: self.syntax_error('invalid attribute name %s'%k) return A
rv = _parser.parse(text,style)
l,rv = _parser.parse(text,style)
def parse(self, text, style): """Given a formatted string will return a list of ParaFrag objects with their calculated widths. If errors occur None will be returned and the self.errors holds a list of the error messages. """
for (None,l) in _parser.errors:
for l in _parser.errors:
def parse(self, text, style): """Given a formatted string will return a list of ParaFrag objects with their calculated widths. If errors occur None will be returned and the self.errors holds a list of the error messages. """
for l in rv: print l.fontName,l.fontSize,l.textColor,l.bold, l.rise, l.text[:25]
print l.fontName,l.fontSize,l.textColor,l.bold, l.rise, l.text[:25]
def parse(self, text, style): """Given a formatted string will return a list of ParaFrag objects with their calculated widths. If errors occur None will be returned and the self.errors holds a list of the error messages. """
style = self.style
def breakLinesCJK(self, width): """Initially, the dumbest possible wrapping algorithm. Cannot handle font variations."""
if version == 0x4F54544F: raise TTFError, 'OpenType fonts with PostScript outlines are not supported' if version != 0x00010000 and version != 0x74727565: raise TTFError, 'Not a TrueType font'
def __init__(self, file, validate=0): """Loads and parses a TrueType font file. file can be a filename or a file object. If validate is set to a false values, skips checksum validation. This can save time, especially if the font is large. """
raise TTFError, 'Not a TrueType font'
raise TTFError("Not a TrueType font: can't read version") if version == 0x4F54544F: raise TTFError, 'OpenType fonts with PostScript outlines are not supported' if version != 0x00010000 and version != 0x74727565 and version!=0x74746366: raise TTFError('Not a TrueType font: version=0x%8.8X' % version)
def __init__(self, file, validate=0): """Loads and parses a TrueType font file. file can be a filename or a file object. If validate is set to a false values, skips checksum validation. This can save time, especially if the font is large. """