Beispiel #1
0
 def zpaq(self, content):
     fd_in = self.write(content)
     path = self.new_path(suffix='.zpaq')
     sh.zpaq('add', path, fd_in.name, '-method', '6')
     fd = open(path, 'rb')
     r = fd.read()
     os.remove(fd_in.name)
     os.remove(fd.name)
     return r
Beispiel #2
0
 def un_zpaq(self, content):
     fd_in = self.write(content, suffix='.zpaq')
     d = self.new_path()
     sh.zpaq('extract', fd_in.name, '-to', d)
     try:
         for r, dirs, files in os.walk(d):
             for f in files:
                 with open(os.path.join(r, f), 'rb') as fd:
                     return fd.read()
     finally:
         os.remove(fd_in.name)
         shutil.rmtree(d)