blob: edda35277c0f77d819a764e5ec562b6bbc0ff06f [file] [log] [blame]
Nathan Knuth418fdc82016-09-16 22:51:15 -07001"""
2Common utility functions
3"""
4
5from loxi.pp import PrettyPrinter
6
7
8def pp(obj):
9 pp = PrettyPrinter(maxwidth=80)
10 pp.pp(obj)
11 return str(pp)
12
13def mac_str_to_tuple(mac):
14 """
15 Convert 'xx:xx:xx:xx:xx:xx' MAC address string to a tuple of integers.
16 Example: mac_str_to_tuple('00:01:02:03:04:05') == (0, 1, 2, 3, 4, 5)
17 """
18 return tuple(int(d, 16) for d in mac.split(':'))