<commit_before>import subprocess, os

import pyperclip


def repository_root():
    return subprocess.check_output(('git', 'rev-parse', '--show-toplevel',)).strip()


def cd_repository_root():
    os.chdir(repository_root())


def current_branch():
    return subprocess.check_output(('git', 'rev-parse', '--abbrev-ref', 'HEAD',)).strip()


def pick_branch():
    branches = subprocess.Popen(('git', 'branch', '-a',), stdout=subprocess.PIPE)
    branch = subprocess.check_output(('pick',), stdin=branches.stdout)
    return branch.split()[-1]<commit_msg>finished writing helper functions, they still need doc strings<commit_after>import subprocess, os
from subprocess import STDOUT, PIPE

import pyperclip


def add_new_line(b):
    if b[-1:] != bytes('\n', 'utf-8'):
        return b + bytes('\n', 'utf-8')
    return b

def repository_root():
    return subprocess.check_output(('git', 'rev-parse', '--show-toplevel',)).strip()

def cd_repository_root():
    os.chdir(repository_root())

def current_branch():
    return subprocess.check_output(('git', 'rev-parse', '--abbrev-ref', 'HEAD',)).strip()


def pick_branch():
    branches = subprocess.Popen(('git', 'branch', '-a',), stdout=PIPE)
    branch = subprocess.check_output(('pick',), stdin=branches.stdout)
    return branch.split()[-1]

def pick_commit(*args):
    commits = subprocess.check_output(('git', 'log', "--pretty=format:'%h %ad | %s%d [%an]'", '--date=short', *args))
    commits = add_new_line(commits)
    p = subprocess.Popen(['pick',], stdin=PIPE, stdout=PIPE, stderr=STDOUT)
    commit = p.communicate(input=commits)[0]
    return commit.split()[0]

def pick_commit_reflog(*args):
    commits = subprocess.check_output(('git', 'reflog', '--all', '--date=short', *args))
    commits = add_new_line(commits)
    p = subprocess.Popen(['pick',], stdin=PIPE, stdout=PIPE, stderr=STDOUT)
    commit = p.communicate(input=commits)[0]
    return commit.split()[0]

def pick_file(*args):
    files = subprocess.Popen(('git', 'ls-tree', '-r', 'master', '--name-only', *args), stdout=PIPE)
    file = subprocess.check_output(('pick',), stdin=files.stdout)
    return file.strip()
{'fraction_non_alphanumeric': 0.19225384974335044, 'fraction_numerical': 0.004199720018665422, 'mean_word_length': 4.826086956521739, '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': '1414712', 'n_tokens_mistral': 755, 'n_tokens_neox': 746, 'n_words': 146}