<s> import os <EOL> import re <EOL> import uuid <EOL> import depends_node <EOL> import depends_util <EOL> """<STR_LIT>""" <EOL> def filenameDictForDataPacketType ( dataPacketType ) : <EOL> """<STR_LIT>""" <EOL> foo = dataPacketType ( None , None ) <EOL> return foo . filenames <EOL> def scenegraphLocationString ( dataPacket ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" + str ( dataPacket . sourceNode . uuid ) + "<STR_LIT::>" + dataPacket . sourceOutputName <EOL> def shorthandScenegraphLocationString ( dataPacket ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" + dataPacket . sourceNode . name + "<STR_LIT::>" + dataPacket . sourceOutputName <EOL> def uuidFromScenegraphLocationString ( string ) : <EOL> """<STR_LIT>""" <EOL> if string == "<STR_LIT>" : <EOL> return None <EOL> if not string . startswith ( "<STR_LIT>" ) : <EOL> return None <EOL> uuidString = string . split ( "<STR_LIT::>" ) [ <NUM_LIT:2> ] <EOL> return uuid . UUID ( uuidString ) <EOL> def nodeAndOutputFromScenegraphLocationString ( string , dag ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> outputNodeUUID = uuidFromScenegraphLocationString ( string ) <EOL> outputNode = dag . node ( nUUID = outputNodeUUID ) <EOL> outputNodeOutputName = string . split ( "<STR_LIT::>" ) [ <NUM_LIT:3> ] <EOL> return ( outputNode , outputNode . outputNamed ( outputNodeOutputName ) ) <EOL> except : <EOL> return ( None , None ) <EOL> class DataPacket ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , sourceNode , sourceOutputName ) : <EOL> self . filenames = dict ( ) <EOL> self . sourceNode = sourceNode <EOL> self . sourceOutputName = sourceOutputName <EOL> self . sequenceRange = None <EOL> def typeStr ( self ) : <EOL> """<STR_LIT>""" <EOL> return re . sub ( r'<STR_LIT>' , r'<STR_LIT>' , type ( self ) . __name__ [ len ( '<STR_LIT>' ) : ] ) <EOL> def setFilename ( self , descriptorName , filename ) : <EOL> """<STR_LIT>""" <EOL> if descriptorName not in self . filenames : <EOL> raise RuntimeError ( "<STR_LIT>" % ( shorthandScenegraphLocationString ( self ) , descriptorName ) ) <EOL> self . filenames [ descriptorName ] = filename <EOL> def setSequenceRange ( self , rangeTuple ) : <EOL> """<STR_LIT>""" <EOL> self . sequenceRange = None <EOL> if rangeTuple : <EOL> lowValue = int ( rangeTuple [ <NUM_LIT:0> ] ) if rangeTuple [ <NUM_LIT:0> ] else None <EOL> highValue = int ( rangeTuple [ <NUM_LIT:1> ] ) if rangeTuple [ <NUM_LIT:1> ] else None <EOL> self . sequenceRange = ( lowValue , highValue ) <EOL> def fileDescriptorNamed ( self , descriptorName ) : <EOL> """<STR_LIT>""" <EOL> if descriptorName not in self . filenames : <EOL> raise RuntimeError ( "<STR_LIT>" % ( shorthandScenegraphLocationString ( self ) , descriptorName ) ) <EOL> return depends_util . framespec ( self . filenames [ descriptorName ] , self . sequenceRange ) <EOL> def dataPresent ( self , specificFileDescriptorName = None ) : <EOL> """<STR_LIT>""" <EOL> fdNameList = list ( ) <EOL> if specificFileDescriptorName : <EOL> fdNameList . append ( specificFileDescriptorName ) <EOL> else : <EOL> fdNameList = self . filenames . keys ( ) <EOL> for fileDescriptor in fdNameList : <EOL> if not self . _filesExist ( depends_util . framespec ( self . filenames [ fileDescriptor ] , self . sequenceRange ) ) : <EOL> return False <EOL> return True <EOL> def _filesExist ( self , framespecObject ) : <EOL> """<STR_LIT>""" <EOL> numFilesInList = len ( framespecObject . frames ( ) ) <EOL> if numFilesInList == <NUM_LIT:0> : <EOL> return False <EOL> for file in framespecObject . frames ( ) : <EOL> if not os . path . exists ( file ) : <EOL> return False <EOL> return True <EOL> def loadChildDataPacketsFromPaths ( pathList ) : <EOL> """<STR_LIT>""" <EOL> for path in pathList : <EOL> dpClassDict = depends_util . allClassesOfInheritedTypeFromDir ( path , DataPacket ) <EOL> for dpc in dpClassDict : <EOL> globals ( ) [ dpc ] = dpClassDict [ dpc ] </s>
