51 lines
1.2 KiB
Python
51 lines
1.2 KiB
Python
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
# source: {{ description.filename }}
|
|
# plugin: python-betterproto
|
|
{% if description.enums %}import enum
|
|
{% endif %}
|
|
from dataclasses import dataclass
|
|
from typing import Dict, List
|
|
|
|
import betterproto
|
|
{% for i in description.imports %}
|
|
|
|
{{ i }}
|
|
{% endfor %}
|
|
|
|
|
|
{% if description.enums %}{% for enum in description.enums %}
|
|
class {{ enum.name }}(enum.IntEnum):
|
|
{% if enum.comment %}
|
|
{{ enum.comment }}
|
|
|
|
{% endif %}
|
|
{% for entry in enum.entries %}
|
|
{% if entry.comment %}
|
|
{{ entry.comment }}
|
|
{% endif %}
|
|
{{ entry.name }} = {{ entry.value }}
|
|
{% endfor %}
|
|
|
|
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% for message in description.messages %}
|
|
@dataclass
|
|
class {{ message.name }}(betterproto.Message):
|
|
{% if message.comment %}
|
|
{{ message.comment }}
|
|
|
|
{% endif %}
|
|
{% for field in message.properties %}
|
|
{% if field.comment %}
|
|
{{ field.comment }}
|
|
{% endif %}
|
|
{{ field.name }}: {{ field.type }} = betterproto.{{ field.field_type }}_field({{ field.number }}{% if field.field_type == 'map'%}, betterproto.{{ field.map_types[0] }}, betterproto.{{ field.map_types[1] }}{% endif %})
|
|
{% endfor %}
|
|
{% if not message.properties %}
|
|
pass
|
|
{% endif %}
|
|
|
|
|
|
{% endfor %}
|