Skip to content

Commit d482e62

Browse files
committed
fix: Template and non-template fields example
1 parent 57da852 commit d482e62

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

initializers/device_types.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
# - name_template: ttyS[1-48]
3232
# type: rj-45
3333
# power_ports:
34-
# - name: psu0 # both non-template and template field specified; non-template field takes precedence
35-
# name_template: psu[0,1]
34+
# - name_template: psu[0,1]
3635
# type: iec-60320-c14
3736
# maximum_draw: 35
3837
# allocated_draw: 35
@@ -46,7 +45,9 @@
4645
# type: 8p8c
4746
# positions_template: "[3,2]"
4847
# device_bays:
49-
# - name_template: bay[0-9]
48+
# - name: bay0 # both non-template and template field specified; non-template field takes precedence
49+
# name_template: bay[0-9]
50+
# label: test0
5051
# label_template: test[0-5,9,6-8]
5152
# description: Test description
5253
# power_outlets:

startup_scripts/190_device_types.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,13 @@ def expand_templates(params: List[dict], device_type: DeviceType) -> List[dict]:
3636

3737
if field in param:
3838
has_plain_fields = True
39-
expanded.append(param)
4039
elif template_value:
4140
expanded_fields[field] = list(expand_alphanumeric_pattern(template_value))
4241

4342
if expanded_fields and has_plain_fields:
4443
raise ValueError(f"Mix of plain and template keys provided for {templateable_fields}")
45-
46-
if not expanded_fields:
44+
elif not expanded_fields:
45+
expanded.append(param)
4746
continue
4847

4948
elements = list(expanded_fields.values())

0 commit comments

Comments
 (0)