def build(self, origin, token, args): """ Build a string suitable for sending """ # If the last argument is "long", package it for sending if len(args) > 0: if args[-1].find(" ") > -1: build_last_arg = ":" + args[-1] build_args = args[0:-1] + build_last_arg.split(" ") else: build_args = args else: build_args = [] # Build the line # Future compatibility - only send \n ret = create_numeric(origin) + " " + token + " " \ + " ".join(build_args) + "\n" # Check we're not sending things which are protocol violations if len(ret) > 512: raise ProtocolError('Line too long to send') if not token.isupper() and not token.isdigit(): raise ProtocolError('Command not in uppercase during build') return ret
def testCreateServerNumericRightLength(self): self.assertEqual('A5', create_numeric((57, None)))
def testCreateClientNumericRightLength(self): self.assertEqual('AqAB6', create_numeric((42, 122)))
def testCreateServerNumeric(self): self.assertEqual('BA', create_numeric((64, None)))
def testCreateClientNumeric(self): self.assertEqual('B]BBa', create_numeric((127, 4186)))