<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 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 = BytesIO()
            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)