def __init__(self): self.pattern_terminals = [ Terminal("K_WHILE", "while"), Terminal("K_IF", "if"), Terminal("K_ELSE", "else"), Terminal("VAR", "[a-zA-Zа-яА-Я]+"), Terminal("OP", "[-+*/]"), Terminal("LBreaket", "[(]"), Terminal("RBreaket", "[)]"), Terminal("LFBreaket", "[{]"), Terminal("RFBreaket", "[}]"), Terminal("WS", r"\s+") ] self.list_of_terminals = []
def get_terminals(self, text): lexem = '' for i in text: letter = i lexem += i if self.search_terminal(lexem): pass else: self.list_of_terminals.append( Terminal(self.search_terminal(lexem[:-1]), lexem[:-1])) lexem = lexem[-1] if not lexem == '': self.list_of_terminals.append( Terminal(self.search_terminal(lexem), f'{lexem}'))
def main(): queue = PriorityQueue() for x in range(WORKERS): w = Worker(queue) w.start() settings = {"unblock_workers": 5} Application(settings) PyMongoDriver(host="127.0.0.1", port=27017, user="******", password="******", database="pipeline").register() test = False if test: FrameworkTest().run() # FrameworkTestThread().start() else: port = 9999 StreamManagement(port) web_api = Web(port) web_api.start() Terminal().start()
def main(): global production_list, t_list, nt_list ctr = 1 t_regex, nt_regex = r'[a-z\W]', r'[A-Z]' while True: production_list.append(input().replace(' ', '')) if production_list[-1].lower() in ['end', '']: del production_list[-1] break head, body = production_list[ctr - 1].split('->') if head not in nt_list.keys(): nt_list[head] = NonTerminal(head) #for all terminals in the body of the production for i in finditer( t_regex, body): #returns an iterator object in the ordered matched. s = i.group( ) #since the group argument is empty, it'll return whatever it matched completely if s not in t_list.keys(): t_list[s] = Terminal(s) #for all non-terminals in the body of the production for i in finditer(nt_regex, body): s = i.group() if s not in nt_list.keys(): nt_list[s] = NonTerminal(s) ctr += 1
def on_actionOpenConnection_triggered(self, s): d = OpenConnection(self) if d.exec() != OpenConnection.Accepted: return t = Terminal(self) self.mdiArea.addSubWindow(t) t.show()
def createTerminal(self, address): conn = sqlite3.connect(Constants.DATABASE_PATH, detect_types=sqlite3.PARSE_DECLTYPES) c = conn.cursor() generatedUUID = uuid.uuid1() c.execute("INSERT INTO terminals VALUES ('{}', '{}', '0')".format(generatedUUID, address)) conn.commit() conn.close() return Terminal(generatedUUID, address)
def append_message_service(cls, message_service_string): if (message_service_string.lower() == 'twilio'): cls.__return_bot = Twilio(cls.__return_bot) elif (message_service_string.lower() == 'terminal'): cls.__return_bot = Terminal(cls.__return_bot) elif (message_service_string.lower() == 'email'): cls.__return_bot = Email(cls.__return_bot) else: raise ValueError
class PARDg5VPlatform(Platform): type = 'PARDg5VPlatform' cxx_header = "hyper/dev/pardg5v/platform.hh" system = Param.System(Parent.any, "system") pciconfig = PciConfigAll() south_bridge = PARDg5VSouthBridge() # "Non-existant" port used for timing purposes by the linux kernel i_dont_exist = IsaFake(pio_addr=x86IOAddress(0x80), pio_size=1) # Ports behind the pci config and data regsiters. These don't do anything, # but the linux kernel fiddles with them anway. behind_pci = IsaFake(pio_addr=x86IOAddress(0xcf8), pio_size=8) # Serial port and terminal com_1 = Uart8250P5V() com_1.pio_addr = x86IOAddress(0x3f8) com_1.terminal = Terminal() # Serial port#2 and terminal com_2 = Uart8250P5V() com_2.pio_addr = x86IOAddress(0x2f8) com_2.terminal = Terminal() # Devices to catch access to non-existant serial ports. com_3 = Uart8250P5V(pio_addr=x86IOAddress(0x3e8), terminal=Terminal()) com_4 = Uart8250P5V(pio_addr=x86IOAddress(0x2e8), terminal=Terminal()) # A device to catch accesses to the non-existant floppy controller. fake_floppy = IsaFake(pio_addr=x86IOAddress(0x3f2), pio_size=2) def attachIO(self, bus, dma_ports=[]): self.south_bridge.attachIO(bus, dma_ports) self.i_dont_exist.pio = bus.master self.behind_pci.pio = bus.master self.com_1.pio = bus.master self.com_2.pio = bus.master self.com_3.pio = bus.master self.com_4.pio = bus.master self.fake_floppy.pio = bus.master self.pciconfig.pio = bus.default bus.use_default_range = True
def start_parsing(file_name, table, first_production): file = open(file_name, 'r') data = file.read() data += '\nepsilon' data = data.split('\n') stack = [Terminal('epsilon', None), NonTerminal(first_production, None)] i = 0 while i <= len(data): if data[i] == '' or data[i] == ' ': continue if len(stack) == 0 and i == len(data) - 1: print('Accept') return elif len(stack) == 0 and i < len(data) or len(stack) > 0 and i == len( data): print('Reject') return if top(stack).type == 'T': if top(stack).value == 'epsilon': stack.pop() continue if top(stack).value == data[i]: stack.pop() print('Matched {}'.format(data[i])) i += 1 else: print('Error: missing {}, inserted'.format(top(stack).value)) stack.pop() elif top(stack).type == 'N': if isinstance(table[top(stack).value][data[i]], Node): # pop that node and reverse its production top_node = stack.pop() production_array = make_array(table[top_node.value][data[i]]) while len(production_array): stack.append(production_array.pop()) elif table[top(stack).value][data[i]] == 'synch': print('synch found poping {}'.format(top(stack).value)) stack.pop() else: print('Error: (illegal {}), discarding {}'.format( top(stack).value, data[i])) i += 1 if len(stack) == 0 and i == len(data) - 1: print('Accept') return elif len(stack) == 0 and i < len(data) or len( stack) > 0 and i == len(data): print('Reject') return
def __init__( self, parent ): wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 700,500 ), style = wx.DEFAULT_DIALOG_STYLE ) self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize ) bSizer1 = wx.BoxSizer( wx.VERTICAL ) self.m_panel1 = Terminal( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL|wx.WANTS_CHARS ) bSizer1.Add( self.m_panel1, 1, wx.EXPAND |wx.ALL, 5 ) self.SetSizer( bSizer1 ) self.Layout() self.Centre( wx.BOTH )
class Pc(Platform): type = 'Pc' cxx_header = "dev/x86/pc.hh" system = Param.System(Parent.any, "system") south_bridge = SouthBridge() pci_host = PcPciHost() # "Non-existant" ports used for timing purposes by the linux kernel i_dont_exist1 = IsaFake(pio_addr=x86IOAddress(0x80), pio_size=1) i_dont_exist2 = IsaFake(pio_addr=x86IOAddress(0xed), pio_size=1) # Ports behind the pci config and data regsiters. These don't do anything, # but the linux kernel fiddles with them anway. behind_pci = IsaFake(pio_addr=x86IOAddress(0xcf8), pio_size=8) # Serial port and terminal com_1 = Uart8250() com_1.pio_addr = x86IOAddress(0x3f8) com_1.device = Terminal() # Devices to catch access to non-existant serial ports. fake_com_2 = IsaFake(pio_addr=x86IOAddress(0x2f8), pio_size=8) fake_com_3 = IsaFake(pio_addr=x86IOAddress(0x3e8), pio_size=8) fake_com_4 = IsaFake(pio_addr=x86IOAddress(0x2e8), pio_size=8) # A device to catch accesses to the non-existant floppy controller. fake_floppy = IsaFake(pio_addr=x86IOAddress(0x3f2), pio_size=2) # NVMe Interface nvme = NVMeInterface(pci_func=0, pci_dev=5, pci_bus=0) def attachIO(self, bus, dma_ports=[]): self.south_bridge.attachIO(bus, dma_ports) self.i_dont_exist1.pio = bus.master self.i_dont_exist2.pio = bus.master self.behind_pci.pio = bus.master self.com_1.pio = bus.master self.fake_com_2.pio = bus.master self.fake_com_3.pio = bus.master self.fake_com_4.pio = bus.master self.fake_floppy.pio = bus.master self.pci_host.pio = bus.default self.nvme.pio = bus.master if dma_ports.count(self.nvme.dma) == 0: self.nvme.dma = bus.slave
def main(): """ This method creates the terminal """ # initial user input inputs = ["Dummy variable"] terminal = Terminal() while (inputs[0] != "exit"): cwd = os.getcwd() inputs = user_input() if inputs[0] in terminal.dic: command = inputs[0] terminal.dic[command]() elif inputs[0] in terminal.dic_args_1: if len(inputs) == 2: command, arg = inputs terminal.dic_args_1[command](arg)
def getAllTerminals(cls): try: with CursorPool() as cursor: terminals:list = [] cursor.execute(cls._SELECT) registers:tuple = cursor.fetchall() for register in registers: terminal:Terminal = Terminal( idTerminal=register[0], name=register[1], place=register[2], number=register[3] ) terminals.append(terminal) log.debug(terminal) log.debug("Getting Terminals Succesfully") return terminals except Exception as e: log.error(f"Error while getting terminals: {e}")
def __init__(self, proyecto_path): Gtk.EventBox.__init__(self) archivo = os.path.join(proyecto_path, "proyecto.ide") arch = open(archivo, "r") self.proyecto = json.load(arch, "utf-8") arch.close() vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.install_path = os.path.join(CONFPATH, self.proyecto["nombre"]) self.widgeticon = WidgetIcon("python", self.install_path) self.notebook = Notebook(proyecto_path) self.terminal = Terminal() label = Gtk.Label(u"Instalador python para: %s versión: %s" % (self.proyecto["nombre"], self.proyecto["version"])) label.modify_font(Pango.FontDescription("%s %s" % ("Monospace", 12))) label.modify_fg(0, Gdk.Color(0, 0, 65000)) hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) image = Gtk.Image() arch = os.path.join(BASEPATH, "Iconos", "gandalftux.png") pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(arch, 100, 100) image.set_from_pixbuf(pixbuf) hbox.pack_start(image, False, False, 0) vbox2 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) vbox2.pack_start(label, False, False, 0) vbox2.pack_start(self.widgeticon, False, False, 0) hbox.pack_start(vbox2, True, True, 0) vbox.pack_start(hbox, False, False, 0) vbox.pack_start(self.notebook, True, True, 0) vbox.pack_start(self.terminal, True, True, 5) self.add(vbox) self.connect("realize", self.__realize) self.show_all() self.widgeticon.connect("iconpath", self.__set_iconpath) self.widgeticon.connect("make", self.__make)
class Pc(Platform): type = 'Pc' system = Param.System(Parent.any, "system") pciconfig = PciConfigAll() south_bridge = SouthBridge() # "Non-existant" port used for timing purposes by the linux kernel i_dont_exist = IsaFake(pio_addr=x86IOAddress(0x80), pio_size=1) # Ports behind the pci config and data regsiters. These don't do anything, # but the linux kernel fiddles with them anway. behind_pci = IsaFake(pio_addr=x86IOAddress(0xcf8), pio_size=8) # Serial port and terminal terminal = Terminal() com_1 = Uart8250() com_1.pio_addr = x86IOAddress(0x3f8) com_1.terminal = terminal # Devices to catch access to non-existant serial ports. fake_com_2 = IsaFake(pio_addr=x86IOAddress(0x2f8), pio_size=8) fake_com_3 = IsaFake(pio_addr=x86IOAddress(0x3e8), pio_size=8) fake_com_4 = IsaFake(pio_addr=x86IOAddress(0x2e8), pio_size=8) # A device to catch accesses to the non-existant floppy controller. fake_floppy = IsaFake(pio_addr=x86IOAddress(0x3f2), pio_size=2) def attachIO(self, bus): self.south_bridge.attachIO(bus) self.i_dont_exist.pio = bus.port self.behind_pci.pio = bus.port self.com_1.pio = bus.port self.fake_com_2.pio = bus.port self.fake_com_3.pio = bus.port self.fake_com_4.pio = bus.port self.fake_floppy.pio = bus.port self.pciconfig.pio = bus.default bus.responder_set = True bus.responder = self.pciconfig
class SimpleBoard(Platform): type = 'SimpleBoard' cxx_header = 'dev/riscv/simpleboard.hh' system = Param.System(Parent.any, 'system') timer_cpu = TimerCpu(pio_addr=0x02000000) term = Terminal() uart = Uart8250(pio_addr=0x10013000) cust_regs = CustomRegs(pio_addr=0x90000000, regs=[0x90000000, 0x90000004, 0x90000008, 0x9000000c]) # attach I/O devices to bus # call this method after bus is defined at system level def attachIO(self, bus): self.cust_regs.pio = bus.master self.timer_cpu.pio = bus.master self.uart.device = self.term self.uart.pio = bus.master
def __init__(self): Gtk.Window.__init__(self) self.set_title("JAMediaTerminal") self.set_icon_from_file( os.path.join(BASE_PATH, "Iconos", "jamediaterminal.svg")) self.set_resizable(True) self.set_size_request(640, 480) self.set_border_width(5) self.set_position(Gtk.WindowPosition.CENTER) box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) toolbar = Toolbar() paned = Gtk.Paned(orientation=Gtk.Orientation.VERTICAL) box.pack_start(toolbar, False, False, 0) box.pack_start(paned, True, True, 0) self.jamediaterminal = Terminal() self.jamediamantree = JAMediaManTree() paned.pack1(self.jamediamantree, resize=True, shrink=False) paned.pack2(self.jamediaterminal, resize=False, shrink=False) self.add(box) self.show_all() self.jamediamantree.hide() import sys toolbar.connect("help", self.__help) toolbar.connect("salir", sys.exit) self.connect("destroy", sys.exit)
def __init__(self): self.quit_game = False self.end_game = False self.pause_game = True self.screen_dimensions = \ [screen_resolution['w'], screen_resolution['h']] pygame.init() self.display = pygame.display.set_mode(self.screen_dimensions) pygame.display.set_caption('PyMan Game') self.clock = pygame.time.Clock() self.map = Map() self.map_view = MapView(self.map, self.display) self.score = 0 self.level = 0 self.lives = 3 self.decision_cycles = 20 self.current_cycle = 0 self.terminal = Terminal(0, 800, 800, 100, liberation_serif, colors['white'], 20, colors['black'], self.display)
def start_parsing(file_name): file = open(file_name, 'r') file_content = file.read() terminal_buffer = '' non_terminal_buffer = '' lhs_buffer = '' first_production = '' is_lhs = False is_rhs = False is_first_rhs_node = True filling_terminal = False productions = {} terminals = [] non_terminals = [] for index, char in enumerate(file_content): if char == '#': is_lhs = True is_rhs = False is_first_rhs_node = True filling_terminal = False lhs_buffer = '' continue if char == '=' and not is_rhs: is_lhs = False is_rhs = True is_first_rhs_node = True productions[lhs_buffer] = [] n = NonTerminal(lhs_buffer, None) if not check_if_existed(non_terminals, n): non_terminals.append(n) if len(productions) == 1: first_production = lhs_buffer continue if is_lhs: if char == ' ': continue if char.isalnum() or char == '_': lhs_buffer += char continue if is_rhs: if char == ' ' or char == '|' or char == '\n': if non_terminal_buffer: n = NonTerminal(non_terminal_buffer, None) if not check_if_existed(non_terminals, n): non_terminals.append(n) if is_first_rhs_node: productions[lhs_buffer].append(n) else: length = len(productions[lhs_buffer]) temp = productions[lhs_buffer][length - 1] while temp.next: temp = temp.next temp.next = n if char == ' ' or char == '\n': is_first_rhs_node = False elif char == '|': is_first_rhs_node = True non_terminal_buffer = '' elif char == '|': is_first_rhs_node = True continue if char == '\'': if terminal_buffer: if terminal_buffer == '\L': terminal_buffer = 'epsilon' t = Terminal(terminal_buffer, None) if not check_if_existed(terminals, t): terminals.append(t) if is_first_rhs_node: productions[lhs_buffer].append(t) else: length = len(productions[lhs_buffer]) temp = productions[lhs_buffer][length - 1] while temp.next: temp = temp.next temp.next = t is_first_rhs_node = False filling_terminal = False terminal_buffer = '' else: filling_terminal = True continue if not filling_terminal: non_terminal_buffer += char elif filling_terminal: terminal_buffer += char check_left_recursion(productions) return { 'productions': productions, 'terminals': terminals, 'non_terminals': non_terminals, 'first_production': first_production }
""" def __init__(self, terminal): """ Creates an instance of MainMenuScreen Parameters: terminal: A Terminal object that allows the module to interface with the OS terminal Returns: An instance of MainMenuScreen """ self.__menu__ = Menu(terminal) self.__menu__.addMenuItem("Post a question") self.__menu__.addMenuItem("Search for posts") self.__menu__.addMenuItem("Logout") self.__menu__.addMenuItem("Exit Program") def printScreen(self): """ Prints MainMenu's menu """ return self.__menu__.printScreen() if __name__ == "__main__": from Terminal import Terminal mainMenu = MainMenuScreen(Terminal()) mainMenu.printScreen()
Returns: userInput if the input provided is valid None if the input provided is invalid """ while True: self.printItems() userInput = input( "Type the number of the item you would like to select: ") try: userInput = int(userInput) - 1 if (userInput <= self.__length__ - 1 and userInput >= 0): return userInput else: input("Invalid selection, press enter to continue: ") except Exception: try: if userInput.upper() == "EXIT": return None except Exception: input("Invalid input, press enter to continue: ") self.__terminal__.clear() if __name__ == "__main__": from Terminal import Terminal menu = Menu(Terminal()) menu.addMenuItem("Just") menu.addMenuItem("A") menu.addMenuItem("Test") print(menu.printScreen())
adminOption = None while adminOption != 5: adminOption: int = int(input(menuAdmin)) if adminOption == 1: terminalOption = None while terminalOption != 5: terminalOption: int = int(input(menuTerminal)) if terminalOption == 1: TerminalDao.getAllTerminals() if terminalOption == 2: nameTerminal: str = input( "Write Terminal Name: ") PlaceToTravelDao.getAllPlaces() placeTerminal: int = int( input("Write id to Place: ")) terminal: Terminal = Terminal( name=nameTerminal, place=placeTerminal) TerminalDao.insertTerminal(terminal) if terminalOption == 3: TerminalDao.getAllTerminals() idTerminal: int = int( input("Write id terminal to update: ")) nameTerminal: str = input( "Write Terminal Name: ") PlaceToTravelDao.getAllPlaces() placeTerminal: int = int( input("Write id to Place: ")) terminal: Terminal = Terminal( idTerminal=idTerminal, name=nameTerminal, place=placeTerminal) TerminalDao.updateTerminal(terminal)
Serves as the main loop of the module. Allowing the user to interface with the program by providing a tag """ self.printTitle() invalidInput = True try: userInput = input("Enter tag you would like to add to the post: ") if self.__chkinp__.checkEscape(userInput): return None self.__tag__.addTag(self.__post__.pid, userInput) except Exception as e: print(e) else: print("Tag successfully added!") finally: input("Type enter to continue: ") if __name__ == "__main__": from Terminal import Terminal from SearchForPostsScreen import SearchForPostsScreen from SelectedPostScreen import SelectedPostScreen sfps = SearchForPostsScreen(Terminal()) post = sfps.printScreen() sps = SelectedPostScreen(Terminal(), post, True) if sps.printScreen() == 3: t = TagScreen(Terminal(), post) t.printScreen()
def topologyGenerator(rootXML, rootSSH, baseVoltageList, substationList, voltageLevelList, generatingUnitList, regulatingControlList, powerTransformerList, energyConsumerList, powerTransformerEndList, breakerList, ratioTapChangerList, synchronousMachineList, ACLinesList): # Initialize variables to use nodeNumber = 1 powerGrid = [Node] busbarSectionList = [] #Find all Coonectivity Nodes for n in rootXML.findall('ConnectivityNode'): IDCN = n.get('ID') nameCN = n.find('IdentifiedObject.name').text containerCN = n.find( 'ConnectivityNode.ConnectivityNodeContainer').attrib['resource'] powerGrid.append(Node(nodeNumber, IDCN, nameCN, containerCN)) TNum = 0 # Find terminals and add them to the CN for nn in rootXML.findall('Terminal'): CNTerminal = nn.find( 'Terminal.ConnectivityNode').attrib['resource'] if CNTerminal[1:] == IDCN: IDTerminal = nn.get('ID') nameTerminal = nn.find('IdentifiedObject.name').text CETerminal = nn.find( 'Terminal.ConductingEquipment').attrib['resource'] powerGrid[nodeNumber].addTerminal( Terminal(IDTerminal, nameTerminal, CETerminal, CNTerminal)) TNum += 1 # Find the Conducting Equipment and add them to the Terminal # First, let's look for bus bars for nnn in rootXML.findall('BusbarSection'): IDBB = nnn.get('ID') if IDBB == CETerminal[1:]: nameBB = nnn.find('IdentifiedObject.name').text equipmentContBB = nnn.find( 'Equipment.EquipmentContainer').attrib['resource'] busbarSectionList.append( Equipment(IDBB, nameBB, equipmentContBB)) powerGrid[nodeNumber].terminalList[TNum].addCE( Equipment(IDBB, nameBB, equipmentContBB)) # Now, let's find the Power Transformers pos = 0 for _ in powerTransformerList: IDPowTrans = powerTransformerList[pos].IDPowTrans if IDPowTrans == CETerminal[1:]: powerGrid[nodeNumber].terminalList[TNum].addCE( powerTransformerList[pos]) pos += 1 # Now, let's find the Breakers pos = 0 for _ in breakerList: IDBreaker = breakerList[pos].IDBreaker if IDBreaker == CETerminal[1:]: powerGrid[nodeNumber].terminalList[TNum].addCE( breakerList[pos]) pos += 1 # Now, let's find the Generation Units pos = 0 for _ in generatingUnitList: IDGenUnit = generatingUnitList[pos].IDGenUnit if IDGenUnit == CETerminal[1:]: powerGrid[nodeNumber].terminalList[TNum].addCE( generatingUnitList[pos]) pos += 1 # Now, let's find the Regulating Units pos = 0 for _ in regulatingControlList: IDRegCtrl = regulatingControlList[pos].IDRegCtrl if IDRegCtrl == CETerminal[1:]: powerGrid[nodeNumber].terminalList[TNum].addCE( regulatingControlList[pos]) pos += 1 # Are you not getting bored? We find the loads pos = 0 for _ in energyConsumerList: IDEnergyConsumer = energyConsumerList[pos].IDEnergyConsumer if IDEnergyConsumer == CETerminal[1:]: powerGrid[nodeNumber].terminalList[TNum].addCE( IDEnergyConsumer[pos]) pos += 1 # Now, we find the Synchronous Machine pos = 0 for _ in synchronousMachineList: IDSynchMach = synchronousMachineList[pos].IDSynchMach if IDSynchMach == CETerminal[1:]: powerGrid[nodeNumber].terminalList[TNum].addCE( synchronousMachineList[pos]) pos += 1 # Almost finally... the Power Transformers End pos = 0 for _ in powerTransformerEndList: IDPTEnd = powerTransformerEndList[pos].IDPTEnd if IDPTEnd == CETerminal[1:]: powerGrid[nodeNumber].terminalList[TNum].addCE( powerTransformerEndList[pos]) pos += 1 # Finally, the AC Lines pos = 0 for _ in ACLinesList: IDLine = ACLinesList[pos].IDLine if IDLine == CETerminal[1:]: powerGrid[nodeNumber].terminalList[TNum].addCE( ACLinesList[pos]) pos += 1 nodeNumber += 1 # GraphMyPowerGrid yBusMtx = CalculateYBusMatrix(voltageLevelList, busbarSectionList, powerTransformerEndList, powerTransformerList, baseVoltageList, ACLinesList, energyConsumerList) for element in yBusMtx: if element != 0: print(element) print() print("All other elements are cero")
def run_command(self, command, respond): terminal = Terminal(self) result = terminal.parse_and_execute(command) respond(result)
def __init__(self, monopolyMode, maskMode): super().__init__(monopolyMode, maskMode) self.elapsedTime = 0 self.addComponent("title", WindowTitle("Main Test Menu")) self.addComponent("close", CloseButton()) self.add("Open New One", lambda win, item: win.addWindow(AList())) self.add( "Run Test", lambda win, item: win.execute(lambda: print("Hello World"), 3000)) self.add("Quit Test", lambda win, item: win.release()) def onUpdate(self, deltaTime): self.elapsedTime += deltaTime if self.elapsedTime > 1000: self.elapsedTime = 0 # print("aaaaa") if __name__ == "__main__": ts = Terminal() ts.addWindow(MainMenu(monopolyMode=True, maskMode=True)) ts.mainLoop()
class T1000(Platform): type = 'T1000' system = Param.System(Parent.any, "system") fake_clk = IsaFake(pio_addr=0x9600000000, pio_size=0x100000000) #warn_access="Accessing Clock Unit -- Unimplemented!") fake_membnks = IsaFake(pio_addr=0x9700000000, pio_size=16384, ret_data64=0x0000000000000000, update_data=False) #warn_access="Accessing Memory Banks -- Unimplemented!") fake_jbi = IsaFake(pio_addr=0x8000000000, pio_size=0x100000000) #warn_access="Accessing JBI -- Unimplemented!") fake_l2_1 = IsaFake(pio_addr=0xA900000000, pio_size=0x8, ret_data64=0x0000000000000001, update_data=True) #warn_access="Accessing L2 Cache Banks -- Unimplemented!") fake_l2_2 = IsaFake(pio_addr=0xA900000040, pio_size=0x8, ret_data64=0x0000000000000001, update_data=True) #warn_access="Accessing L2 Cache Banks -- Unimplemented!") fake_l2_3 = IsaFake(pio_addr=0xA900000080, pio_size=0x8, ret_data64=0x0000000000000001, update_data=True) #warn_access="Accessing L2 Cache Banks -- Unimplemented!") fake_l2_4 = IsaFake(pio_addr=0xA9000000C0, pio_size=0x8, ret_data64=0x0000000000000001, update_data=True) #warn_access="Accessing L2 Cache Banks -- Unimplemented!") fake_l2esr_1 = IsaFake(pio_addr=0xAB00000000, pio_size=0x8, ret_data64=0x0000000000000000, update_data=True) #warn_access="Accessing L2 ESR Cache Banks -- Unimplemented!") fake_l2esr_2 = IsaFake(pio_addr=0xAB00000040, pio_size=0x8, ret_data64=0x0000000000000000, update_data=True) #warn_access="Accessing L2 ESR Cache Banks -- Unimplemented!") fake_l2esr_3 = IsaFake(pio_addr=0xAB00000080, pio_size=0x8, ret_data64=0x0000000000000000, update_data=True) #warn_access="Accessing L2 ESR Cache Banks -- Unimplemented!") fake_l2esr_4 = IsaFake(pio_addr=0xAB000000C0, pio_size=0x8, ret_data64=0x0000000000000000, update_data=True) #warn_access="Accessing L2 ESR Cache Banks -- Unimplemented!") fake_ssi = IsaFake(pio_addr=0xff00000000, pio_size=0x10000000) #warn_access="Accessing SSI -- Unimplemented!") hterm = Terminal() hvuart = Uart8250(pio_addr=0xfff0c2c000) htod = DumbTOD() pterm = Terminal() puart0 = Uart8250(pio_addr=0x1f10000000) iob = Iob() # Attach I/O devices that are on chip def attachOnChipIO(self, bus): self.iob.pio = bus.port self.htod.pio = bus.port # Attach I/O devices to specified bus object. Can't do this # earlier, since the bus object itself is typically defined at the # System level. def attachIO(self, bus): self.hvuart.terminal = self.hterm self.puart0.terminal = self.pterm self.fake_clk.pio = bus.port self.fake_membnks.pio = bus.port self.fake_l2_1.pio = bus.port self.fake_l2_2.pio = bus.port self.fake_l2_3.pio = bus.port self.fake_l2_4.pio = bus.port self.fake_l2esr_1.pio = bus.port self.fake_l2esr_2.pio = bus.port self.fake_l2esr_3.pio = bus.port self.fake_l2esr_4.pio = bus.port self.fake_ssi.pio = bus.port self.fake_jbi.pio = bus.port self.puart0.pio = bus.port self.hvuart.pio = bus.port
def __init__(self, terminal, posts): """ Creates an instance of PostMenuScreen Parameters: terminal: A Terminal object allowing the module to interface with the OS terminal Returns: An instance of Tag """ self.__menu__ = Menu(terminal) for post in posts: self.__menu__.addMenuItem(post) def printScreen(self): """ Prints the menu options of the module """ self.__menu__.printScreen() if __name__ == "__main__": from Terminal import Terminal posts = [ "How do I make eggs?", "Hello anyone out there?", "Yes I am Here!", "Just google it 4head" ] postScreen = PostMenuScreen(Terminal(), posts) postScreen.printScreen()
""" maxIndex = len(posts) - 1 self.__menu__.clearMenu() if (index + POSTPERPAGE > maxIndex): for post in posts[index:]: if isinstance(post, QuestionQuery): self.__menu__.addMenuItem( str(post.title) + " | " + str(post.voteCount) + " | " + str(post.answerCount)) else: self.__menu__.addMenuItem( str(post.title) + " | " + str(post.voteCount)) return False else: for i in range(index, index + POSTPERPAGE): if isinstance(posts[i], QuestionQuery): self.__menu__.addMenuItem( str(posts[i].title) + " | " + str(posts[i].voteCount) + " | " + str(posts[i].answerCount)) else: self.__menu__.addMenuItem( str(posts[i].title) + " | " + str(posts[i].voteCount)) return True if __name__ == "__main__": from Terminal import Terminal searchPostScreen = SearchForPostsScreen(Terminal()) searchPostScreen.printScreen()
""" editType = self.getEditType() if editType == "1": self.printTitleSubTitle() title = input("Enter new title: ") post = self.__postEdit__.changeTitle(self.__post__.pid, title) return post elif editType == "2": self.printTitleSubBody() body = input("Enter new body: ") post = self.__postEdit__.changeBody(self.__post__.pid, body) return post elif editType is None: return None input( "Post has been changed. To see the change, please refresh the post. Type enter to continue: " ) if __name__ == "__main__": from Terminal import Terminal from SearchForPostsScreen import SearchForPostsScreen from SelectedPostScreen import SelectedPostScreen sfps = SearchForPostsScreen(Terminal()) post = sfps.printScreen() sps = SelectedPostScreen(Terminal(), post, True) if sps.printScreen() == 4: pes = PostEditScreen(Terminal(), post) pes.printScreen()