def __init__(self): self.proyectos_db = ProyectoSqlite()
class StealerTerminal(object): def __init__(self): self.proyectos_db = ProyectoSqlite() def list_proyectos(self, limit = setup_options.getLimit(), page = 1): print "======= Listing al projects =======" print "===========In case you want to delete a project press d plus the number ==========================" quantity_proyectos = self.proyectos_db.retrieveAllCount() number = 1 while number != 0: proyectos = self.proyectos_db.selectAll(limit, page) for proyecto in proyectos: print "{0}: {1}".format(proyecto.id, proyecto.nombre) if page > 1: print "To go to the previous page press < " if (page * limit) < quantity_proyectos: print "To go to the next page press > " option = raw_input("Select the number to edit or 0 to come back\n") try: if option == "<": self.list_proyectos(limit, page - 1) number = 0 elif option == ">": self.list_proyectos(limit, page + 1) number = 0 else: number = int(option) if number != 0: self.proyecto_options(number) except ValueError: print "It has to be a number" def proyecto_options(self, elementId): project = ProyectoTerminal(elementId, self.proyectos_db) project.start_up() def new_proyecto(self): print "========== Create a new project ================" aux = Proyecto() has_error = True name = "" while has_error: name = raw_input("[Name] > ") if name != "": has_error = False aux.nombre = name has_error = True description = "" while has_error: description = raw_input("[Description] > ") if name != "": has_error = False aux.descripcion = description aux.id = self.proyectos_db.insert_element(aux) def close_program(self): print "Thank you for using stealer 1.0.0" exit(0) def init_stealer(self): main_menu_text = {1 : 'Create new', 2: 'List', 3 : 'Exit'} main_menu_options = {1 : self.new_proyecto, 2: self.list_proyectos, 3 : self.close_program} options = { 'main' : { 'text' : main_menu_text, 'options' : main_menu_options}} start_point = 'main' selected = start_point print "========== Welcome to stealer 1.0.0 ================" while True: print "========== Main menu ================" displayed = options[selected]['text'] sel_options = options[selected]['options'] for k, v in displayed.iteritems(): print " {0} - {1}".format(k, v) selection = raw_input("[Selection] >") selection_int = 0 try: #print selection selection_int = int(selection) function = sel_options[selection_int] function() except ValueError: print "It has to be a number"
class StealerTerminal(object): def __init__(self): self.proyectos_db = ProyectoSqlite() def list_proyectos(self, limit=setup_options.getLimit(), page=1): print "======= Listing al projects =======" print "===========In case you want to delete a project press d plus the number ==========================" quantity_proyectos = self.proyectos_db.retrieveAllCount() number = 1 while number != 0: proyectos = self.proyectos_db.selectAll(limit, page) for proyecto in proyectos: print "{0}: {1}".format(proyecto.id, proyecto.nombre) if page > 1: print "To go to the previous page press < " if (page * limit) < quantity_proyectos: print "To go to the next page press > " option = raw_input("Select the number to edit or 0 to come back\n") try: if option == "<": self.list_proyectos(limit, page - 1) number = 0 elif option == ">": self.list_proyectos(limit, page + 1) number = 0 else: number = int(option) if number != 0: self.proyecto_options(number) except ValueError: print "It has to be a number" def proyecto_options(self, elementId): project = ProyectoTerminal(elementId, self.proyectos_db) project.start_up() def new_proyecto(self): print "========== Create a new project ================" aux = Proyecto() has_error = True name = "" while has_error: name = raw_input("[Name] > ") if name != "": has_error = False aux.nombre = name has_error = True description = "" while has_error: description = raw_input("[Description] > ") if name != "": has_error = False aux.descripcion = description aux.id = self.proyectos_db.insert_element(aux) def close_program(self): print "Thank you for using stealer 1.0.0" exit(0) def init_stealer(self): main_menu_text = {1: 'Create new', 2: 'List', 3: 'Exit'} main_menu_options = { 1: self.new_proyecto, 2: self.list_proyectos, 3: self.close_program } options = { 'main': { 'text': main_menu_text, 'options': main_menu_options } } start_point = 'main' selected = start_point print "========== Welcome to stealer 1.0.0 ================" while True: print "========== Main menu ================" displayed = options[selected]['text'] sel_options = options[selected]['options'] for k, v in displayed.iteritems(): print " {0} - {1}".format(k, v) selection = raw_input("[Selection] >") selection_int = 0 try: #print selection selection_int = int(selection) function = sel_options[selection_int] function() except ValueError: print "It has to be a number"