Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2c2f731

Browse files
committed
[Sjoerd Mullender]
Don't use CL module since all constants are now in cl.
1 parent 1015be3 commit 2c2f731

3 files changed

Lines changed: 64 additions & 65 deletions

File tree

Lib/aifc.py

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,6 @@
135135

136136
import struct
137137
import __builtin__
138-
try:
139-
import CL
140-
except ImportError:
141-
pass
142138

143139
Error = 'aifc.Error'
144140

@@ -378,13 +374,14 @@ def initfp(self, file):
378374
if not self._comm_chunk_read or not self._ssnd_chunk:
379375
raise Error, 'COMM chunk and/or SSND chunk missing'
380376
if self._aifc and self._decomp:
381-
params = [CL.ORIGINAL_FORMAT, 0,
382-
CL.BITS_PER_COMPONENT, self._sampwidth * 8,
383-
CL.FRAME_RATE, self._framerate]
377+
import cl
378+
params = [cl.ORIGINAL_FORMAT, 0,
379+
cl.BITS_PER_COMPONENT, self._sampwidth * 8,
380+
cl.FRAME_RATE, self._framerate]
384381
if self._nchannels == 1:
385-
params[1] = CL.MONO
382+
params[1] = cl.MONO
386383
elif self._nchannels == 2:
387-
params[1] = CL.STEREO_INTERLEAVED
384+
params[1] = cl.STEREO_INTERLEAVED
388385
else:
389386
raise Error, 'cannot compress more than 2 channels'
390387
self._decomp.SetParams(params)
@@ -483,7 +480,8 @@ def readframes(self, nframes):
483480
## if 0: access *: private
484481

485482
def _decomp_data(self, data):
486-
dummy = self._decomp.SetParam(CL.FRAME_BUFFER_SIZE,
483+
import cl
484+
dummy = self._decomp.SetParam(cl.FRAME_BUFFER_SIZE,
487485
len(data) * 2)
488486
return self._decomp.Decompress(len(data) / self._nchannels,
489487
data)
@@ -537,7 +535,7 @@ def _read_comm_chunk(self, chunk):
537535
return
538536
# for ULAW and ALAW try Compression Library
539537
try:
540-
import cl, CL
538+
import cl
541539
except ImportError:
542540
if self._comptype == 'ULAW':
543541
try:
@@ -549,10 +547,10 @@ def _read_comm_chunk(self, chunk):
549547
pass
550548
raise Error, 'cannot read compressed AIFF-C files'
551549
if self._comptype == 'ULAW':
552-
scheme = CL.G711_ULAW
550+
scheme = cl.G711_ULAW
553551
self._framesize = self._framesize / 2
554552
elif self._comptype == 'ALAW':
555-
scheme = CL.G711_ALAW
553+
scheme = cl.G711_ALAW
556554
self._framesize = self._framesize / 2
557555
else:
558556
raise Error, 'unsupported compression type'
@@ -810,8 +808,9 @@ def close(self):
810808
## if 0: access *: private
811809

812810
def _comp_data(self, data):
813-
dum = self._comp.SetParam(CL.FRAME_BUFFER_SIZE, len(data))
814-
dum = self._comp.SetParam(CL.COMPRESSED_BUFFER_SIZE, len(data))
811+
import cl
812+
dum = self._comp.SetParam(cl.FRAME_BUFFER_SIZE, len(data))
813+
dum = self._comp.SetParam(cl.COMPRESSED_BUFFER_SIZE, len(data))
815814
return self._comp.Compress(nframes, data)
816815

817816
def _lin2ulaw(self, data):
@@ -852,7 +851,7 @@ def _init_compression(self):
852851
self._convert = self._lin2adpcm
853852
return
854853
try:
855-
import cl, CL
854+
import cl
856855
except ImportError:
857856
if self._comptype == 'ULAW':
858857
try:
@@ -863,21 +862,21 @@ def _init_compression(self):
863862
pass
864863
raise Error, 'cannot write compressed AIFF-C files'
865864
if self._comptype == 'ULAW':
866-
scheme = CL.G711_ULAW
865+
scheme = cl.G711_ULAW
867866
elif self._comptype == 'ALAW':
868-
scheme = CL.G711_ALAW
867+
scheme = cl.G711_ALAW
869868
else:
870869
raise Error, 'unsupported compression type'
871870
self._comp = cl.OpenCompressor(scheme)
872-
params = [CL.ORIGINAL_FORMAT, 0,
873-
CL.BITS_PER_COMPONENT, self._sampwidth * 8,
874-
CL.FRAME_RATE, self._framerate,
875-
CL.FRAME_BUFFER_SIZE, 100,
876-
CL.COMPRESSED_BUFFER_SIZE, 100]
871+
params = [cl.ORIGINAL_FORMAT, 0,
872+
cl.BITS_PER_COMPONENT, self._sampwidth * 8,
873+
cl.FRAME_RATE, self._framerate,
874+
cl.FRAME_BUFFER_SIZE, 100,
875+
cl.COMPRESSED_BUFFER_SIZE, 100]
877876
if self._nchannels == 1:
878-
params[1] = CL.MONO
877+
params[1] = cl.MONO
879878
elif self._nchannels == 2:
880-
params[1] = CL.STEREO_INTERLEAVED
879+
params[1] = cl.STEREO_INTERLEAVED
881880
else:
882881
raise Error, 'cannot compress more than 2 channels'
883882
self._comp.SetParams(params)

Lib/plat-irix5/jpeg.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,45 +14,45 @@
1414

1515
def compress(imgdata, width, height, bytesperpixel):
1616
global comp
17-
import cl, CL
18-
if comp is None: comp = cl.OpenCompressor(CL.JPEG)
17+
import cl
18+
if comp is None: comp = cl.OpenCompressor(cl.JPEG)
1919
if bytesperpixel == 1:
20-
format = CL.GRAYSCALE
20+
format = cl.GRAYSCALE
2121
elif bytesperpixel == 4:
22-
format = CL.RGBX
22+
format = cl.RGBX
2323
if options['forcegray']:
24-
iformat = CL.GRAYSCALE
24+
iformat = cl.GRAYSCALE
2525
else:
26-
iformat = CL.YUV
26+
iformat = cl.YUV
2727
# XXX How to support 'optimize'?
28-
params = [CL.IMAGE_WIDTH, width, CL.IMAGE_HEIGHT, height, \
29-
CL.ORIGINAL_FORMAT, format, \
30-
CL.ORIENTATION, CL.BOTTOM_UP, \
31-
CL.QUALITY_FACTOR, options['quality'], \
32-
CL.INTERNAL_FORMAT, iformat, \
28+
params = [cl.IMAGE_WIDTH, width, cl.IMAGE_HEIGHT, height, \
29+
cl.ORIGINAL_FORMAT, format, \
30+
cl.ORIENTATION, cl.BOTTOM_UP, \
31+
cl.QUALITY_FACTOR, options['quality'], \
32+
cl.INTERNAL_FORMAT, iformat, \
3333
]
3434
comp.SetParams(params)
3535
jpegdata = comp.Compress(1, imgdata)
3636
return jpegdata
3737

3838
def decompress(jpegdata):
3939
global decomp
40-
import cl, CL
41-
if decomp is None: decomp = cl.OpenDecompressor(CL.JPEG)
40+
import cl
41+
if decomp is None: decomp = cl.OpenDecompressor(cl.JPEG)
4242
headersize = decomp.ReadHeader(jpegdata)
43-
params = [CL.IMAGE_WIDTH, 0, CL.IMAGE_HEIGHT, 0, CL.INTERNAL_FORMAT, 0]
43+
params = [cl.IMAGE_WIDTH, 0, cl.IMAGE_HEIGHT, 0, cl.INTERNAL_FORMAT, 0]
4444
decomp.GetParams(params)
4545
width, height, format = params[1], params[3], params[5]
46-
if format == CL.GRAYSCALE or options['forcegray']:
47-
format = CL.GRAYSCALE
46+
if format == cl.GRAYSCALE or options['forcegray']:
47+
format = cl.GRAYSCALE
4848
bytesperpixel = 1
4949
else:
50-
format = CL.RGBX
50+
format = cl.RGBX
5151
bytesperpixel = 4
5252
# XXX How to support 'smooth'?
53-
params = [CL.ORIGINAL_FORMAT, format, \
54-
CL.ORIENTATION, CL.BOTTOM_UP, \
55-
CL.FRAME_BUFFER_SIZE, width*height*bytesperpixel]
53+
params = [cl.ORIGINAL_FORMAT, format, \
54+
cl.ORIENTATION, cl.BOTTOM_UP, \
55+
cl.FRAME_BUFFER_SIZE, width*height*bytesperpixel]
5656
decomp.SetParams(params)
5757
imgdata = decomp.Decompress(1, jpegdata)
5858
return imgdata, width, height, bytesperpixel

Lib/plat-irix6/jpeg.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,45 +14,45 @@
1414

1515
def compress(imgdata, width, height, bytesperpixel):
1616
global comp
17-
import cl, CL
18-
if comp is None: comp = cl.OpenCompressor(CL.JPEG)
17+
import cl
18+
if comp is None: comp = cl.OpenCompressor(cl.JPEG)
1919
if bytesperpixel == 1:
20-
format = CL.GRAYSCALE
20+
format = cl.GRAYSCALE
2121
elif bytesperpixel == 4:
22-
format = CL.RGBX
22+
format = cl.RGBX
2323
if options['forcegray']:
24-
iformat = CL.GRAYSCALE
24+
iformat = cl.GRAYSCALE
2525
else:
26-
iformat = CL.YUV
26+
iformat = cl.YUV
2727
# XXX How to support 'optimize'?
28-
params = [CL.IMAGE_WIDTH, width, CL.IMAGE_HEIGHT, height, \
29-
CL.ORIGINAL_FORMAT, format, \
30-
CL.ORIENTATION, CL.BOTTOM_UP, \
31-
CL.QUALITY_FACTOR, options['quality'], \
32-
CL.INTERNAL_FORMAT, iformat, \
28+
params = [cl.IMAGE_WIDTH, width, cl.IMAGE_HEIGHT, height,
29+
cl.ORIGINAL_FORMAT, format,
30+
cl.ORIENTATION, cl.BOTTOM_UP,
31+
cl.QUALITY_FACTOR, options['quality'],
32+
cl.INTERNAL_FORMAT, iformat,
3333
]
3434
comp.SetParams(params)
3535
jpegdata = comp.Compress(1, imgdata)
3636
return jpegdata
3737

3838
def decompress(jpegdata):
3939
global decomp
40-
import cl, CL
41-
if decomp is None: decomp = cl.OpenDecompressor(CL.JPEG)
40+
import cl
41+
if decomp is None: decomp = cl.OpenDecompressor(cl.JPEG)
4242
headersize = decomp.ReadHeader(jpegdata)
43-
params = [CL.IMAGE_WIDTH, 0, CL.IMAGE_HEIGHT, 0, CL.INTERNAL_FORMAT, 0]
43+
params = [cl.IMAGE_WIDTH, 0, cl.IMAGE_HEIGHT, 0, cl.INTERNAL_FORMAT, 0]
4444
decomp.GetParams(params)
4545
width, height, format = params[1], params[3], params[5]
46-
if format == CL.GRAYSCALE or options['forcegray']:
47-
format = CL.GRAYSCALE
46+
if format == cl.GRAYSCALE or options['forcegray']:
47+
format = cl.GRAYSCALE
4848
bytesperpixel = 1
4949
else:
50-
format = CL.RGBX
50+
format = cl.RGBX
5151
bytesperpixel = 4
5252
# XXX How to support 'smooth'?
53-
params = [CL.ORIGINAL_FORMAT, format, \
54-
CL.ORIENTATION, CL.BOTTOM_UP, \
55-
CL.FRAME_BUFFER_SIZE, width*height*bytesperpixel]
53+
params = [cl.ORIGINAL_FORMAT, format,
54+
cl.ORIENTATION, cl.BOTTOM_UP,
55+
cl.FRAME_BUFFER_SIZE, width*height*bytesperpixel]
5656
decomp.SetParams(params)
5757
imgdata = decomp.Decompress(1, jpegdata)
5858
return imgdata, width, height, bytesperpixel

0 commit comments

Comments
 (0)