<commit_before># -*- coding: utf-8 -*-
# Copyright (c) 2016, <NAME>
# This module is distributed under the terms of the new BSD License.

"""
Pure python module to handle the .ico format. Written for Python 2.7
and Python 3.2+. Depends on png.py.
"""

from __future__ import print_function, division, absolute_import

import sys
import struct

from .png import read_png, write_png

if sys.version_info[0] > 2:
    basestring = str  # noqa


VALID_SIZES = 16, 32, 48, 64, 128, 256

# Little endian int encoding (for bmp/icon writing)
w1 = lambda x: struct.pack('<B', x)
w2 = lambda x: struct.pack('<H', x)
w4 = lambda x: struct.pack('<I', x)


def intl(x):
    """ little endian int decoding (for bmp/ico reading)
    """
    if len(x) == 1:
        return struct.unpack('<B', x)[0]
    elif len(x) == 2:
        return struct.unpack('<H', x)[0]
    elif len(x) == 4:
        return struct.unpack('<I', x)[0]


class Icon(object):
    """ Icon class<commit_msg>check compat with Python 4. Changed one check for clarity<commit_after># -*- coding: utf-8 -*-
# Copyright (c) 2016, <NAME>
# This module is distributed under the terms of the new BSD License.

"""
Pure python module to handle the .ico format. Written for Python 2.7
and Python 3.2+. Depends on png.py.
"""

from __future__ import print_function, division, absolute_import

import sys
import struct

from .png import read_png, write_png

if sys.version_info[0] >= 3:
    basestring = str  # noqa


VALID_SIZES = 16, 32, 48, 64, 128, 256

# Little endian int encoding (for bmp/icon writing)
w1 = lambda x: struct.pack('<B', x)
w2 = lambda x: struct.pack('<H', x)
w4 = lambda x: struct.pack('<I', x)


def intl(x):
    """ little endian int decoding (for bmp/ico reading)
    """
    if len(x) == 1:
        return struct.unpack('<B', x)[0]
    elif len(x) == 2:
        return struct.unpack('<H', x)[0]
    elif len(x) == 4:
        return struct.unpack('<I', x)[0]


class Icon(object):
    """ Icon class
{'fraction_non_alphanumeric': 0.1455470737913486, 'fraction_numerical': 0.035114503816793895, 'mean_word_length': 3.2646420824295013, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 7, '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': '4357311', 'n_tokens_mistral': 737, 'n_tokens_neox': 673, 'n_words': 244}