summaryrefslogtreecommitdiff
path: root/src/services/api/graphql/utils/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/services/api/graphql/utils/util.py')
-rw-r--r--src/services/api/graphql/utils/util.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/services/api/graphql/utils/util.py b/src/services/api/graphql/utils/util.py
index bf30f673a..e3dea31bf 100644
--- a/src/services/api/graphql/utils/util.py
+++ b/src/services/api/graphql/utils/util.py
@@ -39,3 +39,17 @@ def is_show_function_name(name):
if re.match(r"^show", name):
return True
return False
+
+def _nth_rsplit(delim: str, n: int, s: str):
+ groups = s.split(delim)
+ l = len(groups)
+ if n > l-1:
+ return ('', s)
+ return (delim.join(groups[:l-n]), delim.join(groups[l-n:]))
+
+def split_compound_op_mode_name(name: str, files: list):
+ for i in range(1, name.count('_') + 1):
+ pair = _nth_rsplit('_', i, name)
+ if pair[1] in files:
+ return pair
+ return (name, '')