Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../usr/lib64/python3..../curses
File: has_key.py
[0] Fix | Delete
#
[1] Fix | Delete
# Emulation of has_key() function for platforms that don't use ncurses
[2] Fix | Delete
#
[3] Fix | Delete
[4] Fix | Delete
import _curses
[5] Fix | Delete
[6] Fix | Delete
# Table mapping curses keys to the terminfo capability name
[7] Fix | Delete
[8] Fix | Delete
_capability_names = {
[9] Fix | Delete
_curses.KEY_A1: 'ka1',
[10] Fix | Delete
_curses.KEY_A3: 'ka3',
[11] Fix | Delete
_curses.KEY_B2: 'kb2',
[12] Fix | Delete
_curses.KEY_BACKSPACE: 'kbs',
[13] Fix | Delete
_curses.KEY_BEG: 'kbeg',
[14] Fix | Delete
_curses.KEY_BTAB: 'kcbt',
[15] Fix | Delete
_curses.KEY_C1: 'kc1',
[16] Fix | Delete
_curses.KEY_C3: 'kc3',
[17] Fix | Delete
_curses.KEY_CANCEL: 'kcan',
[18] Fix | Delete
_curses.KEY_CATAB: 'ktbc',
[19] Fix | Delete
_curses.KEY_CLEAR: 'kclr',
[20] Fix | Delete
_curses.KEY_CLOSE: 'kclo',
[21] Fix | Delete
_curses.KEY_COMMAND: 'kcmd',
[22] Fix | Delete
_curses.KEY_COPY: 'kcpy',
[23] Fix | Delete
_curses.KEY_CREATE: 'kcrt',
[24] Fix | Delete
_curses.KEY_CTAB: 'kctab',
[25] Fix | Delete
_curses.KEY_DC: 'kdch1',
[26] Fix | Delete
_curses.KEY_DL: 'kdl1',
[27] Fix | Delete
_curses.KEY_DOWN: 'kcud1',
[28] Fix | Delete
_curses.KEY_EIC: 'krmir',
[29] Fix | Delete
_curses.KEY_END: 'kend',
[30] Fix | Delete
_curses.KEY_ENTER: 'kent',
[31] Fix | Delete
_curses.KEY_EOL: 'kel',
[32] Fix | Delete
_curses.KEY_EOS: 'ked',
[33] Fix | Delete
_curses.KEY_EXIT: 'kext',
[34] Fix | Delete
_curses.KEY_F0: 'kf0',
[35] Fix | Delete
_curses.KEY_F1: 'kf1',
[36] Fix | Delete
_curses.KEY_F10: 'kf10',
[37] Fix | Delete
_curses.KEY_F11: 'kf11',
[38] Fix | Delete
_curses.KEY_F12: 'kf12',
[39] Fix | Delete
_curses.KEY_F13: 'kf13',
[40] Fix | Delete
_curses.KEY_F14: 'kf14',
[41] Fix | Delete
_curses.KEY_F15: 'kf15',
[42] Fix | Delete
_curses.KEY_F16: 'kf16',
[43] Fix | Delete
_curses.KEY_F17: 'kf17',
[44] Fix | Delete
_curses.KEY_F18: 'kf18',
[45] Fix | Delete
_curses.KEY_F19: 'kf19',
[46] Fix | Delete
_curses.KEY_F2: 'kf2',
[47] Fix | Delete
_curses.KEY_F20: 'kf20',
[48] Fix | Delete
_curses.KEY_F21: 'kf21',
[49] Fix | Delete
_curses.KEY_F22: 'kf22',
[50] Fix | Delete
_curses.KEY_F23: 'kf23',
[51] Fix | Delete
_curses.KEY_F24: 'kf24',
[52] Fix | Delete
_curses.KEY_F25: 'kf25',
[53] Fix | Delete
_curses.KEY_F26: 'kf26',
[54] Fix | Delete
_curses.KEY_F27: 'kf27',
[55] Fix | Delete
_curses.KEY_F28: 'kf28',
[56] Fix | Delete
_curses.KEY_F29: 'kf29',
[57] Fix | Delete
_curses.KEY_F3: 'kf3',
[58] Fix | Delete
_curses.KEY_F30: 'kf30',
[59] Fix | Delete
_curses.KEY_F31: 'kf31',
[60] Fix | Delete
_curses.KEY_F32: 'kf32',
[61] Fix | Delete
_curses.KEY_F33: 'kf33',
[62] Fix | Delete
_curses.KEY_F34: 'kf34',
[63] Fix | Delete
_curses.KEY_F35: 'kf35',
[64] Fix | Delete
_curses.KEY_F36: 'kf36',
[65] Fix | Delete
_curses.KEY_F37: 'kf37',
[66] Fix | Delete
_curses.KEY_F38: 'kf38',
[67] Fix | Delete
_curses.KEY_F39: 'kf39',
[68] Fix | Delete
_curses.KEY_F4: 'kf4',
[69] Fix | Delete
_curses.KEY_F40: 'kf40',
[70] Fix | Delete
_curses.KEY_F41: 'kf41',
[71] Fix | Delete
_curses.KEY_F42: 'kf42',
[72] Fix | Delete
_curses.KEY_F43: 'kf43',
[73] Fix | Delete
_curses.KEY_F44: 'kf44',
[74] Fix | Delete
_curses.KEY_F45: 'kf45',
[75] Fix | Delete
_curses.KEY_F46: 'kf46',
[76] Fix | Delete
_curses.KEY_F47: 'kf47',
[77] Fix | Delete
_curses.KEY_F48: 'kf48',
[78] Fix | Delete
_curses.KEY_F49: 'kf49',
[79] Fix | Delete
_curses.KEY_F5: 'kf5',
[80] Fix | Delete
_curses.KEY_F50: 'kf50',
[81] Fix | Delete
_curses.KEY_F51: 'kf51',
[82] Fix | Delete
_curses.KEY_F52: 'kf52',
[83] Fix | Delete
_curses.KEY_F53: 'kf53',
[84] Fix | Delete
_curses.KEY_F54: 'kf54',
[85] Fix | Delete
_curses.KEY_F55: 'kf55',
[86] Fix | Delete
_curses.KEY_F56: 'kf56',
[87] Fix | Delete
_curses.KEY_F57: 'kf57',
[88] Fix | Delete
_curses.KEY_F58: 'kf58',
[89] Fix | Delete
_curses.KEY_F59: 'kf59',
[90] Fix | Delete
_curses.KEY_F6: 'kf6',
[91] Fix | Delete
_curses.KEY_F60: 'kf60',
[92] Fix | Delete
_curses.KEY_F61: 'kf61',
[93] Fix | Delete
_curses.KEY_F62: 'kf62',
[94] Fix | Delete
_curses.KEY_F63: 'kf63',
[95] Fix | Delete
_curses.KEY_F7: 'kf7',
[96] Fix | Delete
_curses.KEY_F8: 'kf8',
[97] Fix | Delete
_curses.KEY_F9: 'kf9',
[98] Fix | Delete
_curses.KEY_FIND: 'kfnd',
[99] Fix | Delete
_curses.KEY_HELP: 'khlp',
[100] Fix | Delete
_curses.KEY_HOME: 'khome',
[101] Fix | Delete
_curses.KEY_IC: 'kich1',
[102] Fix | Delete
_curses.KEY_IL: 'kil1',
[103] Fix | Delete
_curses.KEY_LEFT: 'kcub1',
[104] Fix | Delete
_curses.KEY_LL: 'kll',
[105] Fix | Delete
_curses.KEY_MARK: 'kmrk',
[106] Fix | Delete
_curses.KEY_MESSAGE: 'kmsg',
[107] Fix | Delete
_curses.KEY_MOVE: 'kmov',
[108] Fix | Delete
_curses.KEY_NEXT: 'knxt',
[109] Fix | Delete
_curses.KEY_NPAGE: 'knp',
[110] Fix | Delete
_curses.KEY_OPEN: 'kopn',
[111] Fix | Delete
_curses.KEY_OPTIONS: 'kopt',
[112] Fix | Delete
_curses.KEY_PPAGE: 'kpp',
[113] Fix | Delete
_curses.KEY_PREVIOUS: 'kprv',
[114] Fix | Delete
_curses.KEY_PRINT: 'kprt',
[115] Fix | Delete
_curses.KEY_REDO: 'krdo',
[116] Fix | Delete
_curses.KEY_REFERENCE: 'kref',
[117] Fix | Delete
_curses.KEY_REFRESH: 'krfr',
[118] Fix | Delete
_curses.KEY_REPLACE: 'krpl',
[119] Fix | Delete
_curses.KEY_RESTART: 'krst',
[120] Fix | Delete
_curses.KEY_RESUME: 'kres',
[121] Fix | Delete
_curses.KEY_RIGHT: 'kcuf1',
[122] Fix | Delete
_curses.KEY_SAVE: 'ksav',
[123] Fix | Delete
_curses.KEY_SBEG: 'kBEG',
[124] Fix | Delete
_curses.KEY_SCANCEL: 'kCAN',
[125] Fix | Delete
_curses.KEY_SCOMMAND: 'kCMD',
[126] Fix | Delete
_curses.KEY_SCOPY: 'kCPY',
[127] Fix | Delete
_curses.KEY_SCREATE: 'kCRT',
[128] Fix | Delete
_curses.KEY_SDC: 'kDC',
[129] Fix | Delete
_curses.KEY_SDL: 'kDL',
[130] Fix | Delete
_curses.KEY_SELECT: 'kslt',
[131] Fix | Delete
_curses.KEY_SEND: 'kEND',
[132] Fix | Delete
_curses.KEY_SEOL: 'kEOL',
[133] Fix | Delete
_curses.KEY_SEXIT: 'kEXT',
[134] Fix | Delete
_curses.KEY_SF: 'kind',
[135] Fix | Delete
_curses.KEY_SFIND: 'kFND',
[136] Fix | Delete
_curses.KEY_SHELP: 'kHLP',
[137] Fix | Delete
_curses.KEY_SHOME: 'kHOM',
[138] Fix | Delete
_curses.KEY_SIC: 'kIC',
[139] Fix | Delete
_curses.KEY_SLEFT: 'kLFT',
[140] Fix | Delete
_curses.KEY_SMESSAGE: 'kMSG',
[141] Fix | Delete
_curses.KEY_SMOVE: 'kMOV',
[142] Fix | Delete
_curses.KEY_SNEXT: 'kNXT',
[143] Fix | Delete
_curses.KEY_SOPTIONS: 'kOPT',
[144] Fix | Delete
_curses.KEY_SPREVIOUS: 'kPRV',
[145] Fix | Delete
_curses.KEY_SPRINT: 'kPRT',
[146] Fix | Delete
_curses.KEY_SR: 'kri',
[147] Fix | Delete
_curses.KEY_SREDO: 'kRDO',
[148] Fix | Delete
_curses.KEY_SREPLACE: 'kRPL',
[149] Fix | Delete
_curses.KEY_SRIGHT: 'kRIT',
[150] Fix | Delete
_curses.KEY_SRSUME: 'kRES',
[151] Fix | Delete
_curses.KEY_SSAVE: 'kSAV',
[152] Fix | Delete
_curses.KEY_SSUSPEND: 'kSPD',
[153] Fix | Delete
_curses.KEY_STAB: 'khts',
[154] Fix | Delete
_curses.KEY_SUNDO: 'kUND',
[155] Fix | Delete
_curses.KEY_SUSPEND: 'kspd',
[156] Fix | Delete
_curses.KEY_UNDO: 'kund',
[157] Fix | Delete
_curses.KEY_UP: 'kcuu1'
[158] Fix | Delete
}
[159] Fix | Delete
[160] Fix | Delete
def has_key(ch):
[161] Fix | Delete
if isinstance(ch, str):
[162] Fix | Delete
ch = ord(ch)
[163] Fix | Delete
[164] Fix | Delete
# Figure out the correct capability name for the keycode.
[165] Fix | Delete
capability_name = _capability_names.get(ch)
[166] Fix | Delete
if capability_name is None:
[167] Fix | Delete
return False
[168] Fix | Delete
[169] Fix | Delete
#Check the current terminal description for that capability;
[170] Fix | Delete
#if present, return true, else return false.
[171] Fix | Delete
if _curses.tigetstr( capability_name ):
[172] Fix | Delete
return True
[173] Fix | Delete
else:
[174] Fix | Delete
return False
[175] Fix | Delete
[176] Fix | Delete
if __name__ == '__main__':
[177] Fix | Delete
# Compare the output of this implementation and the ncurses has_key,
[178] Fix | Delete
# on platforms where has_key is already available
[179] Fix | Delete
try:
[180] Fix | Delete
L = []
[181] Fix | Delete
_curses.initscr()
[182] Fix | Delete
for key in _capability_names.keys():
[183] Fix | Delete
system = _curses.has_key(key)
[184] Fix | Delete
python = has_key(key)
[185] Fix | Delete
if system != python:
[186] Fix | Delete
L.append( 'Mismatch for key %s, system=%i, Python=%i'
[187] Fix | Delete
% (_curses.keyname( key ), system, python) )
[188] Fix | Delete
finally:
[189] Fix | Delete
_curses.endwin()
[190] Fix | Delete
for i in L: print(i)
[191] Fix | Delete
[192] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function