Revert "cleaned up archive_tree function"

This reverts commit 1d03df5c85.
This commit is contained in:
David Zuelke
2014-04-07 19:59:55 +02:00
parent c1a92d4ef5
commit 182b3b67fb
+9 -2
View File
@@ -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