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


Python readline.__doc__方法代码示例

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


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

示例1: get_input_autocomplete

# 需要导入模块: import readline [as 别名]
# 或者: from readline import __doc__ [as 别名]
def get_input_autocomplete(message=''):
    """ Allow user to type input and provide auto-completion """

    # Apple does not ship GNU readline with OS X.
    # It does ship BSD libedit which includes a readline compatibility interface.
    # Source: https://stackoverflow.com/questions/7116038/python-tab-completion-mac-osx-10-7-lion
    if 'libedit' in readline.__doc__:
        readline.parse_and_bind("bind ^I rl_complete")
    else:
        readline.parse_and_bind("tab: complete")
    readline.set_completer(autocomplete)

    try:
        return input(message).strip()
    except KeyboardInterrupt:
        return False
    except Exception:  # Other Exception
        return False 
开发者ID:gabfl,项目名称:vault,代码行数:20,代码来源:autocomplete.py

示例2: Input_completer

# 需要导入模块: import readline [as 别名]
# 或者: from readline import __doc__ [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

示例3: create_argparser

# 需要导入模块: import readline [as 别名]
# 或者: from readline import __doc__ [as 别名]
def create_argparser(self, command):
        try:
            argparse_args = getattr(self, "argparse_" + command)
        except AttributeError:
            return None
        doc_lines = getattr(self, "do_" + command).__doc__.expandtabs().splitlines()
        if '' in doc_lines:
            blank_idx = doc_lines.index('')
            usage = doc_lines[:blank_idx]
            description = doc_lines[blank_idx+1:]
        else:
            usage = doc_lines
            description = []
        parser = argparse.ArgumentParser(
            prog=command,
            usage='\n'.join(usage),
            description='\n'.join(description)
        )
        for args, kwargs in argparse_args:
            parser.add_argument(*args, **kwargs)
        return parser 
开发者ID:dhylands,项目名称:rshell,代码行数:23,代码来源:main.py

示例4: do_help

# 需要导入模块: import readline [as 别名]
# 或者: from readline import __doc__ [as 别名]
def do_help(self, line):
        """help [COMMAND]

           List available commands with no arguments, or detailed help when
           a command is provided.
        """
        # We provide a help function so that we can trim the leading spaces
        # from the docstrings. The builtin help function doesn't do that.
        if not line:
            cmd.Cmd.do_help(self, line)
            self.print(EXIT_STR)
            return
        parser = self.create_argparser(line)
        if parser:
            parser.print_help()
            return
        try:
            doc = getattr(self, 'do_' + line).__doc__
            if doc:
                self.print("%s" % trim(doc))
                return
        except AttributeError:
            pass
        self.print(str(self.nohelp % (line,))) 
开发者ID:dhylands,项目名称:rshell,代码行数:26,代码来源:main.py

示例5: _input_code_with_completion

# 需要导入模块: import readline [as 别名]
# 或者: from readline import __doc__ [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

示例6: init_history

# 需要导入模块: import readline [as 别名]
# 或者: from readline import __doc__ [as 别名]
def init_history(self, histfile):
    
        #readline.parse_and_bind("bind ^I rl_complete")
        
        # Register our completer function
        readline.set_completer(SimpleCompleter(G.cmmands.keys()).complete)
        
        
        #readline.set_completer(TabCompleter().complete)
        ### Add autocompletion
        if 'libedit' in readline.__doc__:
            readline.parse_and_bind("bind -e")
            readline.parse_and_bind("bind '\t' rl_complete")
        else:
            readline.parse_and_bind("tab: complete")
        
        # Use the tab key for completion
        #readline.parse_and_bind('tab: complete')
        if hasattr(readline, "read_history_file"):
            try:
                readline.read_history_file(histfile)
            except:
                pass
            
            atexit.register(self.save_history, histfile) 
开发者ID:alibaba,项目名称:iOSSecAudit,代码行数:27,代码来源:smartconsole.py

示例7: __init__

# 需要导入模块: import readline [as 别名]
# 或者: from readline import __doc__ [as 别名]
def __init__(self):
        Cmd.__init__(self)
        self.do_help.__func__.__doc__ = "Show help menu" 
开发者ID:vulscanteam,项目名称:vulscan,代码行数:5,代码来源:consoles.py

示例8: print_topics

# 需要导入模块: import readline [as 别名]
# 或者: from readline import __doc__ [as 别名]
def print_topics(self, header, cmds, cmdlen, maxcol):
        """make help menu more readable"""
        if cmds:
            self.stdout.write(header)
            self.stdout.write("\n")
            if self.ruler:
                self.stdout.write(self.ruler * len(header))
                self.stdout.write("\n")

            for cmd in cmds:
                help_msg = getattr(self, "do_{}".format(cmd)).__doc__
                self.stdout.write("{:<16}".format(cmd))
                self.stdout.write(help_msg)
                self.stdout.write("\n")
            self.stdout.write("\n") 
开发者ID:vulscanteam,项目名称:vulscan,代码行数:17,代码来源:consoles.py

示例9: help_back

# 需要导入模块: import readline [as 别名]
# 或者: from readline import __doc__ [as 别名]
def help_back(self):
        print
        print('  Usage : back')
        print('  Desp  : {}'.format(getattr(self, 'do_back').__doc__))
        print('  Demo  : back')
        print 
开发者ID:vulscanteam,项目名称:vulscan,代码行数:8,代码来源:consoles.py

示例10: help_pocadd

# 需要导入模块: import readline [as 别名]
# 或者: from readline import __doc__ [as 别名]
def help_pocadd(self):
        print
        print('  Usage :  pocadd /path/to/pocfile or /path/to/poc_dir')
        print('  Desp  :  {}'.format(getattr(self, 'do_pocadd').__doc__))
        print('  Demo  :  pocadd modules')
        print 
开发者ID:vulscanteam,项目名称:vulscan,代码行数:8,代码来源:consoles.py

示例11: help_set

# 需要导入模块: import readline [as 别名]
# 或者: from readline import __doc__ [as 别名]
def help_set(self):
        print
        print('  Usage :  set <key> <value>')
        print('  Desp  :  {}'.format(getattr(self, 'do_set').__doc__))
        print('  Demo  :  set threads 1')
        print 
开发者ID:vulscanteam,项目名称:vulscan,代码行数:8,代码来源:consoles.py

示例12: __init__

# 需要导入模块: import readline [as 别名]
# 或者: from readline import __doc__ [as 别名]
def __init__(self):
        import readline
        if 'libedit' in readline.__doc__:
            readline.parse_and_bind('bind ^I rl_complete')
        else:
            readline.parse_and_bind('tab: complete')

        cmd.Cmd.__init__(self)
        Magic.__init__(self)
        if not os.path.exists(self.ws):
            os.makedirs(self.ws) 
开发者ID:chenpengcheng,项目名称:cli,代码行数:13,代码来源:cli.py

示例13: do_help

# 需要导入模块: import readline [as 别名]
# 或者: from readline import __doc__ [as 别名]
def do_help(self, arg):
        methods = inspect.getmembers(CodeShell, predicate=inspect.ismethod)
        for key, method in methods:
            if key.startswith('do_'):
                name = key.split('_')[1]
                doc = method.__doc__
                if (not arg or arg == name) and doc:
                    print name, '\t', doc
        print """
A tag can refer to a topic (e.g. array) or a company (e.g. amazon).
A keyword can be anything (including a tag).
Commands and options can be completed by <TAB>.""" 
开发者ID:chenpengcheng,项目名称:cli,代码行数:14,代码来源:cli.py

示例14: choice

# 需要导入模块: import readline [as 别名]
# 或者: from readline import __doc__ [as 别名]
def choice():
		global name
		global module
		try:
			if module == "":
				readline.set_completer(completer)
				readline.set_completer_delims('')
				if 'libedit' in readline.__doc__:
					readline.parse_and_bind("bind ^I rl_complete")
				else:
					readline.parse_and_bind("tab: complete")
				raw_choice = raw_input(" >>  [" + name + "]# ")
				choice = raw_choice
				exec_menu(choice)
			else:
				readline.set_completer(completer)
				readline.set_completer_delims('')
				if 'libedit' in readline.__doc__:
					readline.parse_and_bind("bind ^I rl_complete")
				else:
					readline.parse_and_bind("tab: complete")
				raw_choice = raw_input(" >>  [" + name + "][" + module + "]# ")
				choice = raw_choice
				exec_menu(choice)
		except EOFError:
			pass
		except KeyboardInterrupt:
			exec_menu('exit') 
开发者ID:Tylous,项目名称:SniffAir,代码行数:30,代码来源:SniffAir.py

示例15: init_readline

# 需要导入模块: import readline [as 别名]
# 或者: from readline import __doc__ [as 别名]
def init_readline(readline: Any) -> None:
    try:
        readline.read_init_file()
    except OSError:
        if not is_macos:
            raise
    if 'libedit' in readline.__doc__:
        readline.parse_and_bind("bind ^I rl_complete")
    else:
        readline.parse_and_bind('tab: complete') 
开发者ID:kovidgoyal,项目名称:kitty,代码行数:12,代码来源:shell.py


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