def main(): in_file = get_storage_preference() # Set repositories. if in_file: personRepo = PersonFileRepository("storage/people.txt") activityRepo = ActivityFileRepository(personRepo, "storage/activities.txt") else: personRepo = PersonRepository() activityRepo = ActivityRepository() # Set controllers. peopleCtrl = PeopleController(personRepo) activitiesCtrl = ActivitiesController(personRepo, activityRepo) statsCtrl = StatsController(personRepo, activityRepo) undoRedoCtrl = UndoRedoController(peopleCtrl, activitiesCtrl) # Set console. ui = Console(peopleCtrl, activitiesCtrl, statsCtrl, undoRedoCtrl) # Run everything. ui.run() # Store to files if in_file: personRepo.store() activityRepo.store()
def main(): list_of_repositories = repo_choice() student_repository = list_of_repositories[0] discipline_repository = list_of_repositories[1] grade_repository = list_of_repositories[2] add_mock_data_to_repos(student_repository, discipline_repository, grade_repository) list_of_controllers = get_controllers(student_repository, discipline_repository, grade_repository) student_controller = list_of_controllers[0] discipline_controller = list_of_controllers[1] grade_controller = list_of_controllers[2] undo_controller = list_of_controllers[3] console = Console(student_controller, discipline_controller, grade_controller, undo_controller) console.main_menu() if isinstance(student_repository, StudentRepositoryCSV) or isinstance( student_repository, StudentRepositoryBinary): student_repository.write_file() discipline_repository.write_file() grade_repository.write_file()
def __init__(self): self.__text_util = TextUtils() print("\n\n") # Data Directories self.config_path = 'config/' self.config = { 'prefix': None, 'token': None } self.__init_files() # Data self.__command_prefix = self.config['prefix'] self.__token = self.config['token'] # Objects self.__console = Console(self.__text_util) # Discord Client self.__client = discord.Client() self.__message_handler = MessageHandler(self.__client, self.__console, self.__command_prefix) # Initialise self.__set_style() self.__set_client_events() # Run the client if self.__token is not None: self.__client.run(self.__token) else: print("Token is Invalid")
def main(self): filename = "sudoku.txt" problem = Problem() problem.readFromFile(filename) contr = Controller(problem) cons = Console(contr) cons.mainMenu()
# rent1=Rent(101, 10, 'inchiriat') # #repoRents.add(rent1) # rent2=Rent(101, 42, 'inchiriat') # rent3=Rent(101, 19, 'inchiriat') # rent4=Rent(1, 10, 'inchiriat') # rent5=Rent(34, 42, 'inchiriat') # rent6=Rent(34, 19, 'inchiriat') # rent7=Rent(34, 199, 'inchiriat') # rent8=Rent(34,78 , 'inchiriat') # rent9=Rent(34, 20, 'inchiriat') # repoRents.add(rent2) # repoRents.add(rent3) # repoRents.add(rent4) # repoRents.add(rent5) # repoRents.add(rent6) # repoRents.add(rent7) # repoRents.add(rent8) validatorMovie = MovieValidator() validatorClient = ClientValidator() validatorRent = RentValidator() servMovies = MovieService(repoMovies, validatorMovie) servClients = ClientService(repoClients, validatorClient) servRents = RentService(repoMovies, repoClients, repoRents, servMovies, servClients) cons = Console(servMovies, servClients, servRents) cons.run()
''' Created on Nov 1, 2012 @author: Mihai Costea ''' from blackBox import blackBoxTest_updateBook from controller.Controller import LibraryController from controller.tests import test_controller from repository.RepositoryInFiles import BookListInFile, ClientListInFile from repository.Storage import BookList, ClientList from ui.Console import Console if __name__ == '__main__': #bookList = BookList() #clientList = ClientList() bookList = BookListInFile("books.dat") clientList = ClientListInFile("clients.dat") testBookList = BookList() testClientList = ClientList() test_controller(testBookList, testClientList) blackBoxTest_updateBook() libraryController = LibraryController(bookList, clientList) console = Console(libraryController)
from repo.GraphRepository import GraphRepository from solver.TSPSolver import TSPSolver from ui.Console import Console if __name__ == '__main__': repos = GraphRepository() repos.settingsFileName = 'settings/settings.txt' solver = TSPSolver(repos) console = Console(solver) console.run()
from validation.Validators import ValidActor, ValidMovie, ValidCast from persistence.Repositories import RepoActor, RepoMovie, RepoCast from business.Controllers import ServActor, ServMovie, ServCast from ui.Console import Console repoMovie = RepoMovie() validMovie = ValidMovie() servMovie = ServMovie(validMovie, repoMovie) servMovie.add_movie(1, "Morometii2") servMovie.add_movie(2, "Ronin") repoActor = RepoActor() validActor = ValidActor() servActor = ServActor(validActor, repoActor) servActor.add_actor(1, "TomCruise", 23.45) servActor.add_actor(2, "JackBlack", 223.45) repoCast = RepoCast() validCast = ValidCast() servCast = ServCast(validCast, repoCast, repoActor, repoMovie) servCast.add_cast("ilie", 1, 1, 42332132) servCast.add_cast("cochilie", 1, 2, 423122332) servCast.add_cast("iliutza", 1, 2, 31342332) servCast.add_cast("ile", 2, 1, 4332) servCast.add_cast("ilie", 2, 2, 4122) c = Console(servActor, servMovie, servCast) c.run()
''' Created on Mar 14, 2017 @author: Utilizator ''' from ui.Console import Console from controller.Controller import Controller from domain.Graph import Graph graph = Graph( "C:\\Users\\Utilizator\\Desktop\\University\\Semester 2\\Graph Algorithms\\Lab1\\graph" ) ui = Console(Controller(graph)) ui.runApp()
serviceStudent.addStudent(2, "Dumitrescu George", 215) serviceStudent.addStudent(3, "Vaida George", 215) serviceStudent.addStudent(4, "Benga Ionut", 217) serviceStudent.addStudent(5, "Benga Vlad", 217) serviceStudent.addStudent(6, "Grigore Alin", 218) serviceStudent.addStudent(7, "Dragomir Manuel", 215) serviceStudent.addStudent(8, "Marica Andrada", 215) serviceStudent.addStudent(9, "Rauta Milena", 218) serviceStudent.addStudent(10, "Balinth Andrei", 219) serviceLaborator.addLaborator(2, 1, "strings", "22.10.2015") serviceLaborator.addLaborator(2, 2, "strings", "22.12.2015") serviceLaborator.addLaborator(2, 3, "strings", "22.12.2015") serviceLaborator.addLaborator(2, 4, "strings", "22.09.2015") serviceLaborator.addLaborator(3, 1, "clase", "22.10.2016") serviceLaborator.addLaborator(4, 1, "teste", "22.10.2017") serviceLaborator.addLaborator(5, 1, "arhitectura", "22.11.2015") serviceLaborator.addLaborator(6, 1, "operatii", "22.11.2015") serviceLaborator.addLaborator(6, 2, "operatii", "22.12.2015") serviceNota.addNota(2, 2, 1, 10) serviceNota.addNota(3, 2, 2, 9) serviceNota.addNota(4, 2, 2, 10) serviceNota.addNota(6, 2, 4, 6) serviceNota.addNota(6, 3, 1, 3) serviceNota.addNota(7, 2, 2, 10) serviceNota.addNota(3, 6, 1, 2) serviceNota.addNota(6, 6, 1, 5) c = Console(serviceStudent, serviceLaborator, serviceNota) c.run()
''' Created on Nov 3, 2016 @author: AndreiMsc ''' from repository.Student_repository import Student_repository from controller.Student_controller import Student_controller from repository.Assignment_repository import Assignment_repository from controller.Assignment_controller import Assignment_controller from ui.Console import Console stud_repo = Student_repository() stud_ctrl = Student_controller(stud_repo) assign_repo = Assignment_repository() assign_ctrl = Assignment_controller(assign_repo) con = Console(stud_ctrl, assign_ctrl) con.run()
class DiscordBot: def __init__(self): self.__text_util = TextUtils() print("\n\n") # Data Directories self.config_path = 'config/' self.config = { 'prefix': None, 'token': None } self.__init_files() # Data self.__command_prefix = self.config['prefix'] self.__token = self.config['token'] # Objects self.__console = Console(self.__text_util) # Discord Client self.__client = discord.Client() self.__message_handler = MessageHandler(self.__client, self.__console, self.__command_prefix) # Initialise self.__set_style() self.__set_client_events() # Run the client if self.__token is not None: self.__client.run(self.__token) else: print("Token is Invalid") def __set_style(self, foreground=96, background=100): self.__text_util.update_style(foreground, background) def __set_client_events(self): # Initialise Discord Client client = self.__client @client.event async def on_ready(): self.__console.start_message(client) @client.event async def on_message(message): # Process Message response = await self.__message_handler.process_message(message) if response is not None: await client.send_message(message.channel, response) def __init_files(self): # Create Dir if not os.path.isdir(self.config_path): os.mkdir(self.config_path) # Create Config Files for config_name, config_values in self.config.items(): file_path = self.config_path + config_name + '.txt' if not os.path.isfile(file_path): open(file_path, 'w').write('') # Read Files for file in os.listdir(self.config_path): if file.endswith('.txt'): self.config.update({file.split('.')[-2]: open(self.config_path + file, 'r').read()}) # If token is empty, get user token while self.config['token'] == '': print(self.__text_util.format_text(open('Instructions/empty_token_file.txt').read(), [34])) input("\nPress Enter to open WebPage") webbrowser.open('https://discordapp.com/developers/applications/') token = input(self.__text_util.format_text('\nToken > ', [34])) self.config.update({'token': token}) open(self.config_path + 'token.txt', 'w').write(token.strip('\\s')) while self.config['prefix'] == '': prefix = '' confirm = '' while not confirm[:3].lower() == 'yes': prefix = '' while prefix == '': prefix = input(self.__text_util.format_text('\nEnter Prefix > ', [34])) confirm = input('Prefix will be set as [' + prefix + ']\nIs this okay? Type Yes to confirm. > ') self.config.update({"prefix": prefix}) open(self.config_path + 'prefix.txt', 'w').write(prefix)
from tests.Test import Test from business.Service import CookieService from valid.Validation import CookieValidator from repo.Repository import Repository from ui.Console import Console t = Test() t.runTests() repo = Repository() valid = CookieValidator() service = CookieService(repo, valid) console = Console(service) console.run()
''' Created on 31 ian. 2019 @author: sonia ''' from infrastructure.Repositories import FileRepo from business.Service import Service from validation.Validator import ValidJucator from ui.Console import Console repo = FileRepo("jucatori.txt") valid = ValidJucator() serv = Service(repo, valid) c = Console(serv) c.run()
def main(): prodRepo = ProductRepository("products.txt") pharmCtrl = PharmacyController(prodRepo) ui = Console(pharmCtrl) ui.run()
from repository.RepositoryGeneric import GenericFileRepository from ui.Console import Console from domain.comentariu import Comentariu from domain.stire import Stire from service.service_stire import ServiceStire from service.service_comentarii import ServiceCom repo_st = GenericFileRepository('stiri.pkl') repo_com = GenericFileRepository('comentarii.pkl') service_st = ServiceStire(repo_st) service_com = ServiceCom(repo_com) cons = Console(service_st, service_com) cons.run()
from tests.Test import Test from repo.Repository import * from repo.FileRepository import * from valid.Validare import ValidatorClient, ValidatorFilm, ValidatorInchiriere from business.Controllers import ControllerFilm, ControllerClient, ControllerInchiriere from ui.Console import Console t = Test() t.runTests() #filmRepo=FilmRepository() filmRepo = FilmFileRepo('filme.txt') #clientRepo=ClientRepository() clientRepo = ClientFileRepo('clienti.txt') #inchiriereRepo=InchiriereRepository() inchiriereRepo = InchiriereFileRepo('inchirieri.txt') validatorf = ValidatorFilm() validatorc = ValidatorClient() validatorinch = ValidatorInchiriere() contrFilm = ControllerFilm(filmRepo, validatorf) contrClient = ControllerClient(clientRepo, validatorc) contrInchiriere = ControllerInchiriere(inchiriereRepo, validatorinch, filmRepo, clientRepo) consola = Console(contrFilm, contrClient, contrInchiriere) consola.run()
from datetime import date, timedelta from domain.book import Book from domain.client import Client from domain.rental import Rental from repository.BookRepo import BookFileRepository from repository.ClientRepo import ClientFileRepository from repository.RentalRepo import RentalFileRepository from service.BookController import BookController from service.ClientController import ClientController from service.RentalController import RentalController from service.StatisticsController import StatisticsController from service.UndoController import UndoController from ui.Console import Console from repository.Repository import Repository book_repo = BookFileRepository() client_repo = ClientFileRepository() rental_repo = RentalFileRepository() op_list = [] undo_ctrl = UndoController(op_list) b_ctrl = BookController(book_repo, undo_ctrl) c_ctrl = ClientController(client_repo, undo_ctrl) r_ctrl = RentalController(rental_repo, book_repo, client_repo, undo_ctrl) s_ctrl = StatisticsController(book_repo, client_repo, rental_repo) cons = Console(b_ctrl, c_ctrl, r_ctrl, s_ctrl, undo_ctrl) cons.run()
from domain.RouteValidator import RouteValidator from repository.RouteRepository import RouteRepository from controller.RouteController import RouteController from ui.Console import Console route_vali = RouteValidator() repo = RouteRepository("storage/routes.txt", route_vali) ctrl = RouteController(repo) ui = Console(ctrl) ui.run()
from domain.SimpleEntity import read_entity,write_entity from repository.FileCacheRepository import FileCacheRepository from ui.Console import Console from controller.SimpleController import SimpleController repository = FileCacheRepository(4,"simple.txt",read_entity,write_entity) controller = SimpleController(repository) console = Console(controller) console.run()