added tests and small fixes for config

This commit is contained in:
Tim Mundt
2016-12-16 18:46:07 +01:00
parent 04798cbf5b
commit a550b5c112
2 changed files with 81 additions and 2 deletions

View File

@@ -4,7 +4,7 @@ import types
class Config(dict):
def __init__(self, defaults=None):
dict.__init__(self, defaults or {})
super().__init__(defaults or {})
self.LOGO = """
▄▄▄▄▄
▀▀▀██████▄▄▄ _______________
@@ -31,7 +31,10 @@ class Config(dict):
self.ROUTER_CACHE_SIZE = 1024
def __getattr__(self, attr):
return self[attr]
try:
return self[attr]
except KeyError as ke:
raise AttributeError("Config has no '{}'".format(ke.args[0]))
def __setattr__(self, attr, value):
self[attr] = value