silo.low_code_steps.standard.parser module

class silo.low_code_steps.standard.parser.CSVParser

Bases: object

get_opts(action_arg)
class silo.low_code_steps.standard.parser.RegexParser

Bases: object

execute_regex(method_to_call, regex, data, flags)

Execute re.func function to get matched data.

Parameters
  • method_to_call (re.func) – re.function to execute.

  • regex (str) – valid regular expression.

  • data (str) – string where will be applied the regex.

  • flags (int) – sum of flags to take into account in the method execution.

Returns

re.function execution output.

Raises

ParserError – Not supported re.function on the parser.

generate_results(result)

Execute re.func function to get matched data.

generate_results(<re.Match object; span=(4, 7), match='o.C'>)
{
    "match": "o.C",
    "groups": (),
    "span": (4, 7)
 }
Parameters

result (object) – re.function execution output.

Returns

dictionary with relevant information.

Return type

dict

parse_arg_flags(step_config)

Parses the requested flags into a list

parse_arg_flags({"flags": "I,M"})
[re.IGNORECASE, re.MATCHALL]
Parameters

step_config (dict) – Configuration for the step

Returns

List of regex flags to use

Return type

list

parse_arg_method(step_config)

Validates and returns a callable re function.

parse_arg_flags({"method": "search"})
re.search
Parameters

step_config (dict) – Configuration for the step

Returns

callable function

Return type

re.function

Raises

ParserError – If the re.function is not callable.

parse_arg_regex(step_config)

Validates that the regex is valid

parse_arg_regex({"regex": "(.*))"}, "(.*)")
"(.*))"

parse_arg_regex({}, "(.*)")
"(.*))"
Parameters

step_config (dict) – Configuration for the step

Returns

Regular Expression to be executed

Return type

str

Raises

ParserError – Invalid regex or not provided.

parse_args(step_config)

Parse required args for the parser.

{
     "flags": ["I","M"],
     "method": "match",
     "regex": r"[a-z]\.[A-Z]")
 }
{
    "regex": r"[a-z]\.[A-Z]",
    "method": callable re.function,
    "flags": [re.IGNORECASE, re.MULTILINE]
 }
Parameters

step_config (dict) – Configuration for the step

Returns

parsed args in a dictionary.

Return type

dict

silo.low_code_steps.standard.parser.dummy(result)

Return the value unchanged

silo.low_code_steps.standard.parser.json_parser(result)

Converts the JSON string into a python dictionary

Parameters

result (object) – Result from the previous step

Returns

Python representation of the JSON object

Return type

object

silo.low_code_steps.standard.parser.stringfloat(result)

Parse a string to a float.

If the string contains multiple floats, return the first one.

Raises

ResultsParsingError – When anything but a string with parsable digits is passed.

silo.low_code_steps.standard.parser.stringint(result)
TODO: Filters out all characters and returns all numbers as a combined

integer. This is slightly strange behavior, because most people would not expect it to work that way, but it is retaining behavior from silo_ssh. Change this if it is not specifically needed.

Raises

ResultsParsingError – When a non-numeric string/value is passed.