def _parse_osl(root, parser):
    """Assemble Python dictionaries of groups from XML document"""
    if root.findtext('Succeeded') == 'false':
        error_reason = root.findtext('Reason', default='unknown reason')
        raise Exception('Lookup failed: ' + error_reason)
    return parser(root)
