def prompt(questions, render=None, answers=None, theme=themes.Default(), raise_keyboard_interrupt=False): render = render or ConsoleRender(theme=theme) answers = answers or {} try: for question in questions: answers[question.name] = render.render(question, answers) return answers except KeyboardInterrupt: if raise_keyboard_interrupt: raise print("") print("Cancelled by user") print("")
from typing import Any, Dict, List, Optional, Set, Tuple from . import training parent_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '../')) # Use the env var path or ../yuri-data ROOT_PATH = os.environ.get('YURI_ROOT_PATH', os.path.join(parent_path, 'yuri-data')) DEFAULT_DATA_FILE = os.path.join(ROOT_PATH, 'slack_channel_data/data.json') DEFAULT_MODEL_DIR = os.path.join(ROOT_PATH, 'slack_channel_model') DEFAULT_BATCH_SIZE = 10 DIRECTION_NEWER = True DIRECTION_OLDER = False IGNORE_LABEL = 'ignore' CREATE_LABEL = '+add new' INQUIRER_RENDER = ConsoleRender(theme=GreenPassion()) def get_client(token: str, session: Optional[Session] = None) -> slacker.Slacker: if not token: raise Exception(f'No token was provided') if not token.startswith('xoxp-'): raise Exception( f'The provided token is invalid since it not a user token, please use a user token instead' ) return slacker.Slacker(token, session=session) def get_channel_id(token: str, name: str,
def path(message, render=None, **kwargs): render = render or ConsoleRender() question = questions.Path(name="", message=message, **kwargs) return render.render(question)
def checkbox(message, render=None, **kwargs): render = render or ConsoleRender() question = questions.Checkbox(name="", message=message, **kwargs) return render.render(question)
def list_input(message, render=None, **kwargs): render = render or ConsoleRender() question = questions.List(name="", message=message, **kwargs) return render.render(question)
def editor(message, render=None, **kwargs): render = render or ConsoleRender() question = questions.Editor(name="", message=message, **kwargs) return render.render(question)