code: def compress_to(self, archive_path=None):
          
          if archive_path is None:
              archive = tempfile.NamedTemporaryFile(delete=False)
              tar_args = ()
              tar_kwargs = {'fileobj': archive}
              _return = archive.name
          else:
              tar_args = (archive_path)
              tar_kwargs = {}
              _return = archive_path
          tar_kwargs.update({'mode': 'w:gz'})
          with closing(tarfile.open(*tar_args, **tar_kwargs)) as tar:
              tar.add(self.path, arcname=self.file)
  
          return _return
docs: Compress the directory with gzip using tarlib.
  
          :type archive_path: str
          :param archive_path: Path to the archive, if None, a tempfile is created