59 lines
1.6 KiB
Python
Raw Normal View History

2024-12-15 15:02:08 -06:00
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2024 Jacob Babor <jacob@babor.tech>
#
# Distributed under terms of the MIT license.
from csv import DictReader
2024-12-15 15:11:11 -06:00
import datetime
2024-12-15 15:02:08 -06:00
import glob
import json
import os
2024-12-15 15:02:08 -06:00
import re
import subprocess
2024-12-15 15:02:08 -06:00
import textwrap
import time
2024-12-15 15:02:08 -06:00
2024-12-15 15:11:11 -06:00
# Config globals
2024-12-15 15:02:08 -06:00
rate = float(41.00)
timesheet = {}
2024-12-15 15:11:11 -06:00
# First, acquire a CSV to look at
2024-12-15 15:02:08 -06:00
csv = glob.glob('*.csv')
if not csv:
print('No csv found!')
quit()
2024-12-15 15:11:11 -06:00
# Then, open that CSV and collect its data, storing it in timesheet
2024-12-15 15:02:08 -06:00
with open(csv[0], 'r') as csv:
items = DictReader(csv)
for row in items:
issue = row["Issue Key"]
2024-12-15 15:11:11 -06:00
date = datetime.datetime.strptime(row["Work date"], '%Y-%m-%d %H:%M').strftime('%Y-%m-%d')
2024-12-15 15:02:08 -06:00
hours = float(row["Hours"])
if not date in timesheet.keys():
timesheet[date] = {}
if not issue in timesheet[date].keys():
timesheet[date][issue] = 0
timesheet[date][issue] += hours
2024-12-15 15:11:11 -06:00
2024-12-15 15:02:08 -06:00
for k,v in timesheet.items():
print(k)
2024-12-29 20:11:34 -06:00
subprocess.run(["ydotool", "type", f"{k} - Team Meetings\t0.25\t{rate}\t"])
subprocess.run(["ydotool", "type", "\n"])
for i in range(1,4):
subprocess.run(["ydotool", "type", f"{k} - RESERVED {i}\t0.00\t{rate}\t"])
subprocess.run(["ydotool", "type", "\n"])
2024-12-15 15:02:08 -06:00
for i,h in v.items():
print(f' { i } - { h }')
# Now actually do the work
subprocess.run(["ydotool", "type", f"{k} - {i}\t{round(h,2)}\t{rate}\t"])
time.sleep(0.10)
subprocess.run(["ydotool", "type", "\n"])
time.sleep(0.10)