blark.util.get_source_code
- blark.util.get_source_code(fn: str | Path, *, encoding: str = 'utf-8') str [source]
Get source code from the given file.
Supports TwinCAT source files (in XML format) or plain text files.
- Parameters:
- fnstr or pathlib.Path
The path to the source code file.
- encodingstr, optional, keyword-only
The encoding to use when opening the file. Defaults to utf-8.
- Returns:
- str
The source code.
- Raises:
- FileNotFoundError
If
fn
does not point to a valid file.- ValueError
If a TwinCAT file is specified but no source code is associated with it.