summaryrefslogtreecommitdiffstats
path: root/Lib/plat-irix5
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2004-07-18 06:16:08 (GMT)
committerTim Peters <tim.peters@gmail.com>2004-07-18 06:16:08 (GMT)
commit182b5aca27d376b08a2904bed42b751496f932f3 (patch)
treedf13115820dbc879c0fe2eae488c9f8c0215a7da /Lib/plat-irix5
parente6ddc8b20b493fef2e7cffb2e1351fe1d238857e (diff)
downloadcpython-182b5aca27d376b08a2904bed42b751496f932f3.zip
cpython-182b5aca27d376b08a2904bed42b751496f932f3.tar.gz
cpython-182b5aca27d376b08a2904bed42b751496f932f3.tar.bz2
Whitespace normalization, via reindent.py.
Diffstat (limited to 'Lib/plat-irix5')
-rwxr-xr-xLib/plat-irix5/AL.py102
-rwxr-xr-xLib/plat-irix5/CD.py58
-rwxr-xr-xLib/plat-irix5/CL.py38
-rwxr-xr-xLib/plat-irix5/CL_old.py182
-rwxr-xr-xLib/plat-irix5/FL.py58
-rwxr-xr-xLib/plat-irix5/SV.py22
-rwxr-xr-xLib/plat-irix5/cddb.py350
-rwxr-xr-xLib/plat-irix5/cdplayer.py136
-rwxr-xr-xLib/plat-irix5/flp.py30
-rwxr-xr-xLib/plat-irix5/jpeg.py176
-rwxr-xr-xLib/plat-irix5/panel.py344
-rwxr-xr-xLib/plat-irix5/panelparser.py122
-rwxr-xr-xLib/plat-irix5/readcd.py464
-rwxr-xr-xLib/plat-irix5/torgb.py84
14 files changed, 1083 insertions, 1083 deletions
diff --git a/Lib/plat-irix5/AL.py b/Lib/plat-irix5/AL.py
index ed17cde..ec941a2 100755
--- a/Lib/plat-irix5/AL.py
+++ b/Lib/plat-irix5/AL.py
@@ -1,61 +1,61 @@
-RATE_48000 = 48000
-RATE_44100 = 44100
-RATE_32000 = 32000
-RATE_22050 = 22050
-RATE_16000 = 16000
-RATE_11025 = 11025
-RATE_8000 = 8000
+RATE_48000 = 48000
+RATE_44100 = 44100
+RATE_32000 = 32000
+RATE_22050 = 22050
+RATE_16000 = 16000
+RATE_11025 = 11025
+RATE_8000 = 8000
SAMPFMT_TWOSCOMP= 1
-SAMPFMT_FLOAT = 32
-SAMPFMT_DOUBLE = 64
+SAMPFMT_FLOAT = 32
+SAMPFMT_DOUBLE = 64
-SAMPLE_8 = 1
-SAMPLE_16 = 2
- # SAMPLE_24 is the low 24 bits of a long, sign extended to 32 bits
-SAMPLE_24 = 4
+SAMPLE_8 = 1
+SAMPLE_16 = 2
+ # SAMPLE_24 is the low 24 bits of a long, sign extended to 32 bits
+SAMPLE_24 = 4
-MONO = 1
-STEREO = 2
-QUADRO = 4 # 4CHANNEL is not a legal Python name
+MONO = 1
+STEREO = 2
+QUADRO = 4 # 4CHANNEL is not a legal Python name
-INPUT_LINE = 0
-INPUT_MIC = 1
-INPUT_DIGITAL = 2
+INPUT_LINE = 0
+INPUT_MIC = 1
+INPUT_DIGITAL = 2
-MONITOR_OFF = 0
-MONITOR_ON = 1
+MONITOR_OFF = 0
+MONITOR_ON = 1
-ERROR_NUMBER = 0
-ERROR_TYPE = 1
-ERROR_LOCATION_LSP = 2
-ERROR_LOCATION_MSP = 3
-ERROR_LENGTH = 4
+ERROR_NUMBER = 0
+ERROR_TYPE = 1
+ERROR_LOCATION_LSP = 2
+ERROR_LOCATION_MSP = 3
+ERROR_LENGTH = 4
-ERROR_INPUT_UNDERFLOW = 0
-ERROR_OUTPUT_OVERFLOW = 1
+ERROR_INPUT_UNDERFLOW = 0
+ERROR_OUTPUT_OVERFLOW = 1
# These seem to be not supported anymore:
-##HOLD, RELEASE = 0, 1
-##ATTAIL, ATHEAD, ATMARK, ATTIME = 0, 1, 2, 3
-
-DEFAULT_DEVICE = 1
-
-INPUT_SOURCE = 0
-LEFT_INPUT_ATTEN = 1
-RIGHT_INPUT_ATTEN = 2
-INPUT_RATE = 3
-OUTPUT_RATE = 4
-LEFT_SPEAKER_GAIN = 5
-RIGHT_SPEAKER_GAIN = 6
-INPUT_COUNT = 7
-OUTPUT_COUNT = 8
-UNUSED_COUNT = 9
-SYNC_INPUT_TO_AES = 10
-SYNC_OUTPUT_TO_AES = 11
-MONITOR_CTL = 12
-LEFT_MONITOR_ATTEN = 13
-RIGHT_MONITOR_ATTEN = 14
-
-ENUM_VALUE = 0 # only certain values are valid
-RANGE_VALUE = 1 # any value in range is valid
+##HOLD, RELEASE = 0, 1
+##ATTAIL, ATHEAD, ATMARK, ATTIME = 0, 1, 2, 3
+
+DEFAULT_DEVICE = 1
+
+INPUT_SOURCE = 0
+LEFT_INPUT_ATTEN = 1
+RIGHT_INPUT_ATTEN = 2
+INPUT_RATE = 3
+OUTPUT_RATE = 4
+LEFT_SPEAKER_GAIN = 5
+RIGHT_SPEAKER_GAIN = 6
+INPUT_COUNT = 7
+OUTPUT_COUNT = 8
+UNUSED_COUNT = 9
+SYNC_INPUT_TO_AES = 10
+SYNC_OUTPUT_TO_AES = 11
+MONITOR_CTL = 12
+LEFT_MONITOR_ATTEN = 13
+RIGHT_MONITOR_ATTEN = 14
+
+ENUM_VALUE = 0 # only certain values are valid
+RANGE_VALUE = 1 # any value in range is valid
diff --git a/Lib/plat-irix5/CD.py b/Lib/plat-irix5/CD.py
index ad56561..8c1e03b 100755
--- a/Lib/plat-irix5/CD.py
+++ b/Lib/plat-irix5/CD.py
@@ -1,34 +1,34 @@
-ERROR = 0
-NODISC = 1
-READY = 2
-PLAYING = 3
-PAUSED = 4
-STILL = 5
+ERROR = 0
+NODISC = 1
+READY = 2
+PLAYING = 3
+PAUSED = 4
+STILL = 5
-AUDIO = 0
-PNUM = 1
-INDEX = 2
-PTIME = 3
-ATIME = 4
-CATALOG = 5
-IDENT = 6
-CONTROL = 7
+AUDIO = 0
+PNUM = 1
+INDEX = 2
+PTIME = 3
+ATIME = 4
+CATALOG = 5
+IDENT = 6
+CONTROL = 7
-CDDA_DATASIZE = 2352
+CDDA_DATASIZE = 2352
-##CDDA_SUBCODESIZE = (sizeof(struct subcodeQ))
-##CDDA_BLOCKSIZE = (sizeof(struct cdframe))
-##CDDA_NUMSAMPLES = (CDDA_DATASIZE/2)
+##CDDA_SUBCODESIZE = (sizeof(struct subcodeQ))
+##CDDA_BLOCKSIZE = (sizeof(struct cdframe))
+##CDDA_NUMSAMPLES = (CDDA_DATASIZE/2)
##
-##CDQ_PREEMP_MASK = 0xd
-##CDQ_COPY_MASK = 0xb
-##CDQ_DDATA_MASK = 0xd
-##CDQ_BROADCAST_MASK = 0x8
-##CDQ_PREEMPHASIS = 0x1
-##CDQ_COPY_PERMITTED = 0x2
-##CDQ_DIGITAL_DATA = 0x4
-##CDQ_BROADCAST_USE = 0x8
+##CDQ_PREEMP_MASK = 0xd
+##CDQ_COPY_MASK = 0xb
+##CDQ_DDATA_MASK = 0xd
+##CDQ_BROADCAST_MASK = 0x8
+##CDQ_PREEMPHASIS = 0x1
+##CDQ_COPY_PERMITTED = 0x2
+##CDQ_DIGITAL_DATA = 0x4
+##CDQ_BROADCAST_USE = 0x8
##
-##CDQ_MODE1 = 0x1
-##CDQ_MODE2 = 0x2
-##CDQ_MODE3 = 0x3
+##CDQ_MODE1 = 0x1
+##CDQ_MODE2 = 0x2
+##CDQ_MODE3 = 0x3
diff --git a/Lib/plat-irix5/CL.py b/Lib/plat-irix5/CL.py
index 468ecaa..23259c5 100755
--- a/Lib/plat-irix5/CL.py
+++ b/Lib/plat-irix5/CL.py
@@ -1,24 +1,24 @@
# Backward compatible module CL.
# All relevant symbols are now defined in the module cl.
try:
- from cl import *
+ from cl import *
except ImportError:
- from CL_old import *
+ from CL_old import *
else:
- del CompressImage
- del DecompressImage
- del GetAlgorithmName
- del OpenCompressor
- del OpenDecompressor
- del QueryAlgorithms
- del QueryMaxHeaderSize
- del QueryScheme
- del QuerySchemeFromName
- del SetDefault
- del SetMax
- del SetMin
- try:
- del cvt_type
- except NameError:
- pass
- del error
+ del CompressImage
+ del DecompressImage
+ del GetAlgorithmName
+ del OpenCompressor
+ del OpenDecompressor
+ del QueryAlgorithms
+ del QueryMaxHeaderSize
+ del QueryScheme
+ del QuerySchemeFromName
+ del SetDefault
+ del SetMax
+ del SetMin
+ try:
+ del cvt_type
+ except NameError:
+ pass
+ del error
diff --git a/Lib/plat-irix5/CL_old.py b/Lib/plat-irix5/CL_old.py
index d9a4100..967b497 100755
--- a/Lib/plat-irix5/CL_old.py
+++ b/Lib/plat-irix5/CL_old.py
@@ -1,8 +1,8 @@
#
# cl.h - Compression Library typedefs and prototypes
#
-# 01/07/92 Cleanup by Brian Knittel
-# 02/18/92 Original Version by Brian Knittel
+# 01/07/92 Cleanup by Brian Knittel
+# 02/18/92 Original Version by Brian Knittel
#
#
@@ -14,13 +14,13 @@ MAX_NUMBER_OF_ORIGINAL_FORMATS = 32
MONO = 0
STEREO_INTERLEAVED = 1
-# Video
+# Video
# YUV is defined to be the same thing as YCrCb (luma and two chroma components).
-# 422 is appended to YUV (or YCrCb) if the chroma is sub-sampled by 2
-# horizontally, packed as U Y1 V Y2 (byte order).
-# 422HC is appended to YUV (or YCrCb) if the chroma is sub-sampled by 2
-# vertically in addition to horizontally, and is packed the same as
-# 422 except that U & V are not valid on the second line.
+# 422 is appended to YUV (or YCrCb) if the chroma is sub-sampled by 2
+# horizontally, packed as U Y1 V Y2 (byte order).
+# 422HC is appended to YUV (or YCrCb) if the chroma is sub-sampled by 2
+# vertically in addition to horizontally, and is packed the same as
+# 422 except that U & V are not valid on the second line.
#
RGB = 0
RGBX = 1
@@ -29,62 +29,62 @@ RGB332 = 3
GRAYSCALE = 4
Y = 4
-YUV = 5
-YCbCr = 5
-YUV422 = 6 # 4:2:2 sampling
-YCbCr422 = 6 # 4:2:2 sampling
-YUV422HC = 7 # 4:1:1 sampling
-YCbCr422HC = 7 # 4:1:1 sampling
-YUV422DC = 7 # 4:1:1 sampling
-YCbCr422DC = 7 # 4:1:1 sampling
+YUV = 5
+YCbCr = 5
+YUV422 = 6 # 4:2:2 sampling
+YCbCr422 = 6 # 4:2:2 sampling
+YUV422HC = 7 # 4:1:1 sampling
+YCbCr422HC = 7 # 4:1:1 sampling
+YUV422DC = 7 # 4:1:1 sampling
+YCbCr422DC = 7 # 4:1:1 sampling
-BEST_FIT = -1
+BEST_FIT = -1
def BytesPerSample(s):
- if s in (MONO, YUV):
- return 2
- elif s == STEREO_INTERLEAVED:
- return 4
- else:
- return 0
+ if s in (MONO, YUV):
+ return 2
+ elif s == STEREO_INTERLEAVED:
+ return 4
+ else:
+ return 0
def BytesPerPixel(f):
- if f in (RGB, YUV):
- return 3
- elif f in (RGBX, RGBA):
- return 4
- elif f in (RGB332, GRAYSCALE):
- return 1
- else:
- return 2
+ if f in (RGB, YUV):
+ return 3
+ elif f in (RGBX, RGBA):
+ return 4
+ elif f in (RGB332, GRAYSCALE):
+ return 1
+ else:
+ return 2
def AudioFormatName(f):
- if f == MONO:
- return 'MONO'
- elif f == STEREO_INTERLEAVED:
- return 'STEREO_INTERLEAVED'
- else:
- return 'Not a valid format'
+ if f == MONO:
+ return 'MONO'
+ elif f == STEREO_INTERLEAVED:
+ return 'STEREO_INTERLEAVED'
+ else:
+ return 'Not a valid format'
def VideoFormatName(f):
- if f == RGB:
- return 'RGB'
- elif f == RGBX:
- return 'RGBX'
- elif f == RGBA:
- return 'RGBA'
- elif f == RGB332:
- return 'RGB332'
- elif f == GRAYSCALE:
- return 'GRAYSCALE'
- elif f == YUV:
- return 'YUV'
- elif f == YUV422:
- return 'YUV422'
- elif f == YUV422DC:
- return 'YUV422DC'
- else:
- return 'Not a valid format'
+ if f == RGB:
+ return 'RGB'
+ elif f == RGBX:
+ return 'RGBX'
+ elif f == RGBA:
+ return 'RGBA'
+ elif f == RGB332:
+ return 'RGB332'
+ elif f == GRAYSCALE:
+ return 'GRAYSCALE'
+ elif f == YUV:
+ return 'YUV'
+ elif f == YUV422:
+ return 'YUV422'
+ elif f == YUV422DC:
+ return 'YUV422DC'
+ else:
+ return 'Not a valid format'
MAX_NUMBER_OF_AUDIO_ALGORITHMS = 32
MAX_NUMBER_OF_VIDEO_ALGORITHMS = 32
@@ -96,11 +96,11 @@ AUDIO = 0
VIDEO = 1
def AlgorithmNumber(scheme):
- return scheme & 0x7fff
+ return scheme & 0x7fff
def AlgorithmType(scheme):
- return (scheme >> 15) & 1
+ return (scheme >> 15) & 1
def Algorithm(type, n):
- return n | ((type & 1) << 15)
+ return n | ((type & 1) << 15)
#
# "compressionScheme" argument values
@@ -114,7 +114,7 @@ G711_ALAW = Algorithm(AUDIO, 2)
ALAW = Algorithm(AUDIO, 2)
AWARE_MPEG_AUDIO = Algorithm(AUDIO, 3)
AWARE_MULTIRATE = Algorithm(AUDIO, 4)
-
+
UNCOMPRESSED = Algorithm(VIDEO, 0)
UNCOMPRESSED_VIDEO = Algorithm(VIDEO, 0)
RLE = Algorithm(VIDEO, 1)
@@ -130,7 +130,7 @@ RTR1 = Algorithm(VIDEO, 5)
MAX_NUMBER_OF_PARAMS = 256
# Default Parameters
IMAGE_WIDTH = 0
-IMAGE_HEIGHT = 1
+IMAGE_HEIGHT = 1
ORIGINAL_FORMAT = 2
INTERNAL_FORMAT = 3
COMPONENTS = 4
@@ -138,7 +138,7 @@ BITS_PER_COMPONENT = 5
FRAME_RATE = 6
COMPRESSION_RATIO = 7
EXACT_COMPRESSION_RATIO = 8
-FRAME_BUFFER_SIZE = 9
+FRAME_BUFFER_SIZE = 9
COMPRESSED_BUFFER_SIZE = 10
BLOCK_SIZE = 11
PREROLL = 12
@@ -165,10 +165,10 @@ ZOOM_Y = NUMBER_OF_PARAMS + 2
#
# Parameter value types
#
-ENUM_VALUE = 0 # only certain constant values are valid
-RANGE_VALUE = 1 # any value in a given range is valid
-FLOATING_ENUM_VALUE = 2 # only certain constant floating point values are valid
-FLOATING_RANGE_VALUE = 3 # any value in a given floating point range is valid
+ENUM_VALUE = 0 # only certain constant values are valid
+RANGE_VALUE = 1 # any value in a given range is valid
+FLOATING_ENUM_VALUE = 2 # only certain constant floating point values are valid
+FLOATING_RANGE_VALUE = 3 # any value in a given floating point range is valid
#
# Algorithm Functionality
@@ -208,29 +208,29 @@ HEADER_START_CODE = 0xc1C0DEC
# error codes
#
-BAD_NO_BUFFERSPACE = -2 # no space for internal buffers
-BAD_PVBUFFER = -3 # param/val buffer doesn't make sense
-BAD_BUFFERLENGTH_NEG = -4 # negative buffer length
-BAD_BUFFERLENGTH_ODD = -5 # odd length parameter/value buffer
-BAD_PARAM = -6 # invalid parameter
-BAD_COMPRESSION_SCHEME = -7 # compression scheme parameter invalid
-BAD_COMPRESSOR_HANDLE = -8 # compression handle parameter invalid
-BAD_COMPRESSOR_HANDLE_POINTER = -9 # compression handle pointer invalid
-BAD_BUFFER_HANDLE = -10 # buffer handle invalid
-BAD_BUFFER_QUERY_SIZE = -11 # buffer query size too large
-JPEG_ERROR = -12 # error from libjpeg
-BAD_FRAME_SIZE = -13 # frame size invalid
-PARAM_OUT_OF_RANGE = -14 # parameter out of range
-ADDED_ALGORITHM_ERROR = -15 # added algorithm had a unique error
-BAD_ALGORITHM_TYPE = -16 # bad algorithm type
-BAD_ALGORITHM_NAME = -17 # bad algorithm name
-BAD_BUFFERING = -18 # bad buffering calls
-BUFFER_NOT_CREATED = -19 # buffer not created
-BAD_BUFFER_EXISTS = -20 # buffer already created
-BAD_INTERNAL_FORMAT = -21 # invalid internal format
-BAD_BUFFER_POINTER = -22 # invalid buffer pointer
-FRAME_BUFFER_SIZE_ZERO = -23 # frame buffer has zero size
-BAD_STREAM_HEADER = -24 # invalid stream header
-
-BAD_LICENSE = -25 # netls license not valid
-AWARE_ERROR = -26 # error from libawcmp
+BAD_NO_BUFFERSPACE = -2 # no space for internal buffers
+BAD_PVBUFFER = -3 # param/val buffer doesn't make sense
+BAD_BUFFERLENGTH_NEG = -4 # negative buffer length
+BAD_BUFFERLENGTH_ODD = -5 # odd length parameter/value buffer
+BAD_PARAM = -6 # invalid parameter
+BAD_COMPRESSION_SCHEME = -7 # compression scheme parameter invalid
+BAD_COMPRESSOR_HANDLE = -8 # compression handle parameter invalid
+BAD_COMPRESSOR_HANDLE_POINTER = -9 # compression handle pointer invalid
+BAD_BUFFER_HANDLE = -10 # buffer handle invalid
+BAD_BUFFER_QUERY_SIZE = -11 # buffer query size too large
+JPEG_ERROR = -12 # error from libjpeg
+BAD_FRAME_SIZE = -13 # frame size invalid
+PARAM_OUT_OF_RANGE = -14 # parameter out of range
+ADDED_ALGORITHM_ERROR = -15 # added algorithm had a unique error
+BAD_ALGORITHM_TYPE = -16 # bad algorithm type
+BAD_ALGORITHM_NAME = -17 # bad algorithm name
+BAD_BUFFERING = -18 # bad buffering calls
+BUFFER_NOT_CREATED = -19 # buffer not created
+BAD_BUFFER_EXISTS = -20 # buffer already created
+BAD_INTERNAL_FORMAT = -21 # invalid internal format
+BAD_BUFFER_POINTER = -22 # invalid buffer pointer
+FRAME_BUFFER_SIZE_ZERO = -23 # frame buffer has zero size
+BAD_STREAM_HEADER = -24 # invalid stream header
+
+BAD_LICENSE = -25 # netls license not valid
+AWARE_ERROR = -26 # error from libawcmp
diff --git a/Lib/plat-irix5/FL.py b/Lib/plat-irix5/FL.py
index ae665e3..727da4c 100755
--- a/Lib/plat-irix5/FL.py
+++ b/Lib/plat-irix5/FL.py
@@ -7,9 +7,9 @@ _v20 = 1
_v21 = 1
##import fl
##try:
-## _v20 = (fl.get_rgbmode is not None)
+## _v20 = (fl.get_rgbmode is not None)
##except:
-## _v20 = 0
+## _v20 = 0
##del fl
NULL = 0
@@ -20,7 +20,7 @@ EVENT = -1
LABEL_SIZE = 64
if _v20:
- SHORTCUT_SIZE = 32
+ SHORTCUT_SIZE = 32
PLACE_FREE = 0
PLACE_SIZE = 1
PLACE_ASPECT = 2
@@ -119,7 +119,7 @@ TOUCH_BUTTON = 4
INOUT_BUTTON = 5
RETURN_BUTTON = 6
if _v20:
- HIDDEN_RET_BUTTON = 7
+ HIDDEN_RET_BUTTON = 7
BUTTON_BOXTYPE = UP_BOX
BUTTON_COL1 = COL1
BUTTON_COL2 = COL1
@@ -129,20 +129,20 @@ BUTTON_MCOL1 = MCOL
BUTTON_MCOL2 = MCOL
BUTTON_BW = BOUND_WIDTH
if _v20:
- CHART = 4
- BAR_CHART = 0
- HORBAR_CHART = 1
- LINE_CHART = 2
- FILLED_CHART = 3
- SPIKE_CHART = 4
- PIE_CHART = 5
- SPECIALPIE_CHART = 6
- CHART_BOXTYPE = BORDER_BOX
- CHART_COL1 = COL1
- CHART_LCOL = LCOL
- CHART_ALIGN = ALIGN_BOTTOM
- CHART_BW = BOUND_WIDTH
- CHART_MAX = 128
+ CHART = 4
+ BAR_CHART = 0
+ HORBAR_CHART = 1
+ LINE_CHART = 2
+ FILLED_CHART = 3
+ SPIKE_CHART = 4
+ PIE_CHART = 5
+ SPECIALPIE_CHART = 6
+ CHART_BOXTYPE = BORDER_BOX
+ CHART_COL1 = COL1
+ CHART_LCOL = LCOL
+ CHART_ALIGN = ALIGN_BOTTOM
+ CHART_BW = BOUND_WIDTH
+ CHART_MAX = 128
CHOICE = 42
NORMAL_CHOICE = 0
CHOICE_BOXTYPE = DOWN_BOX
@@ -173,11 +173,11 @@ COUNTER_COL2 = 4
COUNTER_LCOL = LCOL
COUNTER_ALIGN = ALIGN_BOTTOM
if _v20:
- COUNTER_BW = BOUND_WIDTH
+ COUNTER_BW = BOUND_WIDTH
else:
- DEFAULT = 51
- RETURN_DEFAULT = 0
- ALWAYS_DEFAULT = 1
+ DEFAULT = 51
+ RETURN_DEFAULT = 0
+ ALWAYS_DEFAULT = 1
DIAL = 22
NORMAL_DIAL = 0
LINE_DIAL = 1
@@ -197,14 +197,14 @@ ALL_FREE = 5
INPUT = 31
NORMAL_INPUT = 0
if _v20:
- FLOAT_INPUT = 1
- INT_INPUT = 2
- HIDDEN_INPUT = 3
- if _v21:
- MULTILINE_INPUT = 4
- SECRET_INPUT = 5
+ FLOAT_INPUT = 1
+ INT_INPUT = 2
+ HIDDEN_INPUT = 3
+ if _v21:
+ MULTILINE_INPUT = 4
+ SECRET_INPUT = 5
else:
- ALWAYS_INPUT = 1
+ ALWAYS_INPUT = 1
INPUT_BOXTYPE = DOWN_BOX
INPUT_COL1 = 13
INPUT_COL2 = 5
diff --git a/Lib/plat-irix5/SV.py b/Lib/plat-irix5/SV.py
index 08fb917..db8efe5 100755
--- a/Lib/plat-irix5/SV.py
+++ b/Lib/plat-irix5/SV.py
@@ -7,16 +7,16 @@ BLANKING_BUFFER_SIZE = 2
MAX_SOURCES = 2
# mode parameter for Bind calls
-IN_OFF = 0 # No Video
-IN_OVER = 1 # Video over graphics
-IN_UNDER = 2 # Video under graphics
-IN_REPLACE = 3 # Video replaces entire win
+IN_OFF = 0 # No Video
+IN_OVER = 1 # Video over graphics
+IN_UNDER = 2 # Video under graphics
+IN_REPLACE = 3 # Video replaces entire win
# mode parameters for LoadMap calls. Specifies buffer, always 256 entries
-INPUT_COLORMAP = 0 # tuples of 8-bit RGB
-CHROMA_KEY_MAP = 1 # tuples of 8-bit RGB
-COLOR_SPACE_MAP = 2 # tuples of 8-bit RGB
-GAMMA_MAP = 3 # tuples of 24-bit red values
+INPUT_COLORMAP = 0 # tuples of 8-bit RGB
+CHROMA_KEY_MAP = 1 # tuples of 8-bit RGB
+COLOR_SPACE_MAP = 2 # tuples of 8-bit RGB
+GAMMA_MAP = 3 # tuples of 24-bit red values
# mode parameters for UseExclusive calls
INPUT = 0
@@ -24,9 +24,9 @@ OUTPUT = 1
IN_OUT = 2
# Format constants for the capture routines
-RGB8_FRAMES = 0 # noninterleaved 8 bit 3:2:3 RBG fields
-RGB32_FRAMES = 1 # 32-bit 8:8:8 RGB frames
-YUV411_FRAMES = 2 # interleaved, 8:2:2 YUV format
+RGB8_FRAMES = 0 # noninterleaved 8 bit 3:2:3 RBG fields
+RGB32_FRAMES = 1 # 32-bit 8:8:8 RGB frames
+YUV411_FRAMES = 2 # interleaved, 8:2:2 YUV format
YUV411_FRAMES_AND_BLANKING_BUFFER = 3
#
diff --git a/Lib/plat-irix5/cddb.py b/Lib/plat-irix5/cddb.py
index c4a95cd..7b2711f 100755
--- a/Lib/plat-irix5/cddb.py
+++ b/Lib/plat-irix5/cddb.py
@@ -20,185 +20,185 @@ _cddbrc = '.cddb'
_DB_ID_NTRACKS = 5
_dbid_map = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ@_=+abcdefghijklmnopqrstuvwxyz'
def _dbid(v):
- if v >= len(_dbid_map):
- return string.zfill(v, 2)
- else:
- return _dbid_map[v]
+ if v >= len(_dbid_map):
+ return string.zfill(v, 2)
+ else:
+ return _dbid_map[v]
def tochash(toc):
- if type(toc) == type(''):
- tracklist = []
- for i in range(2, len(toc), 4):
- tracklist.append((None,
- (int(toc[i:i+2]),
- int(toc[i+2:i+4]))))
- else:
- tracklist = toc
- ntracks = len(tracklist)
- hash = _dbid((ntracks >> 4) & 0xF) + _dbid(ntracks & 0xF)
- if ntracks <= _DB_ID_NTRACKS:
- nidtracks = ntracks
- else:
- nidtracks = _DB_ID_NTRACKS - 1
- min = 0
- sec = 0
- for track in tracklist:
- start, length = track
- min = min + length[0]
- sec = sec + length[1]
- min = min + sec / 60
- sec = sec % 60
- hash = hash + _dbid(min) + _dbid(sec)
- for i in range(nidtracks):
- start, length = tracklist[i]
- hash = hash + _dbid(length[0]) + _dbid(length[1])
- return hash
-
+ if type(toc) == type(''):
+ tracklist = []
+ for i in range(2, len(toc), 4):
+ tracklist.append((None,
+ (int(toc[i:i+2]),
+ int(toc[i+2:i+4]))))
+ else:
+ tracklist = toc
+ ntracks = len(tracklist)
+ hash = _dbid((ntracks >> 4) & 0xF) + _dbid(ntracks & 0xF)
+ if ntracks <= _DB_ID_NTRACKS:
+ nidtracks = ntracks
+ else:
+ nidtracks = _DB_ID_NTRACKS - 1
+ min = 0
+ sec = 0
+ for track in tracklist:
+ start, length = track
+ min = min + length[0]
+ sec = sec + length[1]
+ min = min + sec / 60
+ sec = sec % 60
+ hash = hash + _dbid(min) + _dbid(sec)
+ for i in range(nidtracks):
+ start, length = tracklist[i]
+ hash = hash + _dbid(length[0]) + _dbid(length[1])
+ return hash
+
class Cddb:
- def __init__(self, tracklist):
- if os.environ.has_key('CDDB_PATH'):
- path = os.environ['CDDB_PATH']
- cddb_path = path.split(',')
- else:
- home = os.environ['HOME']
- cddb_path = [home + '/' + _cddbrc]
+ def __init__(self, tracklist):
+ if os.environ.has_key('CDDB_PATH'):
+ path = os.environ['CDDB_PATH']
+ cddb_path = path.split(',')
+ else:
+ home = os.environ['HOME']
+ cddb_path = [home + '/' + _cddbrc]
- self._get_id(tracklist)
+ self._get_id(tracklist)
- for dir in cddb_path:
- file = dir + '/' + self.id + '.rdb'
- try:
- f = open(file, 'r')
- self.file = file
- break
- except IOError:
- pass
- ntracks = int(self.id[:2], 16)
- self.artist = ''
- self.title = ''
- self.track = [None] + [''] * ntracks
- self.trackartist = [None] + [''] * ntracks
- self.notes = []
- if not hasattr(self, 'file'):
- return
- import re
- reg = re.compile(r'^([^.]*)\.([^:]*):[\t ]+(.*)')
- while 1:
- line = f.readline()
- if not line:
- break
- match = reg.match(line)
- if not match:
- print 'syntax error in ' + file
- continue
- name1, name2, value = match.group(1, 2, 3)
- if name1 == 'album':
- if name2 == 'artist':
- self.artist = value
- elif name2 == 'title':
- self.title = value
- elif name2 == 'toc':
- if not self.toc:
- self.toc = value
- if self.toc != value:
- print 'toc\'s don\'t match'
- elif name2 == 'notes':
- self.notes.append(value)
- elif name1[:5] == 'track':
- try:
- trackno = int(name1[5:])
- except strings.atoi_error:
- print 'syntax error in ' + file
- continue
- if trackno > ntracks:
- print 'track number %r in file %r out of range' % (trackno, file)
- continue
- if name2 == 'title':
- self.track[trackno] = value
- elif name2 == 'artist':
- self.trackartist[trackno] = value
- f.close()
- for i in range(2, len(self.track)):
- track = self.track[i]
- # if track title starts with `,', use initial part
- # of previous track's title
- if track and track[0] == ',':
- try:
- off = self.track[i - 1].index(',')
- except ValueError:
- pass
- else:
- self.track[i] = self.track[i-1][:off] \
- + track
+ for dir in cddb_path:
+ file = dir + '/' + self.id + '.rdb'
+ try:
+ f = open(file, 'r')
+ self.file = file
+ break
+ except IOError:
+ pass
+ ntracks = int(self.id[:2], 16)
+ self.artist = ''
+ self.title = ''
+ self.track = [None] + [''] * ntracks
+ self.trackartist = [None] + [''] * ntracks
+ self.notes = []
+ if not hasattr(self, 'file'):
+ return
+ import re
+ reg = re.compile(r'^([^.]*)\.([^:]*):[\t ]+(.*)')
+ while 1:
+ line = f.readline()
+ if not line:
+ break
+ match = reg.match(line)
+ if not match:
+ print 'syntax error in ' + file
+ continue
+ name1, name2, value = match.group(1, 2, 3)
+ if name1 == 'album':
+ if name2 == 'artist':
+ self.artist = value
+ elif name2 == 'title':
+ self.title = value
+ elif name2 == 'toc':
+ if not self.toc:
+ self.toc = value
+ if self.toc != value:
+ print 'toc\'s don\'t match'
+ elif name2 == 'notes':
+ self.notes.append(value)
+ elif name1[:5] == 'track':
+ try:
+ trackno = int(name1[5:])
+ except strings.atoi_error:
+ print 'syntax error in ' + file
+ continue
+ if trackno > ntracks:
+ print 'track number %r in file %r out of range' % (trackno, file)
+ continue
+ if name2 == 'title':
+ self.track[trackno] = value
+ elif name2 == 'artist':
+ self.trackartist[trackno] = value
+ f.close()
+ for i in range(2, len(self.track)):
+ track = self.track[i]
+ # if track title starts with `,', use initial part
+ # of previous track's title
+ if track and track[0] == ',':
+ try:
+ off = self.track[i - 1].index(',')
+ except ValueError:
+ pass
+ else:
+ self.track[i] = self.track[i-1][:off] \
+ + track
- def _get_id(self, tracklist):
- # fill in self.id and self.toc.
- # if the argument is a string ending in .rdb, the part
- # upto the suffix is taken as the id.
- if type(tracklist) == type(''):
- if tracklist[-4:] == '.rdb':
- self.id = tracklist[:-4]
- self.toc = ''
- return
- t = []
- for i in range(2, len(tracklist), 4):
- t.append((None, \
- (int(tracklist[i:i+2]), \
- int(tracklist[i+2:i+4]))))
- tracklist = t
- ntracks = len(tracklist)
- self.id = _dbid((ntracks >> 4) & 0xF) + _dbid(ntracks & 0xF)
- if ntracks <= _DB_ID_NTRACKS:
- nidtracks = ntracks
- else:
- nidtracks = _DB_ID_NTRACKS - 1
- min = 0
- sec = 0
- for track in tracklist:
- start, length = track
- min = min + length[0]
- sec = sec + length[1]
- min = min + sec / 60
- sec = sec % 60
- self.id = self.id + _dbid(min) + _dbid(sec)
- for i in range(nidtracks):
- start, length = tracklist[i]
- self.id = self.id + _dbid(length[0]) + _dbid(length[1])
- self.toc = string.zfill(ntracks, 2)
- for track in tracklist:
- start, length = track
- self.toc = self.toc + string.zfill(length[0], 2) + \
- string.zfill(length[1], 2)
+ def _get_id(self, tracklist):
+ # fill in self.id and self.toc.
+ # if the argument is a string ending in .rdb, the part
+ # upto the suffix is taken as the id.
+ if type(tracklist) == type(''):
+ if tracklist[-4:] == '.rdb':
+ self.id = tracklist[:-4]
+ self.toc = ''
+ return
+ t = []
+ for i in range(2, len(tracklist), 4):
+ t.append((None, \
+ (int(tracklist[i:i+2]), \
+ int(tracklist[i+2:i+4]))))
+ tracklist = t
+ ntracks = len(tracklist)
+ self.id = _dbid((ntracks >> 4) & 0xF) + _dbid(ntracks & 0xF)
+ if ntracks <= _DB_ID_NTRACKS:
+ nidtracks = ntracks
+ else:
+ nidtracks = _DB_ID_NTRACKS - 1
+ min = 0
+ sec = 0
+ for track in tracklist:
+ start, length = track
+ min = min + length[0]
+ sec = sec + length[1]
+ min = min + sec / 60
+ sec = sec % 60
+ self.id = self.id + _dbid(min) + _dbid(sec)
+ for i in range(nidtracks):
+ start, length = tracklist[i]
+ self.id = self.id + _dbid(length[0]) + _dbid(length[1])
+ self.toc = string.zfill(ntracks, 2)
+ for track in tracklist:
+ start, length = track
+ self.toc = self.toc + string.zfill(length[0], 2) + \
+ string.zfill(length[1], 2)
- def write(self):
- import posixpath
- if os.environ.has_key('CDDB_WRITE_DIR'):
- dir = os.environ['CDDB_WRITE_DIR']
- else:
- dir = os.environ['HOME'] + '/' + _cddbrc
- file = dir + '/' + self.id + '.rdb'
- if posixpath.exists(file):
- # make backup copy
- posix.rename(file, file + '~')
- f = open(file, 'w')
- f.write('album.title:\t' + self.title + '\n')
- f.write('album.artist:\t' + self.artist + '\n')
- f.write('album.toc:\t' + self.toc + '\n')
- for note in self.notes:
- f.write('album.notes:\t' + note + '\n')
- prevpref = None
- for i in range(1, len(self.track)):
- if self.trackartist[i]:
- f.write('track%r.artist:\t%s\n' % (i, self.trackartist[i]))
- track = self.track[i]
- try:
- off = track.index(',')
- except ValuError:
- prevpref = None
- else:
- if prevpref and track[:off] == prevpref:
- track = track[off:]
- else:
- prevpref = track[:off]
- f.write('track%r.title:\t%s\n' % (i, track))
- f.close()
+ def write(self):
+ import posixpath
+ if os.environ.has_key('CDDB_WRITE_DIR'):
+ dir = os.environ['CDDB_WRITE_DIR']
+ else:
+ dir = os.environ['HOME'] + '/' + _cddbrc
+ file = dir + '/' + self.id + '.rdb'
+ if posixpath.exists(file):
+ # make backup copy
+ posix.rename(file, file + '~')
+ f = open(file, 'w')
+ f.write('album.title:\t' + self.title + '\n')
+ f.write('album.artist:\t' + self.artist + '\n')
+ f.write('album.toc:\t' + self.toc + '\n')
+ for note in self.notes:
+ f.write('album.notes:\t' + note + '\n')
+ prevpref = None
+ for i in range(1, len(self.track)):
+ if self.trackartist[i]:
+ f.write('track%r.artist:\t%s\n' % (i, self.trackartist[i]))
+ track = self.track[i]
+ try:
+ off = track.index(',')
+ except ValuError:
+ prevpref = None
+ else:
+ if prevpref and track[:off] == prevpref:
+ track = track[off:]
+ else:
+ prevpref = track[:off]
+ f.write('track%r.title:\t%s\n' % (i, track))
+ f.close()
diff --git a/Lib/plat-irix5/cdplayer.py b/Lib/plat-irix5/cdplayer.py
index 0dd3fe0..1c0168f 100755
--- a/Lib/plat-irix5/cdplayer.py
+++ b/Lib/plat-irix5/cdplayer.py
@@ -17,72 +17,72 @@
cdplayerrc = '.cdplayerrc'
class Cdplayer:
- def __init__(self, tracklist):
- import string
- self.artist = ''
- self.title = ''
- if type(tracklist) == type(''):
- t = []
- for i in range(2, len(tracklist), 4):
- t.append((None, \
- (string.atoi(tracklist[i:i+2]), \
- string.atoi(tracklist[i+2:i+4]))))
- tracklist = t
- self.track = [None] + [''] * len(tracklist)
- self.id = 'd' + string.zfill(len(tracklist), 2)
- for track in tracklist:
- start, length = track
- self.id = self.id + string.zfill(length[0], 2) + \
- string.zfill(length[1], 2)
- try:
- import posix
- f = open(posix.environ['HOME'] + '/' + cdplayerrc, 'r')
- except IOError:
- return
- import re
- reg = re.compile(r'^([^:]*):\t(.*)')
- s = self.id + '.'
- l = len(s)
- while 1:
- line = f.readline()
- if line == '':
- break
- if line[:l] == s:
- line = line[l:]
- match = reg.match(line)
- if not match:
- print 'syntax error in ~/' + cdplayerrc
- continue
- name, value = match.group(1, 2)
- if name == 'title':
- self.title = value
- elif name == 'artist':
- self.artist = value
- elif name[:5] == 'track':
- trackno = string.atoi(name[6:])
- self.track[trackno] = value
- f.close()
+ def __init__(self, tracklist):
+ import string
+ self.artist = ''
+ self.title = ''
+ if type(tracklist) == type(''):
+ t = []
+ for i in range(2, len(tracklist), 4):
+ t.append((None, \
+ (string.atoi(tracklist[i:i+2]), \
+ string.atoi(tracklist[i+2:i+4]))))
+ tracklist = t
+ self.track = [None] + [''] * len(tracklist)
+ self.id = 'd' + string.zfill(len(tracklist), 2)
+ for track in tracklist:
+ start, length = track
+ self.id = self.id + string.zfill(length[0], 2) + \
+ string.zfill(length[1], 2)
+ try:
+ import posix
+ f = open(posix.environ['HOME'] + '/' + cdplayerrc, 'r')
+ except IOError:
+ return
+ import re
+ reg = re.compile(r'^([^:]*):\t(.*)')
+ s = self.id + '.'
+ l = len(s)
+ while 1:
+ line = f.readline()
+ if line == '':
+ break
+ if line[:l] == s:
+ line = line[l:]
+ match = reg.match(line)
+ if not match:
+ print 'syntax error in ~/' + cdplayerrc
+ continue
+ name, value = match.group(1, 2)
+ if name == 'title':
+ self.title = value
+ elif name == 'artist':
+ self.artist = value
+ elif name[:5] == 'track':
+ trackno = string.atoi(name[6:])
+ self.track[trackno] = value
+ f.close()
- def write(self):
- import posix
- filename = posix.environ['HOME'] + '/' + cdplayerrc
- try:
- old = open(filename, 'r')
- except IOError:
- old = open('/dev/null', 'r')
- new = open(filename + '.new', 'w')
- s = self.id + '.'
- l = len(s)
- while 1:
- line = old.readline()
- if line == '':
- break
- if line[:l] != s:
- new.write(line)
- new.write(self.id + '.title:\t' + self.title + '\n')
- new.write(self.id + '.artist:\t' + self.artist + '\n')
- for i in range(1, len(self.track)):
- new.write('%s.track.%r:\t%s\n' % (self.id, i, self.track[i]))
- old.close()
- new.close()
- posix.rename(filename + '.new', filename)
+ def write(self):
+ import posix
+ filename = posix.environ['HOME'] + '/' + cdplayerrc
+ try:
+ old = open(filename, 'r')
+ except IOError:
+ old = open('/dev/null', 'r')
+ new = open(filename + '.new', 'w')
+ s = self.id + '.'
+ l = len(s)
+ while 1:
+ line = old.readline()
+ if line == '':
+ break
+ if line[:l] != s:
+ new.write(line)
+ new.write(self.id + '.title:\t' + self.title + '\n')
+ new.write(self.id + '.artist:\t' + self.artist + '\n')
+ for i in range(1, len(self.track)):
+ new.write('%s.track.%r:\t%s\n' % (self.id, i, self.track[i]))
+ old.close()
+ new.close()
+ posix.rename(filename + '.new', filename)
diff --git a/Lib/plat-irix5/flp.py b/Lib/plat-irix5/flp.py
index b22bc1a..4f9175f 100755
--- a/Lib/plat-irix5/flp.py
+++ b/Lib/plat-irix5/flp.py
@@ -80,18 +80,18 @@ def checkcache(filename):
fp.close()
def _unpack_cache(altforms):
- forms = {}
- for name in altforms.keys():
- altobj, altlist = altforms[name]
- obj = _newobj()
- obj.make(altobj)
- list = []
- for altobj in altlist:
- nobj = _newobj()
- nobj.make(altobj)
- list.append(nobj)
- forms[name] = obj, list
- return forms
+ forms = {}
+ for name in altforms.keys():
+ altobj, altlist = altforms[name]
+ obj = _newobj()
+ obj.make(altobj)
+ list = []
+ for altobj in altlist:
+ nobj = _newobj()
+ nobj.make(altobj)
+ list.append(nobj)
+ forms[name] = obj, list
+ return forms
def rdlong(fp):
s = fp.read(4)
@@ -277,8 +277,8 @@ def _parse_line(line):
return line
name, value = match.group(1, 2)
if name[0] == 'N':
- name = string.join(string.split(name),'')
- name = string.lower(name)
+ name = string.join(string.split(name),'')
+ name = string.lower(name)
name = string.capitalize(name)
try:
pf = _parse_func[name]
@@ -292,7 +292,7 @@ def _readline(file):
if not line:
raise EOFError
return line[:-1]
-
+
def _parse_1_line(file):
line = _readline(file)
while line == '':
diff --git a/Lib/plat-irix5/jpeg.py b/Lib/plat-irix5/jpeg.py
index da20d6b..f8fc7e7 100755
--- a/Lib/plat-irix5/jpeg.py
+++ b/Lib/plat-irix5/jpeg.py
@@ -6,7 +6,7 @@
# XXX the resulting file causes weirdness.
class error(Exception):
- pass
+ pass
options = {'quality': 75, 'optimize': 0, 'smooth': 0, 'forcegray': 0}
@@ -14,98 +14,98 @@ 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
+ 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
+ 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)
+ 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)
+ 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)
+ 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)
diff --git a/Lib/plat-irix5/panel.py b/Lib/plat-irix5/panel.py
index 3aa7448..12e62a5 100755
--- a/Lib/plat-irix5/panel.py
+++ b/Lib/plat-irix5/panel.py
@@ -17,82 +17,82 @@ debug = 0
# Test if an object is a list.
#
def is_list(x):
- return type(x) == type([])
+ return type(x) == type([])
# Reverse a list.
#
def reverse(list):
- res = []
- for item in list:
- res.insert(0, item)
- return res
+ 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 []
+ 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 []
+ 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')
+ 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], '=>',
- print item[2]
- else:
- print prefix, '?', item
+ 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], '=>',
+ 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], '=>',
- print item[2]
- else:
- print prefix, '?', item
+ 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], '=>',
+ print item[2]
+ else:
+ print prefix, '?', item
# Exception raised by build_actuator or build_panel.
@@ -103,7 +103,7 @@ panel_error = 'panel error'
# Dummy callback used to initialize the callbacks.
#
def dummy_callback(arg):
- pass
+ pass
# Assign attributes to members of the target.
@@ -111,60 +111,60 @@ def dummy_callback(arg):
# 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
+ 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
+ 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.
@@ -176,27 +176,27 @@ def build_actuator(descr):
# 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()
+ #
+ # 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.
@@ -204,78 +204,78 @@ def build_subactuators(panel, super_act, al):
# 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
+ #
+ # 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
+ # 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 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
+from pnl import * # for export
-dopanel = my_dopanel # override pnl.dopanel
+dopanel = my_dopanel # override pnl.dopanel
diff --git a/Lib/plat-irix5/panelparser.py b/Lib/plat-irix5/panelparser.py
index ee50971..c831c49 100755
--- a/Lib/plat-irix5/panelparser.py
+++ b/Lib/plat-irix5/panelparser.py
@@ -15,47 +15,47 @@ separators = operators + whitespace + ';' + '"'
# 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
+ 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
+ tokens = []
+ while 1:
+ line = fp.readline()
+ if not line: break
+ tokens = tokens + tokenize_string(line)
+ return tokens
# Exception raised by parse_exr.
@@ -71,50 +71,50 @@ syntax_error = 'syntax error'
# 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:]
+ 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
+ tokens = tokenize_file(fp)
+ exprlist = []
+ while tokens:
+ expr, tokens = parse_expr(tokens)
+ exprlist.append(expr)
+ return exprlist
# EXAMPLE:
#
# The input
-# '(hip (hop hur-ray))'
+# '(hip (hop hur-ray))'
#
# passed to tokenize_string() returns the token list
-# ['(', 'hip', '(', 'hop', 'hur-ray', ')', ')']
+# ['(', 'hip', '(', 'hop', 'hur-ray', ')', ')']
#
# When this is passed to parse_expr() it returns the expression
-# ['hip', ['hop', 'hur-ray']]
+# ['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']]]
+# [['hip', ['hop', 'hur-ray']]]
# TOKENIZING:
@@ -123,6 +123,6 @@ def parse_file(fp):
#
# 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.
diff --git a/Lib/plat-irix5/readcd.py b/Lib/plat-irix5/readcd.py
index f278ba4..5453ce4 100755
--- a/Lib/plat-irix5/readcd.py
+++ b/Lib/plat-irix5/readcd.py
@@ -3,242 +3,242 @@
import cd, CD
class Error(Exception):
- pass
+ pass
class _Stop(Exception):
- pass
+ pass
def _doatime(self, cb_type, data):
- if ((data[0] * 60) + data[1]) * 75 + data[2] > self.end:
-## print 'done with list entry', repr(self.listindex)
- raise _Stop
- func, arg = self.callbacks[cb_type]
- if func:
- func(arg, cb_type, data)
+ if ((data[0] * 60) + data[1]) * 75 + data[2] > self.end:
+## print 'done with list entry', repr(self.listindex)
+ raise _Stop
+ func, arg = self.callbacks[cb_type]
+ if func:
+ func(arg, cb_type, data)
def _dopnum(self, cb_type, data):
- if data > self.end:
-## print 'done with list entry', repr(self.listindex)
- raise _Stop
- func, arg = self.callbacks[cb_type]
- if func:
- func(arg, cb_type, data)
+ if data > self.end:
+## print 'done with list entry', repr(self.listindex)
+ raise _Stop
+ func, arg = self.callbacks[cb_type]
+ if func:
+ func(arg, cb_type, data)
class Readcd:
- def __init__(self, *arg):
- if len(arg) == 0:
- self.player = cd.open()
- elif len(arg) == 1:
- self.player = cd.open(arg[0])
- elif len(arg) == 2:
- self.player = cd.open(arg[0], arg[1])
- else:
- raise Error, 'bad __init__ call'
- self.list = []
- self.callbacks = [(None, None)] * 8
- self.parser = cd.createparser()
- self.playing = 0
- self.end = 0
- self.status = None
- self.trackinfo = None
-
- def eject(self):
- self.player.eject()
- self.list = []
- self.end = 0
- self.listindex = 0
- self.status = None
- self.trackinfo = None
- if self.playing:
-## print 'stop playing from eject'
- raise _Stop
-
- def pmsf2msf(self, track, min, sec, frame):
- if not self.status:
- self.cachestatus()
- if track < self.status[5] or track > self.status[6]:
- raise Error, 'track number out of range'
- if not self.trackinfo:
- self.cacheinfo()
- start, total = self.trackinfo[track]
- start = ((start[0] * 60) + start[1]) * 75 + start[2]
- total = ((total[0] * 60) + total[1]) * 75 + total[2]
- block = ((min * 60) + sec) * 75 + frame
- if block > total:
- raise Error, 'out of range'
- block = start + block
- min, block = divmod(block, 75*60)
- sec, frame = divmod(block, 75)
- return min, sec, frame
-
- def reset(self):
- self.list = []
-
- def appendtrack(self, track):
- self.appendstretch(track, track)
-
- def appendstretch(self, start, end):
- if not self.status:
- self.cachestatus()
- if not start:
- start = 1
- if not end:
- end = self.status[6]
- if type(end) == type(0):
- if end < self.status[5] or end > self.status[6]:
- raise Error, 'range error'
- else:
- l = len(end)
- if l == 4:
- prog, min, sec, frame = end
- if prog < self.status[5] or prog > self.status[6]:
- raise Error, 'range error'
- end = self.pmsf2msf(prog, min, sec, frame)
- elif l != 3:
- raise Error, 'syntax error'
- if type(start) == type(0):
- if start < self.status[5] or start > self.status[6]:
- raise Error, 'range error'
- if len(self.list) > 0:
- s, e = self.list[-1]
- if type(e) == type(0):
- if start == e+1:
- start = s
- del self.list[-1]
- else:
- l = len(start)
- if l == 4:
- prog, min, sec, frame = start
- if prog < self.status[5] or prog > self.status[6]:
- raise Error, 'range error'
- start = self.pmsf2msf(prog, min, sec, frame)
- elif l != 3:
- raise Error, 'syntax error'
- self.list.append((start, end))
-
- def settracks(self, list):
- self.list = []
- for track in list:
- self.appendtrack(track)
-
- def setcallback(self, cb_type, func, arg):
- if cb_type < 0 or cb_type >= 8:
- raise Error, 'type out of range'
- self.callbacks[cb_type] = (func, arg)
- if self.playing:
- start, end = self.list[self.listindex]
- if type(end) == type(0):
- if cb_type != CD.PNUM:
- self.parser.setcallback(cb_type, func, arg)
- else:
- if cb_type != CD.ATIME:
- self.parser.setcallback(cb_type, func, arg)
-
- def removecallback(self, cb_type):
- if cb_type < 0 or cb_type >= 8:
- raise Error, 'type out of range'
- self.callbacks[cb_type] = (None, None)
- if self.playing:
- start, end = self.list[self.listindex]
- if type(end) == type(0):
- if cb_type != CD.PNUM:
- self.parser.removecallback(cb_type)
- else:
- if cb_type != CD.ATIME:
- self.parser.removecallback(cb_type)
-
- def gettrackinfo(self, *arg):
- if not self.status:
- self.cachestatus()
- if not self.trackinfo:
- self.cacheinfo()
- if len(arg) == 0:
- return self.trackinfo[self.status[5]:self.status[6]+1]
- result = []
- for i in arg:
- if i < self.status[5] or i > self.status[6]:
- raise Error, 'range error'
- result.append(self.trackinfo[i])
- return result
-
- def cacheinfo(self):
- if not self.status:
- self.cachestatus()
- self.trackinfo = []
- for i in range(self.status[5]):
- self.trackinfo.append(None)
- for i in range(self.status[5], self.status[6]+1):
- self.trackinfo.append(self.player.gettrackinfo(i))
-
- def cachestatus(self):
- self.status = self.player.getstatus()
- if self.status[0] == CD.NODISC:
- self.status = None
- raise Error, 'no disc in player'
-
- def getstatus(self):
- return self.player.getstatus()
-
- def play(self):
- if not self.status:
- self.cachestatus()
- size = self.player.bestreadsize()
- self.listindex = 0
- self.playing = 0
- for i in range(8):
- func, arg = self.callbacks[i]
- if func:
- self.parser.setcallback(i, func, arg)
- else:
- self.parser.removecallback(i)
- if len(self.list) == 0:
- for i in range(self.status[5], self.status[6]+1):
- self.appendtrack(i)
- try:
- while 1:
- if not self.playing:
- if self.listindex >= len(self.list):
- return
- start, end = self.list[self.listindex]
- if type(start) == type(0):
- dummy = self.player.seektrack(
- start)
- else:
- min, sec, frame = start
- dummy = self.player.seek(
- min, sec, frame)
- if type(end) == type(0):
- self.parser.setcallback(
- CD.PNUM, _dopnum, self)
- self.end = end
- func, arg = \
- self.callbacks[CD.ATIME]
- if func:
- self.parser.setcallback(CD.ATIME, func, arg)
- else:
- self.parser.removecallback(CD.ATIME)
- else:
- min, sec, frame = end
- self.parser.setcallback(
- CD.ATIME, _doatime,
- self)
- self.end = (min * 60 + sec) * \
- 75 + frame
- func, arg = \
- self.callbacks[CD.PNUM]
- if func:
- self.parser.setcallback(CD.PNUM, func, arg)
- else:
- self.parser.removecallback(CD.PNUM)
- self.playing = 1
- data = self.player.readda(size)
- if data == '':
- self.playing = 0
- self.listindex = self.listindex + 1
- continue
- try:
- self.parser.parseframe(data)
- except _Stop:
- self.playing = 0
- self.listindex = self.listindex + 1
- finally:
- self.playing = 0
+ def __init__(self, *arg):
+ if len(arg) == 0:
+ self.player = cd.open()
+ elif len(arg) == 1:
+ self.player = cd.open(arg[0])
+ elif len(arg) == 2:
+ self.player = cd.open(arg[0], arg[1])
+ else:
+ raise Error, 'bad __init__ call'
+ self.list = []
+ self.callbacks = [(None, None)] * 8
+ self.parser = cd.createparser()
+ self.playing = 0
+ self.end = 0
+ self.status = None
+ self.trackinfo = None
+
+ def eject(self):
+ self.player.eject()
+ self.list = []
+ self.end = 0
+ self.listindex = 0
+ self.status = None
+ self.trackinfo = None
+ if self.playing:
+## print 'stop playing from eject'
+ raise _Stop
+
+ def pmsf2msf(self, track, min, sec, frame):
+ if not self.status:
+ self.cachestatus()
+ if track < self.status[5] or track > self.status[6]:
+ raise Error, 'track number out of range'
+ if not self.trackinfo:
+ self.cacheinfo()
+ start, total = self.trackinfo[track]
+ start = ((start[0] * 60) + start[1]) * 75 + start[2]
+ total = ((total[0] * 60) + total[1]) * 75 + total[2]
+ block = ((min * 60) + sec) * 75 + frame
+ if block > total:
+ raise Error, 'out of range'
+ block = start + block
+ min, block = divmod(block, 75*60)
+ sec, frame = divmod(block, 75)
+ return min, sec, frame
+
+ def reset(self):
+ self.list = []
+
+ def appendtrack(self, track):
+ self.appendstretch(track, track)
+
+ def appendstretch(self, start, end):
+ if not self.status:
+ self.cachestatus()
+ if not start:
+ start = 1
+ if not end:
+ end = self.status[6]
+ if type(end) == type(0):
+ if end < self.status[5] or end > self.status[6]:
+ raise Error, 'range error'
+ else:
+ l = len(end)
+ if l == 4:
+ prog, min, sec, frame = end
+ if prog < self.status[5] or prog > self.status[6]:
+ raise Error, 'range error'
+ end = self.pmsf2msf(prog, min, sec, frame)
+ elif l != 3:
+ raise Error, 'syntax error'
+ if type(start) == type(0):
+ if start < self.status[5] or start > self.status[6]:
+ raise Error, 'range error'
+ if len(self.list) > 0:
+ s, e = self.list[-1]
+ if type(e) == type(0):
+ if start == e+1:
+ start = s
+ del self.list[-1]
+ else:
+ l = len(start)
+ if l == 4:
+ prog, min, sec, frame = start
+ if prog < self.status[5] or prog > self.status[6]:
+ raise Error, 'range error'
+ start = self.pmsf2msf(prog, min, sec, frame)
+ elif l != 3:
+ raise Error, 'syntax error'
+ self.list.append((start, end))
+
+ def settracks(self, list):
+ self.list = []
+ for track in list:
+ self.appendtrack(track)
+
+ def setcallback(self, cb_type, func, arg):
+ if cb_type < 0 or cb_type >= 8:
+ raise Error, 'type out of range'
+ self.callbacks[cb_type] = (func, arg)
+ if self.playing:
+ start, end = self.list[self.listindex]
+ if type(end) == type(0):
+ if cb_type != CD.PNUM:
+ self.parser.setcallback(cb_type, func, arg)
+ else:
+ if cb_type != CD.ATIME:
+ self.parser.setcallback(cb_type, func, arg)
+
+ def removecallback(self, cb_type):
+ if cb_type < 0 or cb_type >= 8:
+ raise Error, 'type out of range'
+ self.callbacks[cb_type] = (None, None)
+ if self.playing:
+ start, end = self.list[self.listindex]
+ if type(end) == type(0):
+ if cb_type != CD.PNUM:
+ self.parser.removecallback(cb_type)
+ else:
+ if cb_type != CD.ATIME:
+ self.parser.removecallback(cb_type)
+
+ def gettrackinfo(self, *arg):
+ if not self.status:
+ self.cachestatus()
+ if not self.trackinfo:
+ self.cacheinfo()
+ if len(arg) == 0:
+ return self.trackinfo[self.status[5]:self.status[6]+1]
+ result = []
+ for i in arg:
+ if i < self.status[5] or i > self.status[6]:
+ raise Error, 'range error'
+ result.append(self.trackinfo[i])
+ return result
+
+ def cacheinfo(self):
+ if not self.status:
+ self.cachestatus()
+ self.trackinfo = []
+ for i in range(self.status[5]):
+ self.trackinfo.append(None)
+ for i in range(self.status[5], self.status[6]+1):
+ self.trackinfo.append(self.player.gettrackinfo(i))
+
+ def cachestatus(self):
+ self.status = self.player.getstatus()
+ if self.status[0] == CD.NODISC:
+ self.status = None
+ raise Error, 'no disc in player'
+
+ def getstatus(self):
+ return self.player.getstatus()
+
+ def play(self):
+ if not self.status:
+ self.cachestatus()
+ size = self.player.bestreadsize()
+ self.listindex = 0
+ self.playing = 0
+ for i in range(8):
+ func, arg = self.callbacks[i]
+ if func:
+ self.parser.setcallback(i, func, arg)
+ else:
+ self.parser.removecallback(i)
+ if len(self.list) == 0:
+ for i in range(self.status[5], self.status[6]+1):
+ self.appendtrack(i)
+ try:
+ while 1:
+ if not self.playing:
+ if self.listindex >= len(self.list):
+ return
+ start, end = self.list[self.listindex]
+ if type(start) == type(0):
+ dummy = self.player.seektrack(
+ start)
+ else:
+ min, sec, frame = start
+ dummy = self.player.seek(
+ min, sec, frame)
+ if type(end) == type(0):
+ self.parser.setcallback(
+ CD.PNUM, _dopnum, self)
+ self.end = end
+ func, arg = \
+ self.callbacks[CD.ATIME]
+ if func:
+ self.parser.setcallback(CD.ATIME, func, arg)
+ else:
+ self.parser.removecallback(CD.ATIME)
+ else:
+ min, sec, frame = end
+ self.parser.setcallback(
+ CD.ATIME, _doatime,
+ self)
+ self.end = (min * 60 + sec) * \
+ 75 + frame
+ func, arg = \
+ self.callbacks[CD.PNUM]
+ if func:
+ self.parser.setcallback(CD.PNUM, func, arg)
+ else:
+ self.parser.removecallback(CD.PNUM)
+ self.playing = 1
+ data = self.player.readda(size)
+ if data == '':
+ self.playing = 0
+ self.listindex = self.listindex + 1
+ continue
+ try:
+ self.parser.parseframe(data)
+ except _Stop:
+ self.playing = 0
+ self.listindex = self.listindex + 1
+ finally:
+ self.playing = 0
diff --git a/Lib/plat-irix5/torgb.py b/Lib/plat-irix5/torgb.py
index c2b1740..54c86c4 100755
--- a/Lib/plat-irix5/torgb.py
+++ b/Lib/plat-irix5/torgb.py
@@ -51,49 +51,49 @@ uncompress.append('uncompress', '--')
class error(Exception):
- pass
+ 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
+ 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, 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
+ 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, 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