numeric keypad script
- From: Havoc Pennington <hp redhat com>
- To: gnome-libs-devel gnome org
- Subject: numeric keypad script
- Date: 06 May 2001 17:41:53 -0400
Hi,
Here's a script to find suspicious-looking places where numeric keypad
support may be lacking. It misses cases where people use an ascii char
such as '*' instead of GDK_asterisk, etc. though, and will raise some
false alarms.
Someone might want to fix libgnomeui with this.
Havoc
#! /usr/bin/python
import string
import re
import sys
syms = [
('GDK_space', 'GDK_KP_Space'),
('GDK_Tab', 'GDK_KP_Tab'),
('GDK_Tab', 'GDK_ISO_Left_Tab'),
('GDK_Return', 'GDK_KP_Enter'),
('GDK_F1', 'GDK_KP_F1'),
('GDK_F2', 'GDK_KP_F2'),
('GDK_F3', 'GDK_KP_F3'),
('GDK_F4', 'GDK_KP_F4'),
('GDK_Home', 'GDK_KP_Home'),
('GDK_Left', 'GDK_KP_Left'),
('GDK_Up', 'GDK_KP_Up'),
('GDK_Right', 'GDK_KP_Right'),
('GDK_Down', 'GDK_KP_Down'),
('GDK_Prior', 'GDK_KP_Prior'),
('GDK_Page_Up', 'GDK_KP_Page_Up'),
('GDK_Next', 'GDK_KP_Next'),
('GDK_Page_Down', 'GDK_KP_Page_Down'),
('GDK_End', 'GDK_KP_End'),
('GDK_Begin', 'GDK_KP_Begin'),
('GDK_Insert', 'GDK_KP_Insert'),
('GDK_Delete', 'GDK_KP_Delete'),
('GDK_equal', 'GDK_KP_Equal'),
('GDK_asterisk', 'GDK_KP_Multiply'),
('GDK_plus', 'GDK_KP_Add'),
('GDK_minus', 'GDK_KP_Subtract'),
('GDK_period', 'GDK_KP_Decimal'),
('GDK_slash', 'GDK_KP_Divide'),
('GDK_0', 'GDK_KP_0'),
('GDK_1', 'GDK_KP_1'),
('GDK_2', 'GDK_KP_2'),
('GDK_3', 'GDK_KP_3'),
('GDK_4', 'GDK_KP_4'),
('GDK_5', 'GDK_KP_5'),
('GDK_6', 'GDK_KP_6'),
('GDK_7', 'GDK_KP_7'),
('GDK_8', 'GDK_KP_8'),
('GDK_9', 'GDK_KP_9')
]
regs = []
not_indentifier_char = '[^a-zA-Z_0-9]'
for s in syms:
regs.append ( (re.compile (s[0] + not_indentifier_char),
re.compile (s[1] + not_indentifier_char)) )
for file in sys.argv[1:]:
plain_counts = []
kp_counts = []
for s in syms:
plain_counts.append (0)
kp_counts.append (0)
lines = open (file).readlines ()
for line in lines:
i = 0
while i < len (syms):
plain = regs[i][0]
kp = regs[i][1]
match = plain.search (line)
if (match):
plain_counts[i] = plain_counts[i] + 1
match = kp.search (line)
if (match):
kp_counts[i] = kp_counts[i] + 1
i = i + 1
i = 0
while i < len (syms):
p = plain_counts[i]
kp = kp_counts[i]
if (p != kp):
print "File %s has %d %s and %d %s" % (file, p,
syms[i][0], kp, syms[i][1])
i = i + 1
print "Done."
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]