<s> from kraken . core . maths . math_object import MathObject <EOL> from kraken . core . maths . vec3 import Vec3 <EOL> from kraken . core . maths . xfo import Xfo <EOL> from kraken . core . maths . quat import Quat <EOL> from kraken . core . maths import decodeValue <EOL> def logHierarchy ( kObject ) : <EOL> """<STR_LIT>""" <EOL> print kObject . getDecoratedPath ( ) <EOL> for i in xrange ( kObject . getNumChildren ( ) ) : <EOL> child = kObject . getChildByIndex ( i ) <EOL> logHierarchy ( child ) <EOL> def __convertFromJSON ( jsonData ) : <EOL> if type ( jsonData ) is list : <EOL> newList = [ ] <EOL> for item in jsonData : <EOL> newList . append ( __convertFromJSON ( item ) ) <EOL> return newList <EOL> elif type ( jsonData ) is dict : <EOL> if '<STR_LIT>' in jsonData . keys ( ) : <EOL> return decodeValue ( jsonData ) <EOL> for key , value in jsonData . iteritems ( ) : <EOL> jsonData [ key ] = __convertFromJSON ( value ) <EOL> return jsonData <EOL> def prepareToLoad ( jsonData ) : <EOL> """<STR_LIT>""" <EOL> return __convertFromJSON ( jsonData ) <EOL> def __convertToJSON ( jsonData ) : <EOL> if isinstance ( jsonData , MathObject ) : <EOL> return jsonData . jsonEncode ( ) <EOL> elif type ( jsonData ) is list : <EOL> newList = [ ] <EOL> for item in jsonData : <EOL> newList . append ( __convertToJSON ( item ) ) <EOL> return newList <EOL> elif type ( jsonData ) is dict : <EOL> newDict = { } <EOL> for key , value in jsonData . iteritems ( ) : <EOL> newDict [ key ] = __convertToJSON ( value ) <EOL> return newDict <EOL> return jsonData <EOL> def prepareToSave ( jsonData ) : <EOL> """<STR_LIT>""" <EOL> return __convertToJSON ( jsonData ) <EOL> def __mirrorData ( jsonData , plane ) : <EOL> if isinstance ( jsonData , Vec3 ) : <EOL> return jsonData <EOL> if isinstance ( jsonData , Quat ) : <EOL> newQuat = Quat ( jsonData ) <EOL> newQuat . mirror ( plane ) <EOL> return newQuat <EOL> elif isinstance ( jsonData , Xfo ) : <EOL> newXfo = Xfo ( jsonData ) <EOL> if plane == <NUM_LIT:0> : <EOL> newXfo . tr . x = - newXfo . tr . x <EOL> elif plane == <NUM_LIT:1> : <EOL> newXfo . tr . y = - newXfo . tr . y <EOL> elif plane == <NUM_LIT:2> : <EOL> newXfo . tr . z = - newXfo . tr . z <EOL> newXfo . ori . mirror ( plane ) <EOL> return newXfo <EOL> elif type ( jsonData ) is list : <EOL> newList = [ ] <EOL> for item in jsonData : <EOL> newList . append ( __mirrorData ( item , plane ) ) <EOL> return newList <EOL> elif type ( jsonData ) is dict : <EOL> newDict = { } <EOL> for key , value in jsonData . iteritems ( ) : <EOL> newDict [ key ] = __mirrorData ( value , plane ) <EOL> return newDict <EOL> return jsonData <EOL> def mirrorData ( jsonData , plane ) : <EOL> """<STR_LIT>""" <EOL> return __mirrorData ( jsonData , plane ) </s>
