Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finished headings are not recognized when no prior state was assigned #61

Open
novoid opened this issue Nov 11, 2021 · 0 comments
Open
Assignees
Labels
bug priohigh quickfix small change necessary to fix this

Comments

@novoid
Copy link
Owner

novoid commented Nov 11, 2021

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:

******* 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:

  1. the double quotes around the target status as well as
  2. the double quotes the previous status are optional
  3. improvement: do not make the time-stamp optional (* vs. +)
  4. generate test data with and without double quotes for:
  • no status -> DONE
  • no status -> STARTED -> DONE
  1. test it well.
@novoid novoid added bug quickfix small change necessary to fix this priohigh labels Nov 11, 2021
@novoid novoid self-assigned this Nov 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug priohigh quickfix small change necessary to fix this
Projects
None yet
Development

No branches or pull requests

1 participant