Exemple #1
0
 def parse(self, data):
     """ 
     Parses the SWF.
     
     The @data parameter can be a file object or a SWFStream
     """
     self._data = data = data if isinstance(data, SWFStream) else SWFStream(data)
     self._header = SWFHeader(self._data)
     if self._header.compressed:
         temp = StringIO.StringIO()
         if self._header.compressed_zlib:
             import zlib
             data = data.f.read()
             zip = zlib.decompressobj()
             temp.write(zip.decompress(data))
         else:
             import pylzma
             data.readUI32() #consume compressed length
             data = data.f.read()
             temp.write(pylzma.decompress(data))
         temp.seek(0)
         data = SWFStream(temp)
     self._header._frame_size = data.readRECT()
     self._header._frame_rate = data.readFIXED8()
     self._header._frame_count = data.readUI16()
     self.parse_tags(data)
Exemple #2
0
 def parse(self, data):
     """ 
     Parses the SWF.
     
     The @data parameter can be a file object or a SWFStream
     """
     self._data = data = data if isinstance(data,
                                            SWFStream) else SWFStream(data)
     self._header = SWFHeader(self._data)
     if self._header.compressed:
         temp = StringIO.StringIO()
         if self._header.compressed_zlib:
             import zlib
             data = data.f.read()
             zip = zlib.decompressobj()
             temp.write(zip.decompress(data))
         else:
             import pylzma
             data.readUI32()  #consume compressed length
             data = data.f.read()
             temp.write(pylzma.decompress(data))
         temp.seek(0)
         data = SWFStream(temp)
     self._header._frame_size = data.readRECT()
     self._header._frame_rate = data.readFIXED8()
     self._header._frame_count = data.readUI16()
     self.parse_tags(data)
Exemple #3
0
 def __init__(self, file=None):
     super(SWF, self).__init__()
     self._data = None if file is None else SWFStream(file)
     self._header = None
     if self._data is not None:
         self.parse(self._data)