Skip to content
Snippets Groups Projects
Commit 77c107fd authored by Amir MOHAMMADI's avatar Amir MOHAMMADI
Browse files

Add with statement support to File and HDF5File

parent 496df70c
Branches
Tags
No related merge requests found
Pipeline #
...@@ -5,13 +5,34 @@ import bob.core ...@@ -5,13 +5,34 @@ import bob.core
import bob.extension import bob.extension
bob.extension.load_bob_library('bob.io.base', __file__) bob.extension.load_bob_library('bob.io.base', __file__)
from ._library import File, HDF5File, extensions from ._library import File as File_C, HDF5File as HDF5File_C, extensions
from . import version from . import version
from .version import module as __version__ from .version import module as __version__
from .version import api as __api_version__ from .version import api as __api_version__
import os import os
class File(File_C):
__doc__ = File_C.__doc__
def __enter__(self):
return self
def __exit__(self, type, value, traceback):
self.close()
class HDF5File(HDF5File_C):
__doc__ = HDF5File_C.__doc__
def __enter__(self):
return self
def __exit__(self, type, value, traceback):
self.close()
def _is_string(s): def _is_string(s):
"""Returns ``True`` if the given object is a string """Returns ``True`` if the given object is a string
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment