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

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __all__ = [
  5.     'MIMEAudio']
  6. import sndhdr
  7. from cStringIO import StringIO
  8. from email import encoders
  9. from email.mime.nonmultipart import MIMENonMultipart
  10. _sndhdr_MIMEmap = {
  11.     'au': 'basic',
  12.     'wav': 'x-wav',
  13.     'aiff': 'x-aiff',
  14.     'aifc': 'x-aiff' }
  15.  
  16. def _whatsnd(data):
  17.     hdr = data[:512]
  18.     fakefile = StringIO(hdr)
  19.     for testfn in sndhdr.tests:
  20.         res = testfn(hdr, fakefile)
  21.         if res is not None:
  22.             return _sndhdr_MIMEmap.get(res[0])
  23.     
  24.  
  25.  
  26. class MIMEAudio(MIMENonMultipart):
  27.     
  28.     def __init__(self, _audiodata, _subtype = None, _encoder = encoders.encode_base64, **_params):
  29.         if _subtype is None:
  30.             _subtype = _whatsnd(_audiodata)
  31.         
  32.         if _subtype is None:
  33.             raise TypeError('Could not find audio MIME subtype')
  34.         _subtype is None
  35.         MIMENonMultipart.__init__(self, 'audio', _subtype, **_params)
  36.         self.set_payload(_audiodata)
  37.         _encoder(self)
  38.  
  39.  
  40.