pyffi :: spells :: nif :: fix :: SpellCleanStringPalette :: Class SpellCleanStringPalette
[hide private]
[frames] | no frames]

Class SpellCleanStringPalette

source code

object --+        
         |        
     Spell --+    
             |    
      NifSpell --+
                 |
                SpellCleanStringPalette
Known Subclasses:

Remove unused strings from string palette.
Instance Methods [hide private]
 
substitute(self, old_string)
Helper function to substitute strings in the string palette, to allow subclasses of this spell can modify the strings.
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)
Parses string palette of either a single controller sequence, or of all controller sequences in a controller manager.
source code

Inherited from NifSpell: inspectblocktype

Inherited from NifSpell (private): _datainspect

Inherited from Spell: __init__, 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]

Inherited from Spell: get_toast_stream, toastentry, toastexit

Class Variables [hide private]
  SPELLNAME = 'fix_cleanstringpalette'
A str describing how to refer to the spell from the command line.
  READONLY = False
A bool which determines whether the spell is read only or not.

Inherited from Spell: changed, data, stream, toaster

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

substitute(self, old_string)

source code 
Helper function to substitute strings in the string palette, to allow subclasses of this spell can modify the strings. This implementation returns string unmodified.

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 

Parses string palette of either a single controller sequence, or of all controller sequences in a controller manager.

>>> seq = NifFormat.NiControllerSequence()
>>> seq.string_palette = NifFormat.NiStringPalette()
>>> block = seq.add_controlled_block()
>>> block.string_palette = seq.string_palette
>>> block.set_variable_1("there")
>>> block.set_node_name("hello")
>>> block.string_palette.palette.add_string("test")
12
>>> seq.string_palette.palette.get_all_strings()
['there', 'hello', 'test']
>>> SpellCleanStringPalette().branchentry(seq)
pyffi.toaster:INFO:parsing string palette
False
>>> seq.string_palette.palette.get_all_strings()
['hello', 'there']
>>> block.get_variable_1()
'there'
>>> block.get_node_name()
'hello'
Parameters:
  • branch - The branch to cast the spell on.
Returns: bool
True if the children must be processed, False otherwise.
Overrides: Spell.branchentry