Skip to content

Commit 05f85cf

Browse files
Merge pull request #60 from dvklopfenstein/dev
Documentation; minor speed; simplify stop defaults
2 parents 62c2b34 + 395e6be commit 05f85cf

File tree

10 files changed

+70
-41
lines changed

10 files changed

+70
-41
lines changed

.github/workflows/pylint.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
# pylint
2+
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/controlling-permissions-for-github_token
23
name: Pylint
34

45
on: [push]
56

67
jobs:
78
build:
89
runs-on: ubuntu-latest
10+
#permissions:
11+
# actions: none
12+
# attestations: none
13+
# checks: none
14+
#contents: read
15+
# deployments: none
16+
# id-token: write|none
17+
# issues: none
18+
# models: read|none
19+
# discussions: none
20+
#packages: read
21+
# pages: none
22+
# pull-requests: read
23+
# security-events: none
24+
# statuses: none
925
strategy:
1026
matrix:
1127
python-version: ["3.9", "3.10", "3.11", "3.12"]

.github/workflows/pytest.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@ on: [push, workflow_dispatch]
77
jobs:
88
build:
99
runs-on: ubuntu-latest
10+
#permissions:
11+
# actions: none
12+
# attestations: none
13+
# checks: none
14+
#contents: read
15+
# contents: read|write
16+
# deployments: none
17+
# id-token: write|none
18+
# issues: none
19+
# models: read|none
20+
# discussions: none
21+
#packages: read
22+
# pages: none
23+
# pull-requests: read
24+
# security-events: none
25+
# statuses: none
1026
strategy:
1127
matrix:
1228
python-version: ["3.9", "3.10", "3.11", "3.12"]

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# Summary
44
* [**Unreleased**](#unreleased)
5+
* [**Release 2025-06-28 v0.8a0**](#release-2025-06-28-v08a0) Documentation; minor speed; simplify stop defaults
56
* [**Release 2025-06-21 v0.7a0**](#release-2025-06-21-v07a0) Much added functionality for invoicing
67
* [**Release 2025-05-27 v0.6a0**](#release-2025-05-27-v06a0) Added functions to collect various groups of csv files
78
* [**Release 2025-05-18 v0.5a7**](#release-2025-05-18-v05a7) Add starttime to `report`; Bug fix in `cancel`
@@ -32,6 +33,10 @@
3233

3334
## Unreleased
3435

36+
## Release 2025-06-28 v0.8a0
37+
* CHANGED Starttime object for minor import speed improvement
38+
* `trk stop -m msg` message be specified
39+
3540
## Release 2025-06-21 v0.7a0
3641
* ADDED command, `trk invoice`
3742
* ADDED command option, `-b` or `--billable` to `trk stop`
@@ -40,6 +45,7 @@
4045
will be printed in the invoice
4146
* ADDED `trk stop -b` or `trk stop --billable` to add 'Billable' tag with minimum typing
4247
* ADDED `--no-git-add` and `-A` options to the `trk init` command
48+
* CHANGED speed to 100x faster for parsing free text into datetime objects
4349
* CHANGED "Run `trk init`" message so it is clearer that no trk command
4450
will be run until the project is initialized
4551
* CHANGED imports to improve speed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
<img src="https://zenodo.org/badge/DOI/10.5281/zenodo.14803225.svg" alt="DOI"> |
77
<img src="https://img.shields.io/github/license/dvklopfenstein/timetracker" alt="License">
88
</h3>
9+
<pre align="center" style="font-family: monospace; font-size: larger; border: 1px solid #ccc; padding: 10px; display: inline-block;">
10+
┌────────────────────────────┐
11+
│ 🕒 Timetracker CLI Tool │
12+
│ Track time → CSV → pandas │
13+
└────────────────────────────┘
14+
</pre>
915
</p>
1016

1117
---

makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
MAKEFLAGS := --no-print-directory
2+
23
PYTHON := python3
34
CSV := /home/dvklo/timetrackers/timetracker_trk_dvklo.csv
45

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
77
[project]
88
name = "timetracker-csv"
99
description = "Pandas-friendly time tracking from the CLI"
10-
version = "0.7a0"
10+
version = "0.8a0"
1111
license = "AGPL-3.0-or-later"
1212
authors = [
1313
{name = 'DV Klopfenstein, PhD', email = 'dvklopfenstein@protonmail.com'},

tests/test_dateparser.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ def test_dateparser():
2323
print(f'{base}: RELATIVE_BASE Wed Jan 1, 2025')
2424
print(f'{date}: "{timestr}"')
2525

26-
# UNCOMMENT WHEN FIX IS RELEASED:
26+
# UNCOMMENT WHEN dateparser FIX IS RELEASED:
2727
# https://github.com/scrapinghub/dateparser/pull/1274
28-
##assert date == datetime(2024, 12, 29, 9), (
29-
## f'GitHub issue https://github.com/scrapinghub/dateparser/issues/1266\n'
30-
## f'{CALSTR}\n'
31-
## 'If today is Wed, Jan 1, 2025;\n'
32-
## f'then "{timestr}" is Sun, Dec 29, 2024\n\n'
33-
## f'EXP: "2024-12-29 09:00:00"\n'
34-
## f'ACT: "{date}"'
35-
## )
36-
37-
# THIS IS INCORRECT, BUT THAT IS WHAT COMES OUT
38-
assert date == datetime(2024, 1, 29, 9)
28+
assert date == datetime(2024, 12, 29, 9), (
29+
f'GitHub issue https://github.com/scrapinghub/dateparser/issues/1266\n'
30+
f'{CALSTR}\n'
31+
'If today is Wed, Jan 1, 2025;\n'
32+
f'then "{timestr}" is Sun, Dec 29, 2024\n\n'
33+
f'EXP: "2024-12-29 09:00:00"\n'
34+
f'ACT: "{date}"'
35+
)
36+
37+
# THIS IS INCORRECT, BUT THAT IS WHAT COMES OUT WITH OLD dateparser
38+
#assert date == datetime(2024, 1, 29, 9)
3939

4040

4141
if __name__ == '__main__':

timetracker/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
__copyright__ = 'Copyright (C) 2025-present, DV Klopfenstein, PhD. All rights reserved'
44
__author__ = 'DV Klopfenstein, PhD'
5-
__version__ = '0.7a0'
5+
__version__ = '0.8a0'
66

77
# Copyright (C) 2025-present, DV Klopfenstein, PhD. All rights reserved

timetracker/cli.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#print(f'{timedelta(seconds=default_timer()-tic)} TOP OF CLI: IMPORT dt') # PRT
1010

1111
from sys import argv as sys_argv
12-
#from sys import exit as sys_exit
1312
from os import getcwd
1413
#from os.path import exists
1514
#from logging import debug
@@ -27,8 +26,6 @@
2726
#print(f'{timedelta(seconds=default_timer()-tic)} TOP OF CLI: AFTER CfgFinder') # PRT
2827
#from timetracker.cmd.none import cli_run_none
2928
#print(f'{timedelta(seconds=default_timer()-tic)} TOP OF CLI: AFTER cli_run_none') # PRT
30-
from timetracker.proc import get_log1
31-
#print(f'{timedelta(seconds=default_timer()-tic)} TOP OF CLI: AFTER get_log1') # PRT
3229

3330
#print(f'{timedelta(seconds=default_timer()-tic)} TOP OF CLI: AFTER IMPORTS') # PRT
3431

@@ -105,9 +102,6 @@ def _init_args(self, arglist):
105102
from sys import exit as sys_exit
106103
print(f'trk {__version__}')
107104
sys_exit(0)
108-
if args.command == 'stop':
109-
if args.message == 'd':
110-
args.message = get_log1()
111105
return args
112106

113107
def _init_trksubdir(self):
@@ -122,7 +116,7 @@ def _init_trksubdir(self):
122116

123117
@staticmethod
124118
def _get_cmds():
125-
"""In ArgumentParser, usage=f'%(prog)s [-h] {self._get_cmds()}'"""
119+
"""In argumentparser, usage=f'%(prog)s [-h] {self._get_cmds()}'"""
126120
# parser.add_subparsers(dest='command', metavar=self._get_cmds(), help=SUPPRESS)
127121
cmds = ','.join(k for k in FNCS if k != 'invoice')
128122
return f'{{{cmds}}}'
@@ -203,19 +197,11 @@ def _add_subparser_start(subparsers):
203197
'elapsed time(ex: 10min, -10min, 4hr)')
204198
return parser
205199

206-
def _get_last_log(self):
207-
if self.finder.dirgit:
208-
rsp = get_log1()
209-
if rsp.stdout != '':
210-
return f'({rsp.stdout}); invoked w/`-m d`'
211-
return None
212-
213200
def _add_subparser_stop(self, subparsers):
214201
parser = subparsers.add_parser(name='stop',
215202
help='Stop timetracking',
216203
formatter_class=ArgumentDefaultsHelpFormatter)
217204
parser.add_argument('-m', '--message', required=True, metavar='TXT',
218-
default=self._get_last_log(),
219205
help='Message describing the work done in the time unit')
220206
parser.add_argument('-k', '--keepstart', action='store_true', default=False,
221207
#help='Resetting the timer is the normal behavior; Keep the start time this time')

timetracker/starttime.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
__copyright__ = 'Copyright (C) 2025-present, DV Klopfenstein, PhD. All rights reserved.'
44
__author__ = "DV Klopfenstein, PhD"
55

6-
from os import remove
6+
import os
77
import os.path as op
8-
from os.path import exists
98
import datetime
10-
119
from timetracker import consts
12-
from timetracker.cfg.utils import get_username
10+
1311

1412
# 2025-01-21 17:09:47.035936
1513

@@ -18,15 +16,15 @@ class Starttime:
1816

1917
min_trigger = datetime.timedelta(hours=10)
2018

21-
def __init__(self, dircfg, project=None, name=None):
19+
def __init__(self, dircfg, project, name):
2220
self.dircfg = op.abspath(consts.DIRTRK) if dircfg is None else op.normpath(dircfg)
23-
self.project = op.basename(op.dirname(self.dircfg)) if project is None else project
24-
self.name = get_username(name) if name is None else name
25-
self.filename = op.join(self.dircfg, f'start_{self.project}_{self.name}.txt')
21+
self.project = project
22+
self.name = name
23+
self.filename = op.join(self.dircfg, f'start_{project}_{name}.txt')
2624

2725
def started(self):
2826
"""Return True if the timer is starte, False if not"""
29-
return exists(self.filename)
27+
return op.exists(self.filename)
3028

3129
def wr_starttime(self, starttime, activity=None, tags=None):
3230
"""Write the start time into a ./timetracker/start_*.txt"""
@@ -44,14 +42,14 @@ def wr_starttime(self, starttime, activity=None, tags=None):
4442
def get_desc(self, note=' set'):
4543
"""Get a string describing the state of an instance of the CfgProj"""
4644
return (
47-
f'CfgProj {note} {int(exists(self.filename))} '
45+
f'CfgProj {note} {int(op.exists(self.filename))} '
4846
f'fname start {self.filename}')
4947

5048
def rm_starttime(self):
5149
"""Remove the starttime file, thus resetting the timer"""
5250
fstart = self.filename
53-
if exists(fstart):
54-
remove(fstart)
51+
if op.exists(fstart):
52+
os.remove(fstart)
5553

5654
def read_starttime(self):
5755
"""Read the starttime"""

0 commit comments

Comments
 (0)