Esempio n. 1
0
	def decode(cls, frameString):
		"""
		C{frameString} is a L{StringFragment} that ends with "N".
		"""
		try:
			seqNum = strToNonNegLimit(str(frameString[:-1]), 2**53)
		except ValueError:
			raise InvalidFrame("bad seqNum")
		return cls(seqNum)
Esempio n. 2
0
def sackStringToSack(sackString):
	"""
	C{sackString} is a C{str}.  Returns a L{window.SACK}.
	"""
	try:
		# If not enough args for split, Python raises ValueError
		joinedSackList, ackNumberStr = sackString.rsplit('|', 1)
		ackNumber = strToIntInRange(ackNumberStr, -1, 2**53)
		sackList = tuple(strToNonNegLimit(s, 2**53) for s in joinedSackList.split(',')) if joinedSackList else ()
	except ValueError:
		raise InvalidSackString("bad sack")
	return SACK(ackNumber, sackList)
Esempio n. 3
0
def _qidOrThrow(s):
	try:
		return strToNonNegLimit(s, 2**53)
	except ValueError:
		raise InvalidQANFrame("bad qid")
Esempio n. 4
0
	def _call(self, s, limit=2**128):
		return objcheck.strToNonNegLimit(s, limit)