-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenum_example.py
32 lines (24 loc) · 956 Bytes
/
enum_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from enum import Enum
from genie_python.genie_script_generator import ScriptDefinition, cast_parameters_to
class DoRun(ScriptDefinition):
enum_params = ["process_status"]
class process_status_enum(Enum):
ok = 1
still_okay = 2
definitely_not_okay = 3
def run(self, process_status="not_working"):
print("Running do_run with process_status: " + process_status)
@cast_parameters_to(process_status=str)
def parameters_valid(self, process_status="ok"):
# check that the enum value of process_status is ok
if self.process_status_enum[process_status] == self.process_status_enum.definitely_not_okay:
return "process_status must be ok"
def estimate_time(self, process_status="ok"):
if process_status == "ok":
return 10
else:
return 0
def get_help(self):
return """
This is the example ENUM dropdown script.\n
"""