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


Python gnureadline.read_history_file方法代碼示例

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


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

示例1: setup

# 需要導入模塊: import gnureadline [as 別名]
# 或者: from gnureadline import read_history_file [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:reverse-shell,項目名稱:routersploit,代碼行數:22,代碼來源:interpreter.py

示例2: pre_input

# 需要導入模塊: import gnureadline [as 別名]
# 或者: from gnureadline import read_history_file [as 別名]
def pre_input(self, completefn):
        if self.raw_input:
            if HAVE_READLINE:
                import atexit
                self.old_completer = readline.get_completer()
                # Fix Bug #3129: Limit the history size to consume less memory
                readline.set_history_length(self.historysize)
                readline.set_completer(completefn)
                readline.parse_and_bind(self.completekey+": complete")
                try:
                    readline.read_history_file()
                except IOError:
                    pass
                atexit.register(readline.write_history_file)
                self.havecolor = True
                if mswindows and self.enablecolor:
                    self.cwrite = readline.GetOutputFile().write_color
                else:
                    self.cwrite = self.stdout.write 
開發者ID:w3h,項目名稱:isf,代碼行數:21,代碼來源:iohandler.py

示例3: input_loop

# 需要導入模塊: import gnureadline [as 別名]
# 或者: from gnureadline import read_history_file [as 別名]
def input_loop():
    if os.path.exists(HISTORY_FILENAME):
        readline.read_history_file(HISTORY_FILENAME)
    print('Max history file length:',
          readline.get_history_length())
    print('Startup history:', get_history_items())
    try:
        while True:
            line = input('Prompt ("stop" to quit): ')
            if line == 'stop':
                break
            if line:
                print('Adding {!r} to the history'.format(line))
    finally:
        print('Final history:', get_history_items())
        readline.write_history_file(HISTORY_FILENAME)

# Register our completer function 
開發者ID:reingart,項目名稱:pymotw3,代碼行數:20,代碼來源:readline_history.py

示例4: preloop

# 需要導入模塊: import gnureadline [as 別名]
# 或者: from gnureadline import read_history_file [as 別名]
def preloop(self):
        delims = set(readline.get_completer_delims())
        for d in "%*-/":
            try:
                delims.remove(d)
            except KeyError:
                pass
        readline.set_completer_delims(''.join(delims))

        try:
            readline.read_history_file(self.HISTORY_FILE)
        except (OSError, IOError) as e:
            warn("Can't read history file") 
開發者ID:viert,項目名稱:xcute,代碼行數:15,代碼來源:cli.py

示例5: load_cmd_history

# 需要導入模塊: import gnureadline [as 別名]
# 或者: from gnureadline import read_history_file [as 別名]
def load_cmd_history():
  cli_history = os.path.expanduser(settings.CLI_HISTORY)
  if os.path.exists(cli_history):
    readline.read_history_file(cli_history) 
開發者ID:Introspelliam,項目名稱:tools,代碼行數:6,代碼來源:logs.py


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