def testStaticSet(self): brs = [self._createBlob() for i in range(5)] static_set = StaticSet(self.server) br = static_set.save(brs) d = self.server.describe_blob(br) self.assertEqual(d['camliType'], 'static-set') static_set2 = StaticSet(self.server, br) self.assertEqual(sorted(static_set2.data['members']), sorted(brs))
def _put_directory(con, path, permanode=False): """ Put a directory, this function is called recursively over sub-directories. """ # Initialization of the current directory schema. directory = Directory(con, path) # Since a Directory must point to a static set, we initialize one too. static_set = StaticSet(con) static_set_members = [] # Don't walk recursively with walk, since we already # calling _put_dir recursively. root, dirs, files = Dir(path).walk().next() for f in files: static_set_members.append(con.put_file(os.path.join(root, f))) for d in dirs: static_set_members.append(_put_directory(con, os.path.join(root, d), permanode=False)) static_set_br = static_set.save(static_set_members) # We return the directory blobRef return directory.save(static_set_br, permanode=permanode)
def _put_directory(con, path, permanode=False): """ Put a directory, this function is called recursively over sub-directories. """ # Initialization of the current directory schema. directory = Directory(con, path) # Since a Directory must point to a static set, we initialize one too. static_set = StaticSet(con) static_set_members = [] # Don't walk recursively with walk, since we already # calling _put_dir recursively. root, dirs, files = Dir(path).walk().next() for f in files: static_set_members.append(con.put_file(os.path.join(root, f))) for d in dirs: static_set_members.append( _put_directory(con, os.path.join(root, d), permanode=False)) static_set_br = static_set.save(static_set_members) # We return the directory blobRef return directory.save(static_set_br, permanode=permanode)