<commit_before>from io import BufferedIOBase

from cp2k.generator.input import CP2KInputGenerator
from cp2k.generator.xyz import XYZGenerator


def dict2line_iter(nested, ilevel=0):
    """
    Iterator to convert a nested python dict to a CP2K input file.
    """

    indent = ' '*ilevel

    def _keyfunc(keyval):
        """Custom sorting function to get stable CP2K output"""
        key, val = keyval

        # ensure subsection generating entrys are sorted after keywords
        if isinstance(val, (dict, list)):
            # .. by prefixing them with the last possible character before sorting
            return chr(0x10ffff) + key.lower()

        return key.lower()
<commit_msg>generator: disable import of deprecated jinja2-based generator<commit_after>from io import BufferedIOBase

from .xyz import XYZGenerator


def dict2line_iter(nested, ilevel=0):
    """
    Iterator to convert a nested python dict to a CP2K input file.
    """

    indent = ' '*ilevel

    def _keyfunc(keyval):
        """Custom sorting function to get stable CP2K output"""
        key, val = keyval

        # ensure subsection generating entrys are sorted after keywords
        if isinstance(val, (dict, list)):
            # .. by prefixing them with the last possible character before sorting
            return chr(0x10ffff) + key.lower()

        return key.lower()

{'fraction_non_alphanumeric': 0.07827359180687637, 'fraction_numerical': 0.013167520117044623, 'mean_word_length': 2.831932773109244, 'pattern_counts': {'":': 0, '<': 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': '2864444', 'n_tokens_mistral': 392, 'n_tokens_neox': 359, 'n_words': 140}