Closed maphew closed 3 months ago
My test script: patch-date-test.py.txt
Thanks for the big PR! 😊
I have some feedback regarding your changes:
Handling None
Values for Dates:
There could be cases where both dateCreated
and utcDateCreated
are None
. For instance, if I need to correct a typo in the title and only want to change the title
, I would use a command like this:
ea.patch_note(
noteId='some id',
title="new title"
)
The handle_dates
function should be updated to handle this scenario.
Function Location:
You can move the three functions to utils/time_util.py
as they are static methods.
Thanks for the feedback! I was so deep in my local problem I overlooked that date changing is only sometimes the goal. Hah. I'll get on both of these suggestions.
1) patching note without any date changes is allowed (0aff1cc)
2) I've move all the new date functions except handle_dates()
into _timeutil (cfa0670). I'm not that familiar with classes and static functions and utilities. This is my first time splitting code up like this so feel free to advise and critique.
It works great. I've just made a new release.
oh! I expected some more changes needed. Wonderful that wasn't needed =) commit 7d8611cddd6f1edc4f070e62bb6445cc3499cd82 removes the disabled code (won't change the release).
I don't mind commented code; I have a lot of commented code in my own work. I can merge the clean-up PR if you'd like.
it can wait until my next contribution (I know what that is yet. I just know that tri-py is useful enough to me that I'm building workflows around it, and will want something else changed too)
This patch is a bigger touch than the last one and I don't expect it to pass review without changes.
Patch_notes will now take the provided date, convert it to whichever of local or utc is missing, and set both properties on the target note. To use, call
ea.patch_notes()
using either ofdateCreated
orutcDateCreated
optional parameters but not both. If timezone info is missing from the datetime object Patch_notes will use the tz of the local machine.Example output for
res = ea.patch_note(noteId, utcDateCreated=mydate)
follows. Lines prefixed with---
are from my test script (so not emitted from trilium-py):The new functions are:
They could be collapsed into one function. I went back and forth a lot on that.
The pyproject.toml changes can be ignored/discarded. (After review I'll create a new branch with just the clean changes and a fresh PR.)
Known deficits:
I started this almost a full month ago and busted my brain several times sorting out a path that worked, and didn't reverse local/utc or some other logic error. I'm out of my comfort zone and will not be surprised at any mistakes pointed out!