This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import TextIO # For type hinting for the file object in parse_palette | |
def parse_palette(file: TextIO) -> list: | |
""" | |
Parses Paint.NET palette files into a python list that contains the strings of the hex color values: | |
parses the colors, | |
pads hex colors that their length is smaller than 8 with the needed amount of 0's, | |
if line contains non hex characters or it has more than 8 characters it skips them (also skips ; comments), |