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


Python readline.set_completer_delims方法代码示例

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


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

示例1: show_menu

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_completer_delims [as 别名]
def show_menu(CommandClass, CompleterClass, name):
    command = CommandClass(name)
    completer = CompleterClass(command)
    readline.set_completer(completer.complete)
    readline.set_completer_delims(" ")
    readline.parse_and_bind("tab: complete")

    res = False
    while res is not True:
        valid_commands = command.cmd.keys()

        ret_cmd = six.input("%s> " % name).strip()
        cmd, options = (ret_cmd.split(" ")[0], " ".join(ret_cmd.split(" ")[1:]))
        if cmd == "debug":
            pdb.set_trace()

        elif cmd.lower() in valid_commands:
            res = command.run_cmd(cmd, options)

        else:
            print("Invalid command.")

        readline.set_completer(completer.complete) 
开发者ID:depthsecurity,项目名称:armory,代码行数:25,代码来源:armory_interactive.py

示例2: run

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_completer_delims [as 别名]
def run(self, line):
      ishellCompleter = readline.get_completer()
      readline.set_completer_delims(' \t\n;')
      readline.parse_and_bind("tab: complete")
      readline.set_completer(completer.complete)

      sample_file = raw_input('Please enter the filename you want to open: ')
      try:
         sample_fh = open(sample_file,'r')
         feathermodules.samples.extend([sample.strip() for sample in sample_fh.readlines()])
         sample_fh.close()
         feathermodules.samples = filter(lambda x: x != '' and x != None, feathermodules.samples)
      except:
         print 'Something went wrong. Sorry! Please try again.'
      finally:
         readline.set_completer(ishellCompleter) 
开发者ID:nccgroup,项目名称:featherduster,代码行数:18,代码来源:featherduster.py

示例3: setup

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_completer_delims [as 别名]
def setup(self):
        """ Initialization of third-party libraries

        Setting interpreter history.
        Setting appropriate completer function.

        :return:
        """
        if not os.path.exists(self.history_file):
            open(self.history_file, 'a+').close()

        readline.read_history_file(self.history_file)
        readline.set_history_length(self.history_length)
        atexit.register(readline.write_history_file, self.history_file)

        readline.parse_and_bind('set enable-keypad on')

        readline.set_completer(self.complete)
        readline.set_completer_delims(' \t\n;')
        readline.parse_and_bind("tab: complete") 
开发者ID:d0ubl3g,项目名称:Industrial-Security-Auditing-Framework,代码行数:22,代码来源:BaseInterpreter.py

示例4: Input_completer

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_completer_delims [as 别名]
def Input_completer(keywords):
    completer = MyCompleter(keywords)
    readline.set_completer(completer.complete)
    if "libedit" in readline.__doc__:
        readline.parse_and_bind("bind ^I rl_complete")
    else:
        readline.parse_and_bind('tab: complete')
        #readline.parse_and_bind('"\\e[A": complete') # Up arrow
    readline.parse_and_bind("set colored-completion-prefix on")
    readline.parse_and_bind("set show-all-if-unmodified on")
    readline.parse_and_bind("set horizontal-scroll-mode on")
    if os.path.exists(history_file):
        readline.read_history_file(history_file)
        readline.set_history_length(20)
    readline.set_completer_delims(' ')
    atexit.register(save_history) 
开发者ID:OWASP,项目名称:QRLJacking,代码行数:18,代码来源:utils.py

示例5: h5py_item_completer

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_completer_delims [as 别名]
def h5py_item_completer(context, command):
    """Compute possible item matches for dict-like objects"""

    base, item = re_item_match.split(command)[1:4:2]

    try:
        obj = _retrieve_obj(base, context)
    except Exception:
        return []

    path, _ = posixpath.split(item)

    try:
        if path:
            items = (posixpath.join(path, name) for name in obj[path].keys())
        else:
            items = obj.keys()
    except AttributeError:
        return []

    items = list(items)
    readline.set_completer_delims(' \t\n`!@#$^&*()=+[{]}\\|;:\'",<>?')

    return [i for i in items if i[:len(item)] == item] 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:26,代码来源:ipy_completer.py

示例6: use

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_completer_delims [as 别名]
def use(self,args,pointer = None):
		global POINTER
		if(len(args) < 2):
			return None
		POINTER = args[1]
		moduleName = args[1].split('/')
		comp 	= Completer()
		readline.set_completer_delims(' \t\n;')
		readline.parse_and_bind("tab: complete")
		readline.set_completer(comp.complete)
		while True:
			input	= raw_input('SMOD ' + moduleName[0] + '(' + bcolors.OKBLUE + moduleName[-1] + bcolors.ENDC + ') >').strip().split()
			try:			
				result 	= getattr(globals()['Command'](),input[0])(input,args[1])
			except:
				return None
			if (POINTER == None):
				break 
开发者ID:theralfbrown,项目名称:smod-1,代码行数:20,代码来源:Interface.py

示例7: init_readline

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_completer_delims [as 别名]
def init_readline(complete_method, histfile=None):
    """init the readline library if available"""
    try:
        import readline
        readline.parse_and_bind("tab: complete")
        readline.set_completer(complete_method)
        string = readline.get_completer_delims().replace(':', '')
        readline.set_completer_delims(string)
        if histfile is not None:
            try:
                readline.read_history_file(histfile)
            except IOError:
                pass
            import atexit
            atexit.register(readline.write_history_file, histfile)
    except:
        print('readline si not available :-(') 
开发者ID:jlachowski,项目名称:clonedigger,代码行数:19,代码来源:cli.py

示例8: get_command

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_completer_delims [as 别名]
def get_command(self, prompt, auto_complete_fn=None, basefile_fn=None):
        try:
            if auto_complete_fn != None:
                import readline
                readline.set_completer_delims(' \t\n;/')
                readline.parse_and_bind("tab: complete")
                readline.set_completer(auto_complete_fn)
                # readline.set_completion_display_matches_hook(basefile_fn)
        except:
            pass

        # python3 changes raw input name
        if sys.version_info[0] == 3:
            raw_input = input
        else:
            raw_input = __builtins__['raw_input']

        cmd = raw_input("%s" % prompt)
        return cmd.strip() 
开发者ID:zerosum0x0,项目名称:koadic,代码行数:21,代码来源:shell.py

示例9: _input_code_with_completion

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_completer_delims [as 别名]
def _input_code_with_completion(prompt, input_helper, reactor):
    # reminder: this all occurs in a separate thread. All calls to input_helper
    # must go through blockingCallFromThread()
    c = CodeInputter(input_helper, reactor)
    if readline is not None:
        if readline.__doc__ and "libedit" in readline.__doc__:
            readline.parse_and_bind("bind ^I rl_complete")
        else:
            readline.parse_and_bind("tab: complete")
        readline.set_completer(c.completer)
        readline.set_completer_delims("")
        debug("==== readline-based completion is prepared")
    else:
        debug("==== unable to import readline, disabling completion")
    code = input(prompt)
    # Code is str(bytes) on py2, and str(unicode) on py3. We want unicode.
    if isinstance(code, bytes):
        code = code.decode("utf-8")
    c.finish(code)
    return c.used_completion 
开发者ID:warner,项目名称:magic-wormhole,代码行数:22,代码来源:_rlcompleter.py

示例10: ask_list

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_completer_delims [as 别名]
def ask_list(label, items, alt=None, default=None):
    completer = AutoCompleter(items)
    readline.set_completer(completer.complete)
    readline.set_completer_delims('')
    readline.parse_and_bind('tab: complete')

    item = None
    while not item:
        item = ask_string(label, default=default)
        if item not in items:
            if alt and item in alt:
                item = items[alt.index(item)]
            else:
                print("Invalid entry (try pressing TAB)")
                item = None

    readline.set_completer(None)
    return item 
开发者ID:krfricke,项目名称:rl-benchmark,代码行数:20,代码来源:util.py

示例11: init_tabComplete

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_completer_delims [as 别名]
def init_tabComplete(self):
		''' Initializes the tab completer '''
		try:
			if OS_VERSION == "posix":
				global tabCompleter
				global readline
				from utils.PythonCompleter import tabCompleter
				import readline
				comp = tabCompleter()
				# we want to treat '/' as part of a word, so override the delimiters
				readline.set_completer_delims(' \t\n;')
				readline.parse_and_bind("tab: complete")
				readline.set_completer(comp.pathCompleter)
				if not comp:
					return -1
			return 0
		except:
			return -1 
开发者ID:008karan,项目名称:PAN_OCR,代码行数:20,代码来源:pan.py

示例12: main

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_completer_delims [as 别名]
def main():
    commands = {
        'file': {},
        'eat': {'breakfast', 'dinner', 'lunch', 'snack'},
        'play': {'cards', 'chess', 'go'},
        'walk': {'left', 'right', 'straight'},
    }
    readline.parse_and_bind('tab: complete')
    readline.set_completer(make_subcommand_completer(commands))

    # Use the default readline completer delims; Python's readline adds '-'
    # which makes filename completion funky (for files that contain '-').
    readline.set_completer_delims(" \t\n\"\\'`@$><=;|&{(")

    try:
        while True:
            s = input('>> ').strip()
            print('[{0}]'.format(s))
    except (EOFError, KeyboardInterrupt) as e:
        print('\nShutting down...') 
开发者ID:eliben,项目名称:code-for-blog,代码行数:22,代码来源:readline-complete-subcommand.py

示例13: training_loop

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_completer_delims [as 别名]
def training_loop():
    """
    The menu handler loop for the training menu. Reads commands and send them to the processor, otherwise shows the menu prompt.
    :return: None
    """
    try:
        command = ''
        while command == '':
            try:
                readline.set_completer_delims(' \t\n;')
                readline.parse_and_bind("tab: complete")
                readline.set_completer(trainingcomplete)
                command = raw_input(
                    'barq ' + color('training', 'yellow') + ' > ')
            except Exception as e:
                print(e)
            #command = prompt.query('aws sheller training > ', validators=[])
        command = str(command)
        process_training_command(command)
    except KeyboardInterrupt as k:
        print("CTRL C clicked in training")
        menu_backward() 
开发者ID:Voulnet,项目名称:barq,代码行数:24,代码来源:barq.py

示例14: instances_loop

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_completer_delims [as 别名]
def instances_loop():
    """
    The command handler loop for the EC2 instances menu. Commands will be sent to the processor and the prompt will be displayed.
    :return: None
    """
    try:
        command = ''
        while command == '':
            try:
                readline.set_completer_delims(' \t\n;')
                readline.parse_and_bind("tab: complete")
                readline.set_completer(instancecomplete)
                command = raw_input('barq '+color('instances', 'blue')+' > ')
            except Exception as e:
                print(e)
        command = str(command)
        process_instances_command(command)
    except KeyboardInterrupt as k:
        print("CTRL+C pressed.")
        choice = prompt.query(color(
            "Are you sure you want to go back to the main menu? Y/N", 'red'), default='Y')
        if choice == 'Y':
            menu_backward()
        else:
            instances_loop() 
开发者ID:Voulnet,项目名称:barq,代码行数:27,代码来源:barq.py

示例15: main_loop

# 需要导入模块: import readline [as 别名]
# 或者: from readline import set_completer_delims [as 别名]
def main_loop():
    """
    The command handler loop for the main menu. Commands will be sent to the processor and the prompt will be displayed.
    :return: None
    """
    try:
        command = ''
        while command == '':
            try:
                readline.set_completer_delims(' \t\n;')
                readline.parse_and_bind("tab: complete")
                readline.set_completer(maincomplete)
                command = raw_input('barq '+color('main', 'green')+' > ')
            except Exception as e:
                exit()
            #command = prompt.query('aws sheller main> ', validators=[])
        command = str(command)
        process_main_command(command)
    except KeyboardInterrupt as k:
        print(color("CTRL+C pressed. Exiting...", 'red'))
        exit() 
开发者ID:Voulnet,项目名称:barq,代码行数:23,代码来源:barq.py


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