robot.parsing.model package — Robot Framework 7.0.1 documentation (original) (raw)
Submodules
robot.parsing.model.blocks module
class robot.parsing.model.blocks.Container[source]
Bases: Node, ABC
property lineno_: int_
property col_offset_: int_
property end_lineno_: int_
property end_col_offset_: int_
validate(ctx: ValidationContext)[source]
class robot.parsing.model.blocks.File(sections: Sequence[Section] = (), source: Path | None = None, languages: Sequence[str] = ())[source]
Bases: Container
save(output: Path | str | TextIO | None = None)[source]
Save model to the given output
or to the original source file.
The output
can be a path to a file or an already opened file object. If output
is not given, the original source file will be overwritten.
class robot.parsing.model.blocks.Block(header: Statement | None, body: Sequence[Statement | Block] = (), errors: Sequence[str] = ())[source]
Bases: Container, ABC
class robot.parsing.model.blocks.Section(header: Statement | None, body: Sequence[Statement | Block] = (), errors: Sequence[str] = ())[source]
Bases: Block
class robot.parsing.model.blocks.SettingSection(header: Statement | None, body: Sequence[Statement | Block] = (), errors: Sequence[str] = ())[source]
Bases: Section
class robot.parsing.model.blocks.VariableSection(header: Statement | None, body: Sequence[Statement | Block] = (), errors: Sequence[str] = ())[source]
Bases: Section
class robot.parsing.model.blocks.TestCaseSection(header: Statement | None, body: Sequence[Statement | Block] = (), errors: Sequence[str] = ())[source]
Bases: Section
property tasks_: bool_
class robot.parsing.model.blocks.KeywordSection(header: Statement | None, body: Sequence[Statement | Block] = (), errors: Sequence[str] = ())[source]
Bases: Section
Bases: Section
Bases: CommentSection
class robot.parsing.model.blocks.InvalidSection(header: Statement | None, body: Sequence[Statement | Block] = (), errors: Sequence[str] = ())[source]
Bases: Section
class robot.parsing.model.blocks.TestCase(header: Statement | None, body: Sequence[Statement | Block] = (), errors: Sequence[str] = ())[source]
Bases: Block
property name_: str_
validate(ctx: ValidationContext)[source]
class robot.parsing.model.blocks.Keyword(header: Statement | None, body: Sequence[Statement | Block] = (), errors: Sequence[str] = ())[source]
Bases: Block
property name_: str_
validate(ctx: ValidationContext)[source]
class robot.parsing.model.blocks.NestedBlock(header: Statement, body: Sequence[Statement | Block] = (), end: End | None = None, errors: Sequence[str] = ())[source]
Bases: Block
class robot.parsing.model.blocks.If(header: Statement, body: Sequence[Statement | Block] = (), orelse: If | None = None, end: End | None = None, errors: Sequence[str] = ())[source]
Bases: NestedBlock
Represents IF structures in the model.
Used with IF, Inline IF, ELSE IF and ELSE nodes. The type attribute specifies the type.
property type_: str_
property condition_: str | None_
property assign_: tuple[str, ...]_
validate(ctx: ValidationContext)[source]
class robot.parsing.model.blocks.For(header: Statement, body: Sequence[Statement | Block] = (), end: End | None = None, errors: Sequence[str] = ())[source]
Bases: NestedBlock
property assign_: tuple[str, ...]_
property variables_: tuple[str, ...]_
property values_: tuple[str, ...]_
property flavor_: str | None_
property start_: str | None_
property mode_: str | None_
property fill_: str | None_
validate(ctx: ValidationContext)[source]
class robot.parsing.model.blocks.Try(header: Statement, body: Sequence[Statement | Block] = (), next: Try | None = None, end: End | None = None, errors: Sequence[str] = ())[source]
Bases: NestedBlock
property type_: str_
property patterns_: tuple[str, ...]_
property pattern_type_: str | None_
property assign_: str | None_
property variable_: str | None_
validate(ctx: ValidationContext)[source]
class robot.parsing.model.blocks.While(header: Statement, body: Sequence[Statement | Block] = (), end: End | None = None, errors: Sequence[str] = ())[source]
Bases: NestedBlock
property condition_: str_
property limit_: str | None_
property on_limit_: str | None_
property on_limit_message_: str | None_
validate(ctx: ValidationContext)[source]
class robot.parsing.model.blocks.ModelWriter(output: Path | str | TextIO)[source]
Bases: ModelVisitor
visit_Statement(statement: Statement)[source]
class robot.parsing.model.blocks.ModelValidator[source]
Bases: ModelVisitor
visit_Block(node: Block)[source]
visit_Statement(node: Statement)[source]
class robot.parsing.model.blocks.ValidationContext[source]
Bases: object
block(node: Block) → Iterator[None][source]
property parent_block_: Block | None_
property tasks_: bool_
property in_keyword_: bool_
property in_loop_: bool_
property in_finally_: bool_
class robot.parsing.model.blocks.FirstStatementFinder[source]
Bases: ModelVisitor
classmethod find_from(model: Node) → Statement | None[source]
visit_Statement(statement: Statement)[source]
generic_visit(node: Node)[source]
Called if no explicit visitor function exists for a node.
class robot.parsing.model.blocks.LastStatementFinder[source]
Bases: ModelVisitor
classmethod find_from(model: Node) → Statement | None[source]
visit_Statement(statement: Statement)[source]
robot.parsing.model.statements module
class robot.parsing.model.statements.Node[source]
Bases: AST
, ABC
lineno_: int_
col_offset_: int_
end_lineno_: int_
end_col_offset_: int_
errors_: tuple[str, ...]_ = ()
class robot.parsing.model.statements.Statement(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: Node, ABC
type_: str_
handles_types_: ClassVar[tuple[str, ...]]_ = ()
statement_handlers_: ClassVar[dict[str, Type[Statement]]]_ = {'ARGUMENT': <class 'robot.parsing.model.statements.TemplateArguments'>, 'ARGUMENTS': <class 'robot.parsing.model.statements.Arguments'>, 'BREAK': <class 'robot.parsing.model.statements.Break'>, 'COMMENT': <class 'robot.parsing.model.statements.Comment'>, 'COMMENT HEADER': <class 'robot.parsing.model.statements.SectionHeader'>, 'CONFIG': <class 'robot.parsing.model.statements.Config'>, 'CONTINUE': <class 'robot.parsing.model.statements.Continue'>, 'DEFAULT TAGS': <class 'robot.parsing.model.statements.DefaultTags'>, 'DOCUMENTATION': <class 'robot.parsing.model.statements.Documentation'>, 'ELSE': <class 'robot.parsing.model.statements.ElseHeader'>, 'ELSE IF': <class 'robot.parsing.model.statements.ElseIfHeader'>, 'END': <class 'robot.parsing.model.statements.End'>, 'ERROR': <class 'robot.parsing.model.statements.Error'>, 'EXCEPT': <class 'robot.parsing.model.statements.ExceptHeader'>, 'FINALLY': <class 'robot.parsing.model.statements.FinallyHeader'>, 'FOR': <class 'robot.parsing.model.statements.ForHeader'>, 'IF': <class 'robot.parsing.model.statements.IfHeader'>, 'INLINE IF': <class 'robot.parsing.model.statements.InlineIfHeader'>, 'INVALID HEADER': <class 'robot.parsing.model.statements.SectionHeader'>, 'KEYWORD': <class 'robot.parsing.model.statements.KeywordCall'>, 'KEYWORD HEADER': <class 'robot.parsing.model.statements.SectionHeader'>, 'KEYWORD NAME': <class 'robot.parsing.model.statements.KeywordName'>, 'KEYWORD TAGS': <class 'robot.parsing.model.statements.KeywordTags'>, 'LIBRARY': <class 'robot.parsing.model.statements.LibraryImport'>, 'METADATA': <class 'robot.parsing.model.statements.Metadata'>, 'RESOURCE': <class 'robot.parsing.model.statements.ResourceImport'>, 'RETURN': <class 'robot.parsing.model.statements.ReturnSetting'>, 'RETURN STATEMENT': <class 'robot.parsing.model.statements.Return'>, 'SETTING HEADER': <class 'robot.parsing.model.statements.SectionHeader'>, 'SETUP': <class 'robot.parsing.model.statements.Setup'>, 'SUITE NAME': <class 'robot.parsing.model.statements.SuiteName'>, 'SUITE SETUP': <class 'robot.parsing.model.statements.SuiteSetup'>, 'SUITE TEARDOWN': <class 'robot.parsing.model.statements.SuiteTeardown'>, 'TAGS': <class 'robot.parsing.model.statements.Tags'>, 'TASK HEADER': <class 'robot.parsing.model.statements.SectionHeader'>, 'TEARDOWN': <class 'robot.parsing.model.statements.Teardown'>, 'TEMPLATE': <class 'robot.parsing.model.statements.Template'>, 'TEST SETUP': <class 'robot.parsing.model.statements.TestSetup'>, 'TEST TAGS': <class 'robot.parsing.model.statements.TestTags'>, 'TEST TEARDOWN': <class 'robot.parsing.model.statements.TestTeardown'>, 'TEST TEMPLATE': <class 'robot.parsing.model.statements.TestTemplate'>, 'TEST TIMEOUT': <class 'robot.parsing.model.statements.TestTimeout'>, 'TESTCASE HEADER': <class 'robot.parsing.model.statements.SectionHeader'>, 'TESTCASE NAME': <class 'robot.parsing.model.statements.TestCaseName'>, 'TIMEOUT': <class 'robot.parsing.model.statements.Timeout'>, 'TRY': <class 'robot.parsing.model.statements.TryHeader'>, 'VAR': <class 'robot.parsing.model.statements.Var'>, 'VARIABLE': <class 'robot.parsing.model.statements.Variable'>, 'VARIABLE HEADER': <class 'robot.parsing.model.statements.SectionHeader'>, 'VARIABLES': <class 'robot.parsing.model.statements.VariablesImport'>, 'WHILE': <class 'robot.parsing.model.statements.WhileHeader'>}
options_: dict[str, tuple | None]_ = {}
property lineno_: int_
property col_offset_: int_
property end_lineno_: int_
property end_col_offset_: int_
classmethod register(subcls: Type[T]) → Type[T][source]
Register a virtual subclass of an ABC.
Returns the subclass, to allow usage as a class decorator.
classmethod from_tokens(tokens: Sequence[Token]) → Statement[source]
Create a statement from given tokens.
Statement type is got automatically from token types.
This classmethod should be called from Statement, not from its subclasses. If you know the subclass to use, simply create an instance of it directly.
abstract classmethod from_params(*args, **kwargs) → Statement[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
property data_tokens_: list[Token]_
get_token(*types: str) → Token | None[source]
Return a token with any of the given types
.
If there are no matches, return None
. If there are multiple matches, return the first match.
get_tokens(*types: str) → list[Token][source]
Return tokens having any of the given types
.
get_value(type: str, default: str) → str[source]
get_value(type: str, default: None = None) → str | None
Return value of a token with the given type
.
If there are no matches, return default
. If there are multiple matches, return the value of the first match.
get_values(*types: str) → tuple[str, ...][source]
Return values of tokens having any of the given types
.
get_option(name: str, default: str | None = None) → str | None[source]
Return value of a configuration option with the given name
.
If the option has not been used, return default
.
If the option has been used multiple times, values are joined together. This is typically an error situation and validated elsewhere.
New in Robot Framework 6.1.
property lines_: Iterator[list[Token]]_
validate(ctx: ValidationContext)[source]
class robot.parsing.model.statements.DocumentationOrMetadata(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: Statement, ABC
property value_: str_
class robot.parsing.model.statements.SingleValue(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: Statement, ABC
property value_: str | None_
class robot.parsing.model.statements.MultiValue(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: Statement, ABC
property values_: tuple[str, ...]_
class robot.parsing.model.statements.Fixture(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: Statement, ABC
property name_: str_
property args_: tuple[str, ...]_
Bases: Statement
handles_types_: ClassVar[tuple[str, ...]]_ = ('SETTING HEADER', 'VARIABLE HEADER', 'TESTCASE HEADER', 'TASK HEADER', 'KEYWORD HEADER', 'COMMENT HEADER', 'INVALID HEADER')
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
class robot.parsing.model.statements.LibraryImport(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: Statement
type_: str_ = 'LIBRARY'
classmethod from_params(name: str, args: Sequence[str] = (), alias: str | None = None, separator: str = ' ', eol: str = '\n') → LibraryImport[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
property name_: str_
property args_: tuple[str, ...]_
property alias_: str | None_
class robot.parsing.model.statements.ResourceImport(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: Statement
type_: str_ = 'RESOURCE'
classmethod from_params(name: str, separator: str = ' ', eol: str = '\n') → ResourceImport[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
property name_: str_
class robot.parsing.model.statements.VariablesImport(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: Statement
type_: str_ = 'VARIABLES'
classmethod from_params(name: str, args: Sequence[str] = (), separator: str = ' ', eol: str = '\n') → VariablesImport[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
property name_: str_
property args_: tuple[str, ...]_
class robot.parsing.model.statements.Documentation(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: DocumentationOrMetadata
type_: str_ = 'DOCUMENTATION'
classmethod from_params(value: str, indent: str = ' ', separator: str = ' ', eol: str = '\n', settings_section: bool = True) → Documentation[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
class robot.parsing.model.statements.Metadata(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: DocumentationOrMetadata
type_: str_ = 'METADATA'
classmethod from_params(name: str, value: str, separator: str = ' ', eol: str = '\n') → Metadata[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
property name_: str_
class robot.parsing.model.statements.TestTags(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: MultiValue
type_: str_ = 'TEST TAGS'
classmethod from_params(values: Sequence[str], separator: str = ' ', eol: str = '\n') → TestTags[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
class robot.parsing.model.statements.DefaultTags(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: MultiValue
type_: str_ = 'DEFAULT TAGS'
classmethod from_params(values: Sequence[str], separator: str = ' ', eol: str = '\n') → DefaultTags[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
class robot.parsing.model.statements.KeywordTags(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: MultiValue
type_: str_ = 'KEYWORD TAGS'
classmethod from_params(values: Sequence[str], separator: str = ' ', eol: str = '\n') → KeywordTags[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
class robot.parsing.model.statements.SuiteName(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: SingleValue
type_: str_ = 'SUITE NAME'
classmethod from_params(value: str, separator: str = ' ', eol: str = '\n') → SuiteName[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
class robot.parsing.model.statements.SuiteSetup(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: Fixture
type_: str_ = 'SUITE SETUP'
classmethod from_params(name: str, args: Sequence[str] = (), separator: str = ' ', eol: str = '\n') → SuiteSetup[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
class robot.parsing.model.statements.SuiteTeardown(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: Fixture
type_: str_ = 'SUITE TEARDOWN'
classmethod from_params(name: str, args: Sequence[str] = (), separator: str = ' ', eol: str = '\n') → SuiteTeardown[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
class robot.parsing.model.statements.TestSetup(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: Fixture
type_: str_ = 'TEST SETUP'
classmethod from_params(name: str, args: Sequence[str] = (), separator: str = ' ', eol: str = '\n') → TestSetup[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
class robot.parsing.model.statements.TestTeardown(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: Fixture
type_: str_ = 'TEST TEARDOWN'
classmethod from_params(name: str, args: Sequence[str] = (), separator: str = ' ', eol: str = '\n') → TestTeardown[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
class robot.parsing.model.statements.TestTemplate(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: SingleValue
type_: str_ = 'TEST TEMPLATE'
classmethod from_params(value: str, separator: str = ' ', eol: str = '\n') → TestTemplate[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
class robot.parsing.model.statements.TestTimeout(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: SingleValue
type_: str_ = 'TEST TIMEOUT'
classmethod from_params(value: str, separator: str = ' ', eol: str = '\n') → TestTimeout[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
class robot.parsing.model.statements.Variable(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: Statement
type_: str_ = 'VARIABLE'
options_: dict[str, tuple | None]_ = {'separator': None}
classmethod from_params(name: str, value: str | Sequence[str], value_separator: str | None = None, separator: str = ' ', eol: str = '\n') → Variable[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
property name_: str_
property value_: tuple[str, ...]_
property separator_: str | None_
validate(ctx: ValidationContext)[source]
class robot.parsing.model.statements.TestCaseName(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: Statement
type_: str_ = 'TESTCASE NAME'
classmethod from_params(name: str, eol: str = '\n') → TestCaseName[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
property name_: str_
validate(ctx: ValidationContext)[source]
class robot.parsing.model.statements.KeywordName(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: Statement
type_: str_ = 'KEYWORD NAME'
classmethod from_params(name: str, eol: str = '\n') → KeywordName[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
property name_: str_
validate(ctx: ValidationContext)[source]
class robot.parsing.model.statements.Setup(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: Fixture
type_: str_ = 'SETUP'
classmethod from_params(name: str, args: Sequence[str] = (), indent: str = ' ', separator: str = ' ', eol: str = '\n') → Setup[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
class robot.parsing.model.statements.Teardown(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: Fixture
type_: str_ = 'TEARDOWN'
classmethod from_params(name: str, args: Sequence[str] = (), indent: str = ' ', separator: str = ' ', eol: str = '\n') → Teardown[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
class robot.parsing.model.statements.Tags(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: MultiValue
type_: str_ = 'TAGS'
classmethod from_params(values: Sequence[str], indent: str = ' ', separator: str = ' ', eol: str = '\n') → Tags[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
class robot.parsing.model.statements.Template(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: SingleValue
type_: str_ = 'TEMPLATE'
classmethod from_params(value: str, indent: str = ' ', separator: str = ' ', eol: str = '\n') → Template[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
class robot.parsing.model.statements.Timeout(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: SingleValue
type_: str_ = 'TIMEOUT'
classmethod from_params(value: str, indent: str = ' ', separator: str = ' ', eol: str = '\n') → Timeout[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
class robot.parsing.model.statements.Arguments(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: MultiValue
type_: str_ = 'ARGUMENTS'
classmethod from_params(args: Sequence[str], indent: str = ' ', separator: str = ' ', eol: str = '\n') → Arguments[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
validate(ctx: ValidationContext)[source]
class robot.parsing.model.statements.ReturnSetting(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: MultiValue
Represents the deprecated [Return]
setting.
This class was named Return
prior to Robot Framework 7.0. A forward compatible ReturnSetting
alias existed already in Robot Framework 6.1.
type_: str_ = 'RETURN'
classmethod from_params(args: Sequence[str], indent: str = ' ', separator: str = ' ', eol: str = '\n') → ReturnSetting[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
class robot.parsing.model.statements.KeywordCall(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: Statement
type_: str_ = 'KEYWORD'
classmethod from_params(name: str, assign: Sequence[str] = (), args: Sequence[str] = (), indent: str = ' ', separator: str = ' ', eol: str = '\n') → KeywordCall[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
property keyword_: str_
property args_: tuple[str, ...]_
property assign_: tuple[str, ...]_
class robot.parsing.model.statements.TemplateArguments(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: Statement
type_: str_ = 'ARGUMENT'
classmethod from_params(args: Sequence[str], indent: str = ' ', separator: str = ' ', eol: str = '\n') → TemplateArguments[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
property args_: tuple[str, ...]_
Bases: Statement
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
Bases: Statement, ABC
Bases: IfElseHeader
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
Bases: IfElseHeader
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
Bases: IfElseHeader
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
Bases: IfElseHeader
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
Bases: Statement, ABC
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
Bases: NoArgumentHeader
Bases: Statement
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
Bases: NoArgumentHeader
class robot.parsing.model.statements.End(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: NoArgumentHeader
type_: str_ = 'END'
Bases: Statement
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
class robot.parsing.model.statements.Var(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: Statement
type_: str_ = 'VAR'
options_: dict[str, tuple | None]_ = {'scope': ('GLOBAL', 'SUITE', 'TEST', 'TASK', 'LOCAL'), 'separator': None}
classmethod from_params(name: str, value: str | Sequence[str], scope: str | None = None, value_separator: str | None = None, indent: str = ' ', separator: str = ' ', eol: str = '\n') → Var[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
property name_: str_
property value_: tuple[str, ...]_
property scope_: str | None_
property separator_: str | None_
validate(ctx: ValidationContext)[source]
class robot.parsing.model.statements.Return(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: Statement
Represents the RETURN statement.
This class named ReturnStatement
prior to Robot Framework 7.0. The old name still exists as a backwards compatible alias.
type_: str_ = 'RETURN STATEMENT'
classmethod from_params(values: Sequence[str] = (), indent: str = ' ', separator: str = ' ', eol: str = '\n') → Return[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
property values_: tuple[str, ...]_
validate(ctx: ValidationContext)[source]
robot.parsing.model.statements.ReturnStatement
alias of Return
class robot.parsing.model.statements.LoopControl(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: NoArgumentHeader, ABC
validate(ctx: ValidationContext)[source]
class robot.parsing.model.statements.Continue(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: LoopControl
type_: str_ = 'CONTINUE'
class robot.parsing.model.statements.Break(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: LoopControl
type_: str_ = 'BREAK'
Bases: Statement
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
class robot.parsing.model.statements.Config(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: Statement
type_: str_ = 'CONFIG'
classmethod from_params(config: str, eol: str = '\n') → Config[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
property language_: Language | None_
class robot.parsing.model.statements.Error(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: Statement
type_: str_ = 'ERROR'
classmethod from_params(error: str, value: str = '', indent: str = ' ', eol: str = '\n') → Error[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
property values_: list[str]_
property errors_: tuple[str, ...]_
Errors got from the underlying ``ERROR``token.
Errors can be set also explicitly. When accessing errors, they are returned along with errors got from tokens.
class robot.parsing.model.statements.EmptyLine(tokens: Sequence[Token], errors: Sequence[str] = ())[source]
Bases: Statement
type_: str_ = 'EOL'
classmethod from_params(eol: str = '\n')[source]
Create a statement from passed parameters.
Required and optional arguments in general match class properties. Values are used to create matching tokens.
Most implementations support following general properties:
separator
whitespace inserted between each token. Default is four spaces.indent
whitespace inserted before first token. Default is four spaces.eol
end of line sign. Default is'\n'
.
This classmethod should be called from the Statement subclass to create, not from the Statement class itself.
class robot.parsing.model.statements.VariableValidator[source]
Bases: object
validate(statement: Statement)[source]
robot.parsing.model.visitor module
class robot.parsing.model.visitor.VisitorFinder[source]
Bases: object
generic_visit(node: Node) → None | Node | list[Node][source]
class robot.parsing.model.visitor.ModelVisitor[source]
Bases: NodeVisitor
, VisitorFinder
NodeVisitor that supports matching nodes based on their base classes.
The biggest difference compared to the standard ast.NodeVisitor, is that this class allows creating visit_ClassName
methods so that the ClassName
is one of the base classes of the node. For example, the following visitor method matches all node classes that extendStatement
:
def visit_Statement(self, node): ...
Another difference is that visitor methods are cached for performance reasons. This means that dynamically adding visit_Something
methods does not work.
visit(node: Node) → None[source]
Visit a node.
class robot.parsing.model.visitor.ModelTransformer[source]
Bases: NodeTransformer
, VisitorFinder
NodeTransformer that supports matching nodes based on their base classes.
See ModelVisitor for explanation how this is different compared to the standard ast.NodeTransformer.
visit(node: Node) → None | Node | list[Node][source]
Visit a node.