<commit_before># -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import re

# tells flake8 to ignore complexity check for this file
# flake8: noqa

def get_node_by_xpath(mapping, xpath, default=None, ignore_errors=False,
                      handle_list_selector=False):
    '''Return the node pointed to by xpath from mapping.

    Args:
        mapping: nested dictionary.
        xpath: string-like selector.
        default: default value if the attribute doesn't exist.
        ignore_errors: if True, pass silently if the xpath is invalid.
        handle_list_selector: allow to support list element selector

    Example:

    >>> tree = {'level1': {'level2': {'level3': 'bottom'}}}
    >>> get_node_by_xpath(tree, 'level1.level2.level3') == 'bottom'
    True

    '''
    if not isinstance(mapping, dict):
        if not ignore_errors:
            raise KeyError("Mapping is not dictionary: {!r}".format(mapping))
        return default
    for segment in xpath.split('.'):
        if not mapping:
            if not ignore_errors:
                raise KeyError("Empty mapping, but need to access to '{}'".format(xpath))<commit_msg>pylint<commit_after># -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import re

# tells flake8 to ignore complexity check for this file
# flake8: noqa


def get_node_by_xpath(mapping, xpath, default=None, ignore_errors=False,
                      handle_list_selector=False):
    '''Return the node pointed to by xpath from mapping.

    Args:
        mapping: nested dictionary.
        xpath: string-like selector.
        default: default value if the attribute doesn't exist.
        ignore_errors: if True, pass silently if the xpath is invalid.
        handle_list_selector: allow to support list element selector

    Example:

    >>> tree = {'level1': {'level2': {'level3': 'bottom'}}}
    >>> get_node_by_xpath(tree, 'level1.level2.level3') == 'bottom'
    True

    '''
    if not isinstance(mapping, dict):
        if not ignore_errors:
            raise KeyError("Mapping is not dictionary: {!r}".format(mapping))
        return default
    for segment in xpath.split('.'):
        if not mapping:
            if not ignore_errors:
                raise KeyError("Empty mapping, but need to access to '{}'".format(xpath))
{'fraction_non_alphanumeric': 0.0934283452098179, 'fraction_numerical': 0.007125890736342043, 'mean_word_length': 2.9732704402515724, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '2319052', 'n_tokens_mistral': 707, 'n_tokens_neox': 690, 'n_words': 245}