Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use filter instead of exclude #17

Merged
merged 1 commit into from
Sep 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions bpt_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,12 @@ def write_archive(self, target):
SHA256 hash).
"""
# Create .tar.bz2 archive of the package directory.
# Put files inside a folder with same name as archive (minus extension)
arcname = os.path.basename(target)[:-len('.tar.bz2')]
with tarfile.open(target, 'w:bz2') as archive:
archive.add(self._directory,
# Put files inside a folder with same name as archive (minus extension)
arcname=os.path.basename(target)[:-len('.tar.bz2')],
exclude=lambda x: x.startswith('.git')) # Don't add .git folder!
arcname=arcname,
filter=lambda x: None if x.name.startswith(arcname + '/.git') else x) # Don't add .git folder!
# Get the size of the archive.
size = os.stat(target).st_size
# Generate a SHA256 hash of the archive.
Expand Down