<commit_before>function! Tt_block()
python <<EOF

import math
import re
import vim

def get_tab():
    # 4 spaces
    return "    "

def get_totals(a_rows):
    a_totals = []
    for n in range(0, len(a_rows)):
        a_rows[n] = re.sub(r"\s+", "", a_rows[n])
        s_total = a_rows[n].split("->")[1]
        a_totals.append(s_total)
    return a_totals

def sum_totals(a_rows):
    a_totals = get_totals(a_rows)
    n_hours = 0
    n_minutes = 0
    for n in range(0, len(a_totals)):
        n_hours += int(math.floor((float(a_totals[n][:2]))))
        n_minutes += int(math.floor((float(a_totals[n][3:5]))))
    if n_minutes >= 60:
        n_hours += int(math.floor((n_minutes / 60)))
        n_minutes %= 60

    if n_hours < 10:
        s_hours = "0" + str(n_hours)
    else:
        s_hours = str(n_hours)

    if n_minutes < 10:
        s_minutes = "0" + str(n_minutes)
    else:
        s_minutes = str(n_minutes)
    return s_hours + ":" + s_minutes

window = vim.current.window
b = vim.current.buffer
cl, cc = window.cursor

rows_to_sum = []
for l in range(cl - 1, 0, -1):
    if len(b[l]) > 0:
        if b[l][0] == "=":
            # task = b[l]
            break
        else:
            rows_to_sum.append(b[l])

line = "=> " + sum_totals(rows_to_sum)

# Insert tab at beginning of line of there is none
tab = get_tab()
regex = re.compile("^" + tab)
if not re.match(regex, line):
    line = tab + line

b[cl - 1] = line

EOF
endfunction

function! Tt_h_one()
python <<EOF

"""
Prepend current line with header 1
"""
import vim
import re
vim.current.line = re.sub(r"^#*\s*", "", vim.current.line)
vim.current.line = "# " + vim.current.line

EOF
endfunction

function! Tt_h_two()
python <<EOF

"""
Prepend current line with header 2
"""
import vim
import re
vim.current.line = re.sub(r"^#*\s*", "", vim.current.line)
vim.current.line = "## " + vim.current.line

EOF
endfunction

function! Tt_row()
python <<EOF

from datetime import datetime
import re
import vim

def get_tab():
    # 4 spaces
    return "    "

def get_date_time(s_time):
    a_time = s_time.split(":")
    a_time[0] = int(a_time[0])
    a_time[1] = int(a_time[1])
    today = datetime.today()
    date_time = datetime(
        today.year, today.month, today.day, a_time[0], a_time[1]
    )
    return date_time

def time_elapsed(s):
    s = re.sub(r"\s+", "", s)
    a_time = s.split("-")
    t1 = get_date_time(a_time[0])
    t2 = get_date_time(a_time[1])
    d = t2 - t1

    n_hours = d.seconds / (60 * 60)
    n_minutes = (d.seconds % (60 * 60)) / 60

    if n_hours < 10:
        s_hours = "0" + str(n_hours)
    else:
        s_hours = str(n_hours)

    if n_minutes < 10:
        s_minutes = "0" + str(n_minutes)
    else:
        s_minutes = str(n_minutes)

    return a_time[0] + " - " + a_time[1] + \
        " -> " + s_hours + ":" + s_minutes

window = vim.current.window
vim.current.line = get_tab() + time_elapsed(vim.current.line)
l, c = window.cursor
window.cursor = (l, 23)

EOF
endfunction

function! Tt_sum()
python <<EOF

import math
import re
import vim

def get_totals(a_rows):
    a_totals = []
    for n in range(0, len(a_rows)):
        a_rows[n] = re.sub(r"\s+", "", a_rows[n])
        a_total = a_rows[n].split("->")
        if len(a_total) > 1:
            a_totals.append(a_total[1])
    return a_totals

def sum_totals(s):
    a_totals = get_totals(s)
    n_hours = 0
    n_minutes = 0
    for n in range(0, len(a_totals)):
        n_hours += int(math.floor(float(a_totals[n][:2])))
        n_minutes += int(math.floor(float(a_totals[n][3:5])))
    if n_minutes >= 60:
        n_hours += int(math.floor(n_minutes / 60))
        n_minutes %= 60

    if n_hours < 10:
        s_hours = "0" + str(n_hours)
    else:
        s_hours = str(n_hours)
    if n_minutes < 10:
        s_minutes = "0" + str(n_minutes)
    else:
        s_minutes = str(n_minutes)

    return s_hours + ":" + s_minutes

window = vim.current.window
b = vim.current.buffer
cl, cc = window.cursor

rows_to_sum = []
for l in range(cl - 1, 0, -1):
    if len(b[l]) > 0:
        if b[l][0:4] == "#":
            # header = b[l - 1]
            break
        else:
            rows_to_sum.append(b[l])
<commit_msg>Fixed timetracker bug<commit_after>function! Tt_block()
python <<EOF

import math
import re
import vim

def get_tab():
    # 4 spaces
    return "    "

def get_totals(a_rows):
    a_totals = []
    for n in range(0, len(a_rows)):
        a_rows[n] = re.sub(r"\s+", "", a_rows[n])
        s_total = a_rows[n].split("->")[1]
        a_totals.append(s_total)
    return a_totals

def sum_totals(a_rows):
    a_totals = get_totals(a_rows)
    n_hours = 0
    n_minutes = 0
    for n in range(0, len(a_totals)):
        n_hours += int(math.floor((float(a_totals[n][:2]))))
        n_minutes += int(math.floor((float(a_totals[n][3:5]))))
    if n_minutes >= 60:
        n_hours += int(math.floor((n_minutes / 60)))
        n_minutes %= 60

    if n_hours < 10:
        s_hours = "0" + str(n_hours)
    else:
        s_hours = str(n_hours)

    if n_minutes < 10:
        s_minutes = "0" + str(n_minutes)
    else:
        s_minutes = str(n_minutes)
    return s_hours + ":" + s_minutes

window = vim.current.window
b = vim.current.buffer
cl, cc = window.cursor

rows_to_sum = []
for l in range(cl - 1, 0, -1):
    if len(b[l]) > 0:
        if b[l][0] == "=":
            # task = b[l]
            break
        else:
            rows_to_sum.append(b[l])

line = "=> " + sum_totals(rows_to_sum)

# Insert tab at beginning of line of there is none
tab = get_tab()
regex = re.compile("^" + tab)
if not re.match(regex, line):
    line = tab + line

b[cl - 1] = line

EOF
endfunction

function! Tt_h_one()
python <<EOF

"""
Prepend current line with header 1
"""
import vim
import re
vim.current.line = re.sub(r"^#*\s*", "", vim.current.line)
vim.current.line = "# " + vim.current.line

EOF
endfunction

function! Tt_h_two()
python <<EOF

"""
Prepend current line with header 2
"""
import vim
import re
vim.current.line = re.sub(r"^#*\s*", "", vim.current.line)
vim.current.line = "## " + vim.current.line

EOF
endfunction

function! Tt_row()
python <<EOF

from datetime import datetime
import re
import vim

def get_tab():
    # 4 spaces
    return "    "

def get_date_time(s_time):
    a_time = s_time.split(":")
    a_time[0] = int(a_time[0])
    a_time[1] = int(a_time[1])
    today = datetime.today()
    date_time = datetime(
        today.year, today.month, today.day, a_time[0], a_time[1]
    )
    return date_time

def time_elapsed(s):
    s = re.sub(r"\s+", "", s)
    a_time = s.split("-")
    t1 = get_date_time(a_time[0])
    t2 = get_date_time(a_time[1])
    d = t2 - t1

    n_hours = d.seconds / (60 * 60)
    n_minutes = (d.seconds % (60 * 60)) / 60

    if n_hours < 10:
        s_hours = "0" + str(n_hours)
    else:
        s_hours = str(n_hours)

    if n_minutes < 10:
        s_minutes = "0" + str(n_minutes)
    else:
        s_minutes = str(n_minutes)

    return a_time[0] + " - " + a_time[1] + \
        " -> " + s_hours + ":" + s_minutes

window = vim.current.window
vim.current.line = get_tab() + time_elapsed(vim.current.line)
l, c = window.cursor
window.cursor = (l, 23)

EOF
endfunction

function! Tt_sum()
python <<EOF

import math
import re
import vim

def get_totals(a_rows):
    a_totals = []
    for n in range(0, len(a_rows)):
        a_rows[n] = re.sub(r"\s+", "", a_rows[n])
        a_total = a_rows[n].split("->")
        if len(a_total) > 1:
            a_totals.append(a_total[1])
    return a_totals

def sum_totals(s):
    a_totals = get_totals(s)
    n_hours = 0
    n_minutes = 0
    for n in range(0, len(a_totals)):
        n_hours += int(math.floor(float(a_totals[n][:2])))
        n_minutes += int(math.floor(float(a_totals[n][3:5])))
    if n_minutes >= 60:
        n_hours += int(math.floor(n_minutes / 60))
        n_minutes %= 60

    if n_hours < 10:
        s_hours = "0" + str(n_hours)
    else:
        s_hours = str(n_hours)
    if n_minutes < 10:
        s_minutes = "0" + str(n_minutes)
    else:
        s_minutes = str(n_minutes)

    return s_hours + ":" + s_minutes

window = vim.current.window
b = vim.current.buffer
cl, cc = window.cursor

rows_to_sum = []
for l in range(cl - 1, 0, -1):
    if len(b[l]) > 0:
        if b[l][0:2] == "# ":
            # header = b[l - 1]
            break
        else:
            rows_to_sum.append(b[l])

{'fraction_non_alphanumeric': 0.15560586202788038, 'fraction_numerical': 0.02144644346479209, 'mean_word_length': 2.4975, 'pattern_counts': {'":': 12, '<': 35, '<?xml version=': 0, '>': 21, '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': '3588349', 'n_tokens_mistral': 3587, 'n_tokens_neox': 3348, 'n_words': 740}