"""Text utils.""" import re def bytes_to_lines_of_text(bytes_): """Convert bytes to lines of text. Args: bytes_ (bytes): Bytes to convert to lines of text. Returns: list: Lines of text. """ text = None try: text = bytes_.decode('utf-8') except UnicodeDecodeError: text = bytes_.decode('iso-8859-1') lines_of_text = re.compile('(?:\r|\n)+').split(text) return lines_of_text