File: genkeysyms.py

package info (click to toggle)
genius 1.0.24-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 27,952 kB
  • sloc: ansic: 105,597; xml: 67,672; sh: 4,537; makefile: 2,089; lex: 499; yacc: 298; perl: 54; python: 22
file content (27 lines) | stat: -rwxr-xr-x 726 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/python

import os, string, sys

def scanheader(filename):
	definitions = {}
	file = open(filename, "r")
	if file:
		for line in file.readlines():
			if line[:12] == '#define GDK_':
				fields = string.split(line)
				fields[2] = string.lower(fields[2])
				if definitions.has_key(fields[2]):
					definitions[fields[2]] = definitions[fields[2]] + ", " + fields[1]
				else:
					definitions[fields[2]] = fields[1]
		file.close()
	for key in definitions.keys():
		print '\tcase %s: return \"%s\";' % (key, definitions[key])

print '\t/* this file is auto-generated -- do not edit */'

if len(sys.argv) > 1:
	for header in sys.argv[1:]:
		scanheader(header)
else:
	scanheader("/usr/include/gtk-2.0/gdk/gdkkeysyms.h")