Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/olpcfr/tools/registry.py
diff options
context:
space:
mode:
Diffstat (limited to 'olpcfr/tools/registry.py')
-rw-r--r--olpcfr/tools/registry.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/olpcfr/tools/registry.py b/olpcfr/tools/registry.py
new file mode 100644
index 0000000..7e575c3
--- /dev/null
+++ b/olpcfr/tools/registry.py
@@ -0,0 +1,48 @@
+
+# python import
+import logging
+
+
+class Registry(object):
+
+ class __Singleton:
+ """Our singleton object.
+ """
+
+ def __init__(self):
+ """Create the new singleton for a simple use.
+ """
+ # ensure config
+ self.__dict = dict()
+
+ def get_info(self, path):
+ # ..
+ if path in self.__dict:
+ return self.__dict[path]
+ else:
+ return None
+
+ def set_info(self, path, info):
+ # clear previous
+ if path in self.__dict:
+ del self.__dict[path]
+ else:
+ pass
+ # ...
+ self.__dict[path] = info
+
+ # singleton instance
+ instance = None
+
+ def __new__(c, force=False):
+ """Singleton new init.
+ """
+ # if doesn't already initialized
+ if not Registry.instance \
+ or force is True:
+ # create a new instance
+ Registry.instance = Registry.__Singleton()
+ else:
+ pass
+ # return the manager object
+ return Registry.instance