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


Python readline.set_startup_hook方法代码示例

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


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

示例1: ask

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_startup_hook [as 别名]
def ask(string, valid_values, default=-1, case_sensitive=False):
    """ Asks for a keyborad answer """

    v = None
    if not case_sensitive:
        valid_values = [value.lower() for value in valid_values]
    while v not in valid_values:
        readline.set_startup_hook(lambda: readline.insert_text(default))
        try:
            v = raw_input("%s [%s] " % (string, ', '.join(valid_values))).strip()
            if v == '' and default>=0:
                v = valid_values[default]
            if not case_sensitive:
                v = v.lower()
        finally:
            readline.set_startup_hook()
    return v 
开发者ID:eggnogdb,项目名称:eggnog-mapper,代码行数:19,代码来源:release.py

示例2: edit_option

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_startup_hook [as 别名]
def edit_option(self, idx):
        # Go up
        sys.stdout.write('\033[1A' * (len(self.options) - idx))
        # Go left to the beginning of the line
        sys.stdout.write('\033[1D' * (max([len(x) for x in self.options]) + 3))
        sys.stdout.flush()
        prev_value = self.options[idx]
        readline.set_startup_hook(lambda: readline.insert_text(prev_value))
        try:
            new_value = input('E: ')
        finally:
            readline.set_startup_hook()

        self.options[idx] = new_value
        sys.stdout.write('\033[1A' * (idx + 1))
        sys.stdout.write('\033[1D' * (max([len(x) for x in self.options]) + 3))
        sys.stdout.flush()
        self.print_options()
        return prev_value, new_value 
开发者ID:antlarr,项目名称:bard,代码行数:21,代码来源:terminalkeyboard.py

示例3: rlinput

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_startup_hook [as 别名]
def rlinput(prompt, prefill = ''):
   readline.set_startup_hook(lambda: readline.insert_text(prefill))
   try:
      return input(prompt)
   finally:
      readline.set_startup_hook() 
开发者ID:xypnox,项目名称:todxpy,代码行数:8,代码来源:parse_functions.py

示例4: user_input

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_startup_hook [as 别名]
def user_input(msg, initial=''):
    # Function to capture raw_input w/ key buffer flush
    tcflush(sys.stdin, TCIOFLUSH)
    readline.set_startup_hook(lambda: readline.insert_text(initial))
    keyin = raw_input(msg)
    return keyin 
开发者ID:gluster,项目名称:gluster-one,代码行数:8,代码来源:g1modules.py

示例5: rlinput

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_startup_hook [as 别名]
def rlinput(prompt, prefill=''):
    readline.set_startup_hook(lambda: readline.insert_text(prefill))
    try:
        return input(prompt)
    finally:
        readline.set_startup_hook() 
开发者ID:IBM,项目名称:power-up,代码行数:8,代码来源:switch_cfg.py

示例6: rlinput

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_startup_hook [as 别名]
def rlinput(prompt, prefill=''):
    log = logger.getlogger()
    log.debug(f"prompt='{repr(prompt)}' prefill='{prefill}'")
    readline.set_startup_hook(lambda: readline.insert_text(prefill))
    try:
        user_input = input(prompt)
        log.debug(f"user_input='{user_input}'")
        return user_input
    finally:
        readline.set_startup_hook() 
开发者ID:IBM,项目名称:power-up,代码行数:12,代码来源:utilities.py

示例7: rlinput

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_startup_hook [as 别名]
def rlinput(prompt, prefill=''):
    readline.set_startup_hook(lambda: readline.insert_text(prefill))
    try:
        return raw_input(prompt)
    finally:
        readline.set_startup_hook() 
开发者ID:Juniper,项目名称:contrail-server-manager,代码行数:8,代码来源:smgr_add.py

示例8: getInput

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_startup_hook [as 别名]
def getInput( self, prompt, prefill='' ):

		readline.set_startup_hook(lambda: readline.insert_text('\n' + prefill))
		try:
			return input(prompt).replace('\n','')
		finally:
			readline.set_startup_hook() 
开发者ID:mholgatem,项目名称:GPIOnext,代码行数:9,代码来源:config_manager.py


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