#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
+"""A simple compression helper for lowercase ascii text."""
+
import bitstring
from collect.bidict import BiDict
"""
compressed = bitstring.BitArray()
- for (n, letter) in enumerate(uncompressed):
+ for letter in uncompressed:
if 'a' <= letter <= 'z':
bits = ord(letter) - ord('a') + 1 # 1..26
else:
if letter not in special_characters:
- raise Exception(
- f'"{uncompressed}" contains uncompressable char="{letter}"'
- )
+ raise Exception(f'"{uncompressed}" contains uncompressable char="{letter}"')
bits = special_characters[letter]
compressed.append(f"uint:5={bits}")
while len(compressed) % 8 != 0: