Ejemplo n.º 1
0
 def display_hardware_type(self) -> ElementDataRepresentation:
     """
     Nicer representation of hardware types
     :return: Representation of hardware type
     """
     display = hardware_types.get(self.hardware_type, 'Unknown')
     return ElementDataRepresentation("{} ({})".format(
         display, self.hardware_type))
Ejemplo n.º 2
0
class OneParameterDisplayHiddenDemoElement(DemoElementBase):
    """
    Sub-element to test with
    """
    def __init__(self, one):
        self.one = one

    display_one = ElementDataRepresentation('**HIDDEN**')
Ejemplo n.º 3
0
 def display_query_type(self) -> ElementDataRepresentation:
     """
     Nicer representation of query types
     :return: Representation of query type
     """
     display = lq_query_types.get(self.query_type, 'Unknown')
     return ElementDataRepresentation("{} ({})".format(
         display, self.query_type))
Ejemplo n.º 4
0
 def display_link_layer_address(
         self) -> Union[ElementDataRepresentation, bytes]:
     """
     Nicer representation of link-layer address if we know the hardware type
     :return: Representation of link-layer address
     """
     if self.hardware_type == 1:
         return ElementDataRepresentation(
             normalise_hex(self.link_layer_address, include_colons=True))
     else:
         return self.link_layer_address
Ejemplo n.º 5
0
    def display_requested_options(self) -> List[ElementDataRepresentation]:
        """
        Provide a nicer output when displaying the requested options.

        :return: A list of option names
        """
        from dhcpkit.ipv6.option_registry import option_registry

        out = []
        for option_type in self.requested_options:
            class_name = option_registry.get(option_type,
                                             UnknownOption).__name__
            out.append(
                ElementDataRepresentation("{} ({})".format(
                    class_name, option_type)))

        return out
Ejemplo n.º 6
0
 def display_one(self):
     """
     Nicer display for property one
     """
     return ElementDataRepresentation("**{}**".format(self.one))