Commit 680ca08c authored by Barry Warsaw's avatar Barry Warsaw

Some fixes based on feedback from Hans Petter Langtangen.

build(): Fix the logic here for calculating fallbacks if the dbfile
isn't parseable.

main(): Fix the semantics for -d/--database; this should override any
database value found in the .pynche file.

Update some comments, and author contact info.

Bump to v1.4

Whitespace normalization.
parent 83dc2327
"""Pynche -- The PYthon Natural Color and Hue Editor. """Pynche -- The PYthon Natural Color and Hue Editor.
Contact: Barry Warsaw Contact: %(AUTHNAME)s
Email: bwarsaw@python.org Email: %(AUTHEMAIL)s
Version: %(__version__)s Version: %(__version__)s
Pynche is based largely on a similar color editor I wrote years ago for the Pynche is based largely on a similar color editor I wrote years ago for the
Sunview window system. That editor was called ICE: the Interactive Color SunView window system. That editor was called ICE: the Interactive Color
Editor. I'd always wanted to port the editor to X but didn't feel like Editor. I'd always wanted to port the editor to X but didn't feel like
hacking X and C code to do it. Fast forward many years, to where Python + hacking X and C code to do it. Fast forward many years, to where Python +
Tkinter provides such a nice programming environment, with enough power, that Tkinter provides such a nice programming environment, with enough power, that
I finally buckled down and implemented it. I changed the name because these I finally buckled down and implemented it. I changed the name because these
days, too many other systems have the acronym `ICE'. days, too many other systems have the acronym `ICE'.
This program currently requires Python 1.5 with Tkinter. It has only been This program currently requires Python 2.2 with Tkinter.
tested on Solaris 2.6. Feedback is greatly appreciated. Send email to
bwarsaw@python.org
Usage: %(PROGRAM)s [-d file] [-i file] [-X] [-v] [-h] [initialcolor] Usage: %(PROGRAM)s [-d file] [-i file] [-X] [-v] [-h] [initialcolor]
...@@ -38,7 +36,7 @@ Where: ...@@ -38,7 +36,7 @@ Where:
--version --version
-v -v
print the version number print the version number and exit
--help --help
-h -h
...@@ -48,7 +46,7 @@ Where: ...@@ -48,7 +46,7 @@ Where:
initial color, as a color name or #RRGGBB format initial color, as a color name or #RRGGBB format
""" """
__version__ = '1.3' __version__ = '1.4'
import sys import sys
import os import os
...@@ -64,6 +62,8 @@ from TypeinViewer import TypeinViewer ...@@ -64,6 +62,8 @@ from TypeinViewer import TypeinViewer
PROGRAM = sys.argv[0] PROGRAM = sys.argv[0]
AUTHNAME = 'Barry Warsaw'
AUTHEMAIL = 'barry@python.org'
# Default locations of rgb.txt or other textual color database # Default locations of rgb.txt or other textual color database
RGB_TXT = [ RGB_TXT = [
...@@ -120,25 +120,26 @@ def initial_color(s, colordb): ...@@ -120,25 +120,26 @@ def initial_color(s, colordb):
def build(master=None, initialcolor=None, initfile=None, ignore=None): def build(master=None, initialcolor=None, initfile=None, ignore=None,
dbfile=None):
# create all output widgets # create all output widgets
s = Switchboard(not ignore and initfile) s = Switchboard(not ignore and initfile)
# defer to the command line chosen color database, falling back to the one
# load the color database # in the .pynche file.
if dbfile is None:
dbfile = s.optiondb()['DBFILE']
# find a parseable color database
colordb = None colordb = None
files = RGB_TXT[:]
while colordb is None:
try: try:
dbfile = s.optiondb()['DBFILE']
colordb = ColorDB.get_colordb(dbfile) colordb = ColorDB.get_colordb(dbfile)
except (KeyError, IOError): except (KeyError, IOError):
# scoot through the files listed above to try to find a usable color
# database file
for f in RGB_TXT:
try:
colordb = ColorDB.get_colordb(f)
if colordb:
break
except IOError:
pass pass
if colordb is None:
if not files:
break
dbfile = files.pop(0)
if not colordb: if not colordb:
usage(1, 'No color database file found, see the -d option.') usage(1, 'No color database file found, see the -d option.')
s.set_colordb(colordb) s.set_colordb(colordb)
...@@ -193,28 +194,30 @@ def main(): ...@@ -193,28 +194,30 @@ def main():
else: else:
usage(1) usage(1)
ignore = 0 ignore = False
dbfile = None
initfile = os.path.expanduser('~/.pynche') initfile = os.path.expanduser('~/.pynche')
for opt, arg in opts: for opt, arg in opts:
if opt in ('-h', '--help'): if opt in ('-h', '--help'):
usage(0) usage(0)
elif opt in ('-v', '--version'): elif opt in ('-v', '--version'):
print '''\ print """\
Pynche -- The PYthon Natural Color and Hue Editor. Pynche -- The PYthon Natural Color and Hue Editor.
Contact: Barry Warsaw Contact: %(AUTHNAME)s
Email: bwarsaw@python.org Email: %(AUTHEMAIL)s
Version: %s''' % __version__ Version: %(__version__)s""" % globals()
sys.exit(0) sys.exit(0)
elif opt in ('-d', '--database'): elif opt in ('-d', '--database'):
RGB_TXT.insert(0, arg) dbfile = arg
elif opt in ('-X', '--ignore'): elif opt in ('-X', '--ignore'):
ignore = 1 ignore = True
elif opt in ('-i', '--initfile'): elif opt in ('-i', '--initfile'):
initfile = arg initfile = arg
app, sb = build(initialcolor=initialcolor, app, sb = build(initialcolor=initialcolor,
initfile=initfile, initfile=initfile,
ignore=ignore) ignore=ignore,
dbfile=dbfile)
run(app, sb) run(app, sb)
sb.save_views() sb.save_views()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment