コード例 #1
0
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("")
コード例 #2
0
ファイル: __init__.py プロジェクト: bluesliverx/yuri
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,
コード例 #3
0
def path(message, render=None, **kwargs):
    render = render or ConsoleRender()
    question = questions.Path(name="", message=message, **kwargs)
    return render.render(question)
コード例 #4
0
def checkbox(message, render=None, **kwargs):
    render = render or ConsoleRender()
    question = questions.Checkbox(name="", message=message, **kwargs)
    return render.render(question)
コード例 #5
0
def list_input(message, render=None, **kwargs):
    render = render or ConsoleRender()
    question = questions.List(name="", message=message, **kwargs)
    return render.render(question)
コード例 #6
0
def editor(message, render=None, **kwargs):
    render = render or ConsoleRender()
    question = questions.Editor(name="", message=message, **kwargs)
    return render.render(question)