本文整理汇总了Python中pyreadline.logger.log函数的典型用法代码示例。如果您正苦于以下问题:Python log函数的具体用法?Python log怎么用?Python log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_current_history_length
def get_current_history_length(self):
'''Return the number of lines currently in the history.
(This is different from get_history_length(), which returns
the maximum number of lines that will be written to a history file.)'''
value = len(self.history)
log("get_current_history_length:%d"%value)
return value
开发者ID:willbr,项目名称:pyreadline,代码行数:7,代码来源:history.py
示例2: _readline_from_keyboard
def _readline_from_keyboard(self):
c = self.console
while 1:
self._update_line()
event = c.getkeypress()
if self.next_meta:
self.next_meta = False
control, meta, shift, code = event.keyinfo
event.keyinfo = (control, True, shift, code)
# Process exit keys. Only exit on empty line
if event.keyinfo in self.exit_dispatch:
if lineobj.EndOfLine(self.l_buffer) == 0:
raise EOFError
dispatch_func = self.key_dispatch.get(event.keyinfo, self.self_insert)
log("readline from keyboard:%s" % (event.keyinfo,))
r = None
if dispatch_func:
r = dispatch_func(event)
self.l_buffer.push_undo()
self.previous_func = dispatch_func
if r:
self._update_line()
break
开发者ID:HBPSP8Repo,项目名称:exareme,代码行数:26,代码来源:notemacs.py
示例3: forward_search_history
def forward_search_history(self, e): # (C-s)
u"""Search forward starting at the current line and moving down
through the the history as necessary. This is an incremental
search."""
log("fwd_search_history")
self._init_incremental_search(self._history.forward_search_history, e)
self.finalize()
开发者ID:chensunn,项目名称:PortableJekyll,代码行数:7,代码来源:emacs.py
示例4: _init_incremental_search
def _init_incremental_search(self, searchfun, init_event):
u"""Initialize search prompt
"""
log("init_incremental_search")
self.subsearch_query = u""
self.subsearch_fun = searchfun
self.subsearch_old_line = self.l_buffer.get_line_text()
queue = self.process_keyevent_queue
queue.append(self._process_incremental_search_keyevent)
self.subsearch_oldprompt = self.prompt
if self.previous_func != self.reverse_search_history and self.previous_func != self.forward_search_history:
self.subsearch_query = self.l_buffer[0:Point].get_line_text()
if self.subsearch_fun == self.reverse_search_history:
self.subsearch_prompt = u"reverse-i-search%d`%s': "
else:
self.subsearch_prompt = u"forward-i-search%d`%s': "
self.prompt = self.subsearch_prompt % (self._history.history_cursor, "")
if self.subsearch_query:
self.line = self._process_incremental_search_keyevent(init_event)
else:
self.line = u""
开发者ID:chensunn,项目名称:PortableJekyll,代码行数:27,代码来源:emacs.py
示例5: reverse_search_history
def reverse_search_history(self, searchfor, startpos=None):
if startpos is None:
startpos = self.history_cursor
origpos = startpos
result = lineobj.ReadLineTextBuffer("")
for idx, line in list(enumerate(self.history))[startpos:0:-1]:
if searchfor in line:
startpos = idx
break
#If we get a new search without change in search term it means
#someone pushed ctrl-r and we should find the next match
if self.last_search_for == searchfor and startpos > 0:
startpos -= 1
for idx, line in list(enumerate(self.history))[startpos:0:-1]:
if searchfor in line:
startpos = idx
break
if self.history:
result = self.history[startpos].get_line_text()
else:
result = ""
self.history_cursor = startpos
self.last_search_for = searchfor
log("reverse_search_history: old:%d new:%d result:%r"%(origpos, self.history_cursor, result))
return result
开发者ID:willbr,项目名称:pyreadline,代码行数:29,代码来源:history.py
示例6: reverse_search_history
def reverse_search_history(self, e): # (C-r)
'''Search backward starting at the current line and moving up
through the history as necessary. This is an incremental search.'''
log("rev_search_history")
self._init_incremental_search(self._history.reverse_search_history, e)
self.l_buffer.selection_mark = -1
self.finalize()
开发者ID:mishagr,项目名称:pyreadline,代码行数:7,代码来源:emacs.py
示例7: cursor
def cursor(self, visible=None, size=None):
log("cursor(visible='%s')" % visible)
if visible is not None:
if visible:
self._write("\033[?25h")
else:
self._write("\033[?25l")
开发者ID:afeset,项目名称:miner2-tools,代码行数:7,代码来源:ansi_console.py
示例8: _process_non_incremental_search_keyevent
def _process_non_incremental_search_keyevent(self, keyinfo):
keytuple = keyinfo.tuple()
log(u"SearchPromptMode %s %s" % (keyinfo, keytuple))
history = self._history
if keyinfo.keyname == u"backspace":
self.non_inc_query = self.non_inc_query[:-1]
elif keyinfo.keyname in [u"return", u"escape"]:
if self.non_inc_query:
if self.non_inc_direction == -1:
res = history.reverse_search_history(self.non_inc_query)
else:
res = history.forward_search_history(self.non_inc_query)
self._bell()
self.prompt = self.non_inc_oldprompt
self.process_keyevent_queue = self.process_keyevent_queue[:-1]
self._history.history_cursor = len(self._history.history)
if keyinfo.keyname == u"escape":
self.l_buffer = self.non_inc_oldline
else:
self.l_buffer.set_line(res)
return False
elif keyinfo.keyname:
pass
elif keyinfo.control == False and keyinfo.meta == False:
self.non_inc_query += keyinfo.char
else:
pass
self.prompt = self.non_inc_oldprompt + u":" + self.non_inc_query
开发者ID:chensunn,项目名称:PortableJekyll,代码行数:30,代码来源:emacs.py
示例9: install_readline
def install_readline(hook):
log("Installing ansi_console")
global _old_raw_input
if _old_raw_input is not None:
return # don't run _setup twice
try:
f_in = sys.stdin.fileno()
f_out = sys.stdout.fileno()
except (AttributeError, ValueError):
return
if not os.isatty(f_in) or not os.isatty(f_out):
return
if '__pypy__' in sys.builtin_module_names: # PyPy
def _old_raw_input(prompt=''):
# sys.__raw_input__() is only called when stdin and stdout are
# as expected and are ttys. If it is the case, then get_reader()
# should not really fail in _wrapper.raw_input(). If it still
# does, then we will just cancel the redirection and call again
# the built-in raw_input().
try:
del sys.__raw_input__
except AttributeError:
pass
return raw_input(prompt)
sys.__raw_input__ = hook
else:
# this is not really what readline.c does. Better than nothing I guess
import __builtin__
_old_raw_input = __builtin__.raw_input
__builtin__.raw_input = hook
开发者ID:afeset,项目名称:miner2-tools,代码行数:34,代码来源:ansi_console.py
示例10: clear_range
def clear_range(self, pos_range):
u'''Clears range that may span to multiple lines
pos_range is (x1,y1, x2,y2) including
y2 >= y1
x2 == -1 means end of line
'''
log("clearRange(%s)" % str(pos_range))
(x1,y1, x2,y2) = pos_range
if y2 < y1:
return
elif y2 == y1 and x2>=0:
self.pos(x1,y1)
self._write(' '*(x2-x1+1))
else:
start = y1
end = y2+1
if x1 > 0:
self.pos(x1,y1)
self._write("\033[0K")
start = y1+1
if 0 <= x2 < w-1:
self.pos(x2,y2)
self._write("\033[1K")
end = y2
for line in range(start, end):
self.pos(0,line)
self._write("\033[2K")
self.position = None
self.pos(x1,y1)
开发者ID:afeset,项目名称:miner2-tools,代码行数:29,代码来源:ansi_console.py
示例11: size
def size(self):
log("size()")
if self.windowSize:
log("# returned cached value %s" % str(self.windowSize))
return self.windowSize
self._querySize()
return self.windowSize
开发者ID:minersoft,项目名称:miner,代码行数:7,代码来源:ansi_console.py
示例12: test_complete
def test_complete (self):
import rlcompleter
logger.sock_silent = False
log("-" * 50)
r = EmacsModeTest()
completerobj = rlcompleter.Completer()
def _nop(val, word):
return word
completerobj._callable_postfix = _nop
r.completer = completerobj.complete
r._bind_key("tab", r.complete)
r.input(u'"exi(ksdjksjd)"')
r.input(u'Control-a')
r.input(u'Right')
r.input(u'Right')
r.input(u'Right')
r.input(u'Tab')
self.assert_line(r, u"exit(ksdjksjd)", 4)
r.input(u'Escape')
r.input(u'"exi"')
r.input(u'Control-a')
r.input(u'Right')
r.input(u'Right')
r.input(u'Right')
r.input(u'Tab')
self.assert_line(r, u"exit", 4)
开发者ID:Eih3,项目名称:v0.83,代码行数:28,代码来源:test_emacs.py
示例13: _setPos
def _setPos(self, x, y):
if self.positionIsSynchronized and self.position == (x, y):
return
self._write("\033[%d;%dH"%(y+1,x+1))
self.position = (x,y)
self.positionIsSynchronized = True
log("_setPos%s" % str(self.position))
开发者ID:minersoft,项目名称:miner,代码行数:7,代码来源:ansi_console.py
示例14: _process_incremental_search_keyevent
def _process_incremental_search_keyevent(self, keyinfo):
keytuple = keyinfo.tuple()
log(u"IncrementalSearchPromptMode %s %s"%(keyinfo, keytuple))
if keyinfo.keyname == u'backspace':
self.subsearch_query = self.subsearch_query[:-1]
if len(self.subsearch_query) > 0:
self.line=self.subsearch_fun(self.subsearch_query)
else:
self._bell()
self.line = "" #empty query means no search result
elif keyinfo.keyname in [u'return', u'escape']:
self._bell()
self.prompt = self.subsearch_oldprompt
self.process_keyevent_queue = self.process_keyevent_queue[:-1]
self._history.history_cursor = len(self._history.history)
if keyinfo.keyname == u'escape':
self.l_buffer.set_line(self.subsearch_old_line)
return False
elif keyinfo.keyname:
pass
elif keytuple == self.subsearch_init_event:
self._history.history_cursor += self.subsearch_direction
self.line = self.subsearch_fun(self.subsearch_query)
elif keyinfo.control == False and keyinfo.meta == False :
self.subsearch_query += keyinfo.char
self.line=self.subsearch_fun(self.subsearch_query)
else:
pass
self.prompt = self.subsearch_prompt%self.subsearch_query
self.l_buffer.set_line(self.line)
开发者ID:fboender,项目名称:mcplayeredit,代码行数:30,代码来源:emacs.py
示例15: paste
def paste(self,e):
'''Paste windows clipboard.
Assume single line strip other lines and end of line markers and trailing spaces''' #(Control-v)
if self.enable_win32_clipboard:
txt=clipboard.get_clipboard_text_and_convert(False)
txt=txt.split("\n")[0].strip("\r").strip("\n")
log("paste: >%s<"%map(ord,txt))
self.insert_text(txt)
开发者ID:Aha00a,项目名称:play1,代码行数:8,代码来源:basemode.py
示例16: _bind_key
def _bind_key(self, key, func):
'''setup the mapping from key to call the function.'''
if type(func) != type(self._bind_key):
print "Trying to bind non method to keystroke:%s,%s"%(key,func)
raise PyreadlineError("Trying to bind non method to keystroke:%s,%s,%s,%s"%(key,func,type(func),type(self._bind_key)))
keyinfo = make_KeyPress_from_keydescr(key.lower()).tuple()
log(">>>%s -> %s<<<"%(keyinfo,func.__name__))
self.key_dispatch[keyinfo] = func
开发者ID:Aha00a,项目名称:play1,代码行数:8,代码来源:basemode.py
示例17: forward_search_history
def forward_search_history(self, e): # (C-s)
'''Search forward starting at the current line and moving down
through the the history as necessary. This is an incremental
search.'''
log("fwd_search_history")
self._init_incremental_search(self._history.forward_search_history, e)
self.l_buffer.selection_mark = -1
self.finalize()
开发者ID:mishagr,项目名称:pyreadline,代码行数:8,代码来源:emacs.py
示例18: write_plain
def write_plain(self, text, attr=None):
u'''write text at current cursor position.'''
log(u'write("%s", %s)' %(text, attr))
if attr is None:
attr = self.attr
n = c_int(0)
self.SetConsoleTextAttribute(self.hout, attr)
self.WriteConsoleA(self.hout, text, len(text), byref(n), None)
return len(text)
开发者ID:BuildSeash,项目名称:seash,代码行数:9,代码来源:ironpython_console.py
示例19: write_plain
def write_plain(self, text, attr=None):
'''write text at current cursor position.'''
log('write("%s", %s)' %(text,attr))
if attr is None:
attr = self.attr
n = c_int(0)
self.SetConsoleTextAttribute(self.hout, attr)
self.WriteConsoleW(self.hout, ensure_unicode(chunk), len(chunk), byref(junk), None)
return len(text)
开发者ID:Aha00a,项目名称:play1,代码行数:9,代码来源:console.py
示例20: _querySize
def _querySize(self):
try:
w = self._readIntFromCmd("tput cols")
h = self._readIntFromCmd("tput lines")
self.windowSize = (w,h)
log("size() # = " + str(self.windowSize))
except:
print "Get terminal size failed, exitting"
sys.exit(1)
开发者ID:minersoft,项目名称:miner,代码行数:9,代码来源:ansi_console.py
注:本文中的pyreadline.logger.log函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论