home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_2812 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  1.7 KB  |  49 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. from warnings import warnpy3k
  5. warnpy3k('the sunaudio module has been removed in Python 3.0; use the sunau module instead', stacklevel = 2)
  6. del warnpy3k
  7. MAGIC = '.snd'
  8.  
  9. class error(Exception):
  10.     pass
  11.  
  12.  
  13. def get_long_be(s):
  14.     return ord(s[0]) << 24 | ord(s[1]) << 16 | ord(s[2]) << 8 | ord(s[3])
  15.  
  16.  
  17. def gethdr(fp):
  18.     if fp.read(4) != MAGIC:
  19.         raise error, 'gethdr: bad magic word'
  20.     fp.read(4) != MAGIC
  21.     hdr_size = get_long_be(fp.read(4))
  22.     data_size = get_long_be(fp.read(4))
  23.     encoding = get_long_be(fp.read(4))
  24.     sample_rate = get_long_be(fp.read(4))
  25.     channels = get_long_be(fp.read(4))
  26.     excess = hdr_size - 24
  27.     if excess < 0:
  28.         raise error, 'gethdr: bad hdr_size'
  29.     excess < 0
  30.     if excess > 0:
  31.         info = fp.read(excess)
  32.     else:
  33.         info = ''
  34.     return (data_size, encoding, sample_rate, channels, info)
  35.  
  36.  
  37. def printhdr(file):
  38.     hdr = gethdr(open(file, 'r'))
  39.     (data_size, encoding, sample_rate, channels, info) = hdr
  40.     while info[-1:] == '\x00':
  41.         info = info[:-1]
  42.     print 'File name:  ', file
  43.     print 'Data size:  ', data_size
  44.     print 'Encoding:   ', encoding
  45.     print 'Sample rate:', sample_rate
  46.     print 'Channels:   ', channels
  47.     print 'Info:       ', repr(info)
  48.  
  49.