Package pyffi :: Package spells :: Package nif :: Module dump :: Class SpellExportPixelData
[hide private]
[frames] | no frames]

Class SpellExportPixelData

source code

object --+        
         |        
     Spell --+    
             |    
      NifSpell --+
                 |
                SpellExportPixelData

Export embedded images as DDS files. If the toaster's --dryrun option is enabled, the image is written to a temporary file, otherwise, if no further path information is stored in the nif, it is written to <nifname>-pixeldata-<n>.dds. If a path is stored in the nif, then the original file path is used.

The --arg option is used to strip the folder part of the path and to replace it with something else (this is sometimes useful, such as in Bully nft files).

The file extension is forced to .dds.

Instance Methods [hide private]
 
__init__(self, *args, **kwargs)
Initialize the spell data.
source code
bool
datainspect(self)
This is called after pyffi.object_models.FileFormat.Data.inspect has been called, and before pyffi.object_models.FileFormat.Data.read is called.
source code
bool
branchinspect(self, branch)
Like _branchinspect, but for customization: can be overridden to perform an extra inspection (the default implementation always returns True).
source code
bool
branchentry(self, branch)
Cast the spell on the given branch.
source code
 
get_toast_pixeldata_stream(self, texture_filename) source code
 
save_as_dds(self, pixeldata, texture_filename)
Save pixeldata as dds file, using the specified filename.
source code

Inherited from NifSpell: inspectblocktype

Inherited from NifSpell (private): _datainspect

Inherited from Spell: branchexit, dataentry, dataexit, recurse

Inherited from Spell (private): _branchinspect

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

Class Methods [hide private]
 
get_toast_stream(cls, toaster, filename, test_exists=False)
We do not toast the original file, so stream construction is delegated to get_toast_pixeldata_stream.
source code

Inherited from Spell: toastentry, toastexit

Static Methods [hide private]
 
get_pixeldata_head_root(texture_filename)
Transform NiSourceTexture.file_name into something workable.
source code
Class Variables [hide private]
  SPELLNAME = 'dump_pixeldata'
A str describing how to refer to the spell from the command line.

Inherited from Spell: READONLY, changed, data, stream, toaster

Instance Variables [hide private]
  pixeldata_counter
Increments on each pixel data block.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, *args, **kwargs)
(Constructor)

source code 
Initialize the spell data.
Parameters:
  • data - The file data.
  • stream - The file stream.
  • toaster - The toaster this spell is called from (optional).
Overrides: object.__init__
(inherited documentation)

datainspect(self)

source code 
This is called after pyffi.object_models.FileFormat.Data.inspect has been called, and before pyffi.object_models.FileFormat.Data.read is called. Override this function for customization.
Returns: bool
True if the file must be processed, False otherwise.
Overrides: Spell.datainspect
(inherited documentation)

branchinspect(self, branch)

source code 
Like _branchinspect, but for customization: can be overridden to perform an extra inspection (the default implementation always returns True).
Parameters:
  • branch - The branch to check.
Returns: bool
True if the branch must be processed, False otherwise.
Overrides: Spell.branchinspect
(inherited documentation)

branchentry(self, branch)

source code 

Cast the spell on the given branch. First called with branch equal to data's children, then the grandchildren, and so on. The default implementation simply returns True.

Typically, you will override this function to perform an operation on a particular block type and/or to stop recursion at particular block types.

Parameters:
  • branch - The branch to cast the spell on.
Returns: bool
True if the children must be processed, False otherwise.
Overrides: Spell.branchentry
(inherited documentation)

get_toast_stream(cls, toaster, filename, test_exists=False)
Class Method

source code 
We do not toast the original file, so stream construction is delegated to get_toast_pixeldata_stream.
Overrides: Spell.get_toast_stream