okfn / messytables

Tools for parsing messy tabular data. This is now superseded by https://github.com/frictionlessdata/tabulator-py
http://messytables.readthedocs.io/
387 stars 110 forks source link

Remove dependency on Python 2.7 by not using ZipFile context manager #43

Closed maxious closed 11 years ago

maxious commented 11 years ago

This resolves errors with the CKAN datastorer when running under Python 2.6 by not using ZipFile context manager (only available in Python 2.7)

e.g.

File "messytables/messytables/zip.py", line 17, in from_fileobj z = zipfile.ZipFile(fileobj, 'r') AttributeError: ZipFile instance has no attribute 'exit'

Inspired by patches from other projects like https://github.com/Diaoul/subliminal/commit/b24af1732619c9174d0e912df9101ea2240d71fb Includes a naive Zip file test case.

domoritz commented 11 years ago

Thank you fix the fix. Can you add some code that closes the file afterwards? Just like they have done in https://github.com/Diaoul/subliminal/commit/b24af1732619c9174d0e912df9101ea2240d71fb. Maybe even wrap the call in a try ... except ... and put the close in the finally block.

maxious commented 11 years ago

Okay I think I close the Zip file handle now.