fastiot.util.read_yaml module¶
Providing methods to import yaml configuration per service
- fastiot.util.read_yaml.read_config(service)[source]¶
Load YAML-configuration files based on file (provide string) or, preferably, service.
It is possible to read the configuration for a service instantiated multiple times. If both service.yaml and service_id.yaml exist, service_id.yaml will be preferred. Use the environment variable
FASTIOT_SERVICE_ID
to set the individual service id for a service.Also see Configuration for a service for more information about handling configurations.
Example passing your service to get a filename configuration automatically:
>>> from fastiot.core import FastIoTService >>> from fastiot.util.read_yaml import read_config >>> >>> class MyService(FastIoTService) >>> >>> def __init__(self, **kwargs) >>> super().__init__(**kwargs) >>> my_config = read_config(self)
- Parameters:
service (
Union
[FastIoTService
,str
]) – service to load the config for (preferred) or name of the config file.- Return type:
Dict
- Returns:
Dictionary with the loaded configuration. May be empty if no configuration was found.