config.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:live-serial 作者: rosenbrockc 项目源码 文件源码
def _load_sensors(config):
    """Loads all the sensors from the specified config file.

    Args:
        config (ConfigParser): instance from which to extract the sensor list.
          `str` is also allowed, in which case it
          should be the path to the config file to load.
    """
    global _sensors, _sensors_parsed
    if not _sensors_parsed:
        parser = _get_parser(config)
        if parser is not None:
            #Now that we have the thread, we can add configuration for each of the
            #sensors in the config file.
            from fnmatch import fnmatch
            for section in parser.sections():
                if fnmatch(section, "sensor.*"):
                    name = section[len("sensor."):]
                    _sensors[name] = Sensor(None,name,**dict(parser.items(section)))

        _sensors_parsed = True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号