Skip to content

Commit fb816d4

Browse files
committed
Fix Python 3.9 compatibility: replace match statement with if/elif
1 parent 8557356 commit fb816d4

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

test/data/plugins/hello/plugin.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -91,24 +91,23 @@ def _entrypoint(ctx, plugin_content: dict, warnet_content: dict):
9191
"""Called by entrypoint"""
9292
hook_value = warnet_content[WarnetContent.HOOK_VALUE.value]
9393

94-
match hook_value:
95-
case (
96-
HookValue.PRE_NETWORK
97-
| HookValue.POST_NETWORK
98-
| HookValue.PRE_DEPLOY
99-
| HookValue.POST_DEPLOY
100-
):
101-
data = get_data(plugin_content)
102-
if data:
103-
_launch_pod(ctx, install_name=hook_value.value.lower() + "-hello", **data)
104-
else:
105-
_launch_pod(ctx, install_name=hook_value.value.lower() + "-hello")
106-
case HookValue.PRE_NODE:
107-
name = warnet_content[PLUGIN_ANNEX][AnnexMember.NODE_NAME.value] + "-pre-hello-pod"
108-
_launch_pod(ctx, install_name=hook_value.value.lower() + "-" + name, podName=name)
109-
case HookValue.POST_NODE:
110-
name = warnet_content[PLUGIN_ANNEX][AnnexMember.NODE_NAME.value] + "-post-hello-pod"
111-
_launch_pod(ctx, install_name=hook_value.value.lower() + "-" + name, podName=name)
94+
if hook_value in (
95+
HookValue.PRE_NETWORK,
96+
HookValue.POST_NETWORK,
97+
HookValue.PRE_DEPLOY,
98+
HookValue.POST_DEPLOY,
99+
):
100+
data = get_data(plugin_content)
101+
if data:
102+
_launch_pod(ctx, install_name=hook_value.value.lower() + "-hello", **data)
103+
else:
104+
_launch_pod(ctx, install_name=hook_value.value.lower() + "-hello")
105+
elif hook_value == HookValue.PRE_NODE:
106+
name = warnet_content[PLUGIN_ANNEX][AnnexMember.NODE_NAME.value] + "-pre-hello-pod"
107+
_launch_pod(ctx, install_name=hook_value.value.lower() + "-" + name, podName=name)
108+
elif hook_value == HookValue.POST_NODE:
109+
name = warnet_content[PLUGIN_ANNEX][AnnexMember.NODE_NAME.value] + "-post-hello-pod"
110+
_launch_pod(ctx, install_name=hook_value.value.lower() + "-" + name, podName=name)
112111

113112

114113
def get_data(plugin_content: dict) -> Optional[dict]:

0 commit comments

Comments
 (0)