5 from optparse
import OptionParser
7 parser
= OptionParser(version
="%prog 1.0")
8 parser
.add_option("-f", "--file", dest
="rgbtxtFile", default
='/etc/X11/rgb.txt',
9 help="rgb.txt file containing X11 colors (/etc/X11/rgb.txt)",
12 (options
, args
) = parser
.parse_args()
14 f
= open(options
.rgbtxtFile
)
18 colorLine
= re
.compile(r
'''\s*
21 (?P<green>\d+) # green
25 (?P<name>[^\s]+) # name
29 /* Automatically generated file. Do NOT edit. Regenerate it using make-rgb */
36 typedef struct RGBColor {
41 RGBColor rgbColors[] = {'''
44 m
= colorLine
.match(line
)
46 print ''' {{%(red)3s, %(green)3s, %(blue)3s, 0}, "%(name)s"},''' % m
.groupdict()
48 print ''' {{ 0, 0, 0, 0}, NULL}