[Python-3000-checkins] r55271 - in python/branches/p3yk: Doc/lib/lib.tex Doc/lib/libjpeg.tex Doc/lib/libpanel.tex Lib/plat-irix6/jpeg.py Lib/plat-irix6/panel.py Lib/plat-irix6/panelparser.py
fred.drake
python-3000-checkins at python.org
Fri May 11 19:14:52 CEST 2007
Author: fred.drake
Date: Fri May 11 19:14:47 2007
New Revision: 55271
Removed:
python/branches/p3yk/Doc/lib/libjpeg.tex
python/branches/p3yk/Doc/lib/libpanel.tex
python/branches/p3yk/Lib/plat-irix6/jpeg.py
python/branches/p3yk/Lib/plat-irix6/panel.py
python/branches/p3yk/Lib/plat-irix6/panelparser.py
Modified:
python/branches/p3yk/Doc/lib/lib.tex
Log:
remove jpeg, panel libraries for SGI; there is more IRIX stuff left over,
I guess that should be removed too, but will leave for someone who is sure
Modified: python/branches/p3yk/Doc/lib/lib.tex
==============================================================================
--- python/branches/p3yk/Doc/lib/lib.tex (original)
+++ python/branches/p3yk/Doc/lib/lib.tex Fri May 11 19:14:47 2007
@@ -434,9 +434,6 @@
%\input{libstdwin} % STDWIN ONLY
-\input{libjpeg}
-%\input{libpanel}
-
\input{libsun} % SUNOS ONLY
\input{libsunaudio}
% XXX(nnorwitz): the modules below this comment should be kept.
Deleted: /python/branches/p3yk/Doc/lib/libjpeg.tex
==============================================================================
--- /python/branches/p3yk/Doc/lib/libjpeg.tex Fri May 11 19:14:47 2007
+++ (empty file)
@@ -1,80 +0,0 @@
-\section{\module{jpeg} ---
- Read and write JPEG files}
-
-\declaremodule{builtin}{jpeg}
- \platform{IRIX}
-\modulesynopsis{Read and write image files in compressed JPEG format.}
-
-
-The module \module{jpeg} provides access to the jpeg compressor and
-decompressor written by the Independent JPEG Group
-\index{Independent JPEG Group}(IJG). JPEG is a standard for
-compressing pictures; it is defined in ISO 10918. For details on JPEG
-or the Independent JPEG Group software refer to the JPEG standard or
-the documentation provided with the software.
-
-A portable interface to JPEG image files is available with the Python
-Imaging Library (PIL) by Fredrik Lundh. Information on PIL is
-available at \url{http://www.pythonware.com/products/pil/}.
-\index{Python Imaging Library}
-\index{PIL (the Python Imaging Library)}
-\index{Lundh, Fredrik}
-
-The \module{jpeg} module defines an exception and some functions.
-
-\begin{excdesc}{error}
-Exception raised by \function{compress()} and \function{decompress()}
-in case of errors.
-\end{excdesc}
-
-\begin{funcdesc}{compress}{data, w, h, b}
-Treat data as a pixmap of width \var{w} and height \var{h}, with
-\var{b} bytes per pixel. The data is in SGI GL order, so the first
-pixel is in the lower-left corner. This means that \function{gl.lrectread()}
-return data can immediately be passed to \function{compress()}.
-Currently only 1 byte and 4 byte pixels are allowed, the former being
-treated as greyscale and the latter as RGB color.
-\function{compress()} returns a string that contains the compressed
-picture, in JFIF\index{JFIF} format.
-\end{funcdesc}
-
-\begin{funcdesc}{decompress}{data}
-Data is a string containing a picture in JFIF\index{JFIF} format. It
-returns a tuple \code{(\var{data}, \var{width}, \var{height},
-\var{bytesperpixel})}. Again, the data is suitable to pass to
-\function{gl.lrectwrite()}.
-\end{funcdesc}
-
-\begin{funcdesc}{setoption}{name, value}
-Set various options. Subsequent \function{compress()} and
-\function{decompress()} calls will use these options. The following
-options are available:
-
-\begin{tableii}{l|p{3in}}{code}{Option}{Effect}
- \lineii{'forcegray'}{%
- Force output to be grayscale, even if input is RGB.}
- \lineii{'quality'}{%
- Set the quality of the compressed image to a value between
- \code{0} and \code{100} (default is \code{75}). This only affects
- compression.}
- \lineii{'optimize'}{%
- Perform Huffman table optimization. Takes longer, but results in
- smaller compressed image. This only affects compression.}
- \lineii{'smooth'}{%
- Perform inter-block smoothing on uncompressed image. Only useful
- for low-quality images. This only affects decompression.}
-\end{tableii}
-\end{funcdesc}
-
-
-\begin{seealso}
- \seetitle{JPEG Still Image Data Compression Standard}{The
- canonical reference for the JPEG image format, by
- Pennebaker and Mitchell.}
-
- \seetitle[http://www.w3.org/Graphics/JPEG/itu-t81.pdf]{Information
- Technology - Digital Compression and Coding of
- Continuous-tone Still Images - Requirements and
- Guidelines}{The ISO standard for JPEG is also published as
- ITU T.81. This is available online in PDF form.}
-\end{seealso}
Deleted: /python/branches/p3yk/Doc/lib/libpanel.tex
==============================================================================
--- /python/branches/p3yk/Doc/lib/libpanel.tex Fri May 11 19:14:47 2007
+++ (empty file)
@@ -1,74 +0,0 @@
-\section{\module{panel} ---
- None}
-\declaremodule{standard}{panel}
-
-\modulesynopsis{None}
-
-
-\strong{Please note:} The FORMS library, to which the
-\code{fl}\refbimodindex{fl} module described above interfaces, is a
-simpler and more accessible user interface library for use with GL
-than the \code{panel} module (besides also being by a Dutch author).
-
-This module should be used instead of the built-in module
-\code{pnl}\refbimodindex{pnl}
-to interface with the
-\emph{Panel Library}.
-
-The module is too large to document here in its entirety.
-One interesting function:
-
-\begin{funcdesc}{defpanellist}{filename}
-Parses a panel description file containing S-expressions written by the
-\emph{Panel Editor}
-that accompanies the Panel Library and creates the described panels.
-It returns a list of panel objects.
-\end{funcdesc}
-
-\warning{The Python interpreter will dump core if you don't create a
-GL window before calling
-\code{panel.mkpanel()}
-or
-\code{panel.defpanellist()}.}
-
-\section{\module{panelparser} ---
- None}
-\declaremodule{standard}{panelparser}
-
-\modulesynopsis{None}
-
-
-This module defines a self-contained parser for S-expressions as output
-by the Panel Editor (which is written in Scheme so it can't help writing
-S-expressions).
-The relevant function is
-\code{panelparser.parse_file(\var{file})}
-which has a file object (not a filename!) as argument and returns a list
-of parsed S-expressions.
-Each S-expression is converted into a Python list, with atoms converted
-to Python strings and sub-expressions (recursively) to Python lists.
-For more details, read the module file.
-% XXXXJH should be funcdesc, I think
-
-\section{\module{pnl} ---
- None}
-\declaremodule{builtin}{pnl}
-
-\modulesynopsis{None}
-
-
-This module provides access to the
-\emph{Panel Library}
-built by NASA Ames\index{NASA} (to get it, send email to
-\code{panel-request at nas.nasa.gov}).
-All access to it should be done through the standard module
-\code{panel}\refstmodindex{panel},
-which transparently exports most functions from
-\code{pnl}
-but redefines
-\code{pnl.dopanel()}.
-
-\warning{The Python interpreter will dump core if you don't create a
-GL window before calling \code{pnl.mkpanel()}.}
-
-The module is too large to document here in its entirety.
Deleted: /python/branches/p3yk/Lib/plat-irix6/jpeg.py
==============================================================================
--- /python/branches/p3yk/Lib/plat-irix6/jpeg.py Fri May 11 19:14:47 2007
+++ (empty file)
@@ -1,111 +0,0 @@
-# Implement 'jpeg' interface using SGI's compression library
-
-# XXX Options 'smooth' and 'optimize' are ignored.
-
-# XXX It appears that compressing grayscale images doesn't work right;
-# XXX the resulting file causes weirdness.
-
-class error(Exception):
- pass
-
-options = {'quality': 75, 'optimize': 0, 'smooth': 0, 'forcegray': 0}
-
-comp = None
-decomp = None
-
-def compress(imgdata, width, height, bytesperpixel):
- global comp
- import cl
- if comp is None: comp = cl.OpenCompressor(cl.JPEG)
- if bytesperpixel == 1:
- format = cl.GRAYSCALE
- elif bytesperpixel == 4:
- format = cl.RGBX
- if options['forcegray']:
- iformat = cl.GRAYSCALE
- else:
- iformat = cl.YUV
- # XXX How to support 'optimize'?
- params = [cl.IMAGE_WIDTH, width, cl.IMAGE_HEIGHT, height,
- cl.ORIGINAL_FORMAT, format,
- cl.ORIENTATION, cl.BOTTOM_UP,
- cl.QUALITY_FACTOR, options['quality'],
- cl.INTERNAL_FORMAT, iformat,
- ]
- comp.SetParams(params)
- jpegdata = comp.Compress(1, imgdata)
- return jpegdata
-
-def decompress(jpegdata):
- global decomp
- import cl
- if decomp is None: decomp = cl.OpenDecompressor(cl.JPEG)
- headersize = decomp.ReadHeader(jpegdata)
- params = [cl.IMAGE_WIDTH, 0, cl.IMAGE_HEIGHT, 0, cl.INTERNAL_FORMAT, 0]
- decomp.GetParams(params)
- width, height, format = params[1], params[3], params[5]
- if format == cl.GRAYSCALE or options['forcegray']:
- format = cl.GRAYSCALE
- bytesperpixel = 1
- else:
- format = cl.RGBX
- bytesperpixel = 4
- # XXX How to support 'smooth'?
- params = [cl.ORIGINAL_FORMAT, format,
- cl.ORIENTATION, cl.BOTTOM_UP,
- cl.FRAME_BUFFER_SIZE, width*height*bytesperpixel]
- decomp.SetParams(params)
- imgdata = decomp.Decompress(1, jpegdata)
- return imgdata, width, height, bytesperpixel
-
-def setoption(name, value):
- if type(value) is not type(0):
- raise TypeError, 'jpeg.setoption: numeric options only'
- if name == 'forcegrey':
- name = 'forcegray'
- if not options.has_key(name):
- raise KeyError, 'jpeg.setoption: unknown option name'
- options[name] = int(value)
-
-def test():
- import sys
- if sys.argv[1:2] == ['-g']:
- del sys.argv[1]
- setoption('forcegray', 1)
- if not sys.argv[1:]:
- sys.argv.append('/usr/local/images/data/jpg/asterix.jpg')
- for file in sys.argv[1:]:
- show(file)
-
-def show(file):
- import gl, GL, DEVICE
- jpegdata = open(file, 'r').read()
- imgdata, width, height, bytesperpixel = decompress(jpegdata)
- gl.foreground()
- gl.prefsize(width, height)
- win = gl.winopen(file)
- if bytesperpixel == 1:
- gl.cmode()
- gl.pixmode(GL.PM_SIZE, 8)
- gl.gconfig()
- for i in range(256):
- gl.mapcolor(i, i, i, i)
- else:
- gl.RGBmode()
- gl.pixmode(GL.PM_SIZE, 32)
- gl.gconfig()
- gl.qdevice(DEVICE.REDRAW)
- gl.qdevice(DEVICE.ESCKEY)
- gl.qdevice(DEVICE.WINQUIT)
- gl.qdevice(DEVICE.WINSHUT)
- gl.lrectwrite(0, 0, width-1, height-1, imgdata)
- while 1:
- dev, val = gl.qread()
- if dev in (DEVICE.ESCKEY, DEVICE.WINSHUT, DEVICE.WINQUIT):
- break
- if dev == DEVICE.REDRAW:
- gl.lrectwrite(0, 0, width-1, height-1, imgdata)
- gl.winclose(win)
- # Now test the compression and write the result to a fixed filename
- newjpegdata = compress(imgdata, width, height, bytesperpixel)
- open('/tmp/j.jpg', 'w').write(newjpegdata)
Deleted: /python/branches/p3yk/Lib/plat-irix6/panel.py
==============================================================================
--- /python/branches/p3yk/Lib/plat-irix6/panel.py Fri May 11 19:14:47 2007
+++ (empty file)
@@ -1,281 +0,0 @@
-# Module 'panel'
-#
-# Support for the Panel library.
-# Uses built-in module 'pnl'.
-# Applications should use 'panel.function' instead of 'pnl.function';
-# most 'pnl' functions are transparently exported by 'panel',
-# but dopanel() is overridden and you have to use this version
-# if you want to use callbacks.
-
-
-import pnl
-
-
-debug = 0
-
-
-# Test if an object is a list.
-#
-def is_list(x):
- return type(x) == type([])
-
-
-# Reverse a list.
-#
-def reverse(list):
- res = []
- for item in list:
- res.insert(0, item)
- return res
-
-
-# Get an attribute of a list, which may itself be another list.
-# Don't use 'prop' for name.
-#
-def getattrlist(list, name):
- for item in list:
- if item and is_list(item) and item[0] == name:
- return item[1:]
- return []
-
-
-# Get a property of a list, which may itself be another list.
-#
-def getproplist(list, name):
- for item in list:
- if item and is_list(item) and item[0] == 'prop':
- if len(item) > 1 and item[1] == name:
- return item[2:]
- return []
-
-
-# Test if an actuator description contains the property 'end-of-group'
-#
-def is_endgroup(list):
- x = getproplist(list, 'end-of-group')
- return (x and x[0] == '#t')
-
-
-# Neatly display an actuator definition given as S-expression
-# the prefix string is printed before each line.
-#
-def show_actuator(prefix, a):
- for item in a:
- if not is_list(item):
- print(prefix, item)
- elif item and item[0] == 'al':
- print(prefix, 'Subactuator list:')
- for a in item[1:]:
- show_actuator(prefix + ' ', a)
- elif len(item) == 2:
- print(prefix, item[0], '=>', item[1])
- elif len(item) == 3 and item[0] == 'prop':
- print(prefix, 'Prop', item[1], '=>', end=' ')
- print(item[2])
- else:
- print(prefix, '?', item)
-
-
-# Neatly display a panel.
-#
-def show_panel(prefix, p):
- for item in p:
- if not is_list(item):
- print(prefix, item)
- elif item and item[0] == 'al':
- print(prefix, 'Actuator list:')
- for a in item[1:]:
- show_actuator(prefix + ' ', a)
- elif len(item) == 2:
- print(prefix, item[0], '=>', item[1])
- elif len(item) == 3 and item[0] == 'prop':
- print(prefix, 'Prop', item[1], '=>', end=' ')
- print(item[2])
- else:
- print(prefix, '?', item)
-
-
-# Exception raised by build_actuator or build_panel.
-#
-panel_error = 'panel error'
-
-
-# Dummy callback used to initialize the callbacks.
-#
-def dummy_callback(arg):
- pass
-
-
-# Assign attributes to members of the target.
-# Attribute names in exclist are ignored.
-# The member name is the attribute name prefixed with the prefix.
-#
-def assign_members(target, attrlist, exclist, prefix):
- for item in attrlist:
- if is_list(item) and len(item) == 2 and item[0] not in exclist:
- name, value = item[0], item[1]
- ok = 1
- if value[0] in '-0123456789':
- value = eval(value)
- elif value[0] == '"':
- value = value[1:-1]
- elif value == 'move-then-resize':
- # Strange default set by Panel Editor...
- ok = 0
- else:
- print('unknown value', value, 'for', name)
- ok = 0
- if ok:
- lhs = 'target.' + prefix + name
- stmt = lhs + '=' + repr(value)
- if debug: print('exec', stmt)
- try:
- exec(stmt + '\n')
- except KeyboardInterrupt: # Don't catch this!
- raise KeyboardInterrupt
- except:
- print('assign failed:', stmt)
-
-
-# Build a real actuator from an actuator description.
-# Return a pair (actuator, name).
-#
-def build_actuator(descr):
- namelist = getattrlist(descr, 'name')
- if namelist:
- # Assume it is a string
- actuatorname = namelist[0][1:-1]
- else:
- actuatorname = ''
- type = descr[0]
- if type[:4] == 'pnl_': type = type[4:]
- act = pnl.mkact(type)
- act.downfunc = act.activefunc = act.upfunc = dummy_callback
- #
- assign_members(act, descr[1:], ['al', 'data', 'name'], '')
- #
- # Treat actuator-specific data
- #
- datalist = getattrlist(descr, 'data')
- prefix = ''
- if type[-4:] == 'puck':
- prefix = 'puck_'
- elif type == 'mouse':
- prefix = 'mouse_'
- assign_members(act, datalist, [], prefix)
- #
- return act, actuatorname
-
-
-# Build all sub-actuators and add them to the super-actuator.
-# The super-actuator must already have been added to the panel.
-# Sub-actuators with defined names are added as members to the panel
-# so they can be referenced as p.name.
-#
-# Note: I have no idea how panel.endgroup() works when applied
-# to a sub-actuator.
-#
-def build_subactuators(panel, super_act, al):
- #
- # This is nearly the same loop as below in build_panel(),
- # except a call is made to addsubact() instead of addact().
- #
- for a in al:
- act, name = build_actuator(a)
- act.addsubact(super_act)
- if name:
- stmt = 'panel.' + name + ' = act'
- if debug: print('exec', stmt)
- exec(stmt + '\n')
- if is_endgroup(a):
- panel.endgroup()
- sub_al = getattrlist(a, 'al')
- if sub_al:
- build_subactuators(panel, act, sub_al)
- #
- # Fix the actuator to which whe just added subactuators.
- # This can't hurt (I hope) and is needed for the scroll actuator.
- #
- super_act.fixact()
-
-
-# Build a real panel from a panel definition.
-# Return a panel object p, where for each named actuator a, p.name is a
-# reference to a.
-#
-def build_panel(descr):
- #
- # Sanity check
- #
- if (not descr) or descr[0] != 'panel':
- raise panel_error, 'panel description must start with "panel"'
- #
- if debug: show_panel('', descr)
- #
- # Create an empty panel
- #
- panel = pnl.mkpanel()
- #
- # Assign panel attributes
- #
- assign_members(panel, descr[1:], ['al'], '')
- #
- # Look for actuator list
- #
- al = getattrlist(descr, 'al')
- #
- # The order in which actuators are created is important
- # because of the endgroup() operator.
- # Unfortunately the Panel Editor outputs the actuator list
- # in reverse order, so we reverse it here.
- #
- al = reverse(al)
- #
- for a in al:
- act, name = build_actuator(a)
- act.addact(panel)
- if name:
- stmt = 'panel.' + name + ' = act'
- exec(stmt + '\n')
- if is_endgroup(a):
- panel.endgroup()
- sub_al = getattrlist(a, 'al')
- if sub_al:
- build_subactuators(panel, act, sub_al)
- #
- return panel
-
-
-# Wrapper around pnl.dopanel() which calls call-back functions.
-#
-def my_dopanel():
- # Extract only the first 4 elements to allow for future expansion
- a, down, active, up = pnl.dopanel()[:4]
- if down:
- down.downfunc(down)
- if active:
- active.activefunc(active)
- if up:
- up.upfunc(up)
- return a
-
-
-# Create one or more panels from a description file (S-expressions)
-# generated by the Panel Editor.
-#
-def defpanellist(file):
- import panelparser
- descrlist = panelparser.parse_file(open(file, 'r'))
- panellist = []
- for descr in descrlist:
- panellist.append(build_panel(descr))
- return panellist
-
-
-# Import everything from built-in method pnl, so the user can always
-# use panel.foo() instead of pnl.foo().
-# This gives *no* performance penalty once this module is imported.
-#
-from pnl import * # for export
-
-dopanel = my_dopanel # override pnl.dopanel
Deleted: /python/branches/p3yk/Lib/plat-irix6/panelparser.py
==============================================================================
--- /python/branches/p3yk/Lib/plat-irix6/panelparser.py Fri May 11 19:14:47 2007
+++ (empty file)
@@ -1,128 +0,0 @@
-# Module 'parser'
-#
-# Parse S-expressions output by the Panel Editor
-# (which is written in Scheme so it can't help writing S-expressions).
-#
-# See notes at end of file.
-
-
-whitespace = ' \t\n'
-operators = '()\''
-separators = operators + whitespace + ';' + '"'
-
-
-# Tokenize a string.
-# Return a list of tokens (strings).
-#
-def tokenize_string(s):
- tokens = []
- while s:
- c = s[:1]
- if c in whitespace:
- s = s[1:]
- elif c == ';':
- s = ''
- elif c == '"':
- n = len(s)
- i = 1
- while i < n:
- c = s[i]
- i = i+1
- if c == '"': break
- if c == '\\': i = i+1
- tokens.append(s[:i])
- s = s[i:]
- elif c in operators:
- tokens.append(c)
- s = s[1:]
- else:
- n = len(s)
- i = 1
- while i < n:
- if s[i] in separators: break
- i = i+1
- tokens.append(s[:i])
- s = s[i:]
- return tokens
-
-
-# Tokenize a whole file (given as file object, not as file name).
-# Return a list of tokens (strings).
-#
-def tokenize_file(fp):
- tokens = []
- while 1:
- line = fp.readline()
- if not line: break
- tokens = tokens + tokenize_string(line)
- return tokens
-
-
-# Exception raised by parse_exr.
-#
-syntax_error = 'syntax error'
-
-
-# Parse an S-expression.
-# Input is a list of tokens as returned by tokenize_*().
-# Return a pair (expr, tokens)
-# where expr is a list representing the s-expression,
-# and tokens contains the remaining tokens.
-# May raise syntax_error.
-#
-def parse_expr(tokens):
- if (not tokens) or tokens[0] != '(':
- raise syntax_error, 'expected "("'
- tokens = tokens[1:]
- expr = []
- while 1:
- if not tokens:
- raise syntax_error, 'missing ")"'
- if tokens[0] == ')':
- return expr, tokens[1:]
- elif tokens[0] == '(':
- subexpr, tokens = parse_expr(tokens)
- expr.append(subexpr)
- else:
- expr.append(tokens[0])
- tokens = tokens[1:]
-
-
-# Parse a file (given as file object, not as file name).
-# Return a list of parsed S-expressions found at the top level.
-#
-def parse_file(fp):
- tokens = tokenize_file(fp)
- exprlist = []
- while tokens:
- expr, tokens = parse_expr(tokens)
- exprlist.append(expr)
- return exprlist
-
-
-# EXAMPLE:
-#
-# The input
-# '(hip (hop hur-ray))'
-#
-# passed to tokenize_string() returns the token list
-# ['(', 'hip', '(', 'hop', 'hur-ray', ')', ')']
-#
-# When this is passed to parse_expr() it returns the expression
-# ['hip', ['hop', 'hur-ray']]
-# plus an empty token list (because there are no tokens left.
-#
-# When a file containing the example is passed to parse_file() it returns
-# a list whose only element is the output of parse_expr() above:
-# [['hip', ['hop', 'hur-ray']]]
-
-
-# TOKENIZING:
-#
-# Comments start with semicolon (;) and continue till the end of the line.
-#
-# Tokens are separated by whitespace, except the following characters
-# always form a separate token (outside strings):
-# ( ) '
-# Strings are enclosed in double quotes (") and backslash (\) is used
-# as escape character in strings.
More information about the Python-3000-checkins
mailing list