Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def applies(path: Sequence[str], d: Dict[str, Any]) -> bool:
component, path = path[0], path[1:]
if component in d:
if path:
return applies(path, d[component])
return True
return False
return applies(self.metadata_path.split('.'), update)
@dataclass
class OnEntryTrigger:
"""Trigger on entry to a given gate."""
Trigger = Union[TimeTrigger, IntervalTrigger, MetadataTrigger, OnEntryTrigger]
class ConstantNextState(NamedTuple):
"""Defines a constant choice, always chooses `state`."""
state: str
def next_state_for_label(self, label_context: Any) -> str:
"""Returns the constant next state."""
return self.state
def all_destinations(self) -> Iterable[str]:
"""Returns the constant next state."""
return [self.state]
class ContextNextStatesOption(NamedTuple):
def metadata_triggers(self) -> List[MetadataTrigger]:
"""Return a list of the metadata triggers for this state."""
return [x for x in self.triggers if isinstance(x, MetadataTrigger)]
def _load_metadata_trigger(path: Path, yaml_trigger: Yaml) -> MetadataTrigger:
metadata_path = yaml_trigger['metadata']
if not RE_PATH.match(metadata_path): # pragma: no branch
raise ConfigError( # pragma: no cover
f"Metadata trigger '{metadata_path}' at path {'.'.join(path)} is "
f"not a valid dotted path.",
)
return MetadataTrigger(metadata_path=metadata_path)