[Python-checkins] python/dist/src/Tools/pynche Main.py,2.21,2.22

bwarsaw@users.sourceforge.net bwarsaw@users.sourceforge.net
2002年10月21日 07:23:50 -0700


Update of /cvsroot/python/python/dist/src/Tools/pynche
In directory usw-pr-cvs1:/tmp/cvs-serv4624
Modified Files:
	Main.py 
Log Message:
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.
Index: Main.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/pynche/Main.py,v
retrieving revision 2.21
retrieving revision 2.22
diff -C2 -d -r2.21 -r2.22
*** Main.py	23 Aug 2001 16:15:02 -0000	2.21
--- Main.py	21 Oct 2002 14:23:48 -0000	2.22
***************
*** 1,10 ****
 """Pynche -- The PYthon Natural Color and Hue Editor.
 
! Contact: Barry Warsaw
! Email: bwarsaw@python.org
 Version: %(__version__)s
 
 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
 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 +
--- 1,10 ----
 """Pynche -- The PYthon Natural Color and Hue Editor.
 
! Contact: %(AUTHNAME)s
! Email: %(AUTHEMAIL)s
 Version: %(__version__)s
 
 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
 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 +
***************
*** 13,19 ****
 days, too many other systems have the acronym `ICE'.
 
! This program currently requires Python 1.5 with Tkinter. It has only been
! 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]
--- 13,17 ----
 days, too many other systems have the acronym `ICE'.
 
! This program currently requires Python 2.2 with Tkinter.
 
 Usage: %(PROGRAM)s [-d file] [-i file] [-X] [-v] [-h] [initialcolor]
***************
*** 39,43 ****
 --version
 -v
! print the version number
 
 --help
--- 37,41 ----
 --version
 -v
! print the version number and exit
 
 --help
***************
*** 49,53 ****
 """
 
! __version__ = '1.3'
 
 import sys
--- 47,51 ----
 """
 
! __version__ = '1.4'
 
 import sys
***************
*** 65,68 ****
--- 63,68 ----
 
 PROGRAM = sys.argv[0]
+ AUTHNAME = 'Barry Warsaw'
+ AUTHEMAIL = 'barry@python.org'
 
 # Default locations of rgb.txt or other textual color database
***************
*** 121,143 ****
 
 
! def build(master=None, initialcolor=None, initfile=None, ignore=None):
 # create all output widgets
 s = Switchboard(not ignore and initfile)
! 
! # load the color database
! colordb = None
! try:
 dbfile = s.optiondb()['DBFILE']
! colordb = ColorDB.get_colordb(dbfile)
! 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
 if not colordb:
 usage(1, 'No color database file found, see the -d option.')
--- 121,144 ----
 
 
! def build(master=None, initialcolor=None, initfile=None, ignore=None,
! dbfile=None):
 # create all output widgets
 s = Switchboard(not ignore and initfile)
! # defer to the command line chosen color database, falling back to the one
! # in the .pynche file.
! if dbfile is None:
 dbfile = s.optiondb()['DBFILE']
! # find a parseable color database
! colordb = None
! files = RGB_TXT[:]
! while colordb is None:
! try:
! colordb = ColorDB.get_colordb(dbfile)
! except (KeyError, IOError):
! pass
! if colordb is None:
! if not files:
! break
! dbfile = files.pop(0)
 if not colordb:
 usage(1, 'No color database file found, see the -d option.')
***************
*** 154,158 ****
 
 # get the initial color as components and set the color on all views. if
! # there was no initial color given on the command line, use the one that's 
 # stored in the option database
 if initialcolor is None:
--- 155,159 ----
 
 # get the initial color as components and set the color on all views. if
! # there was no initial color given on the command line, use the one that's
 # stored in the option database
 if initialcolor is None:
***************
*** 172,178 ****
 def run(app, s):
 try:
! 	app.start()
 except KeyboardInterrupt:
! 	pass
 
 
--- 173,179 ----
 def run(app, s):
 try:
! app.start()
 except KeyboardInterrupt:
! pass
 
 
***************
*** 180,189 ****
 def main():
 try:
! 	opts, args = getopt.getopt(
 sys.argv[1:],
 'hd:i:Xv',
 ['database=', 'initfile=', 'ignore', 'help', 'version'])
 except getopt.error, msg:
! 	usage(1, msg)
 
 if len(args) == 0:
--- 181,190 ----
 def main():
 try:
! opts, args = getopt.getopt(
 sys.argv[1:],
 'hd:i:Xv',
 ['database=', 'initfile=', 'ignore', 'help', 'version'])
 except getopt.error, msg:
! usage(1, msg)
 
 if len(args) == 0:
***************
*** 192,213 ****
 initialcolor = args[0]
 else:
! 	usage(1)
 
! ignore = 0
 initfile = os.path.expanduser('~/.pynche')
 for opt, arg in opts:
! 	if opt in ('-h', '--help'):
! 	 usage(0)
 elif opt in ('-v', '--version'):
! print '''\
 Pynche -- The PYthon Natural Color and Hue Editor.
! Contact: Barry Warsaw
! Email: bwarsaw@python.org
! Version: %s''' % __version__
 sys.exit(0)
! 	elif opt in ('-d', '--database'):
! 	 RGB_TXT.insert(0, arg)
 elif opt in ('-X', '--ignore'):
! ignore = 1
 elif opt in ('-i', '--initfile'):
 initfile = arg
--- 193,215 ----
 initialcolor = args[0]
 else:
! usage(1)
 
! ignore = False
! dbfile = None
 initfile = os.path.expanduser('~/.pynche')
 for opt, arg in opts:
! if opt in ('-h', '--help'):
! usage(0)
 elif opt in ('-v', '--version'):
! print """\
 Pynche -- The PYthon Natural Color and Hue Editor.
! Contact: %(AUTHNAME)s
! Email: %(AUTHEMAIL)s
! Version: %(__version__)s""" % globals()
 sys.exit(0)
! elif opt in ('-d', '--database'):
! dbfile = arg
 elif opt in ('-X', '--ignore'):
! ignore = True
 elif opt in ('-i', '--initfile'):
 initfile = arg
***************
*** 215,219 ****
 app, sb = build(initialcolor=initialcolor,
 initfile=initfile,
! ignore=ignore)
 run(app, sb)
 sb.save_views()
--- 217,222 ----
 app, sb = build(initialcolor=initialcolor,
 initfile=initfile,
! ignore=ignore,
! dbfile=dbfile)
 run(app, sb)
 sb.save_views()

AltStyle によって変換されたページ (->オリジナル) /