1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-28 10:38:26 +00:00
bazarr/libs/tld/conf.py
josdion a430bffe57 added tld library, fix add space after dot in domain names
- added tld library, so "Common Fixes" mod can detect domain names and won't add spaces after each dot in them.
- fix HI_before_colon_noncaps, so it won't remove http: from URLs.
2020-07-31 12:39:25 +03:00

58 lines
1.3 KiB
Python

from typing import Any
from . import defaults
__author__ = 'Artur Barseghyan'
__copyright__ = '2013-2020 Artur Barseghyan'
__license__ = 'MPL-1.1 OR GPL-2.0-only OR LGPL-2.1-or-later'
__all__ = (
'get_setting',
'reset_settings',
'set_setting',
'settings',
)
class Settings(object):
"""Settings registry."""
def __init__(self):
self._settings = {}
self._settings_get = self._settings.get
def set(self, name: str, value: Any) -> None:
"""
Override default settings.
:param str name:
:param mixed value:
"""
self._settings[name] = value
def get(self, name: str, default: Any = None) -> Any:
"""
Gets a variable from local settings.
:param str name:
:param mixed default: Default value.
:return mixed:
"""
if name in self._settings:
return self._settings_get(name, default)
elif hasattr(defaults, name):
return getattr(defaults, name, default)
return default
def reset(self) -> None:
"""Reset settings."""
for name in defaults.__all__:
self.set(name, getattr(defaults, name))
settings = Settings()
get_setting = settings.get
set_setting = settings.set
reset_settings = settings.reset