Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save RaminNietzsche/f46a7b77fbd985ee89c91fb58f775a73 to your computer and use it in GitHub Desktop.

Select an option

Save RaminNietzsche/f46a7b77fbd985ee89c91fb58f775a73 to your computer and use it in GitHub Desktop.
stofl
I use python cli to make command line for a program, I changed it to read data from some dictionary for autocomplete like this:
> command ordinary : show system top sort_cpu ---> execute show_top_function
show_command_dic = {
'system': {
'datetime' : {show_time_function},
'cpu' : {show_cpu_function},
'mem' : {show_mem_function},
'disk' : {show_disk_function},
'top' : {
'sort_cpu': {show_top_function},
'sort_mem': {show_top_function},
},
}
}
I read data and show in autocomplete, now I have problem whit some dynamic case that I need to read them from the database and send them to autocomplete function. my autocomplete function support this format (shown in above) and when I fetch data from the database I can store them in a list like this:
lst = [{'a' : 'b'}, {'c' : 'd'}, {'e' : 'f__function'}]
but I can't convert it to correct format:
nd = {
'a': {
'b': {
'c': {
'd': {
'e': { f_input }
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment