dav_base: cosmetics
Run tests / Execute tox to run the test suite (push) Successful in 3m29s

This commit is contained in:
2026-05-28 14:51:49 +02:00
parent efd2305b35
commit d9cfffb8c2
8 changed files with 63 additions and 41 deletions
+13 -8
View File
@@ -4,6 +4,8 @@ import re
from django.apps import AppConfig as _AppConfig
from django.core.exceptions import ImproperlyConfigured
from ..constants import DJANGO_MAIN_MODULE, MODULE_APP_SETTINGS_PREFIX
logger = logging.getLogger(__name__)
@@ -18,18 +20,21 @@ class DefaultSetting: # pylint: disable=too-few-public-methods
self.validator = validator
def validate(self, value):
if hasattr(self, 'validator') and self.validator is not None:
if callable(self.validator):
if not self.validator(value):
raise ImproperlyConfigured('Validator callback {clb} returned False'.format(clb=self.validator))
else:
if not re.search(self.validator, value):
raise ImproperlyConfigured('Does not match /{re}/'.format(re=self.validator))
if self.validator is None:
return
if callable(self.validator):
if not self.validator(value):
raise ImproperlyConfigured('Validator callback {clb} returned False'.format(clb=self.validator))
else:
if not re.search(self.validator, value):
raise ImproperlyConfigured('Does not match /{re}/'.format(re=self.validator))
class AppSettings: # pylint: disable=too-few-public-methods
def __init__(self, app_name, defaults):
settings_name = 'main.settings-' + app_name
settings_name = '{main_module}.{prefix}{app_name}'.format(main_module=DJANGO_MAIN_MODULE,
prefix=MODULE_APP_SETTINGS_PREFIX,
app_name=app_name)
try:
settings_module = importlib.import_module(settings_name)