diff options
Diffstat (limited to 'lib/server/tools/registry.py')
-rw-r--r-- | lib/server/tools/registry.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/server/tools/registry.py b/lib/server/tools/registry.py new file mode 100644 index 0000000..7e575c3 --- /dev/null +++ b/lib/server/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 |