Singleton pattern from Wikipedia See http://en.wikipedia.org/wiki/Singleton_Pattern Intended to be used as a __metaclass_ param, as shown for the class below.
| 56 | |
| 57 | |
| 58 | class Singleton(type): |
| 59 | """Singleton pattern from Wikipedia |
| 60 | See http://en.wikipedia.org/wiki/Singleton_Pattern |
| 61 | |
| 62 | Intended to be used as a __metaclass_ param, as shown for the class |
| 63 | below.""" |
| 64 | |
| 65 | def __init__(cls, name, bases, dict_): |
| 66 | super(Singleton, cls).__init__(name, bases, dict_) |
| 67 | cls.instance = None |
| 68 | |
| 69 | def __call__(cls, *args, **kw): |
| 70 | if cls.instance is None: |
| 71 | cls.instance = super(Singleton, cls).__call__(*args, **kw) |
| 72 | return cls.instance |
| 73 | |
| 74 | |
| 75 | class StarrynetLogger(Logger, object): |
nothing calls this directly
no outgoing calls
no test coverage detected