Package pyffi :: Package spells :: Package cgf
[hide private]
[frames] | no frames]

Source Code for Package pyffi.spells.cgf

 1  """ 
 2  :mod:`pyffi.spells.cgf` ---  Crytek Geometry/Animation (.cgf/.cga) spells 
 3  ========================================================================= 
 4   
 5  .. todo:: Write documentation. 
 6  """ 
 7   
 8  # -------------------------------------------------------------------------- 
 9  # ***** BEGIN LICENSE BLOCK ***** 
10  # 
11  # Copyright (c) 2007-2011, NIF File Format Library and Tools. 
12  # All rights reserved. 
13  # 
14  # Redistribution and use in source and binary forms, with or without 
15  # modification, are permitted provided that the following conditions 
16  # are met: 
17  # 
18  #    * Redistributions of source code must retain the above copyright 
19  #      notice, this list of conditions and the following disclaimer. 
20  # 
21  #    * Redistributions in binary form must reproduce the above 
22  #      copyright notice, this list of conditions and the following 
23  #      disclaimer in the documentation and/or other materials provided 
24  #      with the distribution. 
25  # 
26  #    * Neither the name of the NIF File Format Library and Tools 
27  #      project nor the names of its contributors may be used to endorse 
28  #      or promote products derived from this software without specific 
29  #      prior written permission. 
30  # 
31  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
32  # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
33  # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
34  # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
35  # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
36  # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
37  # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
38  # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
39  # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
40  # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
41  # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
42  # POSSIBILITY OF SUCH DAMAGE. 
43  # 
44  # ***** END LICENSE BLOCK ***** 
45  # -------------------------------------------------------------------------- 
46   
47  import pyffi.spells 
48  from pyffi.formats.cgf import CgfFormat 
49   
50 -class CgfSpell(pyffi.spells.Spell):
51 """Base class for spells for cgf files.""" 52
53 - def _datainspect(self):
54 # call base method 55 if not pyffi.spells.Spell._datainspect(self): 56 return False 57 58 # shortcut for common case (speeds up the check in most cases) 59 if not self.toaster.include_types and not self.toaster.exclude_types: 60 return True 61 62 # check that at least one block type of the header is admissible 63 return any(self.toaster.is_admissible_branch_class(header_type) 64 for header_type in self.data.chunk_table.get_chunk_types())
65
66 - def inspectblocktype(self, block_type):
67 """This function heuristically checks whether the given block type 68 is used in the cgf file, using header information only. When in doubt, 69 it returns ``True``. 70 71 :param block_type: The block type. 72 :type block_type: L{CgfFormat.Chunk} 73 :return: ``False`` if the cgf has no block of the given type, 74 with certainty. ``True`` if the cgf has the block, or if it 75 cannot be determined. 76 :rtype: ``bool`` 77 """ 78 return (block_type in self.data.chunk_table.get_chunk_types())
79
80 -class CgfToaster(pyffi.spells.Toaster):
81 FILEFORMAT = CgfFormat
82