<commit_before>#!/usr/bin/env python
# encoding: utf-8
"""
Utilities for reading content in git repositories.

- :func:`read_git_blob` will read unicode text from a git commit (given a
  commit reference and a file path.
"""

import git
import os


def read_git_blob(commit_ref, path):
    """Get text from a git blob."""
    repo = git.Repo('.')
    tree = repo.tree(commit_ref)
    dirname, fname = os.path.split(path)
    text = None
    if dirname == '':
        text = _read_blob(tree, fname)
    else:<commit_msg>Documentation for read_git_blob<commit_after>#!/usr/bin/env python
# encoding: utf-8
"""
Utilities for reading content in git repositories.

- :func:`read_git_blob` will read unicode text from a git commit (given a
  commit reference and a file path.
"""

import git
import os


def read_git_blob(commit_ref, path):
    """Get text from a git blob.

    Parameters
    ----------
    commit_ref : str
        Any SHA or git tag that can resolve into a commit in the
        git repository.
    path : str
        Path to the document in the git repository, relative to the root
        of the repository.

    Returns
    -------
    text : unicode
        The document text.
    """
    repo = git.Repo('.')
    tree = repo.tree(commit_ref)
    dirname, fname = os.path.split(path)
    text = None
    if dirname == '':
        text = _read_blob(tree, fname)
    else:
{'fraction_non_alphanumeric': 0.10951008645533142, 'fraction_numerical': 0.001440922190201729, 'mean_word_length': 2.598445595854922, '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': '7517145', 'n_tokens_mistral': 438, 'n_tokens_neox': 426, 'n_words': 154}