Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion template/plugin/__init__.py.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ from pdk_types import <%- Object.values(schema.schemas).map(schema => schema.nam
# And it returns an output <%- toPythonType(imp.output) %> (<%- formatCommentLine(imp.output.description) %>)
<% } -%>
@extism.import_fn("extism:host/user", "<%- imp.name %>")
def <%- camelToSnakeCase(imp.name) %>(<% if (imp.input) { -%>input: <%- toPythonType(imp.input) %><%} -%>) <% if (imp.output) { %> -> <%- toPythonType(imp.output) %><% } %>:
def <%- camelToSnakeCase(imp.name) %>(<% if (imp.input) { -%>input: <%- toPythonType(imp.input) %><%} -%>) <% if (imp.output) { %> -> <%- toPythonType(imp.output) %><% } %>: # pyright: ignore [reportReturnType]
pass
<% }) %>

# Exports
# The implementations for these functions is in `plugin.py`

<% schema.exports.forEach(ex => { -%>
<% if (hasComment(ex)) { -%>
# <%- formatCommentBlock(ex.description, "# ") %>
<% } -%>
@extism.plugin_fn
def <%- ex.name %>():
res = plugin.<%- camelToSnakeCase(ex.name) %>(<% if (ex.input) { %> extism.input(<%- toPythonType(ex.input) %>) <% } %>)
Expand Down
2 changes: 1 addition & 1 deletion template/plugin/pdk_imports.py.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ from pdk_types import <%- Object.values(schema.schemas).map(schema => schema.nam
# And it returns an output <%- toPythonType(imp.output) %> (<%- formatCommentLine(imp.output.description) %>)
<% } -%>
@extism.import_fn("extism:host/user", "<%- imp.name %>")
def <%- camelToSnakeCase(imp.name) %>(<% if (imp.input) { -%>input: <%- toPythonType(imp.input) %><%} -%>) <% if (imp.output) { %> -> <%- toPythonType(imp.output) %><% } %>:
def <%- camelToSnakeCase(imp.name) %>(<% if (imp.input) { -%>input: <%- toPythonType(imp.input) %><%} -%>) <% if (imp.output) { %> -> <%- toPythonType(imp.output) %><% } %>: # pyright: ignore [reportReturnType]
pass
<% }) %>

Expand Down
3 changes: 3 additions & 0 deletions template/plugin/plugin.py.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ from pdk_imports import <%- schema.imports.map(schema => camelToSnakeCase(schema
from typing import List, Optional # noqa: F401

<% schema.exports.forEach(ex => { -%>
<% if (hasComment(ex)) { -%>
# <%- formatCommentBlock(ex.description, "# ") %>
<% } -%>
def <%- camelToSnakeCase(ex.name) %>(<% if (ex.input) { %>input: <%- toPythonType(ex.input) %> <% } %>) <% if (ex.output) {%>-> <%- toPythonType(ex.output) %><%}%>:
<% if (featureFlags['stub-with-code-samples'] && codeSamples(ex, 'python').length > 0) { -%>
<%- codeSamples(ex, 'python')[0].source %>
Expand Down