Index: leahi_dialin/ui/utils.py =================================================================== diff -u -r9d36fd7bbc0b883dab1140a7377f75fdca70e474 -r9f44c02ff3f40812ab9fd7f9c7346f649a114c19 --- leahi_dialin/ui/utils.py (.../utils.py) (revision 9d36fd7bbc0b883dab1140a7377f75fdca70e474) +++ leahi_dialin/ui/utils.py (.../utils.py) (revision 9f44c02ff3f40812ab9fd7f9c7346f649a114c19) @@ -18,7 +18,22 @@ import struct from subprocess import check_output +def singleton(cls): + """ + This is a singleton decorator + Returns: + cls: as for defintion of the singleton, it created the class instance once and will return on each access, instead of the recreation. + """ + instances = {} + def get_instance(*args, **kwargs): + if cls not in instances: + instances[cls] = cls(*args, **kwargs) + return instances[cls] + + return get_instance + + def srsui(vstr=""): """ for user convenience if wanted to put a note for the SRSUI