<commit_before>import os
import re
import subprocess
import presenter
import logger
from collections import Counter

def get_files(repository_path, argv):

    os.chdir(repository_path)

    parameters = ['git', 'ls-files', argv.path]
    files = subprocess.check_output(parameters, universal_newlines=True)

    return files.split()

def blame(repository_path, file, argv):

    os.chdir(repository_path)

    if is_binary(file) and not argv.force_binaries:
        logger.instance.info('Skipping (binary) {} ...'.format(file))
        return ''

    logger.instance.info('Running over {} ...'.format(file))

    parameters = ['git', 'blame', '--line-porcelain', '-w', file]
    blame = subprocess.check_output(parameters, universal_newlines=True)

    return blame

def is_binary(file):

    parameters = ['file', '--mime', file]

    try:
        mime = subprocess.check_output(parameters, universal_newlines=True)
        match = re.search('charset=binary', mime)
    except UnicodeDecodeError as e:
        logger.instance.warning(file)
        logger.instance.warning(e)
        match = True

    return match is not None

def commit(repository_path, argv):

    accumulator = Counter()

    for file in get_files(repository_path, argv):
        porcelain_blame = blame(repository_path,  file, argv)
        counter = process_blame(porcelain_blame, argv)
        accumulator = accumulator + counter

    logger.instance.info('Final accumulator...')
    logger.instance.info(accumulator)

    return presenter.out(accumulator, argv)

def process_blame(blame, argv):<commit_msg>Add information about elapsed time<commit_after>import os
import re
import subprocess
import presenter
import logger
import time
from collections import Counter

def get_files(repository_path, argv):

    os.chdir(repository_path)

    parameters = ['git', 'ls-files', argv.path]
    files = subprocess.check_output(parameters, universal_newlines=True)

    return files.split()

def blame(repository_path, file, argv):

    os.chdir(repository_path)

    if is_binary(file) and not argv.force_binaries:
        logger.instance.info('Skipping (binary) {} ...'.format(file))
        return ''

    logger.instance.info('Running over {} ...'.format(file))

    parameters = ['git', 'blame', '--line-porcelain', '-w', file]
    blame = subprocess.check_output(parameters, universal_newlines=True)

    return blame

def is_binary(file):

    parameters = ['file', '--mime', file]

    try:
        mime = subprocess.check_output(parameters, universal_newlines=True)
        match = re.search('charset=binary', mime)
    except UnicodeDecodeError as e:
        logger.instance.warning(file)
        logger.instance.warning(e)
        match = True

    return match is not None

def commit(repository_path, argv):

    start_time = time.time()
    accumulator = Counter()

    for file in get_files(repository_path, argv):
        porcelain_blame = blame(repository_path,  file, argv)
        counter = process_blame(porcelain_blame, argv)
        accumulator = accumulator + counter

    elapsed_time = time.time() - start_time

    return presenter.out(accumulator, argv, elapsed_time)

def process_blame(blame, argv):
{'fraction_non_alphanumeric': 0.11229277447607132, 'fraction_numerical': 0.0, 'mean_word_length': 3.6147186147186146, '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': '1742117', 'n_tokens_mistral': 978, 'n_tokens_neox': 934, 'n_words': 228}