Pack people into a network transmittable format

        :param people: People to pack
        :type people: list[paps.people.People]
        :return: The packed people
        :rtype: str
424104
def _pack_people(people):
        
        res = bytearray()
        bits = bytearray([1])

        for person in people:
            bits.extend(person.to_bits())
        aByte = 0

        for i, bit in enumerate(bits[::-1]):
            mod = i % 8
            aByte |= bit << mod
            if mod == 7 or i == len(bits) - 1:
                res.append(aByte)
                aByte = 0
        return struct.pack(APPUpdateMessage.fmt.format(len(res)), *res[::-1])
653499
def encode(self, transmission):
        
        data = ''
        data += self._record_encode(transmission.header)
        for group in transmission.groups:
            data += self._record_encode(group.group_header)
            for transaction in group.transactions:
                for record in transaction:
                    data += self._record_encode(record)
            data += self._record_encode(group.group_trailer)
        data += self._record_encode(transmission.trailer)
        return data
747255
def pack(self):
        

        # Possible structs for packet ID.
        #
        try:
            structs_ = get_structs_for_fields([self.fields[0]])
        except (TypeError):
            # TypeError, if self.fields[0] is a wrong argument to `chr()`.
            raise PackError(self)


        # Possible structs for packet ID + subcode
        #
        if structs_ == []:
            try:
                structs_ = get_structs_for_fields([self.fields[0], self.fields[1]])
            except (IndexError, TypeError):
                # IndexError, if no self.fields[1]
                # TypeError, if self.fields[1] is a wrong argument to `chr()`.
                raise PackError(self)


        # Try to pack the packet with any of the possible structs.
        #
        for struct_ in structs_:
            try:
                return struct_.pack(*self.fields)
            except struct.error:
                pass

        # We only get here if the ``return`` inside the``for`` loop
        # above wasn't reached, i.e. none of the `structs_` matched.
        #
        raise PackError(self)
633010
def send_group_file(self, sender, receiver, media_id):
        
        return self.send_file(sender, 'group', receiver, media_id)
816350
def to_bytes(self):
        '''
        
        '''
        return struct.pack(Ethernet._PACKFMT, self._dst.packed, 
            self._src.packed, self._ethertype.value)
802526
def serialize(self, data: Dict, fields=None, toBytes=True):
        
        if isinstance(data, Dict):
            data = self._sort_dict(data)
        return msgpack.packb(data, use_bin_type=True)
284984
def hosts(self):
        
        network = int(self.network_address)
        broadcast = int(self.broadcast_address)
        for x in long_range(1, broadcast - network + 1):
            yield self._address_class(network + x)
185144
def packed_data(self):
        """"""
        # Pack the header
        scp_header = struct.pack("<2H", self.cmd_rc, self.seq)

        # Potential loop intentionally unrolled
        if self.arg1 is not None:
            scp_header += struct.pack('<I', self.arg1)
        if self.arg2 is not None:
            scp_header += struct.pack('<I', self.arg2)
        if self.arg3 is not None:
            scp_header += struct.pack('<I', self.arg3)

        # Return the SCP header and the rest of the data
        return scp_header + self.data
1322126
def set_report_recipients(self, report, recipients):
        
        to_set = report.getRecipients()
        for recipient in recipients:
            if recipient not in to_set:
                to_set.append(recipient)
        report.setRecipients(to_set)
174540
async def _send_sack(self):
        
        gaps = []
        gap_next = None
        for tsn in sorted(self._sack_misordered):
            pos = (tsn - self._last_received_tsn) % SCTP_TSN_MODULO
            if tsn == gap_next:
                gaps[-1][1] = pos
            else:
                gaps.append([pos, pos])
            gap_next = tsn_plus_one(tsn)

        sack = SackChunk()
        sack.cumulative_tsn = self._last_received_tsn
        sack.advertised_rwnd = max(0, self._advertised_rwnd)
        sack.duplicates = self._sack_duplicates[:]
        sack.gaps = [tuple(x) for x in gaps]

        await self._send_chunk(sack)

        self._sack_duplicates.clear()
        self._sack_needed = False
1166854
def _pack_fn(self):
    
    if not self.packed_length:
      return None
    def my_fn(records):
      """Function from list of TFRecords to list of TFRecords."""
      examples = []
      for record in records:
        x = tf.train.Example()
        x.ParseFromString(record)
        example_dict = {}
        if self.has_inputs:
          example_dict["inputs"] = [
              int(i) for i in x.features.feature["inputs"].int64_list.value]
        example_dict["targets"] = [
            int(i) for i in x.features.feature["targets"].int64_list.value]
        examples.append(example_dict)
      examples = list(self._maybe_pack_examples(examples))
      return [
          generator_utils.to_example(x).SerializeToString() for x in examples]
    return my_fn
845712
def person(person_ids, options = {})
      ids = Array(person_ids)

      result = get('/people', options.merge(personIds: ids)).dig('people')

      return result.first if ids.length == 1

      result
    end
55490
def to_bytes(self):
        '''
        
        '''
        hdr = struct.pack(RIPv2._PACKFMT, self.command.value, 2)
        routes = b''.join([r.to_bytes() for r in self._routes])
        return hdr + routes
203986
def people(self):
        ''''''
        people_response = self.get_request('people/')
        return [Person(self, pjson['user']) for pjson in people_response]
651812
def _packed_data(self):
    '''
    
    '''
    header = self.header()

    packed_data = np.frombuffer(self.data, dtype=np.int8)\
        .reshape((header['number_of_half_frames'], header['half_frame_bytes']))  # create array of half frames
    packed_data = packed_data[::-1, constants.header_offset:]  # slice out header and flip half frame order to reverse time ordering
    packed_data = packed_data.reshape((header['number_of_half_frames']*(header['half_frame_bytes']- constants.header_offset))) # compact into vector

    return packed_data
595955
def get_shared_people(self):
        """"""
        people = []
        output = self._get_data()
        self._logger.debug(output)
        shared_entries = output[0] or []
        for info in shared_entries:
            try:
                people.append(Person(info))
            except InvalidData:
                self._logger.debug('Missing location or other info, dropping person with info: %s', info)
        return people
314883
def create(clients_num, clients_host, clients_port, people_num, throttle):
    
    res = []
    for number in range(clients_num):
        sc = EchoClient({
            'id': number,
            'listen_bind_ip': clients_host,
            #'multicast_bind_ip': "127.0.0.1",
            'listen_port': clients_port + number
        })
        people = []
        for person_number in range(people_num):
            people.append(Person(id=person_number))
        wrapper = WrapperEchoClient({
            'client': sc,
            'people': people,
            'throttle': throttle
        })
        res.append(wrapper)

    return res, cmd_line