コード例 #1
0
ファイル: basemode.py プロジェクト: turky/pyreadline
 def _bind_key(self, key, func):
     """setup the mapping from key to call the function."""
     if not callable(func):
         print("Trying to bind non method to keystroke:%s,%s"%(key,func))
         raise ReadlineError("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
コード例 #2
0
ファイル: basemode.py プロジェクト: 0x0mar/OWASP-ZSC
 def _bind_key(self, key, func):
     """setup the mapping from key to call the function."""
     if not callable(func):
         print("Trying to bind non method to keystroke:%s,%s"%(key,func))
         raise ReadlineError("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
コード例 #3
0
ファイル: rlmain.py プロジェクト: farisachugthai/pyreadline
    def bind_key(self, key, name):
        import types

        if callable(name):
            self.mode._bind_key(key, types.MethodType(name, self.mode))
        else:
            self.mode._bind_key(key, getattr(self.mode, name))
            log("Trying to bind unknown command '%s' to key '%s'" % (name, key))