Read *-keysym-labels.txt from stdin.
This commit is contained in:
		@ -89,11 +89,11 @@ eek_HEADERS = \
 | 
				
			|||||||
eek-keysym.c: eek-special-keysym-labels.h eek-unicode-keysym-labels.h eek-keyname-keysym-labels.h
 | 
					eek-keysym.c: eek-special-keysym-labels.h eek-unicode-keysym-labels.h eek-keyname-keysym-labels.h
 | 
				
			||||||
 | 
					
 | 
				
			||||||
eek-special-keysym-labels.h: special-keysym-labels.txt
 | 
					eek-special-keysym-labels.h: special-keysym-labels.txt
 | 
				
			||||||
	./gen-keysym-labels.py $< special_keysym_labels > $@
 | 
						./gen-keysym-labels.py special_keysym_labels < $< > $@
 | 
				
			||||||
eek-unicode-keysym-labels.h: unicode-keysym-labels.txt
 | 
					eek-unicode-keysym-labels.h: unicode-keysym-labels.txt
 | 
				
			||||||
	./gen-keysym-labels.py $< unicode_keysym_labels > $@
 | 
						./gen-keysym-labels.py unicode_keysym_labels < $< > $@
 | 
				
			||||||
eek-keyname-keysym-labels.h: keyname-keysym-labels.txt
 | 
					eek-keyname-keysym-labels.h: keyname-keysym-labels.txt
 | 
				
			||||||
	./gen-keysym-labels.py $< keyname_keysym_labels > $@
 | 
						./gen-keysym-labels.py keyname_keysym_labels < $< > $@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DISTCLEANFILES = \
 | 
					DISTCLEANFILES = \
 | 
				
			||||||
	eek-special-keysym-labels.h \
 | 
						eek-special-keysym-labels.h \
 | 
				
			||||||
 | 
				
			|||||||
@ -1,27 +1,43 @@
 | 
				
			|||||||
#!/usr/bin/python
 | 
					#!/usr/bin/python
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from __future__ import with_statement
 | 
					# Copyright (C) 2010 Daiki Ueno <ueno@unixuser.org>
 | 
				
			||||||
 | 
					# Copyright (C) 2010 Red Hat, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# This library is free software; you can redistribute it and/or
 | 
				
			||||||
 | 
					# modify it under the terms of the GNU Lesser General Public License
 | 
				
			||||||
 | 
					# as published by the Free Software Foundation; either version 2 of
 | 
				
			||||||
 | 
					# the License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# This library is distributed in the hope that it will be useful, but
 | 
				
			||||||
 | 
					# WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
				
			||||||
 | 
					# Lesser General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# You should have received a copy of the GNU Lesser General Public
 | 
				
			||||||
 | 
					# License along with this library; if not, write to the Free Software
 | 
				
			||||||
 | 
					# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 | 
				
			||||||
 | 
					# 02110-1301 USA
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
import re
 | 
					import re
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if len(sys.argv) != 3:
 | 
					if len(sys.argv) != 2:
 | 
				
			||||||
    print >> sys.stderr, "Usage: %s table.txt table-name" % sys.argv[0]
 | 
					    print >> sys.stderr, "Usage: %s TABLE-NAME" % sys.argv[0]
 | 
				
			||||||
    sys.exit(-1)
 | 
					    sys.exit(-1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
table = dict()
 | 
					table = dict()
 | 
				
			||||||
with open(sys.argv[1], 'r') as fp:
 | 
					for line in sys.stdin:
 | 
				
			||||||
    for line in fp:
 | 
					    line = line.decode('UTF-8')
 | 
				
			||||||
        line = line.decode('UTF-8')
 | 
					    match = re.match(r'\s*(0x[0-9A-F]+)\s+(\S*)', line, re.I)
 | 
				
			||||||
        match = re.match(r'\s*(0x[0-9A-F]+)\s+(\S*)', line, re.I)
 | 
					    if match:
 | 
				
			||||||
        if match:
 | 
					        table[int(match.group(1), 16)] = match.group(2)
 | 
				
			||||||
            table[int(match.group(1), 16)] = match.group(2)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
sys.stdout.write("static const struct eek_keysym_label %s[] = {\n" %
 | 
					sys.stdout.write("static const struct eek_keysym_label %s[] = {\n" %
 | 
				
			||||||
                 sys.argv[2])
 | 
					                 sys.argv[1])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
for index, (keysym, label) in enumerate([(keysym, table[keysym])
 | 
					for index, (keysym, label) in enumerate([(keysym, table[keysym])
 | 
				
			||||||
                                         for keysym in sorted(table.keys())]):
 | 
					                                         for keysym in sorted(table.keys())]):
 | 
				
			||||||
    sys.stdout.write("  { 0x%X, %s }" % (keysym, label.encode('UTF-8')))
 | 
					    sys.stdout.write("    { 0x%X, %s }" % (keysym, label.encode('UTF-8')))
 | 
				
			||||||
    if index < len(table) - 1:
 | 
					    if index < len(table) - 1:
 | 
				
			||||||
        sys.stdout.write(",")
 | 
					        sys.stdout.write(",")
 | 
				
			||||||
    sys.stdout.write("\n")
 | 
					    sys.stdout.write("\n")
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user