def _get_explore()

in dora/grid.py [0:0]


def _get_explore(args):
    # Finds the explorer.
    package = args.package
    root_name = package + ".grids"
    grids = import_or_fatal(root_name)

    grid_file = Path(grids.__file__).parent / f'{args.grid}.py'
    if args.grid is None or not grid_file.exists():
        candidates = []
        for info in pkgutil.walk_packages([Path(grids.__file__).parent]):
            if not info.name.startswith('_'):
                candidates.append(info.name)
        if not grid_file.exists():
            log(f'No grid file {grid_file.name} in package {root_name}. '
                'Maybe you made a typo?')
        log(f"Potential grids are: {', '.join(candidates)}")
        sys.exit(0)

    grid_name = root_name + "." + args.grid
    grid = import_or_fatal(grid_name)

    try:
        explorer = grid.explorer
    except AttributeError:
        fatal(f"{grid_name} has no exploration function `explorer`.")
    if not isinstance(explorer, Explorer):
        fatal(f"{explorer} must be an instance of `dora.Explorer`")
    return explorer