<commit_before>cdef Py_ssize_t BLOCK_SIZE = 2880  # the FITS block size
cdef Py_ssize_t CARD_LENGTH = 80
cdef str VALUE_INDICATOR = '= '  # The standard FITS value indicator
cdef str END_CARD = 'END' + ' ' * 77


def parse_header(fileobj):
    """The main method allowing to parse quickly a FITS header."""

    cards = {}
    read_blocks = []
    cdef int found_end = 0
    cdef bytes block
    cdef str header_str, block_str, card_image, keyword
    cdef Py_ssize_t idx, end_idx, sep_idx

    while True:
        # iterate on blocks
        block = fileobj.read(BLOCK_SIZE)
        if not block or len(block) < BLOCK_SIZE:
            # header looks incorrect, raising exception to fall back to
            # the full Header parsing
            raise Exception

        block_str = block.decode('ascii')
        read_blocks.append(block_str)
        idx = 0
        while idx < BLOCK_SIZE:
            # iterate on cards
            end_idx = idx + CARD_LENGTH
            card_image = block_str[idx:end_idx]
            idx = end_idx

            keyword = card_image[:8].strip()
            sep_idx = card_image.find(VALUE_INDICATOR)

            # We are interested only in standard keyword, so we skip
            # other cards, e.G. CONTINUE, HIERARCH, COMMENT.
            if sep_idx == 8:<commit_msg>Use OrderedDict for Python 3.5<commit_after>from collections import OrderedDict

cdef Py_ssize_t BLOCK_SIZE = 2880  # the FITS block size
cdef Py_ssize_t CARD_LENGTH = 80
cdef str VALUE_INDICATOR = '= '  # The standard FITS value indicator
cdef str END_CARD = 'END' + ' ' * 77


def parse_header(fileobj):
    """The main method allowing to parse quickly a FITS header."""

    cards = OrderedDict()
    read_blocks = []
    cdef int found_end = 0
    cdef bytes block
    cdef str header_str, block_str, card_image, keyword
    cdef Py_ssize_t idx, end_idx, sep_idx

    while True:
        # iterate on blocks
        block = fileobj.read(BLOCK_SIZE)
        if not block or len(block) < BLOCK_SIZE:
            # header looks incorrect, raising exception to fall back to
            # the full Header parsing
            raise Exception

        block_str = block.decode('ascii')
        read_blocks.append(block_str)
        idx = 0
        while idx < BLOCK_SIZE:
            # iterate on cards
            end_idx = idx + CARD_LENGTH
            card_image = block_str[idx:end_idx]
            idx = end_idx

            keyword = card_image[:8].strip()
            sep_idx = card_image.find(VALUE_INDICATOR)

            # We are interested only in standard keyword, so we skip
            # other cards, e.G. CONTINUE, HIERARCH, COMMENT.
            if sep_idx == 8:
{'fraction_non_alphanumeric': 0.07193440178904212, 'fraction_numerical': 0.009690644800596348, 'mean_word_length': 2.2298435619735257, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4090113', 'n_tokens_mistral': 849, 'n_tokens_neox': 797, 'n_words': 260}