robot.parsing.parser package

Submodules

robot.parsing.parser.blockparsers module

class robot.parsing.parser.blockparsers.Parser(model: Container)[source]

Bases: ABC

model: Container
abstract handles(statement: Statement) bool[source]
abstract parse(statement: Statement) Parser | None[source]
class robot.parsing.parser.blockparsers.BlockParser(model: Block)[source]

Bases: Parser, ABC

model: Block
unhandled_tokens = frozenset({'COMMENT HEADER', 'INVALID HEADER', 'KEYWORD HEADER', 'KEYWORD NAME', 'SETTING HEADER', 'TASK HEADER', 'TESTCASE HEADER', 'TESTCASE NAME', 'VARIABLE HEADER'})
handles(statement: Statement) bool[source]
parse(statement: Statement) BlockParser | None[source]
class robot.parsing.parser.blockparsers.TestCaseParser(model: Block)[source]

Bases: BlockParser

model: TestCase
class robot.parsing.parser.blockparsers.KeywordParser(model: Block)[source]

Bases: BlockParser

model: Keyword
class robot.parsing.parser.blockparsers.NestedBlockParser(model: NestedBlock, handle_end: bool = True)[source]

Bases: BlockParser, ABC

model: NestedBlock
handles(statement: Statement) bool[source]
parse(statement: Statement) BlockParser | None[source]
class robot.parsing.parser.blockparsers.ForParser(model: NestedBlock, handle_end: bool = True)[source]

Bases: NestedBlockParser

model: For
class robot.parsing.parser.blockparsers.WhileParser(model: NestedBlock, handle_end: bool = True)[source]

Bases: NestedBlockParser

model: While
class robot.parsing.parser.blockparsers.IfParser(model: NestedBlock, handle_end: bool = True)[source]

Bases: NestedBlockParser

model: If
parse(statement: Statement) BlockParser | None[source]
class robot.parsing.parser.blockparsers.TryParser(model: NestedBlock, handle_end: bool = True)[source]

Bases: NestedBlockParser

model: Try
parse(statement) BlockParser | None[source]

robot.parsing.parser.fileparser module

class robot.parsing.parser.fileparser.FileParser(source: Path | str | TextIO | None = None)[source]

Bases: Parser

model: File
handles(statement: Statement) bool[source]
parse(statement: Statement) SectionParser[source]
class robot.parsing.parser.fileparser.SectionParser(model: Container)[source]

Bases: Parser

model: Section
handles(statement: Statement) bool[source]
parse(statement: Statement) Parser | None[source]
class robot.parsing.parser.fileparser.SettingSectionParser(model: Container)[source]

Bases: SectionParser

model: SettingSection
class robot.parsing.parser.fileparser.VariableSectionParser(model: Container)[source]

Bases: SectionParser

model: VariableSection
class robot.parsing.parser.fileparser.CommentSectionParser(model: Container)[source]

Bases: SectionParser

model: CommentSection
class robot.parsing.parser.fileparser.ImplicitCommentSectionParser(model: Container)[source]

Bases: SectionParser

model: ImplicitCommentSection
class robot.parsing.parser.fileparser.InvalidSectionParser(model: Container)[source]

Bases: SectionParser

model: InvalidSection
class robot.parsing.parser.fileparser.TestCaseSectionParser(model: Container)[source]

Bases: SectionParser

model: TestCaseSection
parse(statement: Statement) Parser | None[source]
class robot.parsing.parser.fileparser.KeywordSectionParser(model: Container)[source]

Bases: SectionParser

model: KeywordSection
parse(statement: Statement) Parser | None[source]

robot.parsing.parser.parser module

robot.parsing.parser.parser.get_model(source: Path | str | TextIO, data_only: bool = False, curdir: str | None = None, lang: Languages | Language | str | Path | Iterable[Language | str | Path] | None = None) File[source]

Parses the given source into a model represented as an AST.

How to use the model is explained more thoroughly in the general documentation of the robot.parsing module.

Parameters:
  • source – The source where to read the data. Can be a path to a source file as a string or as pathlib.Path object, an already opened file object, or Unicode text containing the date directly. Source files must be UTF-8 encoded.

  • data_only – When False (default), returns all tokens. When set to True, omits separators, comments, continuation markers, and other non-data tokens. Model like this cannot be saved back to file system.

  • curdir – Directory where the source file exists. This path is used to set the value of the built-in ${CURDIR} variable during parsing. When not given, the variable is left as-is. Should only be given only if the model will be executed afterward. If the model is saved back to disk, resolving ${CURDIR} is typically not a good idea.

  • lang – Additional languages to be supported during parsing. Can be a string matching any of the supported language codes or names, an initialized Language subclass, a list containing such strings or instances, or a Languages instance.

Use get_resource_model() or get_init_model() when parsing resource or suite initialization files, respectively.

robot.parsing.parser.parser.get_resource_model(source: Path | str | TextIO, data_only: bool = False, curdir: str | None = None, lang: Languages | Language | str | Path | Iterable[Language | str | Path] | None = None) File[source]

Parses the given source into a resource file model.

Same as get_model() otherwise, but the source is considered to be a resource file. This affects, for example, what settings are valid.

robot.parsing.parser.parser.get_init_model(source: Path | str | TextIO, data_only: bool = False, curdir: str | None = None, lang: Languages | Language | str | Path | Iterable[Language | str | Path] | None = None) File[source]

Parses the given source into an init file model.

Same as get_model() otherwise, but the source is considered to be a suite initialization file. This affects, for example, what settings are valid.

class robot.parsing.parser.parser.ConfigParser(model: File)[source]

Bases: ModelVisitor

classmethod parse(model: File)[source]
visit_Config(node: Config)[source]