from BitTorrent.Storage import Storage,FilePool # This is a simple test for the functions of the Storage and FilePool classes. # We need to specify how many files to open (maintained by FilePool) and then # pass it to the constructor of Storage # Then we also need to tell Storage the filenames and their sizes (for the time # being, we consider only one filename and one size. # Then we can use the read/write functions to write to the file and finally # close it. if __name__ == '__main__': config = {'enable_bad_libc_workaround': 0} myfiles = ['hello.txt'] sizes = [20] filepool = FilePool(1) s = Storage(config, filepool, zip(myfiles, sizes), False) str = '0123456789' # Write from location 10 s.write(10, str) # Reverse the string, now it should be '9876543210' str = str[::-1] s.write(0, str) s.close # Now the file should contain '98765432100123456789'