<commit_before>"""
Parsing and manipulation of front matter elements of a document.
"""

from grow.common import utils
import collections
import re
import yaml

BOUNDARY_REGEX = re.compile(r'^-{3,}$', re.MULTILINE)
CONVERT_MESSAGE = """Document contains too many parts: {},
    Please run `grow convert --type content_locale_split` to help update files."""


def _update_deep(orig_dict, new_dict):
    for k, v in new_dict.iteritems():
        if (k in orig_dict and isinstance(orig_dict[k], dict)
                and isinstance(new_dict[k], collections.Mapping)):
            _update_deep(orig_dict[k], new_dict[k])
        else:
            orig_dict[k] = new_dict[k]


class Error(Exception):
    pass


class BadFormatError(Error, ValueError):
    pass


class DocumentFrontMatter(object):
<commit_msg>Correctly split the document front matter with whitespace at the end.<commit_after>"""
Parsing and manipulation of front matter elements of a document.
"""

from grow.common import utils
import collections
import re
import yaml

BOUNDARY_REGEX = re.compile(r'^-{3,}\s*$', re.MULTILINE)
CONVERT_MESSAGE = """Document contains too many parts: {},
    Please run `grow convert --type content_locale_split` to help update files."""


def _update_deep(orig_dict, new_dict):
    for k, v in new_dict.iteritems():
        if (k in orig_dict and isinstance(orig_dict[k], dict)
                and isinstance(new_dict[k], collections.Mapping)):
            _update_deep(orig_dict[k], new_dict[k])
        else:
            orig_dict[k] = new_dict[k]


class Error(Exception):
    pass


class BadFormatError(Error, ValueError):
    pass


class DocumentFrontMatter(object):

{'fraction_non_alphanumeric': 0.1059245960502693, 'fraction_numerical': 0.0011968880909634949, 'mean_word_length': 3.7635327635327633, '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': '2117663', 'n_tokens_mistral': 513, 'n_tokens_neox': 499, 'n_words': 154}