def tar_and_gzip(dir, out_path, filter=None, prefix=''):
 log.warning('tar_and_gzip() is deprecated and will be removed in v0.6.0')
 if (not os.path.isdir(dir)):
  raise IOError(('Not a directory: %r' % (dir,)))
 if (not filter):
  filter = (lambda path: True)
 tar_gz = tarfile.open(out_path, mode='w:gz')
 for (dirpath, dirnames, filenames) in os.walk(dir, followlinks=True):
  for filename in filenames:
   path = os.path.join(dirpath, filename)
   rel_path = path[len(os.path.join(dir, '')):]
   if filter(rel_path):
    real_path = os.path.realpath(path)
    path_in_tar_gz = os.path.join(prefix, rel_path)
    tar_gz.add(real_path, arcname=path_in_tar_gz, recursive=False)
 tar_gz.close()

def tar_and_gzip ( dir , out_path , filter = None , prefix = '' ) : log . warning ( 'tar_and_gzip() is deprecated and will be removed in v0.6.0' ) if ( not os . path . isdir ( dir ) ) : raise IOError ( ( 'Not a directory: %r' % ( dir , ) ) ) if ( not filter ) : filter = ( lambda path : True ) tar_gz = tarfile . open ( out_path , mode = 'w:gz' ) for ( dirpath , dirnames , filenames ) in os . walk ( dir , followlinks = True ) : for filename in filenames : path = os . path . join ( dirpath , filename ) rel_path = path [ len ( os . path . join ( dir , '' ) ) : ] if filter ( rel_path ) : real_path = os . path . realpath ( path ) path_in_tar_gz = os . path . join ( prefix , rel_path ) tar_gz . add ( real_path , arcname = path_in_tar_gz , recursive = False ) tar_gz . close ( )
tar and gzip the given *dir* to a tarball at *out_path* .