Minimal changes to document Singleton and class definitions it wraps

Dmitri Bogomolov 4 years ago
parent 86f0860cb2
commit c63ed02153
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13

@ -43,8 +43,10 @@ BMConfigDefaults = {
class BMConfigParser(ConfigParser.SafeConfigParser):
"""Singleton class inherited from ConfigParser.SafeConfigParser
with additional methods specific to bitmessage config."""
Singleton class inherited from :class:`ConfigParser.SafeConfigParser`
with additional methods specific to bitmessage config.
_temp = {}

@ -1,6 +1,21 @@
Singleton decorator definition
from functools import wraps
def Singleton(cls):
Decorator implementing the singleton pattern:
it restricts the instantiation of a class to one "single" instance.
instances = {}
def getinstance():
"""Find an instance or save newly created one"""
if cls not in instances:
instances[cls] = cls()
return instances[cls]