| Nathan Knuth | 418fdc8 | 2016-09-16 22:51:15 -0700 | [diff] [blame] | 1 | """ |
| 2 | Common utility functions | ||||
| 3 | """ | ||||
| 4 | |||||
| 5 | from loxi.pp import PrettyPrinter | ||||
| 6 | |||||
| 7 | |||||
| 8 | def pp(obj): | ||||
| 9 | pp = PrettyPrinter(maxwidth=80) | ||||
| 10 | pp.pp(obj) | ||||
| 11 | return str(pp) | ||||
| 12 | |||||
| 13 | def 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(':')) | ||||