Debian Codegraph @

README.rst

raw
1 ===========================================================
2 orgparse - Python module for reading Emacs org-mode files
3 ===========================================================
4
5
6 * `Documentation (Read the Docs) <https://orgparse.readthedocs.org>`_
7 * `Repository (at GitHub) <https://github.com/karlicoss/orgparse>`_
8 * `PyPI <https://pypi.python.org/pypi/orgparse>`_
9 * `conda-forge <https://anaconda.org/conda-forge/orgparse>`_
10
11 Install
12 -------
13
14 You can install ``orgpase`` via PyPI
15
16 .. code-block:: console
17
18 pip install orgparse
19
20 or via conda-forge
21
22 .. code-block:: console
23
24 conda install orgparse -c conda-forge
25
26
27 Usage
28 -----
29
30 There are pretty extensive doctests if you're interested in some specific method. Otherwise here are some example snippets:
31
32
33 Load org node
34 ^^^^^^^^^^^^^
35 ::
36
37 from orgparse import load, loads
38
39 load('PATH/TO/FILE.org')
40 load(file_like_object)
41
42 loads('''
43 * This is org-mode contents
44 You can load org object from string.
45 ** Second header
46 ''')
47
48
49 Traverse org tree
50 ^^^^^^^^^^^^^^^^^
51
52 >>> root = loads('''
53 ... * Heading 1
54 ... ** Heading 2
55 ... *** Heading 3
56 ... ''')
57 >>> for node in root[1:]: # [1:] for skipping root itself
58 ... print(node)
59 * Heading 1
60 ** Heading 2
61 *** Heading 3
62 >>> h1 = root.children[0]
63 >>> h2 = h1.children[0]
64 >>> h3 = h2.children[0]
65 >>> print(h1)
66 * Heading 1
67 >>> print(h2)
68 ** Heading 2
69 >>> print(h3)
70 *** Heading 3
71 >>> print(h2.get_parent())
72 * Heading 1
73 >>> print(h3.get_parent(max_level=1))
74 * Heading 1
75
76
77 Accessing node attributes
78 ^^^^^^^^^^^^^^^^^^^^^^^^^
79
80 >>> root = loads('''
81 ... * DONE Heading :TAG:
82 ... CLOSED: [2012-02-26 Sun 21:15] SCHEDULED: <2012-02-26 Sun>
83 ... CLOCK: [2012-02-26 Sun 21:10]--[2012-02-26 Sun 21:15] => 0:05
84 ... :PROPERTIES:
85 ... :Effort: 1:00
86 ... :OtherProperty: some text
87 ... :END:
88 ... Body texts...
89 ... ''')
90 >>> node = root.children[0]
91 >>> node.heading
92 'Heading'
93 >>> node.scheduled
94 OrgDateScheduled((2012, 2, 26))
95 >>> node.closed
96 OrgDateClosed((2012, 2, 26, 21, 15, 0))
97 >>> node.clock
98 [OrgDateClock((2012, 2, 26, 21, 10, 0), (2012, 2, 26, 21, 15, 0))]
99 >>> bool(node.deadline) # it is not specified
100 False
101 >>> node.tags == set(['TAG'])
102 True
103 >>> node.get_property('Effort')
104 60
105 >>> node.get_property('UndefinedProperty') # returns None
106 >>> node.get_property('OtherProperty')
107 'some text'
108 >>> node.body
109 ' Body texts...'
110
111
112 Project status
113 --------------
114
115 Project is maintained by @karlicoss (myself).
116
117 For my personal use, orgparse mostly has all features I need, so there hasn't been much active development lately.
118
119 However, contributions are always welcome! Please provide tests along with your contribution if you're fixing bugs or adding new functionality.