flowserv.scanner module
Simple scanner classes to collect values (e.g., for template parameters) from different sources (e.g. standard input). The Scanner class implements the methods that are used to convert input values into the different data types that are supported for parameter declarations.
- class flowserv.scanner.InputReader
Bases:
flowserv.scanner.TokenReaderToken reader that reads tokens from standard input.
- next_token()
Read token from standard input.
- Return type
string
- class flowserv.scanner.ListReader(tokens)
Bases:
flowserv.scanner.TokenReaderToken reader that is initialized with a list of values. Returns tokens from the list until the end of the list is reached.
- next_token()
Return next token from the token list. If the end of the list has been reached None is returned.
- Return type
string
- class flowserv.scanner.Scanner(reader=None)
Bases:
objectScanner that converts input tokens into the simple scalar data types boolean, float, file, integer and string that are supported in the template parameter declarations.
- next_bool(default_value=None)
Return next token as boolean. If the read token is an empty string the given default value is returned.
Raises ValueError if the token value cannot be converted to boolean.
Any of the following values will be recognized as valid boolean values. All values are case-insensitive:
True: [true, yes, y, t, 1]
False:[false, no, n, f, 0]
- Parameters
default_value (bool, optional) – Default value that is returned if the read token is an empty string
- Return type
bool
- next_file(default_value=None)
Return next token as string representing a file name. There are no tests performed to ensure whether the given value represents a valid path name or not (since the definition of a valid path name is very much dependent on the OS).
- Parameters
default_value (string, optional) – Default value that is returned if the read token is an empty string
- Return type
string
- next_float(default_value=None)
Return next token as float. Raises ValueError if the token value cannot be converted to float.
- Parameters
default_value (float, optional) – Default value that is returned if the read token is an empty string
- Return type
float
- next_int(default_value=None)
Return next token as integer. Raises ValueError if the token value cannot be converted to integer.
- Parameters
default_value (int, optional) – Default value that is returned if the read token is an empty string
- Return type
int
- next_string(default_value=None)
Return next token as string.
- Parameters
default_value (string, optional) – Default value that is returned if the read token is an empty string
- Return type
string