Skip to content

topic/dictionary functions #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 17, 2019
Merged

topic/dictionary functions #1

merged 4 commits into from
Apr 17, 2019

Conversation

jgoetzinger
Copy link
Contributor

In many testcases it is desired to convert the output of a command into a dictionary. The function "split_output_to_dict" executes a command with a given command protocol and generates a dictionary from the output.

Jonathan Goetzinger added 2 commits April 4, 2019 09:42
In many testcases it is desired to convert the output of a command into
a dictionary. The function "split_output_to_dict" executes a command
with a given command protocol and generates a dictionary from the output.

Signed-off-by: Jonathan Goetzinger <j.goetzinger@eckelmann.de>
Signed-off-by: Jonathan Goetzinger <j.goetzinger@eckelmann.de>
@jgoetzinger jgoetzinger changed the title Topic/dictionary functions topic/dictionary functions Apr 4, 2019
Do not count delimiters to check if the line contains one or more delimiters.

Signed-off-by: Jonathan Goetzinger <j.goetzinger@eckelmann.de>
Copy link
Member

@Emantor Emantor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good, however I think the submodule dictionary_functions is quite long. Maybe labgridhelper.dict? Or reference it as a module for the command protocol, i.e. labgridhelper.command?
I think the helper function should not execute the command and leave that to the caller. This affords a more flexible use which does not rely on using the run_check call and allows use with run instead. We also only need to take a command_protocol output in this case.
Than it should also be renamed to split_command_output_to_dict.

@@ -0,0 +1,23 @@
def split_output_to_dict(command_protocoll, command, delimiter="=", strip_chars=""):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

command_protocol with one l please. Other occurences in the file need to be fixed as well.

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 <j.goetzinger@eckelmann.de>
@jgoetzinger
Copy link
Contributor Author

Thanks for the feedback. I changed the function so that it no longer executes the command. Instead it takes the command output as an input argument. The module and function names are shorter now.

@Emantor Emantor merged commit 6a0c746 into labgrid-project:master Apr 17, 2019
@Emantor
Copy link
Member

Emantor commented Apr 17, 2019

Thanks!

@jgoetzinger jgoetzinger deleted the topic/dictionary_functions branch April 17, 2019 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants