Added a default parameter to Config.get.

This commit is contained in:
Fabio Manganiello 2023-07-23 23:31:57 +02:00
parent 37dcaba7a1
commit 315a89fb65
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -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