<commit_before>import fnmatch
import os.path
import re

EXPAND_BRACES_RE = re.compile(r'.*(\{.*?[^\\]?\})')


def get_real_metric_path(absolute_path, metric_path):
    # Support symbolic links (real_metric_path ensures proper cache queries)
    real_absolute_path = os.path.realpath(absolute_path)
    if absolute_path != real_absolute_path:
        # replace left side base_fs_path that contains sym link with real fs path
        relative_fs_path = metric_path.replace('.', os.sep)
        real_absolute_path_no_ext, _ext = os.path.splitext(real_absolute_path)
        base_fs_path = os.path.dirname(real_absolute_path_no_ext[:-len(relative_fs_path)])
        real_base_fs_path = os.path.realpath(base_fs_path)
        real_relative_fs_path = real_absolute_path[len(real_base_fs_path):].lstrip(os.sep)
        return fs_to_metric(real_relative_fs_path)

    return metric_path


def fs_to_metric(path):
    dirpath = os.path.dirname(path)
    filename = os.path.basename(path)<commit_msg>Revert "Fix get_real_metric_path for paths where an intermediate directory is a symlink"<commit_after>import fnmatch
import os.path
import re

EXPAND_BRACES_RE = re.compile(r'.*(\{.*?[^\\]?\})')


def get_real_metric_path(absolute_path, metric_path):
    # Support symbolic links (real_metric_path ensures proper cache queries)
    real_absolute_path = os.path.realpath(absolute_path)
    if absolute_path != real_absolute_path:
        # replace left side base_fs_path that contains sym link with real fs path
        relative_fs_path = metric_path.replace('.', os.sep)
        absolute_path_no_ext, _ext = os.path.splitext(absolute_path)
        base_fs_path = os.path.dirname(absolute_path_no_ext[:-len(relative_fs_path)])
        real_base_fs_path = os.path.realpath(base_fs_path)
        real_relative_fs_path = real_absolute_path[len(real_base_fs_path):].lstrip(os.sep)
        return fs_to_metric(real_relative_fs_path)

    return metric_path


def fs_to_metric(path):
    dirpath = os.path.dirname(path)
    filename = os.path.basename(path)
{'fraction_non_alphanumeric': 0.09803921568627451, 'fraction_numerical': 0.0, 'mean_word_length': 4.457219251336898, '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': '6183834', 'n_tokens_mistral': 695, 'n_tokens_neox': 684, 'n_words': 126}