Package pyffi :: Package formats :: Package cgf :: Class CgfFormat :: Class Data
[hide private]
[frames] | no frames]

Class Data

source code

            object --+            
                     |            
utils.graph.DetailNode --+        
                         |        
    utils.graph.GlobalNode --+    
                             |    
 object_models.FileFormat.Data --+
                                 |
                                CgfFormat.Data

A class to contain the actual cgf data.

Note that L{versions} and L{chunk_table} are not automatically kept in sync with the L{chunks}, but they are resynchronized when calling L{write}.

Instance Methods [hide private]
 
__init__(self, filetype=4294901760, game='Far Cry')
Initialize cgf data.
source code
 
inspect_version_only(self, stream)
This function checks the version only, and is faster than the usual inspect function (which reads the full chunk table).
source code
 
get_global_child_nodes(self, edge_filter=(True, True))
Returns chunks without parent.
source code
 
replace_global_node(self, oldbranch, newbranch, edge_filter=(True, True))
Replace a particular branch in the graph.
source code
generator yielding DetailNodes
get_detail_child_nodes(self, edge_filter=(True, True))
Generator which yields all children of this item in the detail view (by default, all acyclic and active ones).
source code
generator yielding strs
get_detail_child_names(self, edge_filter=(True, True))
Generator which yields all child names of this item in the detail view.
source code
 
inspect(self, stream)
Quickly checks whether the stream appears to contain cgf data, and read the cgf header and chunk table.
source code
 
read(self, stream)
Read a cgf file.
source code
 
write(self, stream)
Write a cgf file.
source code
 
update_versions(self)
Update L{versions} for the given chunks and game.
source code

Inherited from utils.graph.GlobalNode: get_global_child_edge_types, get_global_display, get_global_iterator

Inherited from utils.graph.DetailNode: get_detail_child_edge_types, get_detail_display, get_detail_iterator

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  _link_stack = None
hash(x)
  _block_index_dct = None
hash(x)
  _block_dct = None
hash(x)

Inherited from object_models.FileFormat.Data: user_version, version

Inherited from object_models.FileFormat.Data (private): _byte_order

Instance Variables [hide private]
list of L{CgfFormat.Chunk} chunks
List of chunks (the actual data).
int game
The cgf game.
L{CgfFormat.Header} header
The cgf header.
list of L{int} versions
List of chunk versions.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, filetype=4294901760, game='Far Cry')
(Constructor)

source code 
Initialize cgf data. By default, this creates an empty cgf document of the given filetype and game.
Parameters:
  • filetype (int) - The file type (animation, or geometry).
  • game (str) - The game.
Overrides: object.__init__

inspect_version_only(self, stream)

source code 

This function checks the version only, and is faster than the usual inspect function (which reads the full chunk table). Sets the L{header} and L{game} instance variables if the stream contains a valid cgf file.

Call this function if you simply wish to check that a file is a cgf file without having to parse even the header.

Parameters:
  • stream (file) - The stream from which to read.
Raises:
  • ValueError - If the stream does not contain a cgf file.

get_global_child_nodes(self, edge_filter=(True, True))

source code 
Returns chunks without parent.
Returns:
Generator for global node children.
Overrides: utils.graph.GlobalNode.get_global_child_nodes

replace_global_node(self, oldbranch, newbranch, edge_filter=(True, True))

source code 
Replace a particular branch in the graph.
Overrides: utils.graph.DetailNode.replace_global_node
(inherited documentation)

get_detail_child_nodes(self, edge_filter=(True, True))

source code 

Generator which yields all children of this item in the detail view (by default, all acyclic and active ones).

Override this method if the node has children.

Parameters:
  • edge_filter - The edge type to include.
Returns: generator yielding DetailNodes
Generator for detail tree child nodes.
Overrides: utils.graph.DetailNode.get_detail_child_nodes
(inherited documentation)

get_detail_child_names(self, edge_filter=(True, True))

source code 

Generator which yields all child names of this item in the detail view.

Override this method if the node has children.

Returns: generator yielding strs
Generator for detail tree child names.
Overrides: utils.graph.DetailNode.get_detail_child_names
(inherited documentation)

inspect(self, stream)

source code 

Quickly checks whether the stream appears to contain cgf data, and read the cgf header and chunk table. Resets stream to original position.

Call this function if you only need to inspect the header and chunk table.

Parameters:
  • stream (file) - The file to inspect.
Returns:
True if stream is of particular format, False otherwise.
Overrides: object_models.FileFormat.Data.inspect

read(self, stream)

source code 
Read a cgf file. Does not reset stream position.
Parameters:
  • stream (file) - The stream from which to read.
Overrides: object_models.FileFormat.Data.read

write(self, stream)

source code 
Write a cgf file. The L{header} and L{chunk_table} are recalculated from L{chunks}. Returns number of padding bytes written (this is for debugging purposes only).
Parameters:
  • stream (file) - The stream to which to write.
Returns:
Number of padding bytes written.
Overrides: object_models.FileFormat.Data.write