Skip to content
Snippets Groups Projects
Commit 67916c31 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

[refactoring2016] Moved bob.bio.db.BioDatabase to bob.bio.base

parent 3d6d2148
No related branches found
No related tags found
1 merge request!37Issue 8 remove database configuration
from .utils import *
from . import database
from . import preprocessor
from . import extractor
from . import algorithm
......
from .file import BioFile
from .file import BioFileSet
from .database import BioDatabase
from .database import ZTBioDatabase
# gets sphinx autodoc done right - don't remove it
__all__ = [_ for _ in dir() if not _.startswith('_')]
This diff is collapsed.
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
import bob.db.base
class BioFile(bob.db.base.File):
"""A simple base class that defines basic properties of File object for the use in verification experiments"""
def __init__(self, client_id, path, file_id=None):
"""**Constructor Documentation**
Initialize the File object with the minimum required data.
Parameters:
client_id : various type
The id of the client this file belongs to.
Its type depends on your implementation.
If you use an SQL database, this should be an SQL type like Integer or String.
For path and file_id, please refer to :py:class:`bob.db.base.File` constructor
"""
bob.db.base.File.__init__(self, path, file_id)
# just copy the information
self.client_id = client_id
"""The id of the client, to which this file belongs to."""
class BioFileSet(BioFile):
"""This class defines the minimum interface of a set of database files that needs to be exported.
Use this class, whenever the database provides several files that belong to the same probe.
Each file set has an id, and a list of associated files, which are of type :py:class:`BioFile` of the same client.
The file set id can be anything hashable, but needs to be unique all over the database.
**Parameters:**
file_set_id : str or int
A unique ID that identifies the file set.
files : [:py:class:`BioFile`]
A non-empty list of BioFile objects that should be stored inside this file.
All files of that list need to have the same client ID.
"""
def __init__(self, file_set_id, files, path=None):
# don't accept empty file lists
assert len(files), "Cannot create an empty BioFileSet"
# call base class constructor
BioFile.__init__(self, files[0].client_id, "+".join(f.path for f in files) if path is None else path, file_set_id)
# check that all files come from the same client
assert all(f.client_id == self.client_id for f in files)
# The list of files contained in this set
self.files = files
"""The list of :py:class:`BioFile` objects stored in this file set"""
def __lt__(self, other):
"""Defines an order between file sets by using the order of the file set ids."""
# compare two BioFile set objects by comparing their IDs
return self.id < other.id
......@@ -10,7 +10,7 @@ from .Preprocessor import Preprocessor
class Filename (Preprocessor):
"""This preprocessor is simply passing over the file name, in order to be used in an extractor that loads the data from file.
The file name that will be returned by the :py:meth:`read_data` function will contain the path of the :py:class:`bob.bio.db.BioFile`, but it might contain more paths (such as the ``--preprocessed-directory`` passed on command line).
The file name that will be returned by the :py:meth:`read_data` function will contain the path of the :py:class:`bob.bio.base.database.BioFile`, but it might contain more paths (such as the ``--preprocessed-directory`` passed on command line).
"""
def __init__(self):
......
from bob.bio.db import ZTBioDatabase, BioFile
from bob.bio.base.database import ZTBioDatabase
from bob.bio.base.test.utils import atnt_database_directory
......
from bob.bio.db import ZTBioDatabase, BioFileSet, BioFile
from bob.bio.base.database import ZTBioDatabase, BioFileSet, BioFile
from bob.bio.base.test.utils import atnt_database_directory
class DummyDatabase(ZTBioDatabase):
......
......@@ -8,7 +8,7 @@ logger = bob.core.log.setup("bob.bio.base")
from .. import utils
from . import FileSelector
from bob.bio.db import BioDatabase
from bob.bio.base.database import BioDatabase
"""Execute biometric recognition algorithms on a certain biometric database.
"""
......
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