******* DONE no prior state
CLOSED: [2021-11-11 Thu 10:59]
:PROPERTIES:
:CREATED: [2021-11-11 Thu 10:59]
:END:
:LOGBOOK:
- State "DONE" from [2021-11-11 Thu 10:59]
:END:
The issue is related to the missing double quotes similar to:
******* DONE with prior state
CLOSED: [2021-10-11 Mon 14:24] SCHEDULED: <2021-10-08 Fri>
:PROPERTIES:
:CREATED: [2021-10-05 Tue 13:07]
:END:
:LOGBOOK:
- State "DONE" from "STARTED" [2021-10-11 Mon 14:24]
- State "STARTED" from "WAITING" [2021-10-07 Thu 17:46]
- State "WAITING" from "NEXT" [2021-10-05 Tue 14:16]
:END:
Analysis
>>> import re
>>> LOG_REGEX = re.compile(r'^- State\s+DONE\s+from\s+("\S*"\s+)?([\[{].*[\]}])$',re.IGNORECASE)
>>> LOG_REGEX.match('- State "DONE" from "" [2021-11-11 Thu 10:59]')
>>> LOG_REGEX.match('- State "DONE" from "STARTED" [2021-10-11 Mon 14:24]')
>>> LOG_REGEX.match('- State "DONE" from [2021-11-11 Thu 10:59]')
>>>
And:
>>> LOG_REGEX.match('- State DONE from [2021-11-11 Thu 10:59]')
<re.Match object; span=(0, 50), match='- State DONE from [2021-11-11 Thu 10:59>
>>> LOG_REGEX.match('- State DONE from "STARTED" [2021-10-11 Mon 14:24]')
<re.Match object; span=(0, 59), match='- State DONE from "STARTED" [2021-10-11 >
Proposed Solution
Modify the regex so that:
the double quotes around the target status as well as
the double quotes the previous status are optional
improvement: do not make the time-stamp optional (* vs. +)
generate test data with and without double quotes for:
The regex
LOG_REGEX
in https://github.com/novoid/lazyblorg/blob/master/lib/orgparser.py does not recognize the following snippet as a closed heading:The issue is related to the missing double quotes similar to:
Analysis
Proposed Solution
Modify the regex so that: