From 0136721fff71ff09f7c6e1da88fcb200011dd559 Mon Sep 17 00:00:00 2001
From: Guillaume HEUSCH <guillaume.heusch@idiap.ch>
Date: Wed, 23 Jan 2019 10:15:48 +0100
Subject: [PATCH] [database] used bob.extension.rc for DB directory, modified
 the config name

---
 bob/pad/face/config/casiasurf.py       | 33 --------------------------
 bob/pad/face/config/casiasurf_color.py | 11 +++++++++
 bob/pad/face/database/casiasurf.py     |  4 +++-
 setup.py                               |  2 +-
 4 files changed, 15 insertions(+), 35 deletions(-)
 delete mode 100644 bob/pad/face/config/casiasurf.py
 create mode 100644 bob/pad/face/config/casiasurf_color.py

diff --git a/bob/pad/face/config/casiasurf.py b/bob/pad/face/config/casiasurf.py
deleted file mode 100644
index f74512bd..00000000
--- a/bob/pad/face/config/casiasurf.py
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/env python
-"""CASIA-SURF is a database for face PAD experiments.
-
-"""
-
-from bob.pad.face.database import CasiaSurfPadDatabase
-
-# Directory where the data files are stored.
-# This directory is given in the .bob_bio_databases.txt file located in your home directory
-original_directory = "[YOUR_CASIASURF_DB_DIRECTORY]"
-"""Value of ``~/.bob_bio_databases.txt`` for this database"""
-
-original_extension = ".jpg"  # extension is not used to load the data in the HLDI of this database
-
-database = CasiaSurfPadDatabase(
-    protocol='color',
-    original_directory=original_directory,
-    original_extension=original_extension,
-)
-"""The :py:class:`bob.pad.base.database.PadDatabase` derivative with CASIA-SURF 
-database settings.
-
-.. warning::
-
-   This class only provides a programmatic interface to load data in an orderly
-   manner, respecting usage protocols. It does **not** contain the raw
-   data files. You should procure those yourself.
-
-Notice that ``original_directory`` is set to ``[YOUR_CASIASURF_DB_DIRECTORY]``.
-You must make sure to create ``${HOME}/.bob_bio_databases.txt`` setting this
-value to the place where you actually installed the CASIA-SURF Database, as
-explained in the section :ref:`bob.pad.face.baselines`.
-"""
diff --git a/bob/pad/face/config/casiasurf_color.py b/bob/pad/face/config/casiasurf_color.py
new file mode 100644
index 00000000..4d7cde92
--- /dev/null
+++ b/bob/pad/face/config/casiasurf_color.py
@@ -0,0 +1,11 @@
+#!/usr/bin/env python
+# encoding: utf-8
+
+from bob.pad.face.database import CasiaSurfPadDatabase
+from bob.extension import rc
+
+database = CasiaSurfPadDatabase(
+    protocol='color',
+    original_directory=rc['bob.db.casiasurf.directory'],
+    original_extension=".jpg",
+)
diff --git a/bob/pad/face/database/casiasurf.py b/bob/pad/face/database/casiasurf.py
index 7b2102b9..5b936476 100644
--- a/bob/pad/face/database/casiasurf.py
+++ b/bob/pad/face/database/casiasurf.py
@@ -9,6 +9,8 @@ from bob.bio.video import FrameSelector, FrameContainer
 from bob.pad.face.database import VideoPadFile  
 from bob.pad.base.database import PadDatabase
 
+from bob.extension import rc
+
 class CasiaSurfPadFile(VideoPadFile):
     """
     A high level implementation of the File class for the CASIA-SURF database.
@@ -49,7 +51,7 @@ class CasiaSurfPadFile(VideoPadFile):
             path=s.id)
       
 
-    def load(self, directory=None, extension='.jpg', frame_selector=FrameSelector(selection_style='all')):
+    def load(self, directory=rc['bob.db.casiasurf.directory'], extension='.jpg', frame_selector=FrameSelector(selection_style='all')):
         """Overloaded version of the load method defined in ``VideoPadFile``.
 
         Parameters
diff --git a/setup.py b/setup.py
index 0f6ffa62..994af695 100644
--- a/setup.py
+++ b/setup.py
@@ -74,7 +74,7 @@ setup(
             'batl-db-thermal = bob.pad.face.config.batl_db_thermal:database',
             'celeb-a = bob.pad.face.config.celeb_a:database',
             'maskattack = bob.pad.face.config.maskattack:database',
-            'casiasurf = bob.pad.face.config.casiasurf:database',
+            'casiasurf-color = bob.pad.face.config.casiasurf_color:database',
         ],
 
         # registered configurations:
-- 
GitLab