#NEWLINE# def tar_file( file_to_tar , destination_dir , tar_name = '' ) : #NEWLINE# #INDENT# '\n    tar a file into a desintation dir.\n    :param file_to_tar:\n    :param destination_dir:\n    :param tar_name: optional tar name.\n    :return:\n    ' #NEWLINE# tar_name = ( tar_name or os . path . basename ( file_to_tar ) ) #NEWLINE# tar_path = os . path . join ( tar , '{0}.tar.gz' . format ( tar_name ) ) #NEWLINE# with tarfile . open ( tar_path , 'w:gz' ) as tar : #NEWLINE# #INDENT# tar . add ( file_to_tar , arcname = tar_name ) #NEWLINE# #UNINDENT# return tar_path