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

Function single_input

pywebio/io_ctrl.py:230–261  ·  view source on GitHub ↗

Note: 鲁棒性在上层完成 将单个input构造成input_group,并获取返回值 :param item_spec: 单个输入项的参数 'name' must in item_spec, 参数一定已经验证通过 :param valid_func: Not None :param onchange_func: Not None :param preprocess_func: Not None, 预处理函数,在收到用户提交的单项输入的原始数据后用于在校验前对数据进行预处理

(item_spec, valid_func, preprocess_func, onchange_func)

Source from the content-addressed store, hash-verified

228
229@chose_impl
230def single_input(item_spec, valid_func, preprocess_func, onchange_func):
231 """
232 Note: 鲁棒性在上层完成
233 将单个input构造成input_group,并获取返回值
234 :param item_spec: 单个输入项的参数 'name' must in item_spec, 参数一定已经验证通过
235 :param valid_func: Not None
236 :param onchange_func: Not None
237 :param preprocess_func: Not None, 预处理函数,在收到用户提交的单项输入的原始数据后用于在校验前对数据进行预处理
238 """
239 if item_spec.get('name') is None: # single input
240 item_spec['name'] = 'data'
241 else: # as input_group item
242 # use `single_input_kwargs()` to get the returned value
243 return dict(item_spec=item_spec, valid_func=valid_func,
244 preprocess_func=preprocess_func, onchange_func=onchange_func)
245
246 label = item_spec['label']
247 name = item_spec['name']
248 # todo 是否可以原地修改spec
249 item_spec['label'] = ''
250
251 item_spec.setdefault('auto_focus', True) # 如果没有设置autofocus参数,则开启参数 todo CHECKBOX, RADIO 特殊处理
252
253 spec = dict(label=label, inputs=[item_spec])
254 data = yield input_control(spec=spec,
255 preprocess_funcs={name: preprocess_func},
256 item_valid_funcs={name: valid_func},
257 onchange_funcs={name: onchange_func})
258
259 if not data: # form cancel
260 return None
261 return data[name]
262
263
264@chose_impl

Callers 8

inputFunction · 0.85
textareaFunction · 0.85
selectFunction · 0.85
checkboxFunction · 0.85
radioFunction · 0.85
actionsFunction · 0.85
file_uploadFunction · 0.85
sliderFunction · 0.85

Calls 2

input_controlFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…