Ejemplo n.º 1
0
 def find_href(scheme):
     try:
         return next(
             form.href for form in forms
             if is_scheme_form(form, td.base, scheme) and is_op_form(form))
     except StopIteration:
         return None
Ejemplo n.º 2
0
    def is_supported_interaction(self, td, name):
        """Returns True if the any of the Forms for the Interaction
        with the given name is supported in this Protocol Binding client."""

        forms = td.get_forms(name)

        forms_wss = [
            form for form in forms
            if is_scheme_form(form, td.base, WebsocketSchemes.WSS)
        ]

        forms_ws = [
            form for form in forms
            if is_scheme_form(form, td.base, WebsocketSchemes.WS)
        ]

        return len(forms_wss) or len(forms_ws)
Ejemplo n.º 3
0
    def _pick_mqtt_href(cls, td, forms, op=None):
        """Picks the most appropriate MQTT form href from the given list of forms."""
        def is_op_form(form):
            try:
                return op is None or op == form.op or op in form.op
            except TypeError:
                return False

        return next((form.href for form in forms
                     if is_scheme_form(form, td.base, MQTTSchemes.MQTT)
                     and is_op_form(form)), None)
Ejemplo n.º 4
0
    def is_supported_interaction(self, td, name):
        """Returns True if the any of the Forms for the Interaction
        with the given name is supported in this Protocol Binding client."""

        forms = td.get_forms(name)

        forms_http = [
            form for form in forms
            if is_scheme_form(form, td.base, HTTPSchemes.list())
        ]

        return len(forms_http) > 0