@classmethod
	def _new_aspaths (cls, data, asn4, klass=None):
		as_set = []
		as_seq = []
		as_cset = []
		as_cseq = []

		backup = data

		unpacker = {
			False: '!H',
			True:  '!L',
		}
		size = {
			False: 2,
			True:  4,
		}
		as_choice = {
			ASPath.AS_SEQUENCE: as_seq,
			ASPath.AS_SET:      as_set,
			ASPath.AS_CONFED_SEQUENCE: as_cseq,
			ASPath.AS_CONFED_SET:      as_cset,
		}

		upr = unpacker[asn4]
		length = size[asn4]

		try:

			while data:
				stype = ord(data[0])
				slen  = ord(data[1])

				if stype not in (ASPath.AS_SET, ASPath.AS_SEQUENCE, ASPath.AS_CONFED_SEQUENCE, ASPath.AS_CONFED_SET):
					raise Notify(3,11,'invalid AS Path type sent %d' % stype)

				end = 2+(slen*length)
				sdata = data[2:end]
				data = data[end:]
				# Eat the data and ignore it if the ASPath attribute is know known
				asns = as_choice.get(stype,[])

				for _ in range(slen):
					asn = unpack(upr,sdata[:length])[0]
					asns.append(ASN(asn))
					sdata = sdata[length:]

		except __HOLE__:
			raise Notify(3,11,'not enough data to decode AS_PATH or AS4_PATH')
		except error:  # struct
			raise Notify(3,11,'not enough data to decode AS_PATH or AS4_PATH')

		if klass:
			return klass(as_seq,as_set,as_cseq,as_cset,backup)
		return cls(as_seq,as_set,as_cseq,as_cset,backup)
dataset/ETHPy150Open Exa-Networks/exabgp/lib/exabgp/bgp/message/update/attribute/aspath.py/ASPath._new_aspaths