<commit_before>__author__ = 'mongolrgata'

import os
import sys
import struct


def read_unsigned_int32(file):
    """
    :param file:
    :type file: io.FileIO
    :return:
    :rtype: int
    """

    return struct.unpack('<L', file.read(4))[0]


def extract_png(pna_filename):
    """
    :param pna_filename:
    :type pna_filename: str
    :return:
    """

    with open(pna_filename, 'rb') as pna_file:
        pna_file.seek(16, 1)
        file_count = read_unsigned_int32(pna_file)

        file_names = []
        file_lengths = []

        directory = os.path.splitext(pna_filename)[0]
        if not os.path.exists(directory):
            os.mkdir(directory)

        for i in range(0, file_count):
            pna_file.seek(4, 1)
            file_names.append(os.path.join(directory, str(read_unsigned_int32(pna_file)).zfill(3) + '.png'))
            pna_file.seek(28, 1)
            file_lengths.append(read_unsigned_int32(pna_file))

        for i in range(0, file_count):
            if not file_lengths[i]:
                continue<commit_msg>Через константу SEEK_CUR<commit_after>__author__ = 'mongolrgata'

import os
import sys
import struct


def read_unsigned_int32(file):
    """
    :param file:
    :type file: io.FileIO
    :return:
    :rtype: int
    """

    return struct.unpack('<L', file.read(4))[0]


def extract_png(pna_filename):
    """
    :param pna_filename:
    :type pna_filename: str
    :return:
    """

    with open(pna_filename, 'rb') as pna_file:
        pna_file.seek(16, os.SEEK_CUR)
        file_count = read_unsigned_int32(pna_file)

        file_names = []
        file_lengths = []

        directory = os.path.splitext(pna_filename)[0]
        if not os.path.exists(directory):
            os.mkdir(directory)

        for i in range(0, file_count):
            pna_file.seek(4, os.SEEK_CUR)
            file_names.append(os.path.join(directory, str(read_unsigned_int32(pna_file)).zfill(3) + '.png'))
            pna_file.seek(28, os.SEEK_CUR)
            file_lengths.append(read_unsigned_int32(pna_file))

        for i in range(0, file_count):
            if not file_lengths[i]:
                continue
{'fraction_non_alphanumeric': 0.11985192040721888, 'fraction_numerical': 0.01897269782508098, 'mean_word_length': 2.4426751592356686, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1243736', 'n_tokens_mistral': 791, 'n_tokens_neox': 757, 'n_words': 137}