Skip to content

Commit c903743

Browse files
committed
revision to enable slot_range to have delimited enums too
1 parent c0377ce commit c903743

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

script/tabular_to_schema.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,19 +156,24 @@ def set_mappings(record, row, EXPORT_FORMAT):
156156
record['exact_mappings'] = mappings;
157157

158158

159-
# A single range goes into slot.range; more than one goes into slot.any_of[...]
159+
# OLD: A single range goes into slot.range; more than one goes into slot.any_of[...]
160+
# cardinality controls limit on answers.
160161
def set_range(slot, slot_range, slot_range_2):
161162

162163
# range_2 column gets semi-colon separated list of additional ranges
163-
if slot_range > '':
164-
if slot_range_2 > '':
165-
merged_ranges = [slot_range];
166-
merged_ranges.extend(slot_range_2.split(';'));
167-
slot['any_of'] = [];
168-
for x in merged_ranges:
169-
slot['any_of'].append({'range': x });
170-
else:
171-
slot['range'] = slot_range;
164+
ranges = [];
165+
if len(slot_range):
166+
ranges.extend(slot_range.split(';'));
167+
if len(slot_range_2):
168+
ranges.extend(slot_range_2.split(';'));
169+
170+
if len(ranges) > 1:
171+
slot['any_of'] = [];
172+
for x in ranges:
173+
slot['any_of'].append({'range': x });
174+
175+
elif len(ranges) == 1:
176+
slot['range'] = ranges[0];
172177

173178

174179
# Currently LinkML minimum_value and maximum_value only validate if they are

0 commit comments

Comments
 (0)