diff options
author | Anish Athalye <aathalye@me.com> | 2014-03-19 23:07:30 -0400 |
---|---|---|
committer | Anish Athalye <aathalye@me.com> | 2014-03-20 18:57:56 -0400 |
commit | 60a560e97699a1d9a4320b8e787a50b1a9a7734d (patch) | |
tree | 573ce63c2a49a278af49c0cc6542bfe3b89cf572 /dotbot/util |
Initial commit
Diffstat (limited to 'dotbot/util')
-rw-r--r-- | dotbot/util/__init__.py | 0 | ||||
-rw-r--r-- | dotbot/util/singleton.py | 6 |
2 files changed, 6 insertions, 0 deletions
diff --git a/dotbot/util/__init__.py b/dotbot/util/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/dotbot/util/__init__.py diff --git a/dotbot/util/singleton.py b/dotbot/util/singleton.py new file mode 100644 index 0000000..d6cc857 --- /dev/null +++ b/dotbot/util/singleton.py @@ -0,0 +1,6 @@ +class Singleton(type): + _instances = {} + def __call__(cls, *args, **kwargs): + if cls not in cls._instances: + cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs) + return cls._instances[cls] |