Go to file
Sergio Martínez Portela 55fc87cfdc
All checks were successful
Testing / pytest (push) Successful in 20s
Testing / mypy (push) Successful in 29s
Testing / style-formatting (push) Successful in 19s
Testing / style-sorted-imports (push) Successful in 16s
Testing / stability-extra-test (push) Successful in 22s
Add absence of dependencies as principle.
2025-04-16 01:00:09 +02:00
.gitea/workflows fix(gitea): Fix build with newer images. 2025-02-09 14:13:28 +01:00
extra-tests Rename to org-rw. 2020-12-20 13:03:51 +01:00
org_rw format: Automatic formatting fixes. 2025-02-09 16:50:52 +01:00
scripts feat: Add script to apply formatting tools. 2024-08-18 22:49:06 +02:00
tests Simplify state setting, update .is_todo/.is_done props. 2024-10-07 23:23:15 +02:00
.gitignore Prepare for PyPI pushising, bumb version. 2024-07-19 20:01:27 +02:00
.gitmodules Add testing Organice's testing files. 2020-12-10 00:22:22 +01:00
README.org Add absence of dependencies as principle. 2025-04-16 01:00:09 +02:00
setup.py Prepare for PyPI pushising, bumb version. 2024-07-19 20:01:27 +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, …).

Principles

  • Avoid any dependency outside of Python's standard library.
  • Don't do anything outside of the scope of parsing/re-serializing Org-mode files.
  • Modification of the original text if there's no change is considered a bug (see Known issues).
  • Data structures should be exposed as it's read on Emacs's org-mode or when in doubt as raw as possible.
  • Data in the objects should be modificable as a way to update the document itself. Consider this a Object-oriented design.

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.