from typing import Union
from pathlib import Path
import json


def read_configuration(config_info: Union[str, Path, dict]) -> dict:
    """
    read_configuration(config_info)

    Reads configuration information and stores it as the instance variable
    "configuration".

    Args:
        config_info (str, Path, dict): Configuration information for the
            devices to connect to. Information can either be passed directly
            (dict) or can read from a file (str or Path-like).
    """

    if not isinstance(config_info, (str, Path, dict)):
        raise ValueError('Unsupported type for arguement "config_info"'
                         ' should a str/Path object to a JSON file or a'
                         ' dictionary')

    if isinstance(config_info, dict):
        return config_info

    # read equipment info from file
    with open(config_info, 'rb') as file:
        configuration = json.load(file)
    return configuration