def macaddr_pack(data, bytes = bytes):
	"""
	Pack a MAC address

	Format found in PGSQL src/backend/utils/adt/mac.c, and PGSQL Manual types
	"""
	# Accept all possible PGSQL Macaddr formats as in manual
	# Oh for sscanf() as we could just copy PGSQL C in src/util/adt/mac.c
	colon_parts = data.split(':')
	dash_parts = data.split('-')
	dot_parts = data.split('.')
	if len(colon_parts) == 6:
		mac_parts = colon_parts
	elif len(dash_parts) == 6:
		mac_parts = dash_parts
	elif len(colon_parts) == 2:
		mac_parts = [colon_parts[0][:2], colon_parts[0][2:4], colon_parts[0][4:],
			colon_parts[1][:2], colon_parts[1][2:4], colon_parts[1][4:]]
	elif len(dash_parts) == 2:
		mac_parts = [dash_parts[0][:2], dash_parts[0][2:4], dash_parts[0][4:],
			dash_parts[1][:2], dash_parts[1][2:4], dash_parts[1][4:]]
	elif len(dot_parts) == 3:
		mac_parts = [dot_parts[0][:2], dot_parts[0][2:], dot_parts[1][:2],
			dot_parts[1][2:], dot_parts[2][:2], dot_parts[2][2:]]
	elif len(colon_parts) == 1:
		mac_parts = [data[:2], data[2:4], data[4:6], data[6:8], data[8:10], data[10:]]
	else:
		raise ValueError('data string cannot be parsed to bytes')
	if len(mac_parts) != 6 and len(mac_parts[-1]) != 2:
		raise ValueError('data string cannot be parsed to bytes')
	return bytes([int(p, 16) for p in mac_parts])