當前位置: 首頁>>代碼示例>>Python>>正文


Python pyreadline.parse_and_bind方法代碼示例

本文整理匯總了Python中pyreadline.parse_and_bind方法的典型用法代碼示例。如果您正苦於以下問題:Python pyreadline.parse_and_bind方法的具體用法?Python pyreadline.parse_and_bind怎麽用?Python pyreadline.parse_and_bind使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pyreadline的用法示例。


在下文中一共展示了pyreadline.parse_and_bind方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: init_history

# 需要導入模塊: import pyreadline [as 別名]
# 或者: from pyreadline import parse_and_bind [as 別名]
def init_history(self, histfile):
        readline.parse_and_bind("tab: complete")
        if hasattr(readline, "read_history_file"):
            try:
                readline.read_history_file(histfile)
            except IOError:
                pass
            atexit.register(self.save_history, histfile) 
開發者ID:cj1324,項目名稱:CGIShell,代碼行數:10,代碼來源:cgishell.py

示例2: __init__

# 需要導入模塊: import pyreadline [as 別名]
# 或者: from pyreadline import parse_and_bind [as 別名]
def __init__(self):
        self.sentCache = {}
        self.commands = {}
        self.acceptingInput = False
        self.lastPrompt = True
        self.blockingQueue = Queue.Queue()

        self._queuedCmds = []

        readline.set_completer(self.complete)
        readline.parse_and_bind('tab: complete')

        members = inspect.getmembers(self, predicate = inspect.ismethod)
        for m in members:
            if hasattr(m[1], "clidesc"):
                fname = m[0]
                fn = m[1]
                try:
                    cmd, subcommand = fname.split('_')
                except ValueError:
                    cmd = fname
                    subcommand = "_"


                if not cmd in self.commands:
                    self.commands[cmd] = {}

                self.commands[cmd][subcommand] = {
                   "args": inspect.getargspec(fn)[0][1:],
                   "optional": len(inspect.getargspec(fn)[3]) if inspect.getargspec(fn)[3] else 0,
                   "desc": fn.clidesc,
                   "fn": fn,
                   "order": fn.cliorder
                }
        #self.cv = threading.Condition()
        self.inputThread = threading.Thread(target = self.startInputThread)
        self.inputThread.daemon = True 
開發者ID:svub,項目名稱:whatsapp-rest-webservice,代碼行數:39,代碼來源:cli.py


注:本文中的pyreadline.parse_and_bind方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。