mirror of
https://github.com/kennethreitz/bob-builder-1.git
synced 2026-06-05 23:10:17 +00:00
Revert "cleaned up archive_tree function"
This reverts commit 1d03df5c85.
This commit is contained in:
+9
-2
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user