diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/download_import_cldr.py | 6 | ||||
-rwxr-xr-x | scripts/dump_global.py | 5 |
2 files changed, 4 insertions, 7 deletions
diff --git a/scripts/download_import_cldr.py b/scripts/download_import_cldr.py index bfcab5f..4cc6a4b 100755 --- a/scripts/download_import_cldr.py +++ b/scripts/download_import_cldr.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import contextlib import os import sys import shutil @@ -90,9 +91,8 @@ def main(): shutil.rmtree(common_path) log('Extracting CLDR to \'%s\'', cldr_path) - z = zipfile.ZipFile(zip_path) - z.extractall(cldr_path) - z.close() + with contextlib.closing(zipfile.ZipFile(zip_path)) as z: + z.extractall(cldr_path) subprocess.check_call([ sys.executable, diff --git a/scripts/dump_global.py b/scripts/dump_global.py index ad6c15e..2970bc2 100755 --- a/scripts/dump_global.py +++ b/scripts/dump_global.py @@ -21,11 +21,8 @@ import babel dirname = os.path.join(os.path.dirname(babel.__file__)) filename = os.path.join(dirname, 'global.dat') -fileobj = open(filename, 'rb') -try: +with open(filename, 'rb') as fileobj: data = pickle.load(fileobj) -finally: - fileobj.close() if len(sys.argv) > 1: pprint(data.get(sys.argv[1])) |