dev-pipeline/dev-pipeline-configure

View on GitHub
lib/devpipeline_configure/parser.py

Summary

Maintainability
A
0 mins
Test Coverage
#!/usr/bin/python3

"""Manage reading and writing configurations to disk."""

import configparser


def _make_parser():
    return configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation())


def read_config(path):
    """
    Read a configuration from disk.

    Arguments
    path -- the loation to deserialize
    """
    parser = _make_parser()
    if parser.read(path):
        return parser
    raise Exception("Failed to read {}".format(path))