我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用netaddr.mac_eui48()。
def test_serialization_with_eui_in_different_dialect(self, model): field = fields.MACAddressField() model.mac = netaddr.EUI('78-F8-82-B2-E5-5A', dialect=netaddr.mac_eui48) serialized = field.serialize('mac', model) assert serialized == '78:f8:82:b2:e5:5a'
def _win_query(v): v.dialect = netaddr.mac_eui48 return str(v) # ---- IP address and network filters ----
def hwaddr(value, query = '', alias = 'hwaddr'): ''' Check if string is a HW/MAC address and filter it ''' try: v = netaddr.EUI(value) except: if query and query not in [ 'bool' ]: raise errors.AnsibleFilterError(alias + ': not a hardware address: %s' % value) if not query: if v: return value elif query == 'bool': if v: return True elif query in [ 'win', 'eui48' ]: v.dialect = netaddr.mac_eui48 return str(v) elif query == 'unix': v.dialect = netaddr.mac_unix return str(v) elif query in [ 'pgsql', 'postgresql', 'psql' ]: v.dialect = netaddr.mac_pgsql return str(v) elif query == 'cisco': v.dialect = netaddr.mac_cisco return str(v) elif query == 'bare': v.dialect = netaddr.mac_bare return str(v) elif query == 'linux': v.dialect = mac_linux return str(v) else: raise errors.AnsibleFilterError(alias + ': unknown filter type: %s' % query) return False