Convert print statements to function calls in Tools/.

This commit is contained in:
Collin Winter 2007-08-03 17:06:41 +00:00
parent e5d0e8431f
commit 6afaeb757a
66 changed files with 777 additions and 779 deletions

View file

@ -57,7 +57,7 @@ class ColorDB:
# get this compiled regular expression from derived class
mo = self._re.match(line)
if not mo:
print >> sys.stderr, 'Error in', fp.name, ' line', lineno
print('Error in', fp.name, ' line', lineno, file=sys.stderr)
lineno += 1
continue
# extract the red, green, blue, and name
@ -254,26 +254,26 @@ def triplet_to_brightness(rgbtuple):
if __name__ == '__main__':
colordb = get_colordb('/usr/openwin/lib/rgb.txt')
if not colordb:
print 'No parseable color database found'
print('No parseable color database found')
sys.exit(1)
# on my system, this color matches exactly
target = 'navy'
red, green, blue = rgbtuple = colordb.find_byname(target)
print target, ':', red, green, blue, triplet_to_rrggbb(rgbtuple)
print(target, ':', red, green, blue, triplet_to_rrggbb(rgbtuple))
name, aliases = colordb.find_byrgb(rgbtuple)
print 'name:', name, 'aliases:', COMMASPACE.join(aliases)
print('name:', name, 'aliases:', COMMASPACE.join(aliases))
r, g, b = (1, 1, 128) # nearest to navy
r, g, b = (145, 238, 144) # nearest to lightgreen
r, g, b = (255, 251, 250) # snow
print 'finding nearest to', target, '...'
print('finding nearest to', target, '...')
import time
t0 = time.time()
nearest = colordb.nearest(r, g, b)
t1 = time.time()
print 'found nearest color', nearest, 'in', t1-t0, 'seconds'
print('found nearest color', nearest, 'in', t1-t0, 'seconds')
# dump the database
for n in colordb.unique_names():
r, g, b = colordb.find_byname(n)
aliases = colordb.aliases_of(r, g, b)
print '%20s: (%3d/%3d/%3d) == %s' % (n, r, g, b,
SPACE.join(aliases[1:]))
print('%20s: (%3d/%3d/%3d) == %s' % (n, r, g, b,
SPACE.join(aliases[1:])))

View file

@ -85,9 +85,9 @@ def docstring():
def usage(code, msg=''):
print docstring()
print(docstring())
if msg:
print msg
print(msg)
sys.exit(code)
@ -111,7 +111,7 @@ def initial_color(s, colordb):
# this to be escaped, which is a pain
r, g, b = scan_color('#' + s)
if r is None:
print 'Bad initial color, using gray50:', s
print('Bad initial color, using gray50:', s)
r, g, b = scan_color('gray50')
if r is None:
usage(1, 'Cannot find an initial color to use')
@ -203,11 +203,11 @@ def main():
if opt in ('-h', '--help'):
usage(0)
elif opt in ('-v', '--version'):
print """\
print("""\
Pynche -- The PYthon Natural Color and Hue Editor.
Contact: %(AUTHNAME)s
Email: %(AUTHEMAIL)s
Version: %(__version__)s""" % globals()
Version: %(__version__)s""" % globals())
sys.exit(0)
elif opt in ('-d', '--database'):
dbfile = arg

View file

@ -65,8 +65,7 @@ class Switchboard:
fp = open(initfile)
self.__optiondb = marshal.load(fp)
if not isinstance(self.__optiondb, DictType):
print >> sys.stderr, \
'Problem reading options from file:', initfile
print('Problem reading options from file:', initfile, file=sys.stderr)
self.__optiondb = {}
except (IOError, EOFError, ValueError):
pass
@ -119,8 +118,8 @@ class Switchboard:
try:
fp = open(self.__initfile, 'w')
except IOError:
print >> sys.stderr, 'Cannot write options to file:', \
self.__initfile
print('Cannot write options to file:', \
self.__initfile, file=sys.stderr)
else:
marshal.dump(self.__optiondb, fp)
finally: