當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。