Minimal changes to document Singleton and class definitions it wraps
This commit is contained in:
parent
86f0860cb2
commit
c63ed02153
|
@ -43,8 +43,10 @@ BMConfigDefaults = {
|
|||
|
||||
@Singleton
|
||||
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 = {}
|
||||
|
||||
# https://github.com/sphinx-doc/sphinx/issues/3783
|
||||
@wraps(cls)
|
||||
def getinstance():
|
||||
"""Find an instance or save newly created one"""
|
||||
if cls not in instances:
|
||||
instances[cls] = cls()
|
||||
return instances[cls]
|
||||
|
|
Reference in New Issue
Block a user