robottelo.cli.hammer
¶
Helpers to interact with hammer command line utility.
Module Contents¶
Functions¶
|
An unicode CSV reader which processes unicode strings and return unicode |
|
Replace empty spaces with ‘-’ and lower all chars |
|
Parse JSON output from Hammer CLI and convert it to python dictionary |
|
Normalize all dict’s keys replacing empty spaces with “-” and lowering |
|
Parse CSV output from Hammer CLI and convert it to python dictionary. |
|
Parse the help output from a hammer command and return a dictionary |
|
Return the number of spaces chars the line begin with |
|
Return the indentation level |
|
Parse the info output and returns a dict mapping the values. |
- robottelo.cli.hammer._csv_reader(output)[source]¶
An unicode CSV reader which processes unicode strings and return unicode strings data.
This is needed because the builtin module does not support unicode strings, from Python 2 docs:
Note: This version of the csv module doesn't support Unicode input. Also, there are currently some issues regarding ASCII NUL characters. Accordingly, all input should be UTF-8 or printable ASCII to be safe;"
On Python 3 this generator is not needed because the default string type is unicode.
- Parameters
output – can be any object which supports the iterator protocol and returns a unicode string each time its next() method is called.
- Returns
generator that will yield a list of unicode string values.
- robottelo.cli.hammer.parse_json(stdout)[source]¶
Parse JSON output from Hammer CLI and convert it to python dictionary while normalizing keys.
- robottelo.cli.hammer._normalize_obj(obj)[source]¶
Normalize all dict’s keys replacing empty spaces with “-” and lowering chars
- robottelo.cli.hammer.parse_csv(output)[source]¶
Parse CSV output from Hammer CLI and convert it to python dictionary.
- robottelo.cli.hammer.parse_help(output)[source]¶
Parse the help output from a hammer command and return a dictionary mapping the subcommands and options accepted by that command.
- robottelo.cli.hammer.get_line_indentation_spaces(line, tab_spaces=4)[source]¶
Return the number of spaces chars the line begin with
- Parameters
line (str) – the line string to parse
tab_spaces (int) – The tab char is represent how many spaces
- robottelo.cli.hammer.get_line_indentation_level(line, tab_spaces=4, indentation_spaces=4)[source]¶
Return the indentation level
- Parameters
line (str) – the line string to parse
tab_spaces (int) – The tab char is represent how many spaces
indentation_spaces – how much spaces represent an indentation level
Note:
suppose we have the following lines: ''' level 0 level 1 level 2 ''' assert get_line_indentation_level('level 0') == 0 assert get_line_indentation_level(' level 1') == 1 assert get_line_indentation_level(' level 2') == 2