Пример #1
0
 def _read(reader, tcode, endianness, offset, bytes):
     (n, offset) = parser.read_integer(endianness, offset + 1, bytes)
     val = q_list([])
     if n == 0: return (val, offset)
     for i in range(0, n):
         (item, offset) = reader(endianness, offset, bytes)
         val.append(item)
     if tcode is CHAR_CODE:
         return (q_str(''.join(val)), offset)
     else:
         val._determine_type()
         return (val, offset)
Пример #2
0
 def _read(reader,tcode,endianness,offset,bytes):
   (n, offset) = parser.read_integer(endianness,offset+1,bytes)
   val = q_list([])
   if n == 0: return (val,offset)
   for i in range(0, n):
       (item,offset) = reader(endianness,offset,bytes)
       val.append(item)
   if tcode is CHAR_CODE:
     return (q_str(''.join(val)),offset)
   else:
     val._determine_type()
     return (val,offset)
Пример #3
0
Файл: conn.py Проект: Ricemast/q
    def _receive(self):
        """read the response from the server"""
        header = self.sock.recv(8)
        # Endianness of byte doesn't matter when determining endianness
        endianness = lambda x: x
        if not _parser.read_byte(endianness, 0, header)[0] == 1:
            endianness = '>'.__add__
        (data_size, self.offset) = _parser.read_integer(endianness, 4, header)

        bytes = self._recv_size(data_size - 8)
        # ensure that it reads all the data
        if _parser.read_byte(endianness, 0, bytes)[0] == -128:
            (val, self.offset) = _parser.read_symbol(endianness, 1, bytes)
            raise Exception(val)
        (val, self.offset) = _parser.read(endianness, 0, bytes)
        return val