-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathgeneral_functionalities.py
41 lines (36 loc) · 1.64 KB
/
general_functionalities.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
33
34
35
36
37
38
39
40
41
class ParseShowCommandFunction:
@staticmethod
def parse_show_command(steps, device, command_name: str):
with steps.start(f"Parsing {command_name}", continue_=True) as step:
try:
return device.parse(command_name)
except Exception as e:
step.failed('Could not parse it correctly\n{e}'.format(e=e))
return None
class ParseLearnFunction:
@staticmethod
def parse_learn(steps, device, function_name: str):
with steps.start(f'Learning {function_name}',continue_=True) as step:
try:
return device.learn(function_name).info
except Exception as e:
step.failed('Could not learn it correctly\n{e}'.format(e=e))
return None
class ParseConfigFunction:
@staticmethod
def parse_learn(steps, device, function_name: str):
with steps.start(f'Learning {function_name}',continue_=True) as step:
try:
return device.learn(function_name)
except Exception as e:
step.failed('Could not learn it correctly\n{e}'.format(e=e))
return None
class ParseDictFunction:
@staticmethod
def parse_learn(steps, device, function_name: str):
with steps.start(f'Learning {function_name}',continue_=True) as step:
try:
return device.learn(function_name).to_dict()
except Exception as e:
step.failed('Could not learn it correctly\n{e}'.format(e=e))
return None