|
| 1 | +""" |
| 2 | +{{docstring}} |
| 3 | +""" |
| 4 | + |
| 5 | +# this file was auto-generated! |
| 6 | + |
| 7 | +{{preamble}} |
| 8 | + |
| 9 | +from openminds.base import {{ base_class }} |
| 10 | +from openminds.properties import Property |
| 11 | + |
| 12 | + |
| 13 | +class {{ class_name }}({{ base_class }}): |
| 14 | + """ |
| 15 | + {{ docstring }} |
| 16 | + """ |
| 17 | + type_ = "{{ openminds_type }}" |
| 18 | + context = { |
| 19 | + "@vocab": "https://openminds.ebrains.eu/vocab/" |
| 20 | + } |
| 21 | + schema_version = "{{ schema_version }}" |
| 22 | + |
| 23 | + properties = [ |
| 24 | + {% for property in properties -%} |
| 25 | + Property( |
| 26 | + "{{property.name}}", |
| 27 | + {{property.type}}, |
| 28 | + "{{property.iri}}", |
| 29 | + {%- if property.allow_multiple %} |
| 30 | + multiple={{property.allow_multiple}}, |
| 31 | + unique_items={{property.unique_items}}, |
| 32 | + {% if property.min_items -%}min_items={{property.min_items}},{% endif %} |
| 33 | + {% if property.max_items -%}max_items={{property.max_items}},{% endif %} |
| 34 | + {% endif -%} |
| 35 | + {% if property.type == "str" -%} |
| 36 | + formatting="{{property.formatting}}", |
| 37 | + {% if property.multiline -%}multiline={{property.multiline}},{% endif %} |
| 38 | + {% endif %} |
| 39 | + {%- if property.required -%}required={{property.required}},{% endif %} |
| 40 | + description="{{property.description}}", |
| 41 | + instructions="{{property.instructions}}" |
| 42 | + ), |
| 43 | + {% endfor %} |
| 44 | + ] |
| 45 | + |
| 46 | + def __init__(self{%- if base_class == "LinkedMetadata" %}, id=None{%- endif -%}{%- for property in properties -%}, {{property.name}}=None{%- endfor -%}): |
| 47 | + return super().__init__({%- if base_class == "LinkedMetadata" %}id=id, {%- endif -%}{%- for property in properties -%}{{property.name}}={{property.name}}, {%- endfor -%}) |
| 48 | + |
| 49 | +{{ additional_methods }} |
| 50 | + |
| 51 | +{% for instance_name, instance in instances.items() %} |
| 52 | +{{ class_name }}.{{ instance_name }} = {{ class_name }}( |
| 53 | + {% for key, value in instance.items() -%} |
| 54 | + {% if value is string -%} |
| 55 | + {% if value.startswith('http') and key != 'id' -%} |
| 56 | + {{key}}=IRI("{{value}}"), |
| 57 | + {%- else -%} |
| 58 | + {{key}}="{{value}}", |
| 59 | + {%- endif %} |
| 60 | + {%- else -%} |
| 61 | + {{key}}={{value}}, |
| 62 | + {%- endif %} |
| 63 | + {% endfor -%} |
| 64 | +){% endfor %} |
0 commit comments