def getRange(self, start, cnt): ''' Get the elements from start to start+cnt (include start but not start+cnt) ''' co = self.rootCollection.getRange(0, None) #Can res = co work? Or res.extend(co)? #print co res = [] for i in co: if i in self.filterList: continue res.append(i) #Find all element for i in co: if i in self.filterList: continue childCo = collectionManager.getCollection(i, self.dbInst) childCoContainer = collectionContainer(childCo, self.dbInst) partRes = childCoContainer.getRange(0, None) res.extend(partRes) #print "adding:",partRes,i if not (cnt is None): if len(res) >= start+cnt: #3 element, start=2 cnt=1, OK #3 element, start=3 cnt=1, not OK break #Found all required element, return #print "start:",start #print "cnt:",cnt #print len(res) if cnt is None: return res[start:] return res[start:start+cnt]
def packageCollection(collectionId, dbSysInst, dictElem, folderOnly=False): """ collectionId would be cache system ID or ufsFs url/local path, it would not be cache collectionId """ co = manager.getCollection(collectionId, dbSysInst, folderOnly) res = [] coList = co.getRange(0, None) # print coList for i in coList: if not objTools.isUfsUrl(i): j = objTools.getUfsUrl(i) res.append(j) else: res.append(i) if objTools.isUuid(collectionId): """ file id in cache system: uuid:xxxx-xxxx-xxxx-xxxxx-xxxx """ id = objTools.getUuid(collectionId) # It's a UUID import localLibs.cache.localFileSystemCache as localFileSystemCache try: cacheSys = localFileSystemCache.localFileSystemCache(dbSysInst) cachedPath = cacheSys.getCached(id) targetId = objTools.getUfsUrl(cachedPath) except KeyError: targetId = id elif not objTools.isUfsUrl(collectionId): # It is a local path? targetId = objTools.getUfsUrl(collectionId) else: targetId = collectionId dictElem[targetId] = res
def main(): import localLibs.test.testDbSys as testDbSys res = {} d = testDbSys.testDbSys() co = collectionManager.getCollection('G:/app/wwj/cryptload', d) print '\n\n\n' h=collectionContainer(co, d).getRange(50, 50) print '\n\n\n' print h