コード例 #1
0
ファイル: __init__.py プロジェクト: Dav1dde/SimTools
    def _parse_file(self):
        self.header = dbpf.Header.parse(self._fileobj)

        enforce(self.header.magic == 'DBPF', ValueError, 'This is not a valid DBPF file.')
        enforce(self.header.version == '1.0', ValueError, 'DBPF Version not supported')
        
        self._extract_indices()
        self._extract_holes()
        self._mark_compressed()
コード例 #2
0
    def _parse_file(self):
        self.header = dbpf.Header.parse(self._fileobj)

        enforce(self.header.magic == 'DBPF', ValueError,
                'This is not a valid DBPF file.')
        enforce(self.header.version == '1.0', ValueError,
                'DBPF Version not supported')

        self._extract_indices()
        self._extract_holes()
        self._mark_compressed()
コード例 #3
0
ファイル: file.py プロジェクト: Dav1dde/SimTools
 def _parse_fsh(self):
     io = BytesIO(self.data)
     
     self.header = fsh.Header.parse(io)
     enforce(self.header.magic == 'SHPI', ValueError, 'magic number mismatch')
     self.directory = fsh.Directory.parse(io)
     io.seek(self.directory.offset, SEEK_SET)
     
     self.entry_header = fsh.EntryHeader.parse(io)
     
     enforce(self.entry_header.size == 0, ValueError,
             'corrupt fsh file or unimplemented feauture')
     compression = None
     if self.entry_header.record_id == 0x60:
         compression = squish.DXT1
     elif self.entry_header.record_id == 0x61:
         compression = squish.DXT3
     
     if not compression is None:
         self.data = squish.decompress_image(io.read(), self.entry_header.width,
                                                        self.entry_header.height,
                                             compression)
コード例 #4
0
ファイル: file.py プロジェクト: Dav1dde/SimTools
    def _parse_s3d(self):
        io = BytesIO(self.data)
        
        self.header = s3d.Header.parse(io)
        self.head = s3d.Head.parse(io)

        self.vert = s3d.Vert.parse(io)
        enforce(self.vert.magic == 'VERT', ValueError, 'magic number mismatch')
        for _ in xrange(self.vert.groups):
            group = s3d.VertexGroup.parse(io)
            
            self.vertices.append((group, [s3d.Vertex.parse(io)
                                          for _ in xrange(group.vertices)]))
        
        self.indx = s3d.Indx.parse(io)
        enforce(self.indx.magic == 'INDX', ValueError, 'magic number mismatch')
        for _ in xrange(self.indx.groups):
            group = s3d.IndexGroup.parse(io)
            
            self.indices.append((group, [s3d.Index.parse(io)
                                         for _ in xrange(group.vertices/3)]))
        
        self.prim = s3d.Prim.parse(io)
        enforce(self.prim.magic == 'PRIM', ValueError, 'magic number mismatch')
        for _ in xrange(self.prim.groups):
            self.primitives.append(s3d.PrimGroup.parse(io))
        
        
        self.mats = s3d.Mats.parse(io)
        enforce(self.mats.magic == 'MATS', ValueError, 'magic number mismatch')
        Group = s3d.MaterialGTE15 if float(self.head.version) >= 1.5 \
                    else s3d.MaterialLT15
        for _ in xrange(self.mats.groups):
            self.materials.append(Group.parse(io))
        
        
        self.anim = s3d.Anim.parse(io)
        enforce(self.anim.magic == 'ANIM', ValueError, 'magic number mismatch')
        for _ in xrange(self.anim.groups):
            self.animations.append(s3d.AnimationGroup.parse(io))
        
        self.prop = s3d.Prop.parse(io)
        enforce(self.prop.magic == 'PROP', ValueError, 'magic number mismatch')
        for _ in xrange(self.prop.groups):
            self.properties.append(s3d.PropertyGroup.parse(io))
        
        self.regp = s3d.Regp.parse(io)
        enforce(self.regp.magic == 'REGP', ValueError, 'magic number mismatch')
        for _ in xrange(self.regp.effects):
            group = s3d.EffectGroup.parse(io)
            
            self.effects.append((group, [s3d.Effect.parse(io)
                                         for _ in xrange(group.effects)]))