parameters: (base_name, base_dir, compress="gzip", verbose=0, dry_run=0,
                    owner=None, group=None, logger=None)
return_statement: return archive_name
docstring: Create a (possibly compressed) tar file from all the files under
      'base_dir'.
  
      'compress' must be "gzip" (the default), "bzip2", or None.
  
      'owner' and 'group' can be used to define an owner and a group for the
      archive that is being built. If not provided, the current owner and group
      will be used.
  
      The output tar file will be named 'base_name' +  ".tar", possibly plus
      the appropriate compression extension (".gz", or ".bz2").
  
      Returns the output filename.
docstring_summary: Create a (possibly compressed) tar file from all the files under
      'base_dir'.
docstring_tokens: Create a ( possibly compressed ) tar file from all the files under base_dir .
function: def _make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0,
                    owner=None, group=None, logger=None):
      """Create a (possibly compressed) tar file from all the files under
      'base_dir'.
  
      'compress' must be "gzip" (the default), "bzip2", or None.
  
      'owner' and 'group' can be used to define an owner and a group for the
      archive that is being built. If not provided, the current owner and group
      will be used.
  
      The output tar file will be named 'base_name' +  ".tar", possibly plus
      the appropriate compression extension (".gz", or ".bz2").
  
      Returns the output filename.
      """
      tar_compression = {'gzip': 'gz', None: ''}
      compress_ext = {'gzip': '.gz'}
  
      if _BZ2_SUPPORTED:
          tar_compression['bzip2'] = 'bz2'
          compress_ext['bzip2'] = '.bz2'
  
      # flags for compression program, each element of list will be an argument
      if compress is not None and compress not in compress_ext:
          raise ValueError("bad value for 'compress', or compression format not "
                           "supported : {0}".format(compress))
  
      archive_name = base_name + '.tar' + compress_ext.get(compress, '')
      archive_dir = os.path.dirname(archive_name)
  
      if not os.path.exists(archive_dir):
          if logger is not None:
              logger.info("creating %s", archive_dir)
          if not dry_run:
              os.makedirs(archive_dir)
  
      # creating the tarball
      if logger is not None:
          logger.info('Creating tar archive')
  
      uid = _get_uid(owner)
      gid = _get_gid(group)
  
      def _set_uid_gid(tarinfo):
          if gid is not None:
              tarinfo.gid = gid
              tarinfo.gname = group
          if uid is not None:
              tarinfo.uid = uid
              tarinfo.uname = owner
          return tarinfo
  
      if not dry_run:
          tar = tarfile.open(archive_name, 'w|%s' % tar_compression[compress])
          try:
              tar.add(base_dir, filter=_set_uid_gid)
          finally:
              tar.close()
  
      return archive_name
function_tokens: def _make_tarball ( base_name , base_dir , compress = "gzip" , verbose = 0 , dry_run = 0 , owner = None , group = None , logger = None ) : tar_compression = { 'gzip' : 'gz' , None : '' } compress_ext = { 'gzip' : '.gz' } if _BZ2_SUPPORTED : tar_compression [ 'bzip2' ] = 'bz2' compress_ext [ 'bzip2' ] = '.bz2' # flags for compression program, each element of list will be an argument if compress is not None and compress not in compress_ext : raise ValueError ( "bad value for 'compress', or compression format not " "supported : {0}" . format ( compress ) ) archive_name = base_name + '.tar' + compress_ext . get ( compress , '' ) archive_dir = os . path . dirname ( archive_name ) if not os . path . exists ( archive_dir ) : if logger is not None : logger . info ( "creating %s" , archive_dir ) if not dry_run : os . makedirs ( archive_dir ) # creating the tarball if logger is not None : logger . info ( 'Creating tar archive' ) uid = _get_uid ( owner ) gid = _get_gid ( group ) def _set_uid_gid ( tarinfo ) : if gid is not None : tarinfo . gid = gid tarinfo . gname = group if uid is not None : tarinfo . uid = uid tarinfo . uname = owner return tarinfo if not dry_run : tar = tarfile . open ( archive_name , 'w|%s' % tar_compression [ compress ] ) try : tar . add ( base_dir , filter = _set_uid_gid ) finally : tar . close ( ) return archive_name