File: rgb2py.py

package info (click to toggle)
fofix-dfsg 3.121-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 27,016 kB
  • ctags: 4,131
  • sloc: python: 44,002; makefile: 99; perl: 42; sh: 39
file content (13 lines) | stat: -rwxr-xr-x 347 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
import re

f = open("/etc/X11/rgb.txt")

print "colors = {"
for l in f.readlines():
  if l.startswith("!"): continue
  c = re.split("[ \t]+", l.strip())
  rgb, names = map(int, c[:3]), c[3:]
  rgb = [float(c) / 255.0 for c in rgb]
  for n in names:
    print '  %-24s: (%.2f, %.2f, %.2f),' % ('"%s"' % n.lower(), rgb[0], rgb[1], rgb[2])
print "}"