def main(): """ The main method of the application. It instantiates a console and runs it. """ app = Console() app.run()
def main(): try: Test().testEverything() print("All tests passed :).") except Exception as e: print("Some tests failed :(.") print(e) repo = RouteRepository() controller = RouteController(repo) app = Console(controller) app.run()
def runApplicationWithUndo(): settings = Settings() undoController = UndoController() if str(settings.mode_repository) == "inmemory": student_repository = Repository(StudentValidator) discipline_repository = Repository(DisciplineValidator) grade_repository = Repository(GradeValidator) elif settings.mode_repository == "textfiles": student_repository = FileRepository(StudentValidator, settings.students, Student) discipline_repository = FileRepository(DisciplineValidator, settings.disciplines, Discipline) grade_repository = FileRepository(GradeValidator, settings.grades, Grade) elif settings.mode_repository == "binaryfiles": student_repository = BinaryRepository(StudentValidator, settings.students, Student) discipline_repository = BinaryRepository(DisciplineValidator, settings.disciplines, Discipline) grade_repository = BinaryRepository(GradeValidator, settings.grades, Grade) elif settings.mode_repository == "sqlfiles": student_repository = SQLRepository(StudentValidator, settings.students, Student, "Students", 1) discipline_repository = SQLRepository(DisciplineValidator, settings.disciplines, Discipline, "Disciplines", 1) grade_repository = SQLRepository(GradeValidator, settings.grades, Grade, "Grades", 2) elif settings.mode_repository == "jsonfiles": student_repository = JSONRepository(StudentValidator, settings.students, Student) discipline_repository = JSONRepository(DisciplineValidator, settings.disciplines, Discipline) grade_repository = JSONRepository(GradeValidator, settings.grades, Grade) else: print("You have to insert a valid repository mode!!!") student_controller = StudentController(student_repository, undoController) discipline_controller = DisciplineController(discipline_repository, undoController) grade_controller = GradeController(grade_repository, student_repository, discipline_repository, undoController) if settings.interface_mode == "gui": ui_gui = GUI(student_controller, discipline_controller, grade_controller, undoController) ui_gui.run_app() elif settings.interface_mode == "console": console = Console(student_controller, discipline_controller, grade_controller, undoController) console.runApp() else: print("You have to insert a valid interface!!!")
def run(self): try: Console().cmdloop() except KeyboardInterrupt: print "Exiting...." Facade().exit() except Exception, e: Facade().formatExceptionInfo("ConsoleWorker")
discipline_repository) student_controller = StudentController(student_repository) discipline_controller = DisciplineController(discipline_repository) grade_controller = GradeController(grade_repository, student_repository, discipline_repository, enroll_controller) undo_redo_controller = UndoRedoController(student_repository, discipline_repository, grade_repository, enroll_controller) if settings['ui'] == 'command': console = Console(student_controller, grade_controller, discipline_controller, enroll_controller, undo_redo_controller) if settings['ui'] == 'GUI': console = GUIConsole(student_controller, grade_controller, discipline_controller, enroll_controller, undo_redo_controller) console.run_console() except Exception as ex: print(ex) traceback.print_exc() print("bye")
from controllers.person_controller import PersonController from repository.file_repository import FileRepo from ui.console import Console person_repo = FileRepo('persons') person_controller = PersonController(person_repo) console = Console(person_controller) ok = True while __name__ == '__main__': if ok is True: print("You control these people! As a day passes, one more gets infected.\n") print("Also, one more (if they're vaccinated and ill) gets healthy.\n") print("Vaccinate them, kill them, make one more person appear. It's up to you!\n") print("\tHave fun!\n\n") ok = False console.RunMenu()
''' Created on Feb 8, 2019 Modulul principal al aplicatiei @author: Silviu Anton ''' from ui.console import Console if __name__ == '__main__': myConsole = Console() myConsole.run()
if __name__ == '__main__': settings = Settings() if settings.repo_mode == "inmemory": person_repository = Repository() activity_repository = Repository() appointment_repository = Repository() elif settings.repo_mode == "textfile": person_repository = FileRepository(Person, settings.persons_repo) activity_repository = FileRepository(Activity, settings.activity_repo) appointment_repository = FileRepository(Appointment, settings.apppoinment_repo) elif settings.repo_mode == "binary": person_repository = BinaryRepository(Person, settings.persons_repo) activity_repository = BinaryRepository(Activity, settings.activity_repo) appointment_repository = BinaryRepository(Appointment, settings.apppoinment_repo) personCtrl = PersonController(person_repository) activityCtrl = ActivityController(activity_repository, person_repository) appointmentCtrl = AppointmentController(appointment_repository, person_repository) print("Controllers created") cons = Console(personCtrl, activityCtrl, appointmentCtrl) print("Console created") # personCtrl.populate_repo() # print("Person Repository populated") # cons.populate_activity() # print("Repositories populated") cons.run()
def run(self): console = Console(BattleShip()) console.run_menu()
if __name__=="__main__": #try: config = Config("settings.properties") config.parse_config() print(config.storage_type) if(config.storage_type=="inmemory"): person_repository = Repository(PersonValidator) activity_repository = Repository(ActivityValidator) participation_repository = Repository(ParticipationValidator) person_controller = PersonController(person_repository) activity_controller = ActivityController(activity_repository) participation_controller=ParticipationController(participation_repository,person_controller,activity_controller) console = Console(person_controller,activity_controller,participation_controller) console.run() print("True") if(config.storage_type=="infile"): person_repository = FileRepository(config.person_repository,PersonController.read_entity,PersonController.write_entity,PersonValidator) activity_repository = FileRepository(config.activity_repository,ActivityController.read_entity,ActivityController.write_entity,ActivityValidator) participation_repository = FileRepository(config.participation_repository,ParticipationController.read_entity,ParticipationController.write_entity,ParticipationController) person_controller = PersonController(person_repository) activity_controller = ActivityController(activity_repository) participation_controller=ParticipationController(participation_repository,person_controller,activity_controller) console = Console(person_controller,activity_controller,participation_controller) console.run() if config.storage_type=="inpickledb": person_repository = PickleRepository(config.person_repository,PersonValidator)
def run_application(): """ The main method of the application :return: nothing """ try: undoRedoHandler = UndoHandler() dataManagerType = Settings.getDataManagerType() clientManager = None movieManager = None rentalManager = None if dataManagerType == "memory": # IN MEMORY clientManager = DataManager(ClientValidator) movieManager = DataManager(MovieValidator) rentalManager = DataManager(RentalValidator) elif dataManagerType == "pickle": # WITH PICKLE SERIALIZATION clientManager = DataManagerPickle(ClientValidator, "clients.pickle") movieManager = DataManagerPickle(MovieValidator, "movies.pickle") rentalManager = DataManagerPickle(RentalValidator, "rentals.pickle") elif dataManagerType == "text": # WITH SIMPLE TXT FILES: clientManager = DataManagerText(ClientValidator, "clients.text", Client) movieManager = DataManagerText(MovieValidator, "movies.text", Movie) rentalManager = DataManagerText(RentalValidator, "rentals.text", Rental) elif dataManagerType == "sql": # WITH SQL clientManager = DataManagerSql(ClientValidator, "moviestore", "clients", Client) movieManager = DataManagerSql(MovieValidator, "moviestore", "movies", Movie) rentalManager = DataManagerSql(RentalValidator, "moviestore", "rentals", Rental) elif dataManagerType == "json": # WITH JSON clientManager = DataManagerJson(ClientValidator, "clientsJSON", "clients", Client) movieManager = DataManagerJson(MovieValidator, "moviesJSON", "movies", Movie) rentalManager = DataManagerJson(RentalValidator, "rentalsJSON", "rentals", Rental) print("clientManager: ", type(clientManager)) print("movieManager: ", type(movieManager)) print("rentalManager: ", type(rentalManager)) clientService = ClientService(clientManager) movieService = MovieService(movieManager) rentalService = RentalService(rentalManager) console = Console(clientService, movieService, rentalService, undoRedoHandler) console.startConsole() except Exception as ex: print("Exception: ", ex) traceback.print_exc()
from controller.film_ctrl import FilmCtrl from controller.client_ctrl import ClientCtrl from controller.rent_ctrl import RentCtrl from domain.val_film import FilmValidator from domain.val_rent import RentValidator from domain.val_client import ClientValidator from repository.film_repo import FilmRepo from repository.rent_repo import RentRepo from repository.client_repo import ClientRepo from ui.console import Console valClient = ClientValidator() valFilm = FilmValidator() valGrades = RentValidator() repoClient = ClientRepo() repoFilm = FilmRepo() repoGrade = RentRepo() ctrlClient = ClientCtrl(valClient, repoClient) ctrlFilm = FilmCtrl(valFilm, repoFilm) ctrlRent = RentCtrl(valGrades, repoClient, repoFilm, repoGrade) console = Console(ctrlClient, ctrlFilm, ctrlRent) console.startUI()
config = settings.get_the_settings() try: if config[0] == "inmemory": book_validator = BookValidator() client_validator = ClientValidator() rental_validator = RentalValidator() book_repository = Repository({}) client_repository = Repository({}) rental_repository = Repository({}) book_service = BookService(book_repository, book_validator) client_service = ClientService(client_repository, client_validator) rental_service = RentalService(rental_repository, rental_validator, book_repository, client_repository) console = Console(book_service, client_service, rental_service) console.run_console() elif config[0] == "filerepository": book_validator = BookValidator() client_validator = ClientValidator() rental_validator = RentalValidator() book_repository = BooksFileRepository(config[1]) client_repository = ClientsFileRepository(config[2]) rental_repository = RentalsFileRepository(config[3]) book_service = BookService(book_repository, book_validator) client_service = ClientService(client_repository, client_validator) rental_service = RentalService(rental_repository, rental_validator, book_repository, client_repository) console = Console(book_service, client_service, rental_service)
from repositories.disease_repository import DiseaseRepository from controllers.disease_controller import DiseaseController from ui.console import Console disease_repository = DiseaseRepository() disease_controller = DiseaseController(disease_repository) console = Console(disease_controller) console.run_console()
from repositories.bus_repository import BusRepository from repositories.route_repository import RouteRepository from controllers.bus_routes_controller import BusRoutesController from ui.console import Console """ 1. We initiate the repositories that read and keep the program data. """ bus_repository = BusRepository() route_repository = RouteRepository() """ 2. We initialize the controller which contains all the program logic and serves as the main service for the application. - the controller takes as arguments the repositories defined above """ bus_routes_controller = BusRoutesController(bus_repository, route_repository) """ 3. Finally, initialize the console, given the controller as argument and run the main method. """ console = Console(bus_routes_controller) console.run_console()
if not isinstance(rental_repo, RentalTextFileRepo) and not isinstance( rental_repo, RentalBinaryFileRepo): for i in range(100): date = str(randint(1, 28)) + "." + str(randint(1, 10)) + "." + str( randint(2016, 2018)) dformat = "%d.%m.%Y" duedate = datetime.strptime(date, dformat) + timedelta(days=7) duedate = date_to_str_format(duedate) returdate = datetime.strptime(date, dformat) + timedelta(days=randint(3, 11)) returdate = date_to_str_format(returdate) if i % 3 == 0: rental_serv.rent(i * 46 + 77, i * 56 + 25, i * 8952 + 521, date, duedate, returdate) else: rental_serv.rent(i * 46 + 77, i * 56 + 25, i * 8952 + 521, date, duedate) """ creating an object of the class Console and running the program """ console = None if settings["ui"] == "console": console = Console(book_serv, client_serv, rental_serv, undo_ser) elif settings["ui"] == "GUI": console = GUI(book_serv, client_serv, rental_serv, undo_ser) console.run_console()
''' Created on 28 Nov 2018 @author: Marius ''' from validation.validators import validClient, validBook, validRental from persistence.repositories import RepoBook, RepoClient, RepoRental from business.controllers import ServBook, ServClient, ServRental from ui.console import Console repoBook = RepoBook() validBook = validBook() servBook = ServBook(validBook, repoBook) servBook.addBook(1, "Papillon", "Henri Charriere", "Based on a real story") servBook.addBook(2, "Mythology", "Thor Sonofodin", "Book about Norse Mythology") repoClient = RepoClient() validClient = validClient() servClient = ServClient(validClient, repoClient) servClient.addClient(1, "JeanValjean") servClient.addClient(2, "AlanWatts") repoRental = RepoRental() validRental = validRental() servRental = ServRental(validRental, repoRental, repoClient, repoBook) c = Console(servClient, servBook, servRental) c.run()
from validators.student_validator import StudentValidator from repositories.student_repository import StudentRepository from controllers.student_controller import StudentController from ui.console import Console student_validator = StudentValidator() student_repository = StudentRepository() student_controller = StudentController(student_validator, student_repository) console = Console(student_controller) console.run_console()
from domain.situation import Situation from validators.game_validator import GameValidator from controllers.game_controller import GameController from ui.console import Console situation = Situation() game_validator = GameValidator() game_controller = GameController(situation, game_validator) console = Console(game_controller) console.start_game()
from controller.attenting_ctrl import AttentingCtrl from domain.validators import Validators from repository.attenting_repository import AttendingRepositoryFile from repository.person_repository import PersonRepositoryFile from controller.person_ctrl import PersonCtrl from ui.console import Console from repository.event_repository import EventRepositoryFile from controller.event_ctrl import EventCtrl val = Validators() person_repo = PersonRepositoryFile("persons.txt") person_ctrl = PersonCtrl(val, person_repo) event_repo = EventRepositoryFile("events.txt") event_ctrl = EventCtrl(val, event_repo) attend_repo = AttendingRepositoryFile("atd.txt") attend_ctrl = AttentingCtrl(val, event_repo, person_repo, attend_repo) cons = Console(person_ctrl, event_ctrl, attend_ctrl) cons.startUI()
from ui.console import Console from business.studentService import StudentService from business.disciplineService import DisciplineService from business.gradeService import GradeService from data.repositories.catalogue import Catalogue from data.repositories.catalogueFileRepo import CatalogueFileRepository from data.repositories.GradesRepository import GradesRepository from data.repositories.GradesFileRepo import GradesFileRepository from validation.validators import StudentValidator, DisciplineValidator, GradeValidator from utils.sorting import sort2keys if __name__ == "__main__": #catalogue = Catalogue() catalogue = CatalogueFileRepository("students.txt", "disciplines.txt") #gradesRepo = GradesRepository() gradesRepo = GradesFileRepository() studentValidator = StudentValidator() studentSrv = StudentService(catalogue, studentValidator) disciplineValidator = DisciplineValidator() disciplineSrv = DisciplineService(catalogue, gradesRepo, disciplineValidator) gradeValidator = GradeValidator() gradeSrv = GradeService(gradesRepo, catalogue, disciplineValidator, studentValidator, gradeValidator) console = Console(studentSrv, disciplineSrv, gradeSrv) #tests = Tests() #tests.runTests() console.run()
''' Created on Oct 22, 2017 @author: Gutza ''' from repository.inmemory import InMemoryRepository from controller.controller import ParticipantController from ui.console import Console rep = InMemoryRepository() ctr = ParticipantController(rep) ui = Console(ctr) ui.showUI()
from controller.agendaController import AgendaController from repository.contactRepository import ContactRepository from ui.console import Console import os """ Authors: Forgacs Amelia Dragan Alex Enasoae Simona VVSS Date: 19.05.2020 """ path = os.path.abspath("contacts.txt") repo = ContactRepository(path) ctr = AgendaController(repo) csl = Console(ctr) csl.run_ui()
from controller.sentence_controller import Controller from domain.entities import Sentence from repo.repository import Repository from ui.console import Console repo = Repository() controller = Controller(repo) console = Console(controller) controller.add(Sentence(1, 'the fox is ok')) controller.add(Sentence(2, 'the kid is ok')) while __name__ == '__main__': console.RunMenu()
''' Created on Nov 6, 2018 Modulul principal al aplicatiei @author: Silviu Anton ''' from services.client_service import ClientService from services.movie_service import MovieService from infrastructure.repository import FileRepository, RentFileRepository from domain.validators import ClientValidator, MovieValidator, RentValidator from ui.console import Console from services.rent_service import RentService from domain.entities import Client, Movie if __name__ == '__main__': clientRepository = FileRepository('clienti.txt', Client) clientService = ClientService(clientRepository, ClientValidator()) movieRepository = FileRepository('filme.txt', Movie) movieService = MovieService(movieRepository, MovieValidator()) rentRepository = RentFileRepository('inchirieri.txt') rentService = RentService(rentRepository, RentValidator(), clientRepository, movieRepository) console = Console(clientService, movieService, rentService) console.run()
''' Created on Dec 10, 2014 @author: Iulian ''' from repository.repository import Repository from controller.bicicleta_controller import Bicicleta_controller from ui.console import Console repo = Repository("produse.txt") contr = Bicicleta_controller(repo) consola = Console(contr) consola.UI()
from repositories.hotel_repository import HotelRepository from controllers.hotel_controller import HotelController from ui.console import Console hotel_repository = HotelRepository(rooms_filename="rooms.txt", reservations_filename="reservations.txt") hotel_controller = HotelController(hotel_repository) console = Console(hotel_controller) console.show_menu()
from Graph.graph_class import DirectedGraph from ui.console import Console if __name__ == "__main__": graph = DirectedGraph() app = Console(graph, "sample.txt") print("Please wait until the file reading has finished!") app.run()
if workingApp: ''' initializing all the validators ''' validatorStudent = StudentValidator() validatorAssignments = AssignmentValidator() validatorGrades = GradeValidator() ''' initializing all the controllers ''' controllerStudents = contrStudents(repoStudents, validatorStudent) controllerAssignments = contrAssignments(repoAssignments, validatorAssignments) controllerGrades = contrGrades(repoGrades, validatorGrades, repoStudents, repoAssignments) undoAction = undoAction(controllerStudents, controllerAssignments, controllerGrades) ''' creating the data ''' if inmemory: data = Data(controllerStudents, controllerAssignments, controllerGrades) data.createData() ''' running the console ''' console = Console(controllerStudents, controllerAssignments, controllerGrades, undoAction) console.run()
def play(self): sentences = GameController(SentenceRepository()) console = Console(sentences) console.run_game()