<s> import IECore <EOL> import Gaffer <EOL> class DictPath ( Gaffer . Path ) : <EOL> def __init__ ( self , dict , path , root = "<STR_LIT:/>" , filter = None , dictTypes = ( dict , IECore . CompoundData , IECore . CompoundObject ) ) : <EOL> Gaffer . Path . __init__ ( self , path , root , filter = filter ) <EOL> assert ( isinstance ( dict , dictTypes ) ) <EOL> self . __dictTypes = dictTypes <EOL> self . __dict = dict <EOL> def dict ( self ) : <EOL> return self . __dict <EOL> def isValid ( self ) : <EOL> try : <EOL> self . __dictEntry ( ) <EOL> return True <EOL> except : <EOL> return False <EOL> def isLeaf ( self ) : <EOL> try : <EOL> e = self . __dictEntry ( ) <EOL> return not isinstance ( e , self . __dictTypes ) <EOL> except : <EOL> return False <EOL> def propertyNames ( self ) : <EOL> return Gaffer . Path . propertyNames ( self ) + [ "<STR_LIT>" ] <EOL> def property ( self , name ) : <EOL> if name == "<STR_LIT>" : <EOL> with IECore . IgnoredExceptions ( Exception ) : <EOL> e = self . __dictEntry ( ) <EOL> if not isinstance ( e , self . __dictTypes ) : <EOL> return e <EOL> return Gaffer . Path . property ( self , name ) <EOL> def copy ( self ) : <EOL> return DictPath ( self . __dict , self [ : ] , self . root ( ) , self . getFilter ( ) , self . __dictTypes ) <EOL> def _children ( self ) : <EOL> try : <EOL> e = self . __dictEntry ( ) <EOL> if isinstance ( e , self . __dictTypes ) : <EOL> return [ DictPath ( self . __dict , self [ : ] + [ x ] , self . root ( ) , dictTypes = self . __dictTypes ) for x in e . keys ( ) ] <EOL> except : <EOL> return [ ] <EOL> return [ ] <EOL> def __dictEntry ( self ) : <EOL> e = self . __dict <EOL> for p in self : <EOL> e = e [ p ] <EOL> return e <EOL> IECore . registerRunTimeTyped ( DictPath , typeName = "<STR_LIT>" ) </s>
