diff --git a/weboob/applications/weboobrepos/weboobrepos.py b/weboob/applications/weboobrepos/weboobrepos.py index 67fcc0f7..dbf60405 100644 --- a/weboob/applications/weboobrepos/weboobrepos.py +++ b/weboob/applications/weboobrepos/weboobrepos.py @@ -106,20 +106,21 @@ class WeboobRepos(ReplApplication): continue print 'Create archive for %s' % name - with tarfile.open(tarname, 'w:gz') as tar: - tar.add(module_path, arcname=name, filter=self._archive_filter) + tar = tarfile.open(tarname, 'w:gz') + tar.add(module_path, arcname=name, exclude=self._archive_excludes) + tar.close() # Copy icon. icon_path = os.path.join(module_path, 'favicon.png') if os.path.exists(icon_path): shutil.copy(icon_path, os.path.join(repo_path, '%s.png' % name)) - def _archive_filter(self, tarinfo): + def _archive_excludes(self, filename): # Skip *.pyc files in tarballs. - if tarinfo.name.endswith('.pyc'): - return None + if filename.endswith('.pyc'): + return True # Don't include *.png files in tarball - if tarinfo.name.endswith('.png'): - return None - return tarinfo + if filename.endswith('.png'): + return True + return False diff --git a/weboob/core/repositories.py b/weboob/core/repositories.py index 70821fa2..bed68671 100644 --- a/weboob/core/repositories.py +++ b/weboob/core/repositories.py @@ -496,8 +496,9 @@ class Repositories(object): progress.progress(0.7, 'Setting up module...') # Extract module from tarball. - with tarfile.open('', 'r:gz', fp) as tar: - tar.extractall(self.modules_dir) + tar = tarfile.open('', 'r:gz', fp) + tar.extractall(self.modules_dir) + tar.close() self.versions.set(info.name, info.version)