import re


def _find_in_file(file_path, search_str='__version__'):
    """Finds in a file a variable equaling a string of the type
    'search_str = "xxxx" '

    Parameters
    ----------
    init_path : str
        path to the file to search
    search_str : str
        variable name to search on file

    Returns
    -------
    found variable content

    Raises
    ------
    RuntimeError : in case passed string followed by content is not found in file
    """
    with open(file_path) as ip:
        __init_file__ = ip.read()

    match = re.search(r"^{}\s*=\s*['\"]([^'\"]*)['\"]".format(search_str), __init_file__, re.M)
    if match:
        return match.group(1)

    raise RuntimeError("Unable to find version string.")