Skip to content

Commit

Permalink
removed {has,get}attr calls on config to clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
heartsucker committed Oct 10, 2018
1 parent b8eb1ea commit 02de5cd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions securedrop/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def setup_app(config, app):
global LOCALES
global babel

translation_dirs = getattr(config, 'TRANSLATION_DIRS', None)
translation_dirs = config.TRANSLATION_DIRS

if translation_dirs is None:
translation_dirs = \
Expand All @@ -63,8 +63,8 @@ def setup_app(config, app):

LOCALES = _get_supported_locales(
LOCALES,
getattr(config, 'SUPPORTED_LOCALES', None),
getattr(config, 'DEFAULT_LOCALE', None),
config.SUPPORTED_LOCALES,
config.DEFAULT_LOCALE,
translation_directories)

babel.localeselector(lambda: get_locale(config))
Expand Down Expand Up @@ -106,7 +106,7 @@ def get_locale(config):
if locale:
return locale
else:
return getattr(config, 'DEFAULT_LOCALE', 'en_US')
return config.DEFAULT_LOCALE


def get_text_direction(locale):
Expand Down
2 changes: 1 addition & 1 deletion securedrop/journalist.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@


if __name__ == "__main__": # pragma: no cover
debug = getattr(config, 'env', 'prod') != 'prod'
debug = config.env != 'prod'
app.run(debug=debug, host='0.0.0.0', port=8081) # nosec
2 changes: 1 addition & 1 deletion securedrop/journalist_app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def _handle_http_exception(error):
app.jinja_env.trim_blocks = True
app.jinja_env.lstrip_blocks = True
app.jinja_env.globals['version'] = version.__version__
if hasattr(config, 'CUSTOM_HEADER_IMAGE'):
if config.CUSTOM_HEADER_IMAGE:
app.jinja_env.globals['header_image'] = \
config.CUSTOM_HEADER_IMAGE # type: ignore
app.jinja_env.globals['use_custom_header_image'] = True
Expand Down
2 changes: 1 addition & 1 deletion securedrop/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@


if __name__ == "__main__": # pragma: no cover
debug = getattr(config, 'env', 'prod') != 'prod'
debug = config.env != 'prod'
app.run(debug=debug, host='0.0.0.0', port=8080) # nosec
2 changes: 1 addition & 1 deletion securedrop/source_app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def handle_csrf_error(e):
app.jinja_env.trim_blocks = True
app.jinja_env.lstrip_blocks = True
app.jinja_env.globals['version'] = version.__version__
if getattr(config, 'CUSTOM_HEADER_IMAGE', None):
if config.CUSTOM_HEADER_IMAGE:
app.jinja_env.globals['header_image'] = \
config.CUSTOM_HEADER_IMAGE # type: ignore
app.jinja_env.globals['use_custom_header_image'] = True
Expand Down

0 comments on commit 02de5cd

Please sign in to comment.