karlicoss / orgparse

Python module for reading Emacs org-mode files
https://orgparse.readthedocs.org
BSD 2-Clause "Simplified" License
371 stars 43 forks source link

Harmonize SDC date objects #41

Closed RomainGehrig closed 2 years ago

RomainGehrig commented 3 years ago

Nodes with only the heading returned OrgDate(None) for all SDC dates whereas nodes with multiple lines had the more precise object OrgDateScheduled(None)/... This PR harmonizes these cases by returning the more precise object in each case.

I also hardened the parsing tests by adding a type check (strict type equality between parsed and expected). The type check could be relaxed by checking that the parsed object is a subclass of the expected type.

With the PR, the example in #40 gives:

from orgparse import loads
r0 = loads("""* Heading 1
* Heading 2
  body""")

print([c.scheduled for c in r0.children])  # prints [OrgDateScheduled(None), OrgDateScheduled(None)]

Solves issue #40

karlicoss commented 2 years ago

thanks! and appreciate the test :) sorry it took me a while to get to this, will also do a pypi release soon!