def processAccessible(self, encode, data): ''' Process the accessible paths for the provided data. ''' assert isinstance(encode, EncodeModel), 'Invalid encode model %s' % encode assert isinstance(data, DataModel), 'Invalid data model %s' % data if data.accessibleIsProcessed: return data.accessibleIsProcessed = True if data.accessiblePath is None: return assert isinstance(data.accessiblePath, Path), 'Invalid path %s' % data.accessiblePath #TODO: Make sure when placing the accessible paths that there isn't already an accessible path # that already returns the inherited model see the example for MetaData and ImageData in relation # with MetaInfo and ImageInfo accessible = list(findGetAllAccessible(data.accessiblePath)) # These paths will get updated in the encode model when the data model path is updated # because they are extended from the base path. assert isinstance(encode.modelType, TypeModel) for parentType in encode.modelType.parents(): parentPath = findGetModel(data.accessiblePath, parentType) if parentPath: accessiblePaths = findGetAllAccessible(parentPath) if accessiblePaths: data.modelPaths[parentType] = parentPath accessible.extend(accessiblePaths) if accessible: data.accessible = OrderedDict() for acc in accessible: pathName = pathLongName(acc) if pathName not in data.accessible: data.accessible[pathName] = acc
def processAccessible(self, encode, data): ''' Process the accessible paths for the provided data. ''' assert isinstance(encode, EncodeModel), 'Invalid encode model %s' % encode assert isinstance(data, DataModel), 'Invalid data model %s' % data if data.accessibleIsProcessed: return data.accessibleIsProcessed = True if data.accessiblePath is None: return assert isinstance(data.accessiblePath, Path), 'Invalid path %s' % data.accessiblePath # TODO: Make sure when placing the accessible paths that there isn't already an accessible path # that already returns the inherited model see the example for MetaData and ImageData in relation # with MetaInfo and ImageInfo accessible = list(findGetAllAccessible(data.accessiblePath)) # These paths will get updated in the encode model when the data model path is updated # because they are extended from the base path. assert isinstance(encode.modelType, TypeModel) for parentType in encode.modelType.parents(): parentPath = findGetModel(data.accessiblePath, parentType) if parentPath: accessiblePaths = findGetAllAccessible(parentPath) if accessiblePaths: data.modelPaths[parentType] = parentPath accessible.extend(accessiblePaths) if accessible: data.accessible = OrderedDict() for acc in accessible: pathName = pathLongName(acc) if pathName not in data.accessible: data.accessible[pathName] = acc
def rootPaths(pathOrNode): ''' Provides the root paths. ''' paths = findGetAllAccessible(pathOrNode) paths.sort(key=lambda path: nodeLongName(path.node)) return paths