Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def process_result(self, form):
if self._treeview is not None:
self._scrolled.remove(self._treeview)
self._treeview.destroy()
self._treeview = None
self._menu = None
self._label.hide()
self._scrolled.hide()
if not form:
self._label.show()
return
form = dataforms.extend_form(node=form)
fieldtypes = []
fieldvars = []
for field in form.reported.iter_fields():
if field.type_ == 'boolean':
fieldtypes.append(bool)
elif field.type_ in ('jid-single', 'text-single'):
fieldtypes.append(str)
else:
log.warning('Not supported field received: %s', field.type_)
continue
fieldvars.append(field.var)
liststore = Gtk.ListStore(*fieldtypes)
for item in form.iter_records():
def _show_form(self, form):
if self._dataform_widget is not None:
self.remove(self._dataform_widget)
self._dataform_widget.destroy()
if form is None:
return
form = dataforms.extend_form(node=form)
self._dataform_widget = DataFormWidget(form)
self._dataform_widget.connect('is-valid', self._on_is_valid)
self._dataform_widget.validate()
self._dataform_widget.show_all()
self.add(self._dataform_widget)
def _build_dataform(self, form, is_form):
if not is_form:
return FakeDataFormWidget(form)
dataform = dataforms.extend_form(node=form)
form_widget = DataFormWidget(dataform)
form_widget.connect('is-valid', self._on_is_valid)
form_widget.validate()
return form_widget
def _show_form(self, form):
if self._dataform_widget is not None:
self.remove(self._dataform_widget)
self._dataform_widget.destroy()
if form is None:
return
options = {'form-width': 350}
form = dataforms.extend_form(node=form)
self._dataform_widget = DataFormWidget(form, options=options)
self._dataform_widget.connect('is-valid', self._on_is_valid)
self._dataform_widget.validate()
self._dataform_widget.show_all()
self.add(self._dataform_widget)
return
if configure.getAttr('node') != node:
self._log.warning('Malformed PubSub configure '
'stanza (wrong node): %s', stanza)
return
form = configure.getTag('x', namespace=Namespace.DATA)
if form is None:
self._log.warning('Malformed PubSub configure '
'stanza (no form): %s', stanza)
return
app.nec.push_incoming_event(PubSubConfigReceivedEvent(
None, conn=self._con, node=node,
form=dataforms.extend_form(node=form)))