diff options
author | Guido van Rossum <guido@python.org> | 2007-05-17 18:20:34 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-05-17 18:20:34 (GMT) |
commit | ebe3e16600ddbc19aa7444ec773e2e0786b8a3cf (patch) | |
tree | 1189de0bc8de926ef5b1baa2f646cbd1674b8bab /Lib/plat-irix6/torgb.py | |
parent | e35553e24c6b90db9ab22298cef663192972bbab (diff) | |
download | cpython-ebe3e16600ddbc19aa7444ec773e2e0786b8a3cf.zip cpython-ebe3e16600ddbc19aa7444ec773e2e0786b8a3cf.tar.gz cpython-ebe3e16600ddbc19aa7444ec773e2e0786b8a3cf.tar.bz2 |
Merged revisions 55342-55406 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk
........
r55360 | guido.van.rossum | 2007-05-15 14:57:59 -0700 (Tue, 15 May 2007) | 2 lines
obcheckin.
........
r55361 | guido.van.rossum | 2007-05-15 14:59:18 -0700 (Tue, 15 May 2007) | 2 lines
Get rid of strop module.
........
r55367 | brett.cannon | 2007-05-15 21:06:28 -0700 (Tue, 15 May 2007) | 2 lines
Remove the 'pure' module.
........
r55369 | brett.cannon | 2007-05-15 21:07:31 -0700 (Tue, 15 May 2007) | 2 lines
Remove the lib-old directory (already empty).
........
r55370 | neal.norwitz | 2007-05-15 21:30:40 -0700 (Tue, 15 May 2007) | 1 line
Get rid of a bunch more references to strop
........
r55374 | brett.cannon | 2007-05-15 21:39:00 -0700 (Tue, 15 May 2007) | 2 lines
Complete the removal of IRIX-specific modules.
........
r55379 | brett.cannon | 2007-05-15 22:31:54 -0700 (Tue, 15 May 2007) | 2 lines
Update removed IRIX modules based on what is gone from removing plat-irix6.
........
r55388 | brett.cannon | 2007-05-16 14:34:52 -0700 (Wed, 16 May 2007) | 2 lines
Clean up the docstring for the compiler resource.
........
r55406 | brett.cannon | 2007-05-17 11:05:37 -0700 (Thu, 17 May 2007) | 2 lines
Remove BaseException.message (deprecated in Python 2.6).
........
Diffstat (limited to 'Lib/plat-irix6/torgb.py')
-rw-r--r-- | Lib/plat-irix6/torgb.py | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/Lib/plat-irix6/torgb.py b/Lib/plat-irix6/torgb.py deleted file mode 100644 index 02bcb53..0000000 --- a/Lib/plat-irix6/torgb.py +++ /dev/null @@ -1,99 +0,0 @@ -# Convert "arbitrary" image files to rgb files (SGI's image format). -# Input may be compressed. -# The uncompressed file type may be PBM, PGM, PPM, GIF, TIFF, or Sun raster. -# An exception is raised if the file is not of a recognized type. -# Returned filename is either the input filename or a temporary filename; -# in the latter case the caller must ensure that it is removed. -# Other temporary files used are removed by the function. - -import os -import tempfile -import pipes -import imghdr - -table = {} - -t = pipes.Template() -t.append('fromppm $IN $OUT', 'ff') -table['ppm'] = t - -t = pipes.Template() -t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--') -t.append('fromppm $IN $OUT', 'ff') -table['pnm'] = t -table['pgm'] = t -table['pbm'] = t - -t = pipes.Template() -t.append('fromgif $IN $OUT', 'ff') -table['gif'] = t - -t = pipes.Template() -t.append('tifftopnm', '--') -t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--') -t.append('fromppm $IN $OUT', 'ff') -table['tiff'] = t - -t = pipes.Template() -t.append('rasttopnm', '--') -t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--') -t.append('fromppm $IN $OUT', 'ff') -table['rast'] = t - -t = pipes.Template() -t.append('djpeg', '--') -t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--') -t.append('fromppm $IN $OUT', 'ff') -table['jpeg'] = t - -uncompress = pipes.Template() -uncompress.append('uncompress', '--') - - -class error(Exception): - pass - -def torgb(filename): - temps = [] - ret = None - try: - ret = _torgb(filename, temps) - finally: - for temp in temps[:]: - if temp != ret: - try: - os.unlink(temp) - except os.error: - pass - temps.remove(temp) - return ret - -def _torgb(filename, temps): - if filename[-2:] == '.Z': - (fd, fname) = tempfile.mkstemp() - os.close(fd) - temps.append(fname) - sts = uncompress.copy(filename, fname) - if sts: - raise error, filename + ': uncompress failed' - else: - fname = filename - try: - ftype = imghdr.what(fname) - except IOError as msg: - if type(msg) == type(()) and len(msg) == 2 and \ - type(msg[0]) == type(0) and type(msg[1]) == type(''): - msg = msg[1] - if type(msg) is not type(''): - msg = repr(msg) - raise error, filename + ': ' + msg - if ftype == 'rgb': - return fname - if ftype is None or not table.has_key(ftype): - raise error, '%s: unsupported image file type %r' % (filename, ftype) - (fd, temp) = tempfile.mkstemp() - os.close(fd) - sts = table[ftype].copy(fname, temp) - if sts: - raise error, filename + ': conversion to rgb failed' - return temp |