FileScope#
- class FileScope#
Bases: contextlib.AbstractContextManager
, abc.ABC
Provides an abstract base for file scopes.
Overview#
Close the |
|
Read the contents of a file and create a new |
|
Create a |
Raise any exception triggered within the runtime context. |
Import detail#
from ansys.tools.variableinterop.file_scope import FileScope
Method detail#
- FileScope.__exit__(__exc_type: Type[BaseException] | None, __exc_value: BaseException | None, __traceback: types.TracebackType | None) bool | None #
Raise any exception triggered within the runtime context.
- abstract FileScope.read_from_file(to_read: os.PathLike, mime_type: str | None = None, encoding: str | None = None) ansys.tools.variableinterop.file_value.FileValue #
Read the contents of a file and create a new
FileValue
object backed by a file in this scope.- Parameters:
- to_read
PathLike
Path to the file to read.
- mime_type
Optional
[str
],optional
MIME type of the file. The default is None, which indicates that the file does not have a MIME type or that the type is not known.
- encoding
Optional
[str
],optional
Encoding of the file. The default is None, which indicates that the file does not have a text encoding (for example, because it is a binary file.)
- to_read
- Returns:
FileValue
New
FileValue
object with the contents of the specified file, backed by this scope.
- abstract FileScope.from_api_object(api_object: Dict[str, str | None], load_context: ansys.tools.variableinterop.isave_context.ILoadContext) ansys.tools.variableinterop.file_value.FileValue #
Create a
FileScope
instance from a map of API strings.- Parameters:
- api_object
Dict
[str
,Optional
[str
]] Map of API strings that define the scope.
- load_context
ILoadContext
Load context to read the file contents from.
- api_object