diff --git a/bob/utils.py b/bob/utils.py index b6880e3..7ce4764 100644 --- a/bob/utils.py +++ b/bob/utils.py @@ -48,6 +48,7 @@ def archive_tree(dir, archive): abspath = os.path.abspath(dir) base_root = None + transposed_base = None is_top_level = False with tarfile.open(archive, 'w:gz') as tar: @@ -61,13 +62,18 @@ def archive_tree(dir, archive): if not base_root: base_root = root - transposed_base = root[len(base_root)+1:] + # No path at all for the top-level directory. + if not is_top_level: + transposed_base = root[len(base_root)+1:] + else: + transposed_base = '' + for file in files: standard_path = os.path.join(root, file) - if is_top_level: + if not transposed_base: transposed_path = file else: transposed_path = os.path.join(transposed_base, file) @@ -75,6 +81,7 @@ def archive_tree(dir, archive): # Add the file to the archive, with the proper transposed path. tar.add(standard_path, arcname=transposed_path) + # Close out the top-level directory marker. is_top_level = False