Package pyffi :: Package formats :: Package nif :: Class NifFormat :: Class Data
[hide private]
[frames] | no frames]

Class Data

source code

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

A class to contain the actual nif data.

Note that L{header} and L{blocks} are not automatically kept in sync with the rest of the nif data, but they are resynchronized when calling L{write}.

Nested Classes [hide private]
  VersionUInt
Instance Methods [hide private]
 
__init__(self, version=67108866, user_version=0, user_version2=0)
Initialize nif data.
source code
 
_getVersion(self) source code
 
_setVersion(self, value) source code
 
_getUserVersion(self) source code
 
_setUserVersion(self, value) source code
 
_getUserVersion2(self) source code
 
_setUserVersion2(self, value) 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 header).
source code
 
get_global_child_nodes(self, edge_filter=(True, True))
Generator which yields all children of this item in the global view, of given edge type (default is edges of type 0).
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 nif data, and read the nif header.
source code
 
read(self, stream)
Read a nif file.
source code
 
write(self, stream)
Write a nif file.
source code
 
_makeBlockList(self, root, block_index_dct, block_type_list, block_type_dct)
This is a helper function for write to set up the list of all blocks, the block index map, and the block type map.
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_dct = None
hash(x)
  _string_list = None
hash(x)
  _block_index_dct = None
hash(x)

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

Instance Variables [hide private]
int version
Version of the data.
int user_version
User version (additional version field) of the data.
int user_version2
The nif user version 2.
list of L{NifFormat.NiObject} blocks
List of blocks.
L{NifFormat.Header} header
The nif header.
str modification
Neo Steam ("neosteam") or Ndoors ("ndoors") or Joymaster Interactive Howling Sword ("jmihs1") or Laxe Lore ("laxelore") style nif?
list of L{NifFormat.NiObject} roots
List of root blocks.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, version=67108866, user_version=0, user_version2=0)
(Constructor)

source code 
Initialize nif data. By default, this creates an empty nif document of the given version and user version.
Parameters:
  • version (int) - The version.
  • user_version (int) - The user version.
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 header). Sets the L{version} and L{user_version} instance variables if the stream contains a valid nif file.

Call this function if you simply wish to check that a file is a nif 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 nif file.

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

source code 

Generator which yields all children of this item in the global view, of given edge type (default is edges of type 0).

Override this method.

Returns:
Generator for global node children.
Overrides: utils.graph.GlobalNode.get_global_child_nodes
(inherited documentation)

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 nif data, and read the nif header. Resets stream to original position.

Call this function if you only need to inspect the header of the nif.

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 nif 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 nif file. The L{header} and the L{blocks} are recalculated from the tree at L{roots} (e.g. list of block types, number of blocks, list of block types, list of strings, list of block sizes etc.).
Parameters:
  • stream (file) - The stream to which to write.
Overrides: object_models.FileFormat.Data.write

_makeBlockList(self, root, block_index_dct, block_type_list, block_type_dct)

source code 
This is a helper function for write to set up the list of all blocks, the block index map, and the block type map.
Parameters:
  • root (L{NifFormat.NiObject}) - The root block, whose tree is to be added to the block list.
  • block_index_dct (dict) - Dictionary mapping blocks in self.blocks to their block index.
  • block_type_list (list of str) - List of all block types.
  • block_type_dct (dict) - Dictionary mapping blocks in self.blocks to their block type index.

Instance Variable Details [hide private]

version

Version of the data.
Get Method:
_getVersion(self)
Set Method:
_setVersion(self, value)

user_version

User version (additional version field) of the data.
Get Method:
_getUserVersion(self)
Set Method:
_setUserVersion(self, value)

user_version2

The nif user version 2.
Get Method:
_getUserVersion2(self)
Set Method:
_setUserVersion2(self, value)