MCPcopy Index your code
hub / github.com/pywebio/PyWebIO / _parse_select_options

Function _parse_select_options

pywebio/input.py:310–328  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

308
309
310def _parse_select_options(options):
311 # Convert the `options` parameter in the `select`, `checkbox`, and `radio` functions to a unified format
312 # Available forms of option:
313 # {value:, label:, [selected:,] [disabled:]}
314 # (value, label, [selected,] [disabled])
315 # value (label same as value)
316 opts_res = []
317 for opt in options:
318 opt = copy.deepcopy(opt)
319 if isinstance(opt, Mapping):
320 assert 'value' in opt and 'label' in opt, 'options item must have value and label key'
321 elif isinstance(opt, (list, tuple)):
322 assert len(opt) > 1 and len(opt) <= 4, 'options item format error'
323 opt = dict(zip(('label', 'value', 'selected', 'disabled'), opt))
324 else:
325 opt = dict(value=opt, label=opt)
326 opts_res.append(opt)
327
328 return opts_res
329
330
331def _set_options_selected(options, value):

Callers 4

selectFunction · 0.85
checkboxFunction · 0.85
radioFunction · 0.85
parse_input_update_specFunction · 0.85

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…