import re


def _read_header_info(content):
    """ Read info from info section in file header. """
    def _read_header(pat):
        pattern = pat + r"\s+\S+;"
        data_str = re.compile(pattern).search(content).group()
        return data_str.split(pat)[1][:-1].strip()

    info = {}
    foam_class = _read_header('class').split('Field')[0].split('vol')[1]
    info['foam_class'] = foam_class[0].lower() + foam_class[1:]
    info['name'] = _read_header('object')
    try:
        info['location'] = _read_header('location')
    except AttributeError:
        info['location'] = None
    return info