orgparse - Emacs org-mode parser in Python
Project description
Install
pip install orgparse
Usage
There are pretty extensive doctests if you’re interested in some specific method. Otherwise here are some example snippets:
Load org node
from orgparse import load, loads load('PATH/TO/FILE.org') load(file_like_object) loads(''' * This is org-mode contents You can load org object from string. ** Second header ''')
Traverse org tree
>>> root = loads(''' ... * Heading 1 ... ** Heading 2 ... *** Heading 3 ... ''') >>> for node in root[1:]: # [1:] for skipping root itself ... print(node) * Heading 1 ** Heading 2 *** Heading 3 >>> h1 = root.children[0] >>> h2 = h1.children[0] >>> h3 = h2.children[0] >>> print(h1) * Heading 1 >>> print(h2) ** Heading 2 >>> print(h3) *** Heading 3 >>> print(h2.get_parent()) * Heading 1 >>> print(h3.get_parent(max_level=1)) * Heading 1
Accessing node attributes
>>> root = loads(''' ... * DONE Heading :TAG: ... CLOSED: [2012-02-26 Sun 21:15] SCHEDULED: <2012-02-26 Sun> ... CLOCK: [2012-02-26 Sun 21:10]--[2012-02-26 Sun 21:15] => 0:05 ... :PROPERTIES: ... :Effort: 1:00 ... :OtherProperty: some text ... :END: ... Body texts... ... ''') >>> node = root.children[0] >>> node.heading 'Heading' >>> node.scheduled OrgDateScheduled((2012, 2, 26)) >>> node.closed OrgDateClosed((2012, 2, 26, 21, 15, 0)) >>> node.clock [OrgDateClock((2012, 2, 26, 21, 10, 0), (2012, 2, 26, 21, 15, 0))] >>> bool(node.deadline) # it is not specified False >>> node.tags == set(['TAG']) True >>> node.get_property('Effort') 60 >>> node.get_property('UndefinedProperty') # returns None >>> node.get_property('OtherProperty') 'some text' >>> node.body ' Body texts...'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
orgparse-0.3.0.tar.gz
(36.1 kB
view details)
Built Distribution
orgparse-0.3.0-py3-none-any.whl
(34.7 kB
view details)
File details
Details for the file orgparse-0.3.0.tar.gz
.
File metadata
- Download URL: orgparse-0.3.0.tar.gz
- Upload date:
- Size: 36.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e158d13253a98726fc20aa699d2b13b912d007491c3c7a812949d53cde253b92 |
|
MD5 | 616bb7c3e78e6e206d3fc5da3459a972 |
|
BLAKE2b-256 | 321c33d12b56dd8bc68c78c21139e54ff4475539cce3c19c5e2bb3eb10dda5d1 |
File details
Details for the file orgparse-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: orgparse-0.3.0-py3-none-any.whl
- Upload date:
- Size: 34.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fa616c6f4486a735ebee612c90c8bc34fcbd3dee9121daf2578706d11d53727 |
|
MD5 | 5ce619f45f1ceaff48a9d8d83162da76 |
|
BLAKE2b-256 | 59549726b51e15bac26e0be91de3d9114e1cc760b4ea932d7403687ee145be39 |