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.2.1.tar.gz
(33.4 kB
view details)
Built Distribution
orgparse-0.2.1-py3-none-any.whl
(31.9 kB
view details)
File details
Details for the file orgparse-0.2.1.tar.gz
.
File metadata
- Download URL: orgparse-0.2.1.tar.gz
- Upload date:
- Size: 33.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f510f76340f565b5047510226716837caecb3bb6bd7359ef9c054279e12d5e05 |
|
MD5 | 632d2d37334afcd2f7dd493c600d62b7 |
|
BLAKE2b-256 | b84941f347918f8a61ca15eab4891336cc1371b0b7f5011e5ec5ba79c3eb06e8 |
File details
Details for the file orgparse-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: orgparse-0.2.1-py3-none-any.whl
- Upload date:
- Size: 31.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dda28db7b90a2573040a62f767c5eb5c0a003003f5b1b78a033e5b6e57aad6b6 |
|
MD5 | 72ec849b7d7f5201cef0fbb3542895e9 |
|
BLAKE2b-256 | b2aad70a591b957454f12b136c5a28000fca8e21d5a9292d1683619698c5590f |