Go to file
Lyz c5cc14f65c
feat(Timestamp): add the from_datetime method
To update the current Timestamp instance based on a datetime or date object.

I've also included a set_datetime method to OrgTime

feat: add activate and deactivate methods to TimeRange and OrgTime

I need it in a program I'm making
refactor: Create the Time type hint

I had to move the parse_time and parse_org_time_range below OrgTime
because it used the Time type hint and the Time type hint needed the
other two

style: reformat the code following black

style: Add some type hints and docstrings

style: remove unused imports

tests: Correct some mypy errors
2024-07-19 21:36:00 +02:00
.gitea/workflows Complete typing with mypy --check-untyped-defs. 2023-10-16 00:21:30 +02:00
extra-tests Rename to org-rw. 2020-12-20 13:03:51 +01:00
org_rw feat(Timestamp): add the from_datetime method 2024-07-19 21:36:00 +02:00
scripts Upload version to PyPI. 2021-08-03 23:04:36 +02:00
tests feat(Timestamp): add the from_datetime method 2024-07-19 21:36:00 +02:00
.gitignore Close PROPERTY drawers when there's no empty lines between headlines. 2021-08-14 17:40:08 +02:00
.gitmodules Add testing Organice's testing files. 2020-12-10 00:22:22 +01:00
README.org Move readme to root directory. 2021-02-08 00:00:37 +01:00
requirements.txt Initial commit, simplistic parsing. 2020-06-21 22:48:47 +02:00
setup.py Upload version to PyPI. 2021-08-03 23:04:36 +02:00
tox.ini Rename to org-rw. 2020-12-20 13:03:51 +01:00

Org-rw

A python library to parse, modify and save Org-mode files.

Goals

  • Reading org-mode files, with all the relevant information (format, dates, lists, links, metadata, …).
  • Modify these data and write it back to disk.
  • Keep the original structure intact (indentation, spaces, format, …).

Safety mechanism

As this library is still in early development. Running it over files might produce unexpected changes on them. For this reason it's heavily recommended to have backup copies before using it on important files.

By default the library checks that the re-serialization of the loaded files will not produce any change, and throw an error in case it does. But this cannot guarantee that later changes to the document will not corrupt the output so be careful.

Also, see Known issues:Structure modifications for cases when the structure is not properly stored and can trigger this safety mechanism on a false-positive.

Known issues

Structure modifications

  • The exact format is not retained when saving dates/times. This might cause problems with the safety mechanism if you have dates that. Note that in both cases, doing C-c C-c on the date (from Emacs) will change it to the format that Org-rw serializes it to.

    • Use multiple dashes for hour ranges, like <2020-12-01 10:00----11:00>. It will get re-serialized as <2020-12-01 10:00-11:00>, thus triggering the safety mechanism as unexpected changes have happened.
    • Same in case hours are not two digits (with leading 0's if needed), like <2020-12-01 9:00>. It will get serialized as <2020-12-01 9:00>.

Other python libraries for org-mode

orgparse
More mature, but does not provide format support or writing back to disk.