当前位置: 首页>>代码示例>>Python>>正文


Python Interpreter类代码示例

本文整理汇总了Python中Interpreter的典型用法代码示例。如果您正苦于以下问题:Python Interpreter类的具体用法?Python Interpreter怎么用?Python Interpreter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Interpreter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Printing_Screen

    def Printing_Screen(self):
        self.scrollbar = Scrollbar(self.frame)
        self.scrollbar.grid(row=0, column=2, sticky=N+S)
        
        self.printing_l = Text(self.frame)
        self.printing_l.grid(row=0, column = 0)
        self.scrollbar.config(command=self.printing_l.yview)

        self.pause_b = Button(self.frame, text="Pause Printing", font=("Helvetica", 14),command= self.Pause_Screen)
        self.pause_b.grid(row=1, column = 0, pady=10)
        
        self.quit_b = Button(self.frame, text= "Quit Printing", font=("Helvetica", 14),command= self.to_quit)
        self.quit_b.grid(row=2, column = 0, pady=10)
        
        # Interpreter
        self.display_message("Reading file...")
        bricks = Interpreter.parsing(self.file.name)
        Interpreter.translation(bricks)
        self.display_message("Parsing file...")
        build_order = Interpreter.generate_build_order(bricks)
        self.display_message("Generating build order...")
        #build_list = Interpreter.generate_build_list(build_order)
        
        # Communication
        self.display_message("Opening communication channel...")
        com = Communicator()
        com.setup_connection()
        self.display_message("Communication established.")
        self.display_message("Printing...")
        bricks = com.print_bricks(build_order)
        for instruction in bricks:
    		  com.send_message(instruction[0], instruction[1])
        com.close_connection()
开发者ID:bogini,项目名称:Brickalicious,代码行数:33,代码来源:Gui.py

示例2: test1

def test1():
    '''test loop \"\" is used to post evaluation of a expression'''
    value = "International Bussiness Machine"
    expression = '''substr(value,indexOf(value,',','UWRD',-1),indexOf(value,'LWRD','END',-1))+substr(value,indexOf(value,'LWRD','SYB',1),-6)+substr(value,indexOf(value,'START','NUM',1),indexOf(value,'LWRD','SYB',-1))'''
    loopexp = "foreach(value.split(),\"substr(value,indexOf(value,'START','UWRD'),indexOf(value,'UWRD','LWRD'))\")"
    e = Interpreter(loopexp)
    print e.execute(value)
开发者ID:CDECatapult,项目名称:Web-Karma,代码行数:7,代码来源:testcase.py

示例3: test5

def test5():
    '''test loop'''
    stript = '''substr(value,indexOf(value,'NUM','\.',1),indexOf(value,'\.','22',1))+'edu'+'/'+'images'+'/'+substr(value,indexOf(value,'ANY','NUM',-1),-12)+'/'+substr(value,indexOf(value,'START','NUM',1),-12)+substr(value,-9,-8)+substr(value,5,16)
'''
    value = "1978.43.8_1a.jpg"
    e = Interpreter(stript)
    print e.execute(value)
开发者ID:CDECatapult,项目名称:Web-Karma,代码行数:7,代码来源:testcase.py

示例4: test0

def test0():
    '''test concatenation'''
    s = "13 Jan 2008 00:00:00 +0000"
    scripts = '''substr(value,indexOf(value,'START','NUM',1),12)+loop(value,"substr(value,-11,18)")+substr(value,12,-12)
'''
    a = Interpreter(scripts)
    print a.execute(s)
开发者ID:CDECatapult,项目名称:Web-Karma,代码行数:7,代码来源:testcase.py

示例5: TinyShell

def TinyShell (prompt='>>> '):
    while True:
        try:
            line = raw_input (prompt)
            buffer = StringIO (line)
            Interpreter.evaluate (buffer)
            buffer.close ()
        except EOFError:
            break
开发者ID:erhuabushuo,项目名称:compiler-book,代码行数:9,代码来源:TinyPython.py

示例6: test4

def test4():
    '''test switch function'''
    condi1 = "len(value) < 10"
    condi2 = "len(value) < 10"
    loopexp1 = "foreach(value.split(),\"substr(value,indexOf(value,'START','UWRD'),indexOf(value,'UWRD','LWRD'))\")"
    loopexp2 = '''foreach(foreach(value.split(),\"substr(value,indexOf(value,'START','UWRD'),indexOf(value,'UWRD','LWRD'))\"),\"value+'see'\")'''
    tuplist = "[("+condi1+","+loopexp1+"),("+condi2+","+loopexp2+")]"
    sw = "switch("+tuplist+")"
    value = "International Bussiness Machine"
    e = Interpreter(sw)
    print e.execute(value)
开发者ID:CDECatapult,项目名称:Web-Karma,代码行数:11,代码来源:testcase.py

示例7: TinyPython

def TinyPython ():
    parser = optparse.OptionParser ()
    parser.add_option ("-v", "--version", dest='version', default=False,
                       help="Print version", action="store_true")
    (options, args) = parser.parse_args ()
    if options.version is True:
        PrintVersion ()
        return
    if len (args) > 0:
        try:
            with open (args [0], 'r') as fd:
                Interpreter.evaluate (fd)
        except IOError:
            print >>sys.stderr, 'Unable to open [%s]' % args [0]
    else:
        TinyShell ()
开发者ID:erhuabushuo,项目名称:compiler-book,代码行数:16,代码来源:TinyPython.py

示例8: interactive

def interactive():
    while (True):
        line = raw_input(": ")
        if (line == "quit"): break

        val = Interpreter.evaluate(line, False)
        if (val != 0): return val
开发者ID:crockeo,项目名称:finalproject,代码行数:7,代码来源:Interactive.py

示例9: handle

    def handle(self):
        reload(Interpreter);
        self.recvMsg = self.request.recv(1024).strip();
        self.sndMsg = Interpreter.parseCommand(self.recvMsg, self.client_address);
        cur_thread = threading.currentThread();
        
        print "======== New Event (TCP) @ %s =========" % time.ctime(time.time());
        print "Thread: %s" % cur_thread.getName();
        print "Client: %s" % self.client_address[0];
        print "Incoming Msg: %s" % self.recvMsg;
        print "Outgoing Msg: %s\n\n" % self.sndMsg;
        print "----------------end--------------------";

        if self.sndMsg != None:
            self.request.send(self.sndMsg);
开发者ID:Leo810,项目名称:mobidfs,代码行数:15,代码来源:MainEntry.py

示例10: main

def main():
	"""
	Runs the main JTL program.

	:return: int
	"""

	#Parse arguments
	parser = argparse.ArgumentParser(description='JSON Transformation Language')
	parser.add_argument('-i', '--indent', default=4, type=int, help='Indentation amount.')
	parser.add_argument('-t', '--transform-file', help='The name of the JSON file containing the transformation to run.')
	parser.add_argument('transform', nargs='?', help='The transformation to run.')
	arguments = parser.parse_args(sys.argv[1:])

	#Load the transformation
	if arguments.transform is None and arguments.transform_file is not None:
		#From a file
		with open(arguments.transform_file, 'r') as f:
			transformStr = f.read()
	elif arguments.transform is not None and arguments.transform_file is None:
		#From the command line
		transformStr = arguments.transform
	else:
		print('ERROR: Specify either a transform file or a transform')
		return 1

	transformData = json.loads(transformStr)

	#Read the JSON in from stdin
	#TODO: error handling
	data = json.loads(sys.stdin.read())

	#Transform the JSON
	#TODO: cleaner way to do this
	sys.path.append('.')
	import Interpreter
	result = Interpreter.transformJson(data, transformData)

	#Output the result
	print(json.dumps(result, indent=arguments.indent, sort_keys=True))

	return 0
开发者ID:AgalmicVentures,项目名称:JTL,代码行数:42,代码来源:__init__.py

示例11: test_MultiplyOnly4

 def test_MultiplyOnly4(self):
     interpreter = Interpreter("1*2")
     result = interpreter.interpret();
     self.assertEqual(2, result)
开发者ID:dbarisakkurt,项目名称:interpreter-tutorial,代码行数:4,代码来源:InterpreterTest.py

示例12: test_AddyOnly2

 def test_AddyOnly2(self):
     interpreter = Interpreter("1   +2+3     ")
     result = interpreter.interpret();
     self.assertEqual(6, result)
开发者ID:dbarisakkurt,项目名称:interpreter-tutorial,代码行数:4,代码来源:InterpreterTest.py

示例13: test3

def test3():
    '''test embeded loop'''
    value = "International Bussiness Machine"
    loopexp = '''foreach(foreach(value.split(),\"substr(value,indexOf(value,'START','UWRD'),indexOf(value,'UWRD','LWRD'))\"),\"value+'See'\")'''
    e = Interpreter(loopexp)
    print e.execute(value)
开发者ID:CDECatapult,项目名称:Web-Karma,代码行数:6,代码来源:testcase.py

示例14: test_Mixed2

 def test_Mixed2(self):
     interpreter = Interpreter("0/2-3+1*2")
     result = interpreter.interpret();
     self.assertEqual(-1, result)
开发者ID:dbarisakkurt,项目名称:interpreter-tutorial,代码行数:4,代码来源:InterpreterTest.py

示例15: analyse_buffer_options

def analyse_buffer_options(globalpos, env, posargs, dictargs, defaults=None, need_complete=True):
    """
    Must be called during type analysis, as analyse is called
    on the dtype argument.

    posargs and dictargs should consist of a list and a dict
    of tuples (value, pos). Defaults should be a dict of values.

    Returns a dict containing all the options a buffer can have and
    its value (with the positions stripped).
    """
    if defaults is None:
        defaults = buffer_defaults
    
    posargs, dictargs = Interpreter.interpret_compiletime_options(posargs, dictargs, type_env=env, type_args = (0,'dtype'))
    
    if len(posargs) > buffer_positional_options_count:
        raise CompileError(posargs[-1][1], ERR_BUF_TOO_MANY)

    options = {}
    for name, (value, pos) in dictargs.iteritems():
        if not name in buffer_options:
            raise CompileError(pos, ERR_BUF_OPTION_UNKNOWN % name)
        options[name] = value

    for name, (value, pos) in zip(buffer_options, posargs):
        if not name in buffer_options:
            raise CompileError(pos, ERR_BUF_OPTION_UNKNOWN % name)
        if name in options:
            raise CompileError(pos, ERR_BUF_DUP % name)
        options[name] = value

    # Check that they are all there and copy defaults
    for name in buffer_options:
        if not name in options:
            try:
                options[name] = defaults[name]
            except KeyError:
                if need_complete:
                    raise CompileError(globalpos, ERR_BUF_MISSING % name)

    dtype = options.get("dtype")
    if dtype and dtype.is_extension_type:
        raise CompileError(globalpos, ERR_BUF_DTYPE)

    ndim = options.get("ndim")
    if ndim and (not isinstance(ndim, int) or ndim < 0):
        raise CompileError(globalpos, ERR_BUF_NDIM)

    mode = options.get("mode")
    if mode and not (mode in ('full', 'strided', 'c', 'fortran')):
        raise CompileError(globalpos, ERR_BUF_MODE)

    def assert_bool(name):
        x = options.get(name)
        if not isinstance(x, bool):
            raise CompileError(globalpos, ERR_BUF_BOOL % name)

    assert_bool('negative_indices')
    assert_bool('cast')

    return options
开发者ID:bhy,项目名称:cython-haoyu,代码行数:62,代码来源:Buffer.py


注:本文中的Interpreter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。