]> git.lizzy.rs Git - nhentai.git/blob - nhentai/utils.py
忘记干啥了..
[nhentai.git] / nhentai / utils.py
1 # coding: utf-8
2
3
4 class _Singleton(type):
5     """ A metaclass that creates a Singleton base class when called. """
6     _instances = {}
7
8     def __call__(cls, *args, **kwargs):
9         if cls not in cls._instances:
10             cls._instances[cls] = super(_Singleton, cls).__call__(*args, **kwargs)
11         return cls._instances[cls]
12
13
14 class Singleton(_Singleton('SingletonMeta', (object,), {})): pass