Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 "
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 "