JANINE/janine/sources.py

42 lines
1.2 KiB
Python
Raw Normal View History

2020-08-22 13:09:59 +00:00
from janine.utils import dict_get_fallback
class WarningSources:
'''
A collection of sources of the BBK
'''
@staticmethod
def bbk_dwd():
return 'https://warnung.bund.de/bbk.dwd/unwetter.json'
@staticmethod
def bbk_mowas():
return 'https://warnung.bund.de/bbk.mowas/gefahrendurchsagen.json'
@staticmethod
def bbk_biwapp():
return 'https://warnung.bund.de/bbk.biwapp/warnmeldungen.json'
@staticmethod
def bbk_ihp():
return 'https://warnung.bund.de/bbk.lhp/hochwassermeldungen.json'
@staticmethod
def source_by_name(name):
return {
'IHP': WarningSources.bbk_ihp(),
'DWD': WarningSources.bbk_dwd(),
'MOWAS': WarningSources.bbk_mowas(),
'BIWAPP': WarningSources.bbk_biwapp()
}[name]
def sources_from_config(config):
sources = []
for module in ('IHP', 'DWD', 'BIWAPP', 'MOWAS'):
option = dict_get_fallback(config['General'],
module,
'n')
if option == 'y':
sources.append(WarningSources.source_by_name(module))
return sources