forked from platypush/platypush
Added a default
parameter to Config.get
.
This commit is contained in:
parent
37dcaba7a1
commit
315a89fb65
1 changed files with 3 additions and 3 deletions
|
@ -11,7 +11,7 @@ import shutil
|
||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
from urllib.parse import quote
|
from urllib.parse import quote
|
||||||
from typing import Dict, Optional, Set
|
from typing import Any, Dict, Optional, Set
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
@ -471,7 +471,7 @@ class Config:
|
||||||
return workdir # type: ignore
|
return workdir # type: ignore
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get(cls, key: Optional[str] = None):
|
def get(cls, key: Optional[str] = None, default: Optional[Any] = None):
|
||||||
"""
|
"""
|
||||||
Get a config value or the whole configuration object.
|
Get a config value or the whole configuration object.
|
||||||
|
|
||||||
|
@ -480,7 +480,7 @@ class Config:
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
config = cls._get_instance()._config.copy()
|
config = cls._get_instance()._config.copy()
|
||||||
if key:
|
if key:
|
||||||
return config.get(key)
|
return config.get(key, default)
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue