How to use the routemaster.text_utils.join_comma_or function in routemaster

To help you get started, we’ve selected a few routemaster examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thread / routemaster / routemaster / config / loader.py View on Github external
VALID_TOP_LEVEL = ('feeds', 'history', 'metadata')

    for lookup in lookups:
        location, *rest = lookup.split('.')

        if location not in VALID_TOP_LEVEL:
            valid_top_level = join_comma_or(f"'{x}'" for x in VALID_TOP_LEVEL)
            raise ConfigError(
                f"Invalid context lookup at {'.'.join(path)}: key {lookup} "
                f"must start with one of {valid_top_level}.",
            )

        if location == 'feeds':
            feed_name = rest[0]
            if feed_name not in feed_names:
                valid_names = join_comma_or(f"'{x}'" for x in feed_names)
                raise ConfigError(
                    f"Invalid feed name at {'.'.join(path)}: key {lookup} "
                    f"references unknown feed '{feed_name}' (configured "
github thread / routemaster / routemaster / config / loader.py View on Github external
def _validate_context_lookups(
    path: Path,
    lookups: Iterable[str],
    feed_names: List[str],
) -> None:
    # Changing this? Also change context lookups in
    # `routemaster.context.Context`
    VALID_TOP_LEVEL = ('feeds', 'history', 'metadata')

    for lookup in lookups:
        location, *rest = lookup.split('.')

        if location not in VALID_TOP_LEVEL:
            valid_top_level = join_comma_or(f"'{x}'" for x in VALID_TOP_LEVEL)
            raise ConfigError(
                f"Invalid context lookup at {'.'.join(path)}: key {lookup} "
                f"must start with one of {valid_top_level}.",
            )

        if location == 'feeds':
            feed_name = rest[0]
            if feed_name not in feed_names:
                valid_names = join_comma_or(f"'{x}'" for x in feed_names)
                raise ConfigError(
                    f"Invalid feed name at {'.'.join(path)}: key {lookup} "
                    f"references unknown feed '{feed_name}' (configured "