Skip to content
Snippets Groups Projects
Commit 8e8f16b5 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

Adds load method to File

parent 9312f570
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@ import bob.db.utils
from sqlalchemy.orm import backref
from sqlalchemy.ext.declarative import declarative_base
import numpy
import bob
Base = declarative_base()
......@@ -163,6 +164,24 @@ class File(Base):
raise RuntimeError, "%s is not an attack" % self
return self.attack[0]
def load(self, directory=None, extension='.hdf5'):
"""Loads the data at the specified location and using the given extension.
Keyword parameters:
data
The data blob to be saved (normally a :py:class:`numpy.ndarray`).
directory
[optional] If not empty or None, this directory is prefixed to the final
file destination
extension
[optional] The extension of the filename - this will control the type of
output and the codec for saving the input blob.
"""
return bob.io.load(self.make_path(directory, extension))
def save(self, data, directory=None, extension='.hdf5'):
"""Saves the input data at the specified location and using the given
extension.
......@@ -173,12 +192,12 @@ class File(Base):
The data blob to be saved (normally a :py:class:`numpy.ndarray`).
directory
If not empty or None, this directory is prefixed to the final file
destination
[optional] If not empty or None, this directory is prefixed to the final
file destination
extension
The extension of the filename - this will control the type of output and
the codec for saving the input blob.
[optional] The extension of the filename - this will control the type of
output and the codec for saving the input blob.
"""
path = self.make_path(directory, extension)
......
......@@ -210,23 +210,9 @@ class Database(object):
return self.session.query(Client).filter(Client.id==id).count() != 0
def protocols(self):
"""Returns the names of all registered protocols
.. deprecated:: 1.1.0
This function is *deprecated*, use :py:meth:`.Database.protos` instead.
"""Returns all protocol objects.
"""
import warnings
warnings.warn("The method Database.protocols() is deprecated, use Database.protos() for more powerful object retrieval", DeprecationWarning)
self.assert_validity()
return tuple([k.name for k in self.session.query(Protocol)])
def protos(self):
"""Returns all registered protocols"""
self.assert_validity()
return list(self.session.query(Protocol))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment