Update pre-commit hooks and reformat

master
Mark Veidemanis 2 years ago
parent 1424e34f38
commit 32de41ed89
Signed by: m
GPG Key ID: 5ACFCEED46C0904F

@ -16,7 +16,7 @@ repos:
args: [--max-line-length=88] args: [--max-line-length=88]
exclude: ^core/migrations exclude: ^core/migrations
- repo: https://github.com/rtts/djhtml - repo: https://github.com/rtts/djhtml
rev: 'v1.5.2' # replace with the latest tag on GitHub rev: 'v1.5.2'
hooks: hooks:
- id: djhtml - id: djhtml
args: [-t 2] args: [-t 2]
@ -24,6 +24,10 @@ repos:
exclude : ^core/static/css # slow exclude : ^core/static/css # slow
- id: djjs - id: djjs
exclude: ^core/static/js # slow exclude: ^core/static/js # slow
- repo: https://github.com/sirwart/ripsecrets.git
rev: v0.1.5
hooks:
- id: ripsecrets
# - repo: https://github.com/thibaudcolas/curlylint # - repo: https://github.com/thibaudcolas/curlylint
# rev: v0.13.1 # rev: v0.13.1
# hooks: # hooks:

@ -7,13 +7,10 @@ https://github.com/jakubroztocil/django-settings-export
from django.conf import settings as django_settings from django.conf import settings as django_settings
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
__version__ = "1.2.1"
__version__ = '1.2.1'
VARIABLE_NAME = getattr(django_settings, "SETTINGS_EXPORT_VARIABLE_NAME", "settings")
VARIABLE_NAME = getattr(django_settings,
'SETTINGS_EXPORT_VARIABLE_NAME',
'settings')
class SettingsExportError(ImproperlyConfigured): class SettingsExportError(ImproperlyConfigured):
@ -35,16 +32,13 @@ def settings_export(request):
set, the context variable will be `settings`. set, the context variable will be `settings`.
""" """
variable_name = getattr(django_settings, variable_name = getattr(
'SETTINGS_EXPORT_VARIABLE_NAME', django_settings, "SETTINGS_EXPORT_VARIABLE_NAME", "settings"
'settings') )
return { return {variable_name: _get_exported_settings()}
variable_name: _get_exported_settings()
}
class ExportedSettings(dict): class ExportedSettings(dict):
def __getitem__(self, item): def __getitem__(self, item):
"""Fail loudly if accessing a setting that is not exported.""" """Fail loudly if accessing a setting that is not exported."""
try: try:
@ -55,24 +49,21 @@ class ExportedSettings(dict):
# can access the existing attribute (e.g. `items()`). # can access the existing attribute (e.g. `items()`).
raise raise
raise UnexportedSettingError( raise UnexportedSettingError(
'The `{key}` setting key is not accessible' "The `{key}` setting key is not accessible"
' from templates: add "{key}" to' ' from templates: add "{key}" to'
' `settings.SETTINGS_EXPORT` to change that.' " `settings.SETTINGS_EXPORT` to change that.".format(key=item)
.format(key=item)
) )
def _get_exported_settings(): def _get_exported_settings():
exported_settings = ExportedSettings() exported_settings = ExportedSettings()
for key in getattr(django_settings, 'SETTINGS_EXPORT', []): for key in getattr(django_settings, "SETTINGS_EXPORT", []):
try: try:
value = getattr(django_settings, key) value = getattr(django_settings, key)
except AttributeError: except AttributeError:
raise UndefinedSettingError( raise UndefinedSettingError(
'"settings.%s" is included in settings.SETTINGS_EXPORT ' '"settings.%s" is included in settings.SETTINGS_EXPORT '
'but it does not exist. ' "but it does not exist. " % key
% key
) )
exported_settings[key] = value exported_settings[key] = value
return exported_settings return exported_settings

Loading…
Cancel
Save