Skip to content

Commit

Permalink
Update to_j_js_plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
devinrsmith committed Dec 13, 2023
1 parent c23950f commit 0522799
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions py/server/deephaven_internal/plugin/js/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@
#

import jpy
import pathlib

from deephaven.plugin.js import JsPlugin

_JJsPlugin = jpy.get_type("io.deephaven.plugin.js.JsPlugin")
_JPath = jpy.get_type("java.nio.file.Path")


def to_j_js_plugin(js_plugin: JsPlugin) -> jpy.JType:
j_path = _JPath.of(str(js_plugin.path))
path = js_plugin.path()
if not isinstance(path, pathlib.Path):
# Adding a little bit of extra safety for this version of the server.
# There's potential that the return type of JsPlugin.path expands in the future.
raise Exception(
f"Expecting pathlib.Path, is type(js_plugin.path())={type(path)}, js_plugin={js_plugin}"
)
j_path = _JPath.of(str(path))
main_path = j_path.relativize(j_path.resolve(js_plugin.main))
builder = _JJsPlugin.builder()
builder.name(js_plugin.name)
builder.version(js_plugin.version)
builder.main(main_path)
builder.path(path)
builder.path(j_path)
return builder.build()

0 comments on commit 0522799

Please sign in to comment.