Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
workspaces
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ssa
workspaces
Commits
1efdda0d
Commit
1efdda0d
authored
4 years ago
by
Nathan Hertz
Browse files
Options
Downloads
Patches
Plain Diff
Created helpers file for helper classes/functions; added CapabilityStep and CapabilitySequence
parent
cee93f54
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
shared/workspaces/src/workspaces/helpers.py
+48
-0
48 additions, 0 deletions
shared/workspaces/src/workspaces/helpers.py
with
48 additions
and
0 deletions
shared/workspaces/src/workspaces/helpers.py
0 → 100644
+
48
−
0
View file @
1efdda0d
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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment