Пример #1
0
 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
Пример #2
0
 def testCreateServerNumericRightLength(self):
     self.assertEqual('A5', create_numeric((57, None)))
Пример #3
0
 def testCreateClientNumericRightLength(self):
     self.assertEqual('AqAB6', create_numeric((42, 122)))
Пример #4
0
 def testCreateServerNumeric(self):
     self.assertEqual('BA', create_numeric((64, None)))
Пример #5
0
 def testCreateClientNumeric(self):
     self.assertEqual('B]BBa', create_numeric((127, 4186)))