diff --git a/bob/bio/base/database/utils.py b/bob/bio/base/database/utils.py index 88b5d72992a718879e21c65d5bed7e4d602fcd0f..8fa550111d479e18cdc6b08d4962538da0835b2f 100644 --- a/bob/bio/base/database/utils.py +++ b/bob/bio/base/database/utils.py @@ -1,5 +1,25 @@ class File: - """This class defines the minimum interface of a file that needs to be exported""" + """This class defines the minimum interface of a database file that needs to be exported. + + Each file has a path, an id and an associated client (aka. identity, person, user). + Usually, this file is part of a database, which has a common directory for all files. + The path of this file is usually *relative* to that common directory, and it is usually stored *without* filename extension. + The file id can be anything hashable, but needs to be unique all over the database. + The client id can be anything hashable, but needs to be identical for different files of the same client, and different between clients. + + **Parameters:** + + file_id : str or int + A unique ID that identifies the file. + This ID might be identical to the ``path``, though integral IDs perform faster. + + client_id : str or int + A unique ID that identifies the client (user) to which this file belongs. + This ID might be the name of the person, though integral IDs perform faster. + + path : str + The file path of the file, which is relative to the common database directory, and without filename extension. + """ def __init__(self, file_id, client_id, path): # The **unique** id of the file @@ -10,12 +30,35 @@ class File: self.path = path def __lt__(self, other): + """Defines an order between files by using the order of the file ids.""" # compare two File objects by comparing their IDs return self.id < other.id class FileSet: - """This class defines the minimum interface of a file set that needs to be exported""" + """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, an associated client (aka. identity, person, user), and a list of associated files. + Usually, these files are part of a database, which has a common directory for all files. + The paths of this file set are usually *relative* to that common directory, and they are usually stored *without* filename extension. + The file id can be anything hashable, but needs to be unique all over the database. + The client id can be anything hashable, but needs to be identical for different files of the same client, and different between clients. + + **Parameters:** + + file_id : str or int + A unique ID that identifies the file. + This ID might be identical to the ``path``, though integral IDs perform faster. + + client_id : str or int + A unique ID that identifies the client (user) to which this file belongs. + This ID might be the name of the person, though integral IDs perform faster. + + path : str + The file path of the file, which is relative to the common database directory, and without filename extension. + """ def __init__(self, file_set_id, client_id, file_set_name): # The **unique** id of the file set diff --git a/bob/bio/base/tools/scoring.py b/bob/bio/base/tools/scoring.py index 7e1d990473ac44fd006e1dfb7002297d2ec46fbd..9f04846a88c9097386be5306b9851847276e390d 100644 --- a/bob/bio/base/tools/scoring.py +++ b/bob/bio/base/tools/scoring.py @@ -68,7 +68,7 @@ def _open_to_write(score_file, write_compressed): def _write(f, data, write_compressed): """Writes the given data to file, after converting it to the required type.""" if write_compressed: - if sys.version_info[0] <= 2: + if sys.version_info[0] > 2: data = str.encode(data) f.write(data)