-
Notifications
You must be signed in to change notification settings - Fork 193
/
Copy pathpy_wrapper.mustache
63 lines (52 loc) · 1.97 KB
/
py_wrapper.mustache
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import six
from ipywidgets import (
Widget, DOMWidget, widget_serialization, register
)
from ipywidgets.widgets.trait_types import TypedTuple, InstanceDict
from traitlets import (
Unicode, Int, CInt, Instance, ForwardDeclaredInstance, This, Enum,
Tuple, List, Dict, Float, CFloat, Bool, Union, Any,
)
from {{ py_base_relative_path }}_base.Three import ThreeWidget
from {{ py_base_relative_path }}_base.uniforms import uniforms_serialization
from {{ py_base_relative_path }}enums import *
from {{ py_base_relative_path }}traits import *
from {{ superClass.pyRelativePath }} import {{ superClass.className }}
{{#each dependencies as |dep depName|}}
{{#notSuper dep.className}}
from {{ dep.pyRelativePath }} import {{ dep.className }}
{{/notSuper}}
{{/each}}
{{#unless hasOverride}}
@register
{{/unless}}
class {{ className }}({{ superClass.className }}):
"""{{ className }}
Autogenerated by {{ generatorScriptName }}
{{#if isCustom}}
This class is a custom class for pythreejs, with no
direct corresponding class in three.js.
{{else}}
See {{ threejs_docs_url }}
{{/if}}
"""
{{#if todo}}
def __init__(self, **kwargs):
raise NotImplementedError('{{ className }} is not yet implemented!')
{{else}}
{{#unless constructor.hasParameters}}
def __init__(self, {{#each constructor.args as |arg|}}{{{ arg.name }}}{{#if arg.prop.defaultJson}}={{{ arg.prop.defaultJson }}}{{/if}}, {{/each}}**kwargs):
{{#each constructor.args as |arg|}}
kwargs['{{{ arg.name }}}'] = {{{ arg.name }}}
{{/each}}
super({{ className }}, self).__init__(**kwargs)
{{/unless}}
{{/if}}
_model_name = Unicode('{{ modelName }}').tag(sync=True)
{{#each properties as |prop propName|}}
{{ propName }} = {{{ prop.trait_declaration }}}
{{/each}}
if six.PY3:
import inspect
# Include explicit signature since the metaclass screws it up
{{ className }}.__signature__ = inspect.signature({{ className }}.__init__)