def findLibResources(self, lib, filter=None): def getCache(lib): cacheId = "resinlib-%s" % lib._path liblist = self._genobj._cache.read(cacheId, dependsOn=None, memory=True) return liblist, cacheId def isSkipFile(f): if [x for x in map(lambda x: re.search(x, f), ignoredFiles) if x!=None]: return True else: return False # - Main -------------------------------------------------------------- cacheList = [] # to poss. populate cache cacheId = "" # will be filled in getCache() ignoredFiles = [r'\.meta$',] # files not considered as resources # create wrapper object libObj = Library(lib, self._genobj._console) # retrieve list of library resources libList, cacheId = getCache(libObj) if libList: inCache = True else: libList = libObj.scanResourcePath() inCache = False # go through list of library resources and add suitable for resource in libList: # scanResourcePath() yields absolute paths to a resource, but # we only want to match against the 'resource' part of it resourcePart = Path.getCommonPrefix(libObj._resourcePath, resource)[2] if not inCache: cacheList.append(resource) if isSkipFile(resource): continue elif (filter and not filter(resourcePart)): continue else: yield resource if not inCache: # cache write self._genobj._cache.write(cacheId, cacheList, memory=True, writeToFile=False) return