From ef2eee04d3511ffa53689ae9143ae64937745202 Mon Sep 17 00:00:00 2001 From: crouzet Date: Wed, 23 Sep 2020 15:37:54 +0200 Subject: [PATCH] =?utf8?q?int=C3=A9gration=20patch=20Nabil=20remplacement?= =?utf8?q?=20exclude=20par=20filter=20dans=20tarfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- commands/package.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/commands/package.py b/commands/package.py index ff289b1..3446730 100644 --- a/commands/package.py +++ b/commands/package.py @@ -152,7 +152,7 @@ def add_files(tar, name_archive, d_content, logger, f_exclude=None): try: key=local_path+"->"+in_archive if key not in already_added: - tar.add(local_path, arcname=in_archive, exclude=f_exclude) + tar.add(local_path, arcname=in_archive, filter=f_exclude) already_added.add(key) logger.write(src.printcolors.printcSuccess(_("OK")), 3) except Exception as e: @@ -162,21 +162,22 @@ def add_files(tar, name_archive, d_content, logger, f_exclude=None): logger.write("\n", 3) return success -def exclude_VCS_and_extensions(filename): +def exclude_VCS_and_extensions(tarinfo): ''' The function that is used to exclude from package the link to the VCS repositories (like .git) :param filename Str: The filname to exclude (or not). - :return: True if the file has to be exclude - :rtype: Boolean + :return: None if the file has to be exclude + :rtype: tarinfo or None ''' + filename = tarinfo.name for dir_name in IGNORED_DIRS: if dir_name in filename: - return True + return None for extension in IGNORED_EXTENSIONS: if filename.endswith(extension): - return True - return False + return None + return tarinfo def produce_relative_launcher(config, logger, @@ -945,7 +946,7 @@ def make_archive(prod_name, prod_info, where): local_path = prod_info.source_dir tar_prod.add(local_path, arcname=prod_name, - exclude=exclude_VCS_and_extensions) + filter=exclude_VCS_and_extensions) tar_prod.close() return path_targz_prod -- 2.39.2