File: mac.py

package info (click to toggle)
xen-3.0 3.0.3-0-2
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 31,772 kB
  • ctags: 70,362
  • sloc: ansic: 417,153; python: 28,855; asm: 23,892; sh: 5,157; makefile: 4,830; objc: 613; perl: 372; xml: 351
file content (11 lines) | stat: -rw-r--r-- 268 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11

from string import join, split

def macToString(mac):
    return ':'.join(map(lambda x: "%02x" % x, mac))

def macFromString(str):
    mac = [ int(x, 16) for x in str.split(':') ]
    if len(mac) != 6:
        raise ValueError("invalid mac: %s" % str)
    return mac