Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../usr/lib64/python2....
File: sunaudio.py
"""Interpret sun audio headers."""
[0] Fix | Delete
from warnings import warnpy3k
[1] Fix | Delete
warnpy3k("the sunaudio module has been removed in Python 3.0; "
[2] Fix | Delete
"use the sunau module instead", stacklevel=2)
[3] Fix | Delete
del warnpy3k
[4] Fix | Delete
[5] Fix | Delete
[6] Fix | Delete
MAGIC = '.snd'
[7] Fix | Delete
[8] Fix | Delete
class error(Exception):
[9] Fix | Delete
pass
[10] Fix | Delete
[11] Fix | Delete
[12] Fix | Delete
def get_long_be(s):
[13] Fix | Delete
"""Convert a 4-char value to integer."""
[14] Fix | Delete
return (ord(s[0])<<24) | (ord(s[1])<<16) | (ord(s[2])<<8) | ord(s[3])
[15] Fix | Delete
[16] Fix | Delete
[17] Fix | Delete
def gethdr(fp):
[18] Fix | Delete
"""Read a sound header from an open file."""
[19] Fix | Delete
if fp.read(4) != MAGIC:
[20] Fix | Delete
raise error, 'gethdr: bad magic word'
[21] Fix | Delete
hdr_size = get_long_be(fp.read(4))
[22] Fix | Delete
data_size = get_long_be(fp.read(4))
[23] Fix | Delete
encoding = get_long_be(fp.read(4))
[24] Fix | Delete
sample_rate = get_long_be(fp.read(4))
[25] Fix | Delete
channels = get_long_be(fp.read(4))
[26] Fix | Delete
excess = hdr_size - 24
[27] Fix | Delete
if excess < 0:
[28] Fix | Delete
raise error, 'gethdr: bad hdr_size'
[29] Fix | Delete
if excess > 0:
[30] Fix | Delete
info = fp.read(excess)
[31] Fix | Delete
else:
[32] Fix | Delete
info = ''
[33] Fix | Delete
return (data_size, encoding, sample_rate, channels, info)
[34] Fix | Delete
[35] Fix | Delete
[36] Fix | Delete
def printhdr(file):
[37] Fix | Delete
"""Read and print the sound header of a named file."""
[38] Fix | Delete
hdr = gethdr(open(file, 'r'))
[39] Fix | Delete
data_size, encoding, sample_rate, channels, info = hdr
[40] Fix | Delete
while info[-1:] == '\0':
[41] Fix | Delete
info = info[:-1]
[42] Fix | Delete
print 'File name: ', file
[43] Fix | Delete
print 'Data size: ', data_size
[44] Fix | Delete
print 'Encoding: ', encoding
[45] Fix | Delete
print 'Sample rate:', sample_rate
[46] Fix | Delete
print 'Channels: ', channels
[47] Fix | Delete
print 'Info: ', repr(info)
[48] Fix | Delete
[49] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function