fmetools.scripted_selection
This module defines the API for the Scripted Selection GUI element. A Scripted Selection provides choices that may be presented in a tree structure. Each choice has a display name and an ID. This GUI element is typically used to present choices that:
Originate from an external API
Vary depending on the value of other parameters
Have a hierarchy, such as files and folders
Have a user-facing display name and an internal ID that’s very different
Have IDs that are not meaningful to the user, such as GUIDs
A Scripted Selection is composed of two parts:
An implementation of
ScriptedSelectionCallback
A Scripted Selection GUI element definition, which includes a reference to the
ScriptedSelectionCallback
implementation above, and other configuration, such as Input Parameters, search support, and more.
- class fmetools.scripted_selection.ContainerContentResponse(contents: List[Item], continuation: PaginationInfo | None = None)
Bases:
dict
Represents the return value of
ScriptedSelectionCallback.get_container_contents()
that’s expected by FME.- __init__(contents: List[Item], continuation: PaginationInfo | None = None)
- property pagination: PaginationInfo | None
If there are more results to fetch, then this holds the arguments needed to request the next page of results. The arguments are added to the next call to
ScriptedSelectionCallback.get_container_contents()
.
- class fmetools.scripted_selection.Item(id: str, name: str, is_container: bool)
Bases:
dict
An Item is a selectable element in a Scripted Selection. Containers are a type of Item that may contain other Items. Every Item has an ID, a display name, and a flag for whether it represents a container.
- class fmetools.scripted_selection.PaginationInfo(args: Dict[str, Any])
Bases:
dict
Holds the information needed to request the next page of results for a Scripted Selection.
- class fmetools.scripted_selection.ScriptedSelectionCallback(args: dict[str, Any])
Bases:
ABC
Abstract base class representing the interface for Scripted Selection GUI element callbacks.
Every Scripted Selection element must specify an implementation of this class.
- __init__(args: dict[str, Any])
- Parameters:
args – The names and values of the Input Parameters and Input Dictionary configured on the Scripted Selection GUI element.
- abstractmethod get_container_contents(*, container_id: str | None = None, limit: int | None = None, query: str | None = None, **kwargs) ContainerContentResponse
Get the Items in a given container. Returns direct children only. Must not return other descendants.
- Parameters:
container_id – Return the Items in the container with this ID. The root container may be represented by None, empty string, “/”, or a default value defined by the implementation.
limit – The maximum number of Items this method should return. If the number of Items in the container exceeds this limit, then pagination info should also be returned.
query – A string to filter the results by. The implementation decides how to interpret the value. Only applicable if the Scripted Selection supports search and the user has provided input in the search field.
kwargs –
Additional arguments, including:
Input Parameters. Values may have changed from initialization.
Input Dictionary.
Pagination arguments if this is a request for the next page of results.
- Returns:
A response that lists the container’s direct children, with pagination arguments for the next page if applicable.