Exemple #1
0
def selector_to_pattern(selector: str) -> str:
    try:
        model, explore = selector.split("/")
        assert model
        assert explore
    except (ValueError, AssertionError):
        raise SpectaclesException(
            name="invalid-selector-format",
            title="Specified explore selector is invalid.",
            detail=(f"'{selector}' is not a valid format. "
                    "Instead, use the format 'model_name/explore_name'. "
                    f"Use 'model_name/*' to select all explores in a model."),
        )
    return f"^{selector.replace('*', '.+?')}$"