pytuflow.Scope.from_string#
- static Scope.from_string(template, string, event_var=None)#
Extracts scope from a string. It will also try and extract the scope name based on another string object.
e.g.
template = 'test_files_<<~s~>>.txt' string = 'test_files_scenario1.txt' scope = Scope('SCENARIO', name='scenario1', var='<<~s~>>')
If it can’t figure out the scope name, the name will be the same as the variable name. There is no obligation to be able to extract the scope name, it just may be useful later to get the user a list of possible scope names.
- Parameters:
template (str) – the raw string that contains variables in it
string (str) – the completed string that has been filled in with values
event_var (list[str], optional) – a list of patterns to search for in the string to try and extract event variable names
- Returns:
A list of Scope objects that represent the scopes in the string.
- Return type:
ScopeList