当前位置: 首页>>代码示例>>Python>>正文


Python Session.get_io方法代码示例

本文整理汇总了Python中session.Session.get_io方法的典型用法代码示例。如果您正苦于以下问题:Python Session.get_io方法的具体用法?Python Session.get_io怎么用?Python Session.get_io使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在session.Session的用法示例。


在下文中一共展示了Session.get_io方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: retrieve_data_point_count

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import get_io [as 别名]
def retrieve_data_point_count(session: Session) -> int:
    while True:
        data_point_count = get_integer_from_user(session, 'How many data points do you want to create: ')
        if data_point_count <= 0:
            session.get_io().output('Your input must be greater than zero, instead got {}'.format(str(data_point_count)))
            time.sleep(1)
            session.clear()
            continue
        return data_point_count
开发者ID:notfoundry,项目名称:PyMenuArchitect,代码行数:11,代码来源:datainitializationcommand.py

示例2: execute

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import get_io [as 别名]
    def execute(self, session: Session, args: Dict[str, Any]) -> ExitCode:
        data_to_remove = get_data_to_remove(session)

        data = args['data']
        args['data'] = deque(filterfalse(lambda x: x == data_to_remove, data))

        session.get_io().output('Removed {} data points'.format(len(data) - len(args['data'])))

        return ExitCode.SUCCESS
开发者ID:notfoundry,项目名称:PyMenuArchitect,代码行数:11,代码来源:deletealloccourrencescommand.py

示例3: get_data_points_per_line

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import get_io [as 别名]
def get_data_points_per_line(session: Session) -> int:
    while True:
        data_points_per_line = get_integer_from_user(session, 'How many data points per line should be outputted: ')
        if data_points_per_line <= 0:
            session.get_io().output('Your input must be greater than zero, instead got {}'.format(str(data_points_per_line)))
            time.sleep(1)
            session.clear()
            continue
        return data_points_per_line
开发者ID:notfoundry,项目名称:PyMenuArchitect,代码行数:11,代码来源:dataprintingcommand.py

示例4: execute

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import get_io [as 别名]
    def execute(self, session: Session, args: Dict[str, Any]) -> ExitCode:
        data_to_remove = get_data_to_remove(session)

        try:
            args['data'].remove(data_to_remove)
            session.get_io().output('Removed the first instance of data point "{}"'.format(data_to_remove))
        except ValueError:
            session.get_io().error('Data point "{}" is not present in the data store!'.format(data_to_remove))

        return ExitCode.SUCCESS
开发者ID:notfoundry,项目名称:PyMenuArchitect,代码行数:12,代码来源:deletefirstoccurrencecommand.py

示例5: execute

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import get_io [as 别名]
    def execute(self, session: Session, args: Dict[str, Any]) -> ExitCode:
        if not ensure_data_not_overwritten(session, args.get('data')):
            session.get_io().output("Not modifying existing data store. Continuing...")
            return ExitCode.SUCCESS

        data_point_count = retrieve_data_point_count(session)
        min_data_value = retrieve_min_data_value(session)
        max_data_value = retrieve_max_data_value(session)
        args['data'] = deque((random.randint(min(min_data_value, max_data_value), max(min_data_value, max_data_value)) for _ in range(data_point_count)))

        session.get_io().output('{} data points initialized with values between {} and {}'
                                .format(data_point_count, min_data_value, max_data_value))
        return ExitCode.SUCCESS
开发者ID:notfoundry,项目名称:PyMenuArchitect,代码行数:15,代码来源:datainitializationcommand.py

示例6: ensure_data_not_overwritten

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import get_io [as 别名]
def ensure_data_not_overwritten(session: Session, data_lookup: Optional[Any]) -> bool:
    if data_lookup is None:
        return True

    while True:
        session.get_io().output('Data has already been loaded for this session. Do you want to replace it? (y/n): ', end='')
        user_input = session.get_io().input().lower()
        if user_input == 'y':
            return True
        elif user_input == 'n':
            return False
        else:
            session.get_io().error('Your response must be either "y" or "n", instead got "{}"'.format(user_input))
            time.sleep(1)
            session.clear()
开发者ID:notfoundry,项目名称:PyMenuArchitect,代码行数:17,代码来源:datainitializationcommand.py

示例7: execute

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import get_io [as 别名]
    def execute(self, session: Session, args: Dict[str, Any]) -> ExitCode:
        data_to_find = get_data_to_try_to_sum(session)

        point_dict = {}
        curr_sum = 0
        curr_index = 0
        for point in reversed(args['data']):
            curr_sum += point
            indices = point_dict.setdefault(curr_sum, list())
            indices.append(curr_index)
            curr_index += 1

        session.get_io().output(len(args['data']) - min(point_dict.get(data_to_find)) - 1)

        return ExitCode.SUCCESS
开发者ID:notfoundry,项目名称:PyMenuArchitect,代码行数:17,代码来源:findfirstsumindexcommand.py

示例8: execute

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import get_io [as 别名]
    def execute(self, session: Session, args: Dict[str, Any]) -> ExitCode:
        data_points_per_line = get_data_points_per_line(session)

        num = 0
        for point in args['data']:
            num += 1
            end = ' '
            if num == data_points_per_line:
                num = 0
                end = '\n'
            session.get_io().output(point, end=end)
        if num > 0:
            session.get_io().output('', end='\n')

        session.get_io().output('Press any key to return to the menu', end='')
        session.get_io().input()

        return ExitCode.SUCCESS
开发者ID:notfoundry,项目名称:PyMenuArchitect,代码行数:20,代码来源:dataprintingcommand.py

示例9: run_console

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import get_io [as 别名]
def run_console(session: Session, menu: Menu, **kwargs: Dict[str, Any]) -> None:
    session.clear()
    if len(menu) == 0:
        session.get_io().output("No commands present in menu. Exiting...")
        return

    while True:
        show_menu_options(session.get_io(), menu)
        try:
            command_lookup = retrieve_user_command_choice(session.get_io(), menu)  # type: MenuCommand
            handle_valid_command(command_lookup, session, kwargs)
        except IllegalCommandIndexException as illegal_input_ex:
            handle_illegal_command_index_exception(illegal_input_ex, session.get_io(), menu)
        except MalformedInputException as malformed_input_ex:
            handle_malformed_input_exception(malformed_input_ex, session.get_io())

        session.clear()
开发者ID:notfoundry,项目名称:PyMenuArchitect,代码行数:19,代码来源:runner.py

示例10: handle_valid_command

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import get_io [as 别名]
def handle_valid_command(command: MenuCommand, session: Session, args: Dict[str, Any]) -> None:
    session.clear()
    exit_code = command.execute(session, args)  # type: ExitCode
    session.get_io().output('Command "{}" completed with exit code {}'.format(command.name(), exit_code.name))
    time.sleep(1)
开发者ID:notfoundry,项目名称:PyMenuArchitect,代码行数:7,代码来源:runner.py


注:本文中的session.Session.get_io方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。