From 7d124f94f9ecb9583e46e4fb6132d4a3a37f1e46 Mon Sep 17 00:00:00 2001
From: Andre Anjos <andre.dos.anjos@gmail.com>
Date: Wed, 22 Aug 2012 15:15:26 +0200
Subject: [PATCH] Use namespaces

---
 .gitignore                                  |  1 +
 buildout.cfg                                |  2 +-
 docs/conf.py                                |  6 +++---
 docs/index.rst                              |  4 ++--
 replay/__init__.py                          |  0
 setup.py                                    | 21 +++++++++++----------
 xbob/__init__.py                            |  2 ++
 xbob/db/__init__.py                         |  2 ++
 {replay/db => xbob/db/replay}/__init__.py   |  3 ++-
 {replay/db => xbob/db/replay}/checkfiles.py |  0
 {replay/db => xbob/db/replay}/create.py     |  0
 {replay/db => xbob/db/replay}/driver.py     |  2 +-
 {replay/db => xbob/db/replay}/dumplist.py   |  0
 {replay/db => xbob/db/replay}/models.py     |  0
 {replay/db => xbob/db/replay}/query.py      |  0
 {replay => xbob/db/replay}/test.py          |  0
 16 files changed, 25 insertions(+), 18 deletions(-)
 delete mode 100644 replay/__init__.py
 create mode 100644 xbob/__init__.py
 create mode 100644 xbob/db/__init__.py
 rename {replay/db => xbob/db/replay}/__init__.py (97%)
 rename {replay/db => xbob/db/replay}/checkfiles.py (100%)
 rename {replay/db => xbob/db/replay}/create.py (100%)
 rename {replay/db => xbob/db/replay}/driver.py (98%)
 rename {replay/db => xbob/db/replay}/dumplist.py (100%)
 rename {replay/db => xbob/db/replay}/models.py (100%)
 rename {replay/db => xbob/db/replay}/query.py (100%)
 rename {replay => xbob/db/replay}/test.py (100%)

diff --git a/.gitignore b/.gitignore
index 8d0685e..f9de064 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,4 @@ src
 develop-eggs
 built-docs
 dist
+sphinx
diff --git a/buildout.cfg b/buildout.cfg
index bb063d7..efd3f48 100644
--- a/buildout.cfg
+++ b/buildout.cfg
@@ -13,7 +13,7 @@ versions = versions
 ;current sys.path settings. Also note that your current 'eggs' directory may
 ;not take precedence over that.
 eggs = bob==master
-       bob.db.replay
+       xbob.db.replay
 
 [versions]
 ;If you would like to pin-down the recipes package version so you are not
diff --git a/docs/conf.py b/docs/conf.py
index 80c0953..dbaac04 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -77,10 +77,10 @@ copyright = u'%s, Idiap Research Institute' % time.strftime('%Y')
 # built documents.
 #
 # The short X.Y version.
-from replay.db import version as db_version
-version = db_version()
+from xbob.db.replay.driver import Interface
+version = Interface().version()
 # The full version, including alpha/beta/rc tags.
-release = db_version()
+release = version
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff --git a/docs/index.rst b/docs/index.rst
index af04bc5..52b3f61 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -6,6 +6,6 @@
  Replay Attack Database
 ========================
 
-.. automodule:: replay.db
+.. automodule:: xbob.db.replay
 
-.. autoclass:: replay.db.Database
+.. autoclass:: xbob.db.replay.Database
diff --git a/replay/__init__.py b/replay/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/setup.py b/setup.py
index ad0322d..2103154 100644
--- a/setup.py
+++ b/setup.py
@@ -9,7 +9,7 @@ from setuptools import setup, find_packages
 # parameters that define our package.
 setup(
 
-    name='bob.db.replay',
+    name='xbob.db.replay',
     version='master',
     description='Replay Attack Database Access API for Bob',
     url='http://github.com/bioidiap/bob.db.replay',
@@ -24,23 +24,24 @@ setup(
     zip_safe=False,
 
     install_requires=[
-        "bob",  # base signal proc./machine learning library
+      'setuptools',
+      'bob',  # base signal proc./machine learning library
     ],
 
-    entry_points={
-      'console_scripts': [
-        # for tests or db creation, enable the following line:
-        #'replay_manager.py = bob.db.script.dbmanage:main',
-        ],
-      
+    namespace_packages = [
+      'xbob',
+      'xbob.db',
+      ],
+
+    entry_points = {
       # bob database declaration
       'bob.db': [
-        'replay = replay.db.driver:Interface',
+        'replay = xbob.db.replay.driver:Interface',
         ],
 
       # bob unittest declaration
       'bob.test': [
-        'replay = replay.test:ReplayDatabaseTest',
+        'replay = xbob.db.replay.test:ReplayDatabaseTest',
         ],
       },
 
diff --git a/xbob/__init__.py b/xbob/__init__.py
new file mode 100644
index 0000000..60381ea
--- /dev/null
+++ b/xbob/__init__.py
@@ -0,0 +1,2 @@
+#see http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
+__import__('pkg_resources').declare_namespace(__name__)
diff --git a/xbob/db/__init__.py b/xbob/db/__init__.py
new file mode 100644
index 0000000..60381ea
--- /dev/null
+++ b/xbob/db/__init__.py
@@ -0,0 +1,2 @@
+#see http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
+__import__('pkg_resources').declare_namespace(__name__)
diff --git a/replay/db/__init__.py b/xbob/db/replay/__init__.py
similarity index 97%
rename from replay/db/__init__.py
rename to xbob/db/replay/__init__.py
index 86d7424..13cb82f 100644
--- a/replay/db/__init__.py
+++ b/xbob/db/replay/__init__.py
@@ -25,4 +25,5 @@ on your references:
 """
 
 from .query import Database
-__all__ = dir()
+
+__all__ = ['Database']
diff --git a/replay/db/checkfiles.py b/xbob/db/replay/checkfiles.py
similarity index 100%
rename from replay/db/checkfiles.py
rename to xbob/db/replay/checkfiles.py
diff --git a/replay/db/create.py b/xbob/db/replay/create.py
similarity index 100%
rename from replay/db/create.py
rename to xbob/db/replay/create.py
diff --git a/replay/db/driver.py b/xbob/db/replay/driver.py
similarity index 98%
rename from replay/db/driver.py
rename to xbob/db/replay/driver.py
index 8e1b5af..9d6e9d6 100644
--- a/replay/db/driver.py
+++ b/xbob/db/replay/driver.py
@@ -81,7 +81,7 @@ class Interface(BaseInterface):
 
   def version(self):
     import pkg_resources  # part of setuptools
-    return pkg_resources.require('bob.db.%s' % self.name())[0].version
+    return pkg_resources.require('xbob.db.%s' % self.name())[0].version
 
   def location(self):
     return os.path.dirname(os.path.realpath(__file__))
diff --git a/replay/db/dumplist.py b/xbob/db/replay/dumplist.py
similarity index 100%
rename from replay/db/dumplist.py
rename to xbob/db/replay/dumplist.py
diff --git a/replay/db/models.py b/xbob/db/replay/models.py
similarity index 100%
rename from replay/db/models.py
rename to xbob/db/replay/models.py
diff --git a/replay/db/query.py b/xbob/db/replay/query.py
similarity index 100%
rename from replay/db/query.py
rename to xbob/db/replay/query.py
diff --git a/replay/test.py b/xbob/db/replay/test.py
similarity index 100%
rename from replay/test.py
rename to xbob/db/replay/test.py
-- 
GitLab