From e6080db08a219419eed54f3cced35b959b21778d Mon Sep 17 00:00:00 2001 From: Manuel Guenther <manuel.guenther@idiap.ch> Date: Fri, 29 Aug 2014 12:59:39 +0200 Subject: [PATCH] renamed create_directories_save to create_directories_safe; added HDF5File.get and .write methods (only in Python bindings). --- bob/io/base/__init__.py | 5 +++-- bob/io/base/hdf5.cpp | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/bob/io/base/__init__.py b/bob/io/base/__init__.py index cc2119a..71dbc36 100644 --- a/bob/io/base/__init__.py +++ b/bob/io/base/__init__.py @@ -24,7 +24,7 @@ def __is_string__(s): return (version_info[0] < 3 and isinstance(s, (str, unicode))) or \ isinstance(s, (bytes, str)) -def create_directories_save(directory, dryrun=False): +def create_directories_safe(directory, dryrun=False): """Creates a directory if it does not exists, with concurrent access support. This function will also create any parent directories that might be required. If the dryrun option is selected, it does not actually create the directory, @@ -138,12 +138,13 @@ def save(array, filename, create_directories = False): """ # create directory if not existent yet if create_directories: - create_directories_save(os.path.dirname(filename)) + create_directories_safe(os.path.dirname(filename)) return File(filename, 'w').write(array) # Just to make it homogenous with the C++ API write = save +read = load def append(array, filename): """Appends the contents of an array-like object to file. diff --git a/bob/io/base/hdf5.cpp b/bob/io/base/hdf5.cpp index dcb4249..0eec57a 100644 --- a/bob/io/base/hdf5.cpp +++ b/bob/io/base/hdf5.cpp @@ -2546,6 +2546,12 @@ static PyMethodDef PyBobIoHDF5File_Methods[] = { METH_VARARGS|METH_KEYWORDS, s_read_doc, }, + { + "get", + (PyCFunction)PyBobIoHDF5File_Read, + METH_VARARGS|METH_KEYWORDS, + s_read_doc, + }, { s_lread_str, (PyCFunction)PyBobIoHDF5File_ListRead, @@ -2570,6 +2576,12 @@ static PyMethodDef PyBobIoHDF5File_Methods[] = { METH_VARARGS|METH_KEYWORDS, s_set_doc, }, + { + "write", + (PyCFunction)PyBobIoHDF5File_Set, + METH_VARARGS|METH_KEYWORDS, + s_set_doc, + }, { s_copy_str, (PyCFunction)PyBobIoHDF5File_Copy, -- GitLab