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

Repeated_tasks and logbook parsing #38

Closed
MorphicResonance opened this issue Jun 1, 2021 · 4 comments
Closed

Repeated_tasks and logbook parsing #38

MorphicResonance opened this issue Jun 1, 2021 · 4 comments

Comments

@MorphicResonance
Copy link

MorphicResonance commented Jun 1, 2021

It seems like orgparse get logbook drawer into the body.
If I set property drawer and logbook drawer it wiil get logbook drawer as body text.

Test this sample.

  • DONE header 1 :blog:@Flat:template:
    CLOSED: [2021-06-02 Wed 00:48]
    :PROPERTIES:
    :CREATED: [2021-05-25 Tue 00:33]
    :TEMPLATE: test
    :END:
    :LOGBOOK:
  • State "DONE" from "SOMEDAY" [2021-06-02 Wed 00:48]
  • State "SOMEDAY" from "WAITING" [2021-06-02 Wed 00:48]
  • State "WAITING" from "STARTED" [2021-06-02 Wed 00:48]
    :END:
    Fish are aquatic, craniate, gill-bearing animals that lack limbs with digits.
    next sentence

** DONE subheader 1 :template:blog:
CLOSED: [2021-05-25 Tue 00:51]
:PROPERTIES:
:CREATED: [2021-05-25 Tue 00:33]
:TEMPLATE: test
:END:
:LOGBOOK:

  • State "DONE" from "CANCELLED" [2021-05-25 Tue 00:51]
  • State "CANCELLED" from [2021-05-25 Tue 00:51] \
    stopped
  • State "STARTED" from "WAITING" [2021-05-25 Tue 00:51]
  • State "WAITING" from "STARTED" [2021-05-25 Tue 00:37] \
    time
    :END:
    The earliest organisms that can be classified as fish were soft-bodied chordates that first appeared during the Cambrian period.

*** DONE subsubheader :article:
CLOSED: [2021-05-25 Tue 00:51]
:PROPERTIES:
:CREATED: [2021-05-25 Tue 00:33]
:TEMPLATE: test
:END:
:LOGBOOK:

  • State "DONE" from "CANCELLED" [2021-05-25 Tue 00:51]
  • State "CANCELLED" from [2021-05-25 Tue 00:51] \
    stopped
    :END:
    Most fish are ectothermic ("cold-blooded"), allowing their body temperatures to vary as ambient temperatures change, though some of the large active swimmers like white shark and tuna can hold a higher core temperature.

** subheader 2 :blog:
:PROPERTIES:
:CREATED: [2021-05-25 Tue 00:38]
:END:
Fish are an important resource for humans worldwide, especially as food.

then run node.body .
I breaks on double 🔚 and gets logbbok into the body.

@MorphicResonance MorphicResonance changed the title Process org-mode file with unknown structure Multiple drawers jumps into body text of the parsed node Jun 13, 2021
@karlicoss
Copy link
Owner

Hey, sorry for late reply. Haven't tried logbook parsing personally, but it's possible! Perhaps somewhat related issue: #8

A PR with a test that reproduces this will be welcome (even if it's failing at the moment, we can disable it for now and fix it later)

@MorphicResonance
Copy link
Author

Body can be extracted without drawers.
By the way, it seems like repeated_tasks does not work anymore. I've tried with example from the docs. Something wrong with regex.

@MorphicResonance MorphicResonance changed the title Multiple drawers jumps into body text of the parsed node Repeated_tasks and logbook parsing Nov 16, 2021
@karlicoss
Copy link
Owner

hey, I just checked the doctest from here

orgparse/orgparse/node.py

Lines 1398 to 1439 in 349a61f

"""
Get repeated tasks marked DONE in an entry having repeater.
:rtype: list of :class:`orgparse.date.OrgDateRepeatedTask`
>>> from orgparse import loads
>>> node = loads('''
... * TODO Pay the rent
... DEADLINE: <2005-10-01 Sat +1m>
... - State "DONE" from "TODO" [2005-09-01 Thu 16:10]
... - State "DONE" from "TODO" [2005-08-01 Mon 19:44]
... - State "DONE" from "TODO" [2005-07-01 Fri 17:27]
... ''').children[0]
>>> node.repeated_tasks # doctest: +NORMALIZE_WHITESPACE
[OrgDateRepeatedTask((2005, 9, 1, 16, 10, 0), 'TODO', 'DONE'),
OrgDateRepeatedTask((2005, 8, 1, 19, 44, 0), 'TODO', 'DONE'),
OrgDateRepeatedTask((2005, 7, 1, 17, 27, 0), 'TODO', 'DONE')]
>>> node.repeated_tasks[0].before
'TODO'
>>> node.repeated_tasks[0].after
'DONE'
Repeated tasks in ``:LOGBOOK:`` can be fetched by the same code.
>>> node = loads('''
... * TODO Pay the rent
... DEADLINE: <2005-10-01 Sat +1m>
... :LOGBOOK:
... - State "DONE" from "TODO" [2005-09-01 Thu 16:10]
... - State "DONE" from "TODO" [2005-08-01 Mon 19:44]
... - State "DONE" from "TODO" [2005-07-01 Fri 17:27]
... :END:
... ''').children[0]
>>> node.repeated_tasks # doctest: +NORMALIZE_WHITESPACE
[OrgDateRepeatedTask((2005, 9, 1, 16, 10, 0), 'TODO', 'DONE'),
OrgDateRepeatedTask((2005, 8, 1, 19, 44, 0), 'TODO', 'DONE'),
OrgDateRepeatedTask((2005, 7, 1, 17, 27, 0), 'TODO', 'DONE')]
See: `(info "(org) Repeated tasks")
<http://orgmode.org/manual/Repeated-tasks.html>`_
"""
and it does extract repeated tasks for me? Can you post a minimal example which doesn't work for you? Thanks :)

@MorphicResonance
Copy link
Author

It works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants