Fix to still use with keyword with Python 2.6
Also add imports for Python 2.6 usage.
This commit is contained in:
parent
7d3a717722
commit
adb7b95796
2 changed files with 8 additions and 6 deletions
|
|
@ -17,6 +17,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import with_statement
|
||||
|
||||
from datetime import datetime
|
||||
import tarfile
|
||||
|
|
@ -24,6 +25,7 @@ import os
|
|||
import shutil
|
||||
import sys
|
||||
from copy import copy
|
||||
from contextlib import closing
|
||||
|
||||
from weboob.core.repositories import Repository
|
||||
|
||||
|
|
@ -106,9 +108,8 @@ class WeboobRepos(ReplApplication):
|
|||
continue
|
||||
|
||||
print 'Create archive for %s' % name
|
||||
tar = tarfile.open(tarname, 'w:gz')
|
||||
tar.add(module_path, arcname=name, exclude=self._archive_excludes)
|
||||
tar.close()
|
||||
with closing(tarfile.open(tarname, 'w:gz')) as tar:
|
||||
tar.add(module_path, arcname=name, exclude=self._archive_excludes)
|
||||
|
||||
# Copy icon.
|
||||
icon_path = os.path.join(module_path, 'favicon.png')
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import with_statement
|
||||
|
||||
import tarfile
|
||||
import posixpath
|
||||
|
|
@ -25,6 +26,7 @@ import re
|
|||
import sys
|
||||
import os
|
||||
from datetime import datetime
|
||||
from contextlib import closing
|
||||
|
||||
from .modules import Module
|
||||
from weboob.tools.log import getLogger
|
||||
|
|
@ -499,9 +501,8 @@ class Repositories(object):
|
|||
progress.progress(0.7, 'Setting up module...')
|
||||
|
||||
# Extract module from tarball.
|
||||
tar = tarfile.open('', 'r:gz', fp)
|
||||
tar.extractall(self.modules_dir)
|
||||
tar.close()
|
||||
with closing(tarfile.open('', 'r:gz', fp)) as tar:
|
||||
tar.extractall(self.modules_dir)
|
||||
|
||||
self.versions.set(info.name, info.version)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue