import click
import json
import collections


def _get_ldap_dict(ldap_json):
    """ return an OrderedDict for the given json file

    Parameters
    ----------
    ldap_json : string
        filepath to json file with config options to be loaded

    Returns
    -------
    ldap_dict : collections.OrderedDict
        ordered dictionary for use in configuring artifactory
    """
    try:
        with click.open_file(ldap_json) as f:
            json_dict = json.load(f, object_pairs_hook=collections.OrderedDict)
    except:
        click.echo("Can't open that LDAP json file")
        raise

    return json_dict