summaryrefslogtreecommitdiffstats
path: root/Tools/pynche
diff options
context:
space:
mode:
authorCollin Winter <collinw@gmail.com>2007-08-03 17:06:41 (GMT)
committerCollin Winter <collinw@gmail.com>2007-08-03 17:06:41 (GMT)
commit6afaeb757af0dbd8508a0f2352ade61e41bec84c (patch)
treef1b31bc7138b17ff39791bbb45aa81583c3b6e46 /Tools/pynche
parente5d0e8431f929cad2da77b63fe1b7dc0ff21a428 (diff)
downloadcpython-6afaeb757af0dbd8508a0f2352ade61e41bec84c.zip
cpython-6afaeb757af0dbd8508a0f2352ade61e41bec84c.tar.gz
cpython-6afaeb757af0dbd8508a0f2352ade61e41bec84c.tar.bz2
Convert print statements to function calls in Tools/.
Diffstat (limited to 'Tools/pynche')
-rw-r--r--Tools/pynche/ColorDB.py16
-rw-r--r--Tools/pynche/Main.py10
-rw-r--r--Tools/pynche/Switchboard.py7
3 files changed, 16 insertions, 17 deletions
diff --git a/Tools/pynche/ColorDB.py b/Tools/pynche/ColorDB.py
index 96b6ce6..2e7a1b5 100644
--- a/Tools/pynche/ColorDB.py
+++ b/Tools/pynche/ColorDB.py
@@ -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:])))
diff --git a/Tools/pynche/Main.py b/Tools/pynche/Main.py
index a0a2d81..4db560b 100644
--- a/Tools/pynche/Main.py
+++ b/Tools/pynche/Main.py
@@ -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
diff --git a/Tools/pynche/Switchboard.py b/Tools/pynche/Switchboard.py
index ee83d47..29f99af 100644
--- a/Tools/pynche/Switchboard.py
+++ b/Tools/pynche/Switchboard.py
@@ -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: