Mercurial > libervia-backend
diff libervia/frontends/tools/xmlui.py @ 4270:0d7bb4df2343
Reformatted code base using black.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 19 Jun 2024 18:44:57 +0200 |
parents | 26b7ed2817da |
children |
line wrap: on
line diff
--- a/libervia/frontends/tools/xmlui.py Tue Jun 18 12:06:45 2024 +0200 +++ b/libervia/frontends/tools/xmlui.py Wed Jun 19 18:44:57 2024 +0200 @@ -272,8 +272,15 @@ This class must not be instancied directly """ - def __init__(self, host, parsed_dom, title=None, flags=None, callback=None, - profile=C.PROF_KEY_NONE): + def __init__( + self, + host, + parsed_dom, + title=None, + flags=None, + callback=None, + profile=C.PROF_KEY_NONE, + ): """Initialise the XMLUI instance @param host: %(doc_host)s @@ -364,6 +371,7 @@ class ValueGetter(object): """dict like object which return values of widgets""" + # FIXME: widget which can keep multiple values are not handled def __init__(self, widgets, attr="value"): @@ -401,8 +409,17 @@ widget_factory = None - def __init__(self, host, parsed_dom, title=None, flags=None, callback=None, - ignore=None, whitelist=None, profile=C.PROF_KEY_NONE): + def __init__( + self, + host, + parsed_dom, + title=None, + flags=None, + callback=None, + ignore=None, + whitelist=None, + profile=C.PROF_KEY_NONE, + ): """ @param title(unicode, None): title of the @@ -449,7 +466,9 @@ raise ValueError(_("XMLUI can have only one main container")) self._main_cont = value - def _parse_childs(self, _xmlui_parent, current_node, wanted=("container",), data=None): + def _parse_childs( + self, _xmlui_parent, current_node, wanted=("container",), data=None + ): """Recursively parse childNodes of an element @param _xmlui_parent: widget container with '_xmlui_append' method @@ -487,7 +506,10 @@ # used or even useful, it should probably be removed # and all "is not None" tests for it should be removed too # to be checked for 0.8 - cont, node, ("widget", "container"), {CURRENT_LABEL: None} + cont, + node, + ("widget", "container"), + {CURRENT_LABEL: None}, ) elif type_ == "advanced_list": try: @@ -536,9 +558,7 @@ if not name or not "tabs_cont" in data: raise InvalidXMLUI if self.type == "param": - self._current_category = ( - name - ) # XXX: awful hack because params need category and we don't keep parent + self._current_category = name # XXX: awful hack because params need category and we don't keep parent tab_cont = data["tabs_cont"] new_tab = tab_cont._xmlui_add_tab(label or name, selected) self._parse_childs(new_tab, node, ("widget", "container")) @@ -586,8 +606,10 @@ data[CURRENT_LABEL] = ctrl elif type_ == "hidden": if name in self.hidden: - raise exceptions.ConflictError("Conflict on hidden value with " - "name {name}".format(name=name)) + raise exceptions.ConflictError( + "Conflict on hidden value with " + "name {name}".format(name=name) + ) self.hidden[name] = value continue elif type_ == "jid": @@ -1090,27 +1112,40 @@ # TODO: remove this method, as there are seme use cases where different XMLUI # classes can be used in the same frontend, so a global value is not good assert type_ in (CLASS_PANEL, CLASS_DIALOG) - log.warning("register_class for XMLUI is deprecated, please use partial with " - "xmlui.create and class_map instead") + log.warning( + "register_class for XMLUI is deprecated, please use partial with " + "xmlui.create and class_map instead" + ) if type_ in _class_map: - log.debug(_("XMLUI class already registered for {type_}, ignoring").format( - type_=type_)) + log.debug( + _("XMLUI class already registered for {type_}, ignoring").format(type_=type_) + ) return _class_map[type_] = class_ -def create(host, xml_data, title=None, flags=None, dom_parse=None, dom_free=None, - callback=None, ignore=None, whitelist=None, class_map=None, - profile=C.PROF_KEY_NONE): +def create( + host, + xml_data, + title=None, + flags=None, + dom_parse=None, + dom_free=None, + callback=None, + ignore=None, + whitelist=None, + class_map=None, + profile=C.PROF_KEY_NONE, +): """ - @param dom_parse: methode equivalent to minidom.parseString (but which must manage unicode), or None to use default one - @param dom_free: method used to free the parsed DOM - @param ignore(list[unicode], None): name of widgets to ignore - widgets with name in this list and their label will be ignored - @param whitelist(list[unicode], None): name of widgets to keep - when not None, only widgets in this list and their label will be kept - mutually exclusive with ignore + @param dom_parse: methode equivalent to minidom.parseString (but which must manage unicode), or None to use default one + @param dom_free: method used to free the parsed DOM + @param ignore(list[unicode], None): name of widgets to ignore + widgets with name in this list and their label will be ignored + @param whitelist(list[unicode], None): name of widgets to keep + when not None, only widgets in this list and their label will be kept + mutually exclusive with ignore """ if class_map is None: class_map = _class_map