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
8 changes: 3 additions & 5 deletions packages/schema/bind/src/bindings/python/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,9 @@ export const generateBinding: GenerateBindingFn = (
name: options.projectName,
type: "plugin",
version: latestWrapManifestVersion,
abi: JSON.stringify(
sort((options.abi as unknown) as Record<string, unknown>),
null,
2
),
abi: Buffer.from(
JSON.stringify(sort((options.abi as unknown) as Record<string, unknown>))
).toString("base64"),
};

output.entries = renderTemplates(templatePath(""), { ...abi, manifest }, {});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# NOTE: This is an auto-generated file. All modifications will be overwritten.
# type: ignore

from .types import *
from .module import *
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# NOTE: This is an auto-generated file. All modifications will be overwritten.
# type: ignore
from __future__ import annotations

from abc import abstractmethod
Expand Down Expand Up @@ -38,7 +39,7 @@ class Module(Generic[TConfig], PluginModule[TConfig]):
{{#moduleType}}
{{#methods}}
@abstractmethod
def {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}(
async def {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}(
self,
args: Args{{#toUpper}}{{name}}{{/toUpper}},
client: InvokerClient[UriPackageOrWrapper],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# NOTE: This is an auto-generated file. All modifications will be overwritten.
# type: ignore
from __future__ import annotations

from typing import TypedDict, Optional
Expand Down Expand Up @@ -36,12 +37,12 @@ from polywrap_msgpack import GenericMap
{{#enumTypes}}
class {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}(IntEnum):
{{#constants}}
{{#detectKeyword}}{{.}}{{/detectKeyword}} = auto() - 1, "{{.}}"
{{#detectKeyword}}{{.}}{{/detectKeyword}} = auto(), "{{.}}"
{{/constants}}

def __new__(cls, value: int, *aliases: str):
obj = int.__new__(cls)
obj._value_ = value
obj._value_ = value - 1
for alias in aliases:
cls._value2member_map_[alias] = obj
return obj
Expand All @@ -68,12 +69,12 @@ class {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}(IntEn
# URI: "{{uri}}" #
class {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}(IntEnum):
{{#constants}}
{{#detectKeyword}}{{.}}{{/detectKeyword}} = auto() - 1
{{#detectKeyword}}{{.}}{{/detectKeyword}} = auto()
{{/constants}}

def __new__(cls, value: int, *aliases: str):
obj = int.__new__(cls)
obj._value_ = value
obj._value_ = value - 1
for alias in aliases:
cls._value2member_map_[alias] = obj
return obj
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# NOTE: This is an auto-generated file. All modifications will be overwritten.
# type: ignore
from __future__ import annotations

import json
from base64 import b64decode

from polywrap_manifest import WrapManifest

{{#manifest}}
abi = json.loads("""
{{abi}}
""")
abi = json.loads(b64decode("{{abi}}").decode("utf-8"))

manifest = WrapManifest.parse_obj({
"name": "{{name}}",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# NOTE: This is an auto-generated file. All modifications will be overwritten.
# type: ignore

from .types import *
from .module import *
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# NOTE: This is an auto-generated file. All modifications will be overwritten.
# type: ignore
from __future__ import annotations

from abc import abstractmethod
Expand Down Expand Up @@ -57,7 +58,7 @@ def __new__(cls, *args, **kwargs):
return instance

@abstractmethod
def module_method(
async def module_method(
self,
args: ArgsModuleMethod,
client: InvokerClient[UriPackageOrWrapper],
Expand All @@ -66,7 +67,7 @@ def module_method(
pass

@abstractmethod
def object_method(
async def object_method(
self,
args: ArgsObjectMethod,
client: InvokerClient[UriPackageOrWrapper],
Expand All @@ -75,7 +76,7 @@ def object_method(
pass

@abstractmethod
def optional_env_method(
async def optional_env_method(
self,
args: ArgsOptionalEnvMethod,
client: InvokerClient[UriPackageOrWrapper],
Expand All @@ -84,7 +85,7 @@ def optional_env_method(
pass

@abstractmethod
def r_if(
async def r_if(
self,
args: ArgsIf,
client: InvokerClient[UriPackageOrWrapper],
Expand Down
25 changes: 13 additions & 12 deletions packages/test-cases/cases/bind/sanity/output/plugin-py/types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# NOTE: This is an auto-generated file. All modifications will be overwritten.
# type: ignore
from __future__ import annotations

from typing import TypedDict, Optional
Expand Down Expand Up @@ -83,23 +84,23 @@

### Enums START ###
class CustomEnum(IntEnum):
STRING = auto() - 1, "STRING"
BYTES = auto() - 1, "BYTES"
STRING = auto(), "STRING"
BYTES = auto(), "BYTES"

def __new__(cls, value: int, *aliases: str):
obj = int.__new__(cls)
obj._value_ = value
obj._value_ = value - 1
for alias in aliases:
cls._value2member_map_[alias] = obj
return obj

class While(IntEnum):
r_for = auto() - 1, "for"
r_in = auto() - 1, "in"
r_for = auto(), "for"
r_in = auto(), "in"

def __new__(cls, value: int, *aliases: str):
obj = int.__new__(cls)
obj._value_ = value
obj._value_ = value - 1
for alias in aliases:
cls._value2member_map_[alias] = obj
return obj
Expand Down Expand Up @@ -131,24 +132,24 @@ def __new__(cls, value: int, *aliases: str):

# URI: "testimport.uri.eth" #
class TestImportEnum(IntEnum):
STRING = auto() - 1
BYTES = auto() - 1
STRING = auto()
BYTES = auto()

def __new__(cls, value: int, *aliases: str):
obj = int.__new__(cls)
obj._value_ = value
obj._value_ = value - 1
for alias in aliases:
cls._value2member_map_[alias] = obj
return obj

# URI: "testimport.uri.eth" #
class TestImportEnumReturn(IntEnum):
STRING = auto() - 1
BYTES = auto() - 1
STRING = auto()
BYTES = auto()

def __new__(cls, value: int, *aliases: str):
obj = int.__new__(cls)
obj._value_ = value
obj._value_ = value - 1
for alias in aliases:
cls._value2member_map_[alias] = obj
return obj
Expand Down
Loading