def setUp(self): self.programa = Program("FirstProgram",5) self.programaB = Program("SecondProgram") self.instruccionA = Instruccion("Accion 1") self.instruccionB = Instruccion("Accion 2") self.instruccionC = Instruccion("Accion 3") self.instruccionD = IOInstruccion("Imprimir Pagina. ", "Printer") self.instruccionE = IOInstruccion("Leer CD. ", "CDROM")
def main (): prog = sys.argv[1] ## open program to parse (read whole program into memory, it's small enough) with open(prog,'r') as f: towerProgram = Program.removeCommentedText(f.read()) ### parse instrumentlibrary for additional metadata insLib = parse('instrumentlibrary.xml') ## parse program to get aliases, constants, and units aliases = Program.getAliases(towerProgram) constants = Program.getConstants(towerProgram) units = Program.getUnits(towerProgram) ## start and initialize new xml for this program doc = xmlutils.createNewProgramXML() xmlutils.addTextNodeToRoot(doc,"progName",prog) tablesNode = xmlutils.addNode(doc,'root','tables') ### put datatable info in the progxml tables = Program.getTables(towerProgram) for text in tables: ### use text and program info to construct Table object table = Table(text,aliases,constants,units) ### add table info (name and interval) to xml tableNode = doc.createElement("table") table.addTableInfo(doc,tableNode) ### process output instructions and store variable info ### to the progxml variablesNode = xmlutils.addNode(doc,tableNode,'variables') table.processOutputInstructions(doc,variablesNode,insLib) tablesNode.appendChild(tableNode) #do some cleaning up of xml (so it's easy for humans to view in texteditor) progxml = xmlutils.cleanupXML(doc) ### save progxml xmlout = open(prog + '.xml','w') print >>xmlout, progxml
def breach(): breach = prg.Breach(deck["breach"]) breach.setSkillLvl(deck["breach"]) stmt, chk = breach.skillCheck() textBox.insert(END, stmt) if chk: textBox.insert(END, "You're in.") else: textBox.insert(END, "No dice.")
def btn_Chup(self): mauphathien = "None" ret, img = self.cam.read() ret, img = self.cam.read() name = self.cbb_Mauthu1.currentText() data = pg.read_from_db(name) _, phathien = BoLoc(data, img) if phathien: mauphathien = name g2.send("A") else: name = self.cbb_Mauthu2.currentText() data = pg.read_from_db(name) _, phathien = BoLoc(data, img) if phathien: mauphathien = name g2.send("B") else: name = self.cbb_Mauthu3.currentText() data = pg.read_from_db(name) _, phathien = BoLoc(data, img) if phathien: mauphathien = name g2.send("C") else: mauphathien = "None" frame = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # get frame infos height, width, channel = frame.shape step = channel * width # create QImage from RGB frame qImg = QImage(frame.data, width, height, step, QImage.Format_RGB888) self.lb_Img.setPixmap(QPixmap.fromImage(qImg)) self.lb_Mauphathien.setText(mauphathien)
def __init__(self, x, y, size): self.pos = math3d.vec2(x, y) self.size = size if mapSquare.vbuff == None or mapSquare.tbuff == None or mapSquare.ibuff == None: mapSquare.vbuff = array.array("f") mapSquare.tbuff = array.array("f") mapSquare.ibuff = array.array("I") mapSquare.tex = ImageTexture2DArray(globs.mapTextures) Shapes.createSquare(mapSquare.vbuff, self.size, self.pox.x, self.pos.y) Shapes.createSquareIndexArray(mapSquare.ibuff) glCommands.setup(mapSquare.vbuff, mapSquare.ibuff, mapSquare.tbuff) mapSquare.prog = Program("vs.txt", "fs.txt")
def mate(self, mother, father): child = Program.Program('Child', self.config) child.assignments['preloop'] = [] for assignment in mother.assignments['preloop']: new_assignment = Program.Assignment( self.config, assignment.variable, False, np.random.normal( assignment.lhs, self.config.CONST_MATING_DRIFT * abs(assignment.lhs))) child.assignments['preloop'].append(new_assignment) if ('const' in assignment.variable): child.consts['loop'].append(assignment.variable) child.consts['global'].append(assignment.variable) for assignment in father.assignments['preloop']: new_assignment = Program.Assignment( self.config, assignment.variable, False, np.random.normal( assignment.lhs, self.config.CONST_MATING_DRIFT * abs(assignment.lhs))) child.assignments['preloop'].append(new_assignment) if ('const' in assignment.variable): child.consts['loop'].append(assignment.variable) child.consts['global'].append(assignment.variable) tree_mother = copy.deepcopy(mother.loop_tree) tree_father = copy.deepcopy(father.loop_tree) crossover_mother = rec_select_random_tree_node(tree_mother) crossover_father = rec_select_random_tree_node(tree_father) crossover_direction = random.choice(['LEFT', 'RIGHT']) if (crossover_direction == 'LEFT'): crossover_mother.left_child = crossover_father else: crossover_mother.right_child = crossover_father child.loop_tree = tree_mother child.rec_reduce() return child
def setup(pointArray): glEnable(GL_MULTISAMPLE) glClearColor(0, 0, 0, 1.0) my_buffer = Buffer(pointArray)#array.array("f", [0, 0])) # GenerateVAO tmp = array.array("I", [0]) glGenVertexArrays(1, tmp) vao = tmp[0] glBindVertexArray(vao) # Tell GL about buffer layout and use the buffer my_buffer.bind(GL_ARRAY_BUFFER) glEnableVertexAttribArray(0) # which pipe, items per vertex, type per item, auto-normalize, data size per item in bytes, start in buffer # numPoints = len(arrayOfPoints) glVertexAttribPointer(0, 2, GL_FLOAT, False, 2 * 4, 0) # unbind # glBindVertexArray(0) prog = Program("vs.txt", "fs.txt") prog.use()
def parse(self): tok = self.lex.get_next_token() self.match(tok, TokenType.FUNC_KW_TOK) id_var = self.get_id() tok = self.lex.get_next_token() self.match(tok, TokenType.OPEN_PAREN_TOK) tok = self.lex.get_next_token() self.match(tok, TokenType.CLOSE_PAREN_TOK) block = self.get_block() tok = self.lex.get_next_token() self.match(tok, TokenType.END_KW_TOK) tok = self.lex.get_next_token() self.match(tok, TokenType.EOS_TOK) return Program.Program(block)
def loadDataOnGui(self, name): global data data = pg.read_from_db(name) self.horizontalSlider.setValue(data[0][0]) self.horizontalSlider_2.setValue(data[0][1]) self.horizontalSlider_3.setValue(data[0][2]) self.horizontalSlider_4.setValue(data[0][3]) self.horizontalSlider_5.setValue(data[0][4]) self.horizontalSlider_6.setValue(data[0][5]) self.label_16.setText(str(data[0][0])) self.label_17.setText(str(data[0][1])) self.label_18.setText(str(data[0][2])) self.label_19.setText(str(data[0][3])) self.label_20.setText(str(data[0][4])) self.label_21.setText(str(data[0][5]))
def AddProgramIfThereIsntOne(self): # check if there is already a program in the document doc = cad.GetApp() object = doc.GetFirstChild() while object != None: if object.GetType() == Program.type: self.program = object return object = doc.GetNextChild() # add a program self.program = Program.Program() programs.append(self.program) self.program.add_initial_children() cad.AddUndoably(self.program)
def main(): # Trap on SIGINTs signal.signal(signal.SIGINT, signalHandler) # parse arguments parser = CliParser.initParser() # run program Program.Run(parser) # Process the verbose log file to write the test execution results to an # Excel file in a more readable format if need be. processResults() return
def testCheckPointInElement(self): #Arrange x1 = Pslg.GridPoint(0, 0) x2 = Pslg.GridPoint(2, 0) x3 = Pslg.GridPoint(1, 1) e = ElementAwarePslg.Element(x1, x2, x3, 0) program = Program.FemResultsViewer(None, None) #Act & Assert self.assertTrue(program.CheckPointInElement(e, 0, 0)) self.assertTrue(program.CheckPointInElement(e, 2, 0)) self.assertTrue(program.CheckPointInElement(e, 1, 1)) self.assertTrue(program.CheckPointInElement(e, 1, 0)) self.assertTrue(program.CheckPointInElement(e, 1.5, 0.5)) self.assertTrue(program.CheckPointInElement(e, 0.5, 0.5)) self.assertTrue(program.CheckPointInElement(e, 1, 0.5))
def __init__(self, startPos): self.life = globs.particleLife self.currentTime = 0 self.startTime = 0 self.worldMatrix = translation2(startPos) if ParticleSystem.vao == None: vbuff = array.array("f") tbuff = array.array("f") Shapes.createRandPoints(vbuff, globs.particleCount) #Create randomVelocities tbuff = Shapes.createSquareTextureArray(tbuff) ParticleSystem.vao = glCommands.setup(vbuff, tbuff) ParticleSystem.vSize = len(vbuff) ParticleSystem.tex = ImageTexture2DArray(globs.starTextures[0]) ParticleSystem.prog = Program("particleVS.txt", "particleFS.txt")
def alter(): subject = inpBox.get('1.0', END) if subject == '\n': textBox.insert(END, "What are you altering?") else: subject = subject[:-1] alter = prg.Alter(deck["alter"]) stmt, chk = alter.skillCheck() textBox.insert(END, stmt) if chk: textBox.insert(END, subject + " successfully changed, backing out.") else: textBox.insert(END, "No dice.")
def __init__(self, pos, scale, life, speed, name, centered=False): self.name = name self.pos = pos.xyz self.scale = scale.xyz self.rotation = 0 self.worldMatrix = None self.setWorldMatrix() self.life = life self.speed = speed #self.hitBox = BoundingBox(self.pos, vec3(x+Width, y+Height, z+Depth)) self.deathFadeT = globs.bulletLife self.State = globs.ALIVE self.fadeTime = 0 self.centered = centered if Entity.vao == None: vbuff = array.array("f") centerVbuff = array.array("f") tbuff = array.array("f") centerTBuff = array.array("f") ibuff = array.array("I") centerIBuff = array.array("I") Shapes.createSquare( vbuff, 1, 1, 0, 0) #create vbuff of square that is 1 by 1 at center of screen Shapes.createSquare(centerVbuff, 1, 1, 0, 0, True) Shapes.createSquareIndexArray(ibuff) Shapes.createSquareIndexArray(centerIBuff, True) Shapes.createSquareTextureArray(tbuff) Shapes.createSquareTextureArray(centerTBuff, 1, True) Entity.vao = glCommands.setup(vbuff, tbuff, ibuff) Entity.centerVao = glCommands.setup(centerVbuff, centerTBuff, centerIBuff) Entity.ibuffSize = len(ibuff) Entity.ibuffCenterSize = len(centerIBuff) Entity.ibuffStart = 0 Entity.prog = Program("vs.txt", "fs.txt")
def parse(src): i = 0 prog = Program.Program() lines, lastnewline = 1, -1 # so can give error locations as line:char tokenstart = 0, 1, 1 # byte, line, char state = 0 while i < len(src): while i < len(src) and src[i] not in (A, B, C): i += 1 if i >= len(src): break if state == 0: tokenstart = (i, lines, i - lastnewline) if src[i] == "\n": lines += 1 lastnewline = i next = DFA[(state, src[i])] action = type(next) if action is int: # next state in tree state = next elif action is tuple: # next opcode state = 0 opcode, parameter = next if parameter is int: (x, i) = parseNumber(src, i + 1) lines += 1 # parseNumber will end on a \n lastnewline = i prog.programdata.append(opcode(tokenstart, x)) elif parameter is str: (x, i) = parseString(src, i + 1) lines += 1 lastnewline = i prog.programdata.append(opcode(tokenstart, x)) else: prog.programdata.append(opcode(tokenstart)) else: # invalid state print( "Error parsing script: %s is not a valid command at byte 0x%X (line %d char %d)\n" % ((next, ) + tokenstart)) print("Program so far: ", repr(prog)) return None i += 1 # find all the labels for i in range(len(prog.programdata)): if prog.programdata[i].opcode == Program.Opcodes.Label: prog.labels[prog.programdata[i].label] = i return prog
def __init__(self, pos, meshName, shininess): self.pos = pos.xyz self.worldMatrix = translation3(self.pos) self.mesh = None self.Light = LightObj( vec3(0, .5, 1), # Position vec3(.3, .7, 1), # Color vec3(.1,.6,1), # Attenuation 1, # Positional 0 or 1 -1, # Spotlight angle -1 for omnidirectional vec3(0,0,1)) # Spotlight Dir self.alpha = 1 self.shininess = shininess if MapRoom.prog == None: MapRoom.prog = Program("vs.txt", "fs.txt") self.setMesh(meshName)
def __init__(self, fontname, size): if Text.prog == None: Text.prog = Program("TextVertexShader.txt", "TextFragmentShader.txt") self.txt = "temp" self.samp = Sampler() self.font = TTF_OpenFont( os.path.join("assets", fontname).encode(), size) open(os.path.join("assets", fontname)) vbuff = Buffer(array.array("f", [0, 0, 1, 0, 1, 1, 0, 1])) ibuff = Buffer(array.array("I", [0, 1, 2, 0, 2, 3])) tmp = array.array("I", [0]) glGenVertexArrays(1, tmp) self.vao = tmp[0] glBindVertexArray(self.vao) ibuff.bind(GL_ELEMENT_ARRAY_BUFFER) vbuff.bind(GL_ARRAY_BUFFER) glEnableVertexAttribArray(0) glVertexAttribPointer(0, 2, GL_FLOAT, False, 2 * 4, 0) glBindVertexArray(0) self.tex = DataTexture2DArray(1, 1, 1, array.array("B", [0, 0, 0, 0])) self.textQuadSize = vec2(0, 0) self.pos = vec2(0, 0) self.dirty = False surf1p = TTF_RenderUTF8_Blended(self.font, self.txt.encode(), SDL_Color(255, 255, 255, 255)) surf2p = SDL_ConvertSurfaceFormat(surf1p, SDL_PIXELFORMAT_ABGR8888, 0) w = surf2p.contents.w h = surf2p.contents.h pitch = surf2p.contents.pitch if pitch != w * 4: print("Uh Oh!", pitch, w) pix = surf2p.contents.pixels B = string_at(pix, pitch * h) self.tex.setData(w, h, 1, B) SDL_FreeSurface(surf2p) SDL_FreeSurface(surf1p) self.textQuadSize = vec2(w, h) self.dirty = False Program.setUniform("textPosInPixels", self.pos) Program.setUniform("textQuadSizeInPixels", self.textQuadSize) Program.updateUniforms()
def processData(rawData): main = processFunction(rawData['main'], 'main') program = Program(main) if 'fun1' in rawData: f1 = processFunction(rawData['fun1'], 'fun1') program.addFunction(f1) if 'fun2' in rawData: f2 = processFunction(rawData['fun2'], 'fun2') program.addFunction(f2) return program
def __init__(self, fontname, size): if Text.prog == None: Text.prog = Program("textvs.txt", "textfs.txt") TTF_Init() self.font = TTF_OpenFont( os.path.join("assets", fontname).encode(), size) vbuff = Buffer(array.array("f", [0, 0, 1, 0, 1, 1, 0, 1])) ibuff = Buffer(array.array("I", [0, 1, 2, 0, 2, 3])) tmp = array.array("I", [0]) glGenVertexArrays(1, tmp) self.vao = tmp[0] glBindVertexArray(self.vao) ibuff.bind(GL_ELEMENT_ARRAY_BUFFER) vbuff.bind(GL_ARRAY_BUFFER) glEnableVertexAttribArray(0) glVertexAttribPointer(0, 2, GL_FLOAT, False, 2 * 4, 0) glBindVertexArray(0) self.tex = DataTexture2DArray(1, 1, 1, array.array("B", [0, 0, 0, 0])) self.textQuadSize = vec2(0, 0) self.pos = vec2(0, 0) self.dirty = False
def main(): f = open("input.txt", "r") inp = f.read().strip() res = None i = 0 program = None while res is None: program = Program.Program(inp) (op_code, argument) = program.program[i] if (op_code != nop.nop) & (op_code != Jump.jump): i += 1 continue if op_code == nop.nop: program.program[i] = Jump.jump, argument else: program.program[i] = nop.nop, argument res = program.start() i += 1 print(i) (res, cmp) = res print(cmp.accumulator)
def btnSave(self): r = self.table.rowCount() c = self.table.columnCount() data = [] error = 0 for row in range(1, r): d = [] for column in range(c): item = self.table.item(row, column).text() if column == 5: d.append(item) else: try: d.append(float(item)) except: error = 1 message = "row: " + str(row + 1) + " Column: " + str( column + 1) + " must be number!" QMessageBox.about(self, "Program Error", message) break if error: break else: data.append(d) if error == 0: namepg = self.cbb_Program.currentText() pg.del_and_update(namepg) pg.create_table(namepg) for r in range(len(data)): pg.data_entry(namepg, data[r]) pg.conn.commit() message = namepg + " save Ok" QMessageBox.about(self, "Save", message) name2 = pg.get_all_nameTableDB() self.cbb_Program.clear() self.cbb_Program.addItems(name2[::-1]) self.loadTable(namepg)
class uAssembler: def __init__(self): self.program = Program() def parseFile(self, filename): #Read the lines with open(filename) as f: lines = f.readlines() i = 1 #Add the lines to the program structure for line in lines: newLine = ProgramLine(line, i) self.program.addLine(newLine) i += 1 self.program.cleanLines() self.program.parseConstants()
class MainWin(QtGui.QMainWindow): def __init__(self,bt): QtGui.QMainWindow.__init__(self) self.bt = bt # Set up the user interface from Designer. self.ui = uic.loadUi(UI_FILE) self.ui.show() sc = TehFigure(self.ui.plotlayout) self.HLT = XTun(self.ui, bt, "h", self.ui.HLTSet, self.ui.HLTTemp, self.ui.toggleHLT, self.ui.HLTdial,self.ui.HLTPower) self.MLT = XTun(self.ui, bt, "m", self.ui.MLTSet, self.ui.MLTTemp, self.ui.toggleMLT, self.ui.MLTdial,self.ui.MLTPower) self.programstatus = Program(self.ui, bt,sc,self.ui.tableView) def updateui(self): self.MLT.update() self.HLT.update() self.programstatus.update() def startprogram(self, filename): self.programstatus.load(filename) self.programstatus.run()
class TestProgram(unittest.TestCase): def setUp(self): self.programa = Program("FirstProgram",5) self.programaB = Program("SecondProgram") self.instruccionA = Instruccion("Accion 1") self.instruccionB = Instruccion("Accion 2") self.instruccionC = Instruccion("Accion 3") self.instruccionD = IOInstruccion("Imprimir Pagina. ", "Printer") self.instruccionE = IOInstruccion("Leer CD. ", "CDROM") def tearDown(self): pass def testBuilder(self): self.assertEquals(len(self.programa.instruction),0) self.assertFalse(self.programa.isInMemory()) self.assertEquals(self.programa.priority,5) self.assertEquals(self.programaB.priority,10) def testAddyGetSize(self): self.programa.add(self.instruccionA) self.programa.add(self.instruccionB) self.assertEquals(len(self.programa.instruction),2) self.assertEquals(self.programa.getSize(),2) self.programa.add(self.instruccionC) self.programa.add(self.instruccionD) self.programa.add(self.instruccionE) self.assertEquals(self.programa.getSize(),5) def testgetName(self): self.assertEquals(self.programa.getName(),"FirstProgram") def testLoadInMemory(self): self.programa.loadInMemory() self.assertTrue(self.programa.isInMemory())
print("1. About to import program") import Program print("2. Program imported") print("3. Printing header") Program.print_header() print("4. Done with Program!")
def test_parseAction_Encode(): """Test parsovani akce.""" assert p.parseAction('Z') == 1
def test_decodeText_Filip(): """Test dekodovani.""" assert p.decodeText('..-. .. .-.. .. .--.') == 'FILIP'
def test_encodeText_Filip(): """Test kodovani.""" assert p.encodeText('Filip') == '..-. .. .-.. .. .--.'
def test_decodeText_Numbers(): """Test dekodovani.""" assert p.decodeText('.---- .-..-. ..--- .-..-. ...--') == '1 2 3'
def __init__(self): self.program = Program()
IoInstruccion2 = IOInstruccion("Imprimir Pagina 2. ", "Printer") IoInstruccion3 = IOInstruccion("Imprimir Pagina 3. ", "Printer") IoInstruccion4 = IOInstruccion("Imprimir Pagina 4. ", "Printer") IoInstruccion5 = IOInstruccion("Imprimir Pagina 5. ", "Printer") IoInstruccion6 = IOInstruccion("Leer Pista 1. ", "CDROM") IoInstruccion7 = IOInstruccion("Leer Pista 2. ", "CDROM") IoInstruccion8 = IOInstruccion("Leer Pista 3. ", "CDROM") IoInstruccion9 = IOInstruccion("Leer Pista 4. ", "CDROM") IoInstruccion10 = IOInstruccion("Leer Pista 5. ", "CDROM") CpuInstruccion1= Instruccion("Instruccion de CPU #1") CpuInstruccion2= Instruccion("Instruccion de CPU #2") CpuInstruccion3= Instruccion("Instruccion de CPU #3") CpuInstruccion4= Instruccion("Instruccion de CPU #4") CpuInstruccion5= Instruccion("Instruccion de CPU #5") Programa1 = Program("Programa1") Programa1.add(CpuInstruccion1) Programa1.add(CpuInstruccion2) Programa1.add(IoInstruccion1) Programa1.add(IoInstruccion5) Programa1.add(CpuInstruccion4) Programa2 = Program("Programa2",2) Programa2.add(CpuInstruccion4) Programa2.add(CpuInstruccion5) Programa2.add(IoInstruccion3) Programa2.add(IoInstruccion6) Programa2.add(CpuInstruccion5) Programa2.add(IoInstruccion4) Programa2.add(IoInstruccion7) Programa2.add(CpuInstruccion3) Programa2.add(IoInstruccion5)
self.pcbTable.addPCB(pcb) schedulerLong.addPCB(pcb, self) #Prueba # number last cpu i1 = Instruction(1, False, True) i2 = Instruction(2, False, True) i3 = Instruction(3, False, False) # es de I/O i4 = Instruction(4, False, True) i5 = Instruction(5, False, True) i6 = Instruction(6, True, True) i7 = Instruction(7, True, True) i8 = Instruction(8, True, True) p1 = Program("p1",1) p1.addInstruction(i1) p1.addInstruction(i6) p2 = Program("p2",5) p2.addInstruction(i2) p2.addInstruction(i3) p2.addInstruction(i7) p3 = Program("p3",8) p3.addInstruction(i4) p3.addInstruction(i5) p3.addInstruction(i8) disk = Disk() disk.write(p1)
class SimpleTests(unittest.TestCase): def setUp(self): """Call before every test case.""" self.parser = ProgramParser() self.program = Program() self.program.name="TestProgram" def testNormalProg(self): self.parser.loadFromFile("normal.stdl") self.program.tokens=self.parser.tokens gen=self.program.populate() try: typ,imp=gen.next() gen.next() except StopIteration: pass else: self.fail('Why has execution stopped') assert typ=='imp',typ assert imp==['imports.stdl'],imp imports=self.program.initParams.params["imports"][0] assert imports=="imports.stdl",imports def testDefectiveProg1(self): self.parser.loadFromFile("defective1.stdl") self.program.tokens=self.parser.tokens self.assertRaises(SemanticInitException,self.program.populate().next) def testDuplicates(self): test1=Test() test2=Test() test3=Test() test4=Test() test1.test="a" test2.test="b" test3.test="b" test4.test="a" self.program.children=[test1,test2,test3,test4] duplicates=self.program.getDuplicates() assert ' a ' in duplicates assert ' b ' in duplicates #-------------------------- Integration tests ------------------------------------------------- def testGetCode1(self): self.parser.loadFromFile('normal.stdl') self.program.tokens=self.parser.tokens gen=self.program.populate() try: typ,imp=gen.next() gen.next() except StopIteration: pass else: self.fail('Why has execution stopped') c,code=self.program.getCode() assert 'returns >= 2' in code assert 'c2.add(new Point(-1,-1));' in code assert 'c1.add(new Point(-1,1));' in code def testGetCode2(self): self.parser.loadFromFile('..\\examples\\dateCheck.stdl') self.program.tokens=self.parser.tokens gen=self.program.populate() try: typ,imp=gen.next() except StopIteration: pass else: self.fail('Why has execution stopped') c,code=self.program.getCode() assert 'day = 28' in code assert 'assert returns == true' in code assert 'month = 6' in code
from Program import * game = Program() game.execute()
def setUp(self): """Call before every test case.""" self.parser = ProgramParser() self.program = Program() self.program.name="TestProgram"
def test_encodeText_Numbers(): """Test kodovani.""" assert p.encodeText('1 2 3') == '.---- .-..-. ..--- .-..-. ...--'
class TestProgram(unittest.TestCase): def setUp(self): self.programa = Program("FirstProgram", 5) self.programaB = Program("SecondProgram") self.instruccionA = Instruccion("Accion 1") self.instruccionB = Instruccion("Accion 2") self.instruccionC = Instruccion("Accion 3") self.instruccionD = IOInstruccion("Imprimir Pagina. ", "Printer") self.instruccionE = IOInstruccion("Leer CD. ", "CDROM") def tearDown(self): pass def testBuilder(self): self.assertEquals(len(self.programa.instruction), 0) self.assertFalse(self.programa.isInMemory()) self.assertEquals(self.programa.priority, 5) self.assertEquals(self.programaB.priority, 10) def testAddyGetSize(self): self.programa.add(self.instruccionA) self.programa.add(self.instruccionB) self.assertEquals(len(self.programa.instruction), 2) self.assertEquals(self.programa.getSize(), 2) self.programa.add(self.instruccionC) self.programa.add(self.instruccionD) self.programa.add(self.instruccionE) self.assertEquals(self.programa.getSize(), 5) def testgetName(self): self.assertEquals(self.programa.getName(), "FirstProgram") def testLoadInMemory(self): self.programa.loadInMemory() self.assertTrue(self.programa.isInMemory())
def setup(): global starAmount global starsVao global quadProg global StarProgram global ShipProg global beep global enemyProg global enemy1Prog global backgroundProg global main_program global monster_program global ship global fire global enemy global enemy1 global nebula global powerup global powerup1 global cam global monster global starList global bullet1 global myShip global skyboxProg global skybox global skyboxTexture beep = Mix_LoadWAV(os.path.join("assets", "Beep-09.ogg").encode()) glEnable(GL_MULTISAMPLE) glClearColor(0.0, 0.0, 0.0, 1.0) starAmount = 50 starList = [] star_points = [] for i in range(starAmount): starList.append(Star()) for i in range(len(starList)): star_points.append(starList[i].x) star_points.append(starList[i].y) A = array.array("f", star_points) b = Buffer(A) tmp = array.array("I", [0]) glGenVertexArrays(1, tmp) starsVao = tmp[0] glBindVertexArray(starsVao) b.bind(GL_ARRAY_BUFFER) glEnableVertexAttribArray(0) glVertexAttribPointer(0, 2, GL_FLOAT, False, 2 * 4, 0) glBindVertexArray(0) myShip = Ship() cam = Camera(myShip.pos, myShip.up, myShip.facing) for i in range(3): asteroid_list.append(Asteroid(vec4(0, 0, 0, 0))) skyboxTexture = ImageTextureCube("nebula-%04d.jpg") skybox = Mesh("cube.obj.mesh") skybox.materials[0].tex = skyboxTexture skyboxProg = Program("skyboxVertexShader.txt", "skyboxFragmentShader.txt") StarProgram = Program("StarsVertexShader.txt", "StarsFragmentShader.txt") main_program = Program("MainVS.txt", "MainFS.txt") glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) glEnable(GL_DEPTH_TEST) glDepthFunc(GL_LEQUAL) Program.setUniform("lightPos", vec3(0, 1, -1) + myShip.pos.xyz) #vec3(0,1,-1) Program.updateUniforms() print("Setup Done")
import Program Program.Main()
def execute(src): prog = parse(src) if prog != None: #print repr(prog) # uncomment to dump the contents of the program to stdout Program.vm (prog)