<commit_before>import os

from PIL import Image, ImageFile

DEFAULT_PALETTE = "classic"
PALETTES = {
    "classic": [0x9B, 0xBC, 0x0F, 0x8B, 0xAC, 0x0F, 0x30, 0x62, 0x30, 0x0F, 0x38, 0x0F],
    "blue": [0xFF, 0xFF, 0xFF, 0x63, 0xA5, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00],
    "brown": [0xFF, 0xFF, 0xFF, 0xFF, 0xAD, 0x63, 0x84, 0x31, 0x00, 0x00, 0x00, 0x00],
    "dark_blue": [0xFF, 0xFF, 0xFF, 0x8C, 0x8C, 0xDE, 0x52, 0x52, 0x8C, 0x00, 0x00, 0x00],
    "dark_brown": [0xFF, 0xE6, 0xC5, 0xCE, 0x9C, 0x84, 0x84, 0x6B, 0x29, 0x5A, 0x31, 0x08],
    "dark_green": [0xFF, 0xFF, 0xFF, 0x7B, 0xFF, 0x31, 0x00, 0x63, 0xC5, 0x00, 0x00, 0x00],
    "grayscale": [0xFF, 0xFF, 0xFF, 0xA5, 0xA5, 0xA5, 0x52, 0x52, 0x52, 0x00, 0x00, 0x00],
    "green": [0xFF, 0xFF, 0xFF, 0x52, 0xFF, 0x00, 0xFF, 0x42, 0x00, 0x00, 0x00, 0x00],
    "inverted": [0x00, 0x00, 0x00, 0x00, 0x84, 0x84, 0xFF, 0xDE, 0x00, 0xFF, 0xFF, 0xFF],
    "orange": [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00],
    "pastel_mix": [0xFF, 0xFF, 0xA5, 0xFF, 0x94, 0x94, 0x94, 0x94, 0xFF, 0x00, 0x00, 0x00],
    "red": [0xFF, 0xFF, 0xFF, 0xFF, 0x84, 0x84, 0x94, 0x3A, 0x3A, 0x00, 0x00, 0x00],
    "yellow": [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x7B, 0x4A, 0x00, 0x00, 0x00, 0x00],
}


class GBCamImageFile(ImageFile.ImageFile):
    format = "GBCamera"
    format_description = "Game Boy Camera save file"
    _close_exclusive_fp_after_loading = False

    __fp = None
    __frame = 0
    _n_frames = 30

    def _open(self):
        self.fp.seek(0, os.SEEK_END)
        if self.fp.tell() != 131072:
            raise SyntaxError("GB Camera save file must be 128K")

        self.mode = "P"
        self.size = (16 * 8, 14 * 8)

        # Apparently ImageFile does 'self.fp = None' after loading, so we must keep a reference to it.
        self.__fp = self.fp
        self.seek(0)
<commit_msg>Issue #3: Wrong palettes<commit_after>import os

from PIL import Image, ImageFile

DEFAULT_PALETTE = "classic"
PALETTES = {
    "classic": [0x9B, 0xBC, 0x0F, 0x30, 0x62, 0x30, 0x8B, 0xAC, 0x0F, 0x0F, 0x38, 0x0F],
    "blue": [0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x63, 0xA5, 0xFF, 0x00, 0x00, 0x00],
    "brown": [0xFF, 0xFF, 0xFF, 0x84, 0x31, 0x00, 0xFF, 0xAD, 0x63, 0x00, 0x00, 0x00],
    "dark_blue": [0xFF, 0xFF, 0xFF, 0x52, 0x52, 0x8C, 0x8C, 0x8C, 0xDE, 0x00, 0x00, 0x00],
    "dark_brown": [0xFF, 0xE6, 0xC5, 0x84, 0x6B, 0x29, 0xCE, 0x9C, 0x84, 0x5A, 0x31, 0x08],
    "dark_green": [0xFF, 0xFF, 0xFF, 0x00, 0x63, 0xC5, 0x7B, 0xFF, 0x31, 0x00, 0x00, 0x00],
    "grayscale": [0xFF, 0xFF, 0xFF, 0x52, 0x52, 0x52, 0xA5, 0xA5, 0xA5, 0x00, 0x00, 0x00],
    "green": [0xFF, 0xFF, 0xFF, 0x52, 0x94, 0x00, 0x52, 0xFF, 0x00, 0x00, 0x00, 0x00],
    "inverted": [0x00, 0x00, 0x00, 0xFF, 0xDE, 0x00, 0x00, 0x84, 0x84, 0xFF, 0xFF, 0xFF],
    "orange": [0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00],
    "pastel_mix": [0xFF, 0xFF, 0xA5, 0x94, 0x94, 0xFF, 0xFF, 0x94, 0x94, 0x00, 0x00, 0x00],
    "red": [0xFF, 0xFF, 0xFF, 0x94, 0x3A, 0x3A, 0xFF, 0x84, 0x84, 0x00, 0x00, 0x00],
    "yellow": [0xFF, 0xFF, 0xFF, 0x7B, 0x4A, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00],
}


class GBCamImageFile(ImageFile.ImageFile):
    format = "GBCamera"
    format_description = "Game Boy Camera save file"
    _close_exclusive_fp_after_loading = False

    __fp = None
    __frame = 0
    _n_frames = 30

    def _open(self):
        self.fp.seek(0, os.SEEK_END)
        if self.fp.tell() != 131072:
            raise SyntaxError("GB Camera save file must be 128K")

        self.mode = "P"
        self.size = (16 * 8, 14 * 8)

        # Apparently ImageFile does 'self.fp = None' after loading, so we must keep a reference to it.
        self.__fp = self.fp
        self.seek(0)

{'fraction_non_alphanumeric': 0.15462543321780858, 'fraction_numerical': 0.19008264462809918, 'mean_word_length': 3.403755868544601, 'pattern_counts': {'":': 26, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '573944', 'n_tokens_mistral': 2349, 'n_tokens_neox': 1851, 'n_words': 477}