Skip to content

Commit 4eb74c4

Browse files
author
Jonathan Goetzinger
committed
dictionary_functions: renamed to dict, do not execute commands
the function split_to_dict is no longer executing the command. Instead it takes the command output as an input argument. This leaves the decision to execute with run or with run_check to the caller. Signed-off-by: Jonathan Goetzinger <[email protected]>
1 parent 549870c commit 4eb74c4

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

labgridhelper/barebox.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from labgrid.driver import BareboxDriver
2-
from labgridhelper.dictionary_functions import split_output_to_dict
2+
from labgridhelper.dict import split_to_dict
33

44
def get_commands(command):
55
"""Returns the available commands of a running Barebox bootloader
@@ -25,4 +25,5 @@ def get_globals(command):
2525
dict: name as key and value as key-value
2626
"""
2727
assert isinstance(command, BareboxDriver)
28-
return split_output_to_dict(command, "global", delimiter=":", strip_chars="* ")
28+
out = command.run_check("global")
29+
return split_to_dict(out, delimiter=":", strip_chars="* ")

labgridhelper/dictionary_functions.py renamed to labgridhelper/dict.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
def split_output_to_dict(command_protocoll, command, delimiter="=", strip_chars=""):
1+
def split_to_dict(command_output, delimiter="=", strip_chars=""):
22
'''
3-
returns a dictionary that contains the results of the command, where the key
4-
is the part before and the value is the part after the first delimiter optional
5-
chars can be specified to be stript from the value
3+
returns a dictionary that splits the content of the command_output.
4+
The key is the part before and the value is the part after the first
5+
delimiter. Optional chars can be specified to be stript from key and
6+
value.
67
Args:
7-
command_protocoll: command_protocoll to execute command (shell, barebox, ...)
8-
command: command to execute
8+
command_output: output to split into dict
99
delimiter: character that seperates key and value
1010
strip_chars: characters to strip from key and value
1111
Returns:
1212
output_dict: dictionary that contains the pairs of key and value
1313
'''
14-
command_output = command_protocoll.run_check(command)
1514
output_dict = {}
1615
for line in command_output:
1716
try:

0 commit comments

Comments
 (0)