def run(self): while not self.command: if self.exit: log.info("Bye") sys.exit(0) self._wait_input()
def _wait_input(self): log.info("1. Host list") log.info("2. Add host") log.info("3. Delete host") log.info("0. Exit") action_list = { '0': self._exit, '1': self.print_hosts_list, '2': self._add, '3': self._remove } action = readline("Action", '1') if action not in action_list: log.error("Unknown action") return action_list[action]()
import hostseditor.log as log import hostseditor.color as color from hostseditor.editor import Editor, VERSION import sys __version__ = VERSION __all__ = ["log", "color", "Editor", "__version__"] if __name__ == '__main__': app = Editor() while app.command: if app.exit: log.info("Bye") sys.exit(0) app.run()
def _remove(self): host = readline("Host", "localhost") self.remove(host) log.info("Host `" + host + "` has been deleted")
def _add(self): host = readline("Host", "localhost") ip = readline("IP", "127.0.0.1") self.add(host, ip) log.info("Host `" + host + "` (" + ip + ") has been added")