import six
from ipywidgets import Widget, DOMWidget, widget_serialization, Color, register
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 }}enums import *
from {{ py_base_relative_path }}traits import *

from {{ superClass.pyRelativePath }} import {{ superClass.className }}

{{#each dependencies as |dep depName|}}
from {{ dep.pyRelativePath }} import {{ dep.className }}
{{/each}}

{{#unless hasOverride}}
@register
{{/unless}}
class {{ className }}({{ superClass.className }}):
    """{{ className }}

    Autogenerated by {{ generatorScriptName }}
    Date: {{ now }}
    {{#if isCustom}}
    This class is a custom class for pythreejs, with no
    direct corresponding class in three.js.
    {{else}}
    See {{ threejs_docs_url }}
    {{/if}}
    """

    {{#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}}
    _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__)
