From 87811a902f7bbe51ca0b09986ae7d9f4c19301c2 Mon Sep 17 00:00:00 2001
From: Manuel Guenther <manuel.guenther@idiap.ch>
Date: Thu, 25 Jun 2015 12:01:14 +0200
Subject: [PATCH] Fixed py3 binary io issue (now for real)

---
 bob/bio/base/database/utils.py | 47 ++++++++++++++++++++++++++++++++--
 bob/bio/base/tools/scoring.py  |  2 +-
 2 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/bob/bio/base/database/utils.py b/bob/bio/base/database/utils.py
index 88b5d729..8fa55011 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 7e1d9904..9f04846a 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)
-- 
GitLab