# 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