Class NotebookReader
java.lang.Object
io.deephaven.enterprise.dnd.notebook.NotebookReader
Tools for getting Files and Folders out of the Web IDE notebooks that are stored in DbInternal.WorkspaceData.
This is exposed from the deephaven_enterprise.notebook Python module.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
A record class that represents a file or folder.static final class
An exception thrown when a Notebook is not found. -
Method Summary
Modifier and TypeMethodDescriptionstatic NotebookReader
Creates a notebook reader that takes a static snapshot of notebook state as the basis for its operations.static NotebookReader
Functions likecreate(Database)
, except notebook state is live and a callback is executed when notebooks are added or removed.static @NotNull NotebookReader.FileOrFolder
getFileOrFolder
(@NotNull Database database, @NotNull String path, boolean usesSlash, @NotNull String suffix) Functions asgetFileOrFolder(Database, String, boolean, String, Table)
, except without providing workspace data.static @NotNull NotebookReader.FileOrFolder
getFileOrFolder
(@NotNull Database database, @NotNull String path, boolean usesSlash, @NotNull String suffix, @Nullable Table workspaceData) Gets a FileOrFolder pointed to by path.Get the available notebook path names.getNotebookPaths
(@NotNull String suffix) Functions likegetNotebookPaths()
, except notebooks will be filtered by the supplied suffix.static @NotNull String
getNotebookText
(@NotNull Database database, @NotNull String notebookName) Functions asgetNotebookText(Database, String, Table)
, except without providing workspace data.static @NotNull String
getNotebookText
(@NotNull Database database, @NotNull String notebookName, @Nullable Table workspaceData) Get the text of a notebook at the given path.getNotebookText
(@NotNull String notebookName) Get the text of a notebook at the given path.
-
Method Details
-
create
Creates a notebook reader that takes a static snapshot of notebook state as the basis for its operations.- Parameters:
database
- the database object to retrieve tables and the user context from (must be aDatabaseInternal
)- Returns:
- a new notebook reader
-
create
public static NotebookReader create(@NotNull @NotNull Database database, @NotNull @NotNull Runnable callback) Functions likecreate(Database)
, except notebook state is live and a callback is executed when notebooks are added or removed.- Parameters:
database
- the database object to retrieve tables and the user context from (must be aDatabaseInternal
)callback
- logic to execute upon notebook addition or removal- Returns:
- a new notebook reader
-
getNotebookPaths
Get the available notebook path names.- Returns:
- the available notebook path names, or an empty set if none are available
-
getNotebookPaths
Functions likegetNotebookPaths()
, except notebooks will be filtered by the supplied suffix.- Parameters:
suffix
- optional suffix to filter notebook names- Returns:
- the available notebook path names, or an empty set if none are available
-
getNotebookText
Get the text of a notebook at the given path.- Parameters:
notebookName
- the name of the notebook, starting with "/"- Returns:
- the text of the notebook, if not found an Exception is thrown
-
getNotebookText
@NotNull public static @NotNull String getNotebookText(@NotNull @NotNull Database database, @NotNull @NotNull String notebookName, @Nullable @Nullable Table workspaceData) Get the text of a notebook at the given path.- Parameters:
database
- the database object to retrieve tables and the user context from (must be aDatabaseInternal
)notebookName
- the name of the notebook, starting with "/"workspaceData
- optional source of workspace data to base processing on- Returns:
- the text of the notebook, if not found an Exception is thrown
-
getNotebookText
@NotNull public static @NotNull String getNotebookText(@NotNull @NotNull Database database, @NotNull @NotNull String notebookName) Functions asgetNotebookText(Database, String, Table)
, except without providing workspace data.- Parameters:
database
- the database object to retrieve tables and the user context from (must be aDatabaseInternal
)notebookName
- the name of the notebook, starting with "/"- Returns:
- the text of the notebook, if not found an Exception is thrown
-
getFileOrFolder
@NotNull public static @NotNull NotebookReader.FileOrFolder getFileOrFolder(@NotNull @NotNull Database database, @NotNull @NotNull String path, boolean usesSlash, @NotNull @NotNull String suffix, @Nullable @Nullable Table workspaceData) Gets a FileOrFolder pointed to by path.This is used by the
getNotebookText(java.lang.String)
and Python import machinery. In each case you must begin your path with a separator (e.g. "/bill.py" or ".bill"). The optional suffix is used for the imports to search for folders followed by files along the imported path.- Parameters:
database
- the database object to retrieve tables and the user context from (must be aDatabaseInternal
)path
- the path to retrieveusesSlash
- use "/+" for the path separator, otherwises uses "\." for Python importssuffix
- the optional suffix to append to the last component (e.g., ".py" for an import); or empty if no suffix searching should be performedworkspaceData
- optional source of workspace data to base processing on- Returns:
- the FileOrFolder that was found at the given path, or an exception is thrown
-
getFileOrFolder
@NotNull public static @NotNull NotebookReader.FileOrFolder getFileOrFolder(@NotNull @NotNull Database database, @NotNull @NotNull String path, boolean usesSlash, @NotNull @NotNull String suffix) Functions asgetFileOrFolder(Database, String, boolean, String, Table)
, except without providing workspace data.- Parameters:
database
- the database object to retrieve tables and the user context from (must be aDatabaseInternal
)path
- the path to retrieveusesSlash
- use "/+" for the path separator, otherwises uses "\." for Python importssuffix
- the optional suffix to append to the last component (e.g., ".py" for an import); or empty if no suffix searching should be performed- Returns:
- the FileOrFolder that was found at the given path, or an exception is thrown
-