Skip to content
Snippets Groups Projects
Commit 1efdda0d authored by Nathan Hertz's avatar Nathan Hertz
Browse files

Created helpers file for helper classes/functions; added CapabilityStep and CapabilitySequence

parent cee93f54
No related branches found
No related tags found
No related merge requests found
from typing import Optional, List, Iterator
from shared.workspaces.src.workspaces.capability_interfaces import CapabilityStepType
class CapabilityStep:
"""
Class that represents a step in a capability sequence. A step is of a certain type and
certain step types can have a value
"""
def __init__(self, step_type: CapabilityStepType, step_value: Optional[str]):
self.step_type = step_type
self.step_value = step_value
def __str__(self):
if self.step_value:
return f'{self.step_type.name} {self.step_value}'
else:
return f'{self.step_type.name}'
class CapabilitySequence:
"""
Class that represents a capability sequence with a list of steps
"""
def __init__(self, steps: List[CapabilityStep]):
self.steps = steps
def __iter__(self) -> Iterator:
"""
Allows CapabilitySequence objects to be iterated over
:return: Iterator object
"""
return iter(self.steps)
def __len__(self) -> int:
"""
Allows len() to be called on CapabilitySequence objects
:return: Number of capability steps
"""
return len(self.steps)
def __str__(self) -> str:
"""
Provides a string representation of the object
:return: String representation
"""
return ','.join(self)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment