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.4.tar.gz
(34.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
orgparse-0.2.4-py3-none-any.whl
(33.2 kB
view details)
File details
Details for the file orgparse-0.2.4.tar.gz.
File metadata
- Download URL: orgparse-0.2.4.tar.gz
- Upload date:
- Size: 34.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b6c3012cf459b0201d42f58dd02da96beeed0913f64080f150b2666655b4d74
|
|
| MD5 |
d2737d3fbd3c8f3808fd3db586eee72c
|
|
| BLAKE2b-256 |
6ff09ab5ef5f2f7fc51c177e14e107df8fe350bf8d3678c9d1896a26e40bb7bb
|
File details
Details for the file orgparse-0.2.4-py3-none-any.whl.
File metadata
- Download URL: orgparse-0.2.4-py3-none-any.whl
- Upload date:
- Size: 33.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f3ef34198b7adc0f392808742e65779285896dd3de1ffb0aa20b751b9fc6e60
|
|
| MD5 |
2644d2de68d9da701a2796735490dcb5
|
|
| BLAKE2b-256 |
aab6fb7a27d32b8589a78f2c9d0ab2ac02d5b53e96f47c4708fbc8fdc891bd7f
|