Skip to content

robot.parsing.model.blocks

File

1
2
3
4
5
File(
    sections: Sequence[Section] = (),
    source: Path | None = None,
    languages: Sequence[str] = (),
)

Bases: Container

Source code in src/robot/parsing/model/blocks.py
def __init__(self, sections: 'Sequence[Section]' = (), source: 'Path|None' = None,
             languages: Sequence[str] = ()):
    super().__init__()
    self.sections = list(sections)
    self.source = source
    self.languages = list(languages)

save

save(output: Path | str | TextIO | None = None)

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.

Source code in src/robot/parsing/model/blocks.py
def save(self, output: 'Path|str|TextIO|None' = None):
    """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.
    """
    output = output or self.source
    if output is None:
        raise TypeError('Saving model requires explicit output '
                        'when original source is not path.')
    ModelWriter(output).write(self)

If

1
2
3
4
5
6
7
If(
    header: Statement,
    body: Body = (),
    orelse: If | None = None,
    end: End | None = None,
    errors: Errors = (),
)

Bases: NestedBlock

Represents IF structures in the model.

Used with IF, Inline IF, ELSE IF and ELSE nodes. The :attr:type attribute specifies the type.

Source code in src/robot/parsing/model/blocks.py
def __init__(self, header: Statement, body: Body = (), orelse: 'If|None' = None,
             end: 'End|None' = None, errors: Errors = ()):
    super().__init__(header, body, end, errors)
    self.orelse = orelse