(values: dict[bytes, int])
| 193 | |
| 194 | |
| 195 | def _encode_bytes_values(values: dict[bytes, int]) -> list[bytes]: |
| 196 | value_by_index = {index: value for value, index in values.items()} |
| 197 | result = [] |
| 198 | line: list[bytes] = [] |
| 199 | line_len = 0 |
| 200 | for i in range(len(values)): |
| 201 | value = value_by_index[i] |
| 202 | c_init = format_int(len(value)) |
| 203 | c_len = len(c_init) + len(value) |
| 204 | if line_len > 0 and line_len + c_len > 70: |
| 205 | result.append(format_int(len(line)) + b"".join(line)) |
| 206 | line = [] |
| 207 | line_len = 0 |
| 208 | line.append(c_init + value) |
| 209 | line_len += c_len |
| 210 | if line: |
| 211 | result.append(format_int(len(line)) + b"".join(line)) |
| 212 | result.append(b"") |
| 213 | return result |
| 214 | |
| 215 | |
| 216 | def format_int(n: int) -> bytes: |
searching dependent graphs…