From ed2e6b90331ad530fe213ef9113cc128b375f54b Mon Sep 17 00:00:00 2001 From: Steve Slaven Date: Thu, 23 Jul 2009 14:52:44 -0700 Subject: Get rid of some unused functions diff --git a/fusearchive.py b/fusearchive.py index ea2d99e..f97911b 100755 --- a/fusearchive.py +++ b/fusearchive.py @@ -32,15 +32,6 @@ def dmsg(level,message): if level <= debug_level: print str(level) + ": " + str(message) -def flag2mode(flags): - md = {os.O_RDONLY: 'r', os.O_WRONLY: 'w', os.O_RDWR: 'w+'} - m = md[flags & (os.O_RDONLY | os.O_WRONLY | os.O_RDWR)] - - if flags | os.O_APPEND: - m = m.replace('w', 'a', 1) - - return m - # This will write out a data block, it will return a key that can get this # data back later def save_chunk( chunk ): @@ -129,63 +120,6 @@ def load_chunk( key ): return chunk -# Inflate a file, src is a packed file, dest is where the unpacked file -# should go -# we assume our chunks are in storage/ -def inflate( src, dest ): - dmsg( 1, "inflate!" ) - - out = open( dest, "w" ) - - dmsg( 3, "Unpickling: " + src ) - # TODO: return an IO error if inflating fails - inp = gzip.open( src, "r" ) - magic = pickle.load( inp ) - inp.close() - dmsg( 3, "Got data: " + str( magic ) ) - - #pdb.set_trace() - - # Now unserialize the chunks back in to a file - for key in magic[ 'data' ]: - out.write( load_chunk( key ) ) - - dmsg( 2, "File inflated" ) - out.close() - -# TODO: deflate only if the file has been modified - -# Deflate a file, src is the unpacked file, dest is where we want to pack -# to, and we assume storage/ is where chunks are stored -def deflate( src, dest ): - dmsg( 2, "deflate!" ) - inp = open( src, "r" ) - - hashs = [] - # This is retarded: - # http://groups.google.com/group/comp.lang.python/browse_thread/thread/ed25388487b3ac7b - # - # Why can't I just do: - # while( chunk = inp.read( magic_blocksize ) ): - # I though python was supposed to be easier! :( - - while True: - chunk = inp.read( magic_blocksize ) - if len( chunk ) == 0: - break - - key = save_chunk( chunk ) - hashs.append( key ) - - inp.close() - - out = gzip.open( dest, "w" ) - pickle.dump( { - 'stat': os.stat( src ), - 'data': hashs - }, out ) - out.close() - class FuseArchiveStat(fuse.Stat): def __init__(self, stat): self.st_mode = stat.st_mode -- cgit v0.10.2