def has_key(ch): if type(ch) == type(''): ch = ord(ch) # Figure out the correct capability name for the keycode. capability_name = _capability_names[ch] #Check the current terminal description for that capability; #if present, return true, else return false. if _curses.tigetstr(capability_name): return 1 else: return 0 if __name__ == '__main__': # Compare the output of this implementation and the ncurses has_key, # on platforms where has_key is already available try: L = [] _curses.initscr() for key in _capability_names.keys(): system = _curses.has_key(key) python = has_key(key) if system != python: L.append('Mismatch for key %s, system=%i, Python=%i' % (_curses.keyname(key), system, python)) finally: _curses.endwin() for i in L: print i
if isinstance(ch, str): ch = ord(ch) # Figure out the correct capability name for the keycode. capability_name = _capability_names.get(ch) if capability_name is None: return False #Check the current terminal description for that capability; #if present, return true, else return false. if _curses.tigetstr( capability_name ): return True else: return False if __name__ == '__main__': # Compare the output of this implementation and the ncurses has_key, # on platforms where has_key is already available try: L = [] _curses.initscr() for key in _capability_names.keys(): system = key in _curses python = has_key(key) if system != python: L.append( 'Mismatch for key %s, system=%i, Python=%i' % (_curses.keyname( key ), system, python) ) finally: _curses.endwin() for i in L: print i
def has_key(ch): if isinstance(ch, str): ch = ord(ch) capability_name = _capability_names.get(ch) if capability_name is None: return False elif _curses.tigetstr(capability_name): return True else: return False return if __name__ == '__main__': try: L = [] _curses.initscr() for key in _capability_names.keys(): system = key in _curses python = has_key(key) if system != python: L.append('Mismatch for key %s, system=%i, Python=%i' % (_curses.keyname(key), system, python)) finally: _curses.endwin() for i in L: print i # okay decompyling c:\Users\PC\wotsources\files\originals\res_bw\scripts\common\lib\curses\has_key.pyc # decompiled 1 files: 1 okay, 0 failed, 0 verify failed # 2015.11.18 12:02:51 Støední Evropa (bìžný èas)
_curses.KEY_SUSPEND: 'kspd', _curses.KEY_UNDO: 'kund', _curses.KEY_UP: 'kcuu1'} def has_key(ch): if isinstance(ch, str): ch = ord(ch) capability_name = _capability_names.get(ch) if capability_name is None: return False elif _curses.tigetstr(capability_name): return True else: return False return if __name__ == '__main__': try: L = [] _curses.initscr() for key in _capability_names.keys(): system = key in _curses python = has_key(key) if system != python: L.append('Mismatch for key %s, system=%i, Python=%i' % (_curses.keyname(key), system, python)) finally: _curses.endwin() for i in L: print i