Changeset 30949f8 for src


Ignore:
Timestamp:
May 11, 2020, 9:00:05 PM (7 years ago)
Author:
Joachim Langenbach <joachim.langenbach@…>
Branches:
debian/bullseye, master
Children:
cd3ea37
Parents:
812f687
Message:

Added config_get function to retrieve option values from an config object or dict

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/gnuboat/common/webservice/Config.py

    r812f687 r30949f8  
    2626
    2727    return config
     28
     29
     30def config_get(config_object, option, default_value):
     31    """
     32        Returns the value of option in config_object object.
     33        If config_object has no attribute option, it returns
     34        default_value
     35    """
     36    if hasattr(config_object, option):
     37        return getattr(config_object, option)
     38    if isinstance(config_object, dict) and option in config_object:
     39        return config_object[option]
     40    return default_value
Note: See TracChangeset for help on using the changeset viewer.