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))
class OneParameterDisplayHiddenDemoElement(DemoElementBase): """ Sub-element to test with """ def __init__(self, one): self.one = one display_one = ElementDataRepresentation('**HIDDEN**')
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))
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
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
def display_one(self): """ Nicer display for property one """ return ElementDataRepresentation("**{}**".format(self.one))