Skip to content

Commit

Permalink
feat(operation): add component attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
gboutry committed Jun 17, 2022
1 parent b777a8a commit 7c9193f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tdp/core/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

# service: <service>_<action>
RE_IS_SERVICE = re.compile("^([^_]+)_[^_]+$")
# component: <service>_<component>_<action>
# operation: <service>_<component>_<action>
RE_GET_SERVICE = re.compile("^([^_]+)_.*")
RE_GET_COMPONENT = re.compile("^[^_]+_(.*)_[^_]+$")
RE_GET_ACTION = re.compile(".*_([^_]+)$")

NODE_NAME_MAX_LENGTH = 50
Expand All @@ -35,6 +36,12 @@ def __init__(self, name, collection_name=None, depends_on=None, noop=False):
raise ValueError(f"Fail to parse action name for component '{self.name}'")
self.action = match.group(1)

match = RE_GET_COMPONENT.search(self.name)
if not match:
self.component = None
else:
self.component = match.group(1)

def is_service(self):
"""Return True if the component is a service, False otherwise"""
"""Return True if the operation is about a service, False otherwise"""
return bool(RE_IS_SERVICE.search(self.name))

0 comments on commit 7c9193f

Please sign in to comment.