* wait I forgot to comit locally * cp the entire core directory and then rm the .git subdir
16 lines
370 B
Python
16 lines
370 B
Python
# TODO (cliandy): consolidate with decorators later
|
|
from functools import wraps
|
|
|
|
|
|
def singleton(cls):
|
|
"""Decorator to make a class a Singleton class."""
|
|
instances = {}
|
|
|
|
@wraps(cls)
|
|
def get_instance(*args, **kwargs):
|
|
if cls not in instances:
|
|
instances[cls] = cls(*args, **kwargs)
|
|
return instances[cls]
|
|
|
|
return get_instance
|