-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpython.consts.j2
More file actions
41 lines (36 loc) · 1.38 KB
/
python.consts.j2
File metadata and controls
41 lines (36 loc) · 1.38 KB
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
from typing import List
from enum import Enum, auto
class PhysicalQuantities(Enum):
{%- for PhysicalQuantity in data['PhysicalQuantities'] %}
{{ PhysicalQuantity.Name }} = auto(), # {{PhysicalQuantity.UnitDescription}} ({{PhysicalQuantity.Unit}})
{%- endfor %}
class FieldTypes(Enum):
{%- for fieldType in data['FieldTypes'] %}
{{ fieldType.Name }} = auto(), # {{fieldType.Description}} ({{fieldType.EncodingDescription}})
{%- endfor %}
{% set manufacturer_codes = data['LookupEnumerations'] | selectattr('Name', 'equalto', 'MANUFACTURER_CODE') | first %}
ManufacturerCodes: List[str] = [
{%- for manufacturer in manufacturer_codes.EnumValues %}
"{{ manufacturer.Name }}",
{%- endfor %}]
IndirectLookupEncodeMaps = {
{%- for lookup in data['LookupIndirectEnumerations'] %}
"{{ lookup.Name }}": {
{%- set value1_groups = namespace(groups={}) %}
{%- for item in lookup.EnumValues %}
{%- if item.Value1 in value1_groups.groups %}
{%- set _ = value1_groups.groups[item.Value1].append(item) %}
{%- else %}
{%- set _ = value1_groups.groups.update({item.Value1: [item]}) %}
{%- endif %}
{%- endfor %}
{%- for value1, items in value1_groups.groups.items() %}
{{ value1 }}: {
{%- for item in items %}
"{{ item.Name }}": {{ item.Value2 }},
{%- endfor %}
},
{%- endfor %}
},
{%- endfor %}
}