Comments (3)
Hi! Not familiar with this bit of API (I'm not the one who implemented it), but I did a quick check.
Looks like it supports per-file todo keywords.
import orgparse
data = """#+TODO: TODO WAITING | DONE CANCELED
* WAITING do it later...
"""
od = orgparse.loads(data).root.children[0]
>>> od.todo
'WAITING'
>>> od.heading
'do it later...'
However, you probably have these set in your emacs config and don't want to specify in each file.
Looks like it's indeed hidden in the OrgEnv
class and the user has no control about it. I guess need to figure out what was the intended way of using this class.. Looks like it should be an env
keyword argument that's passed all the way up from loads/load/loadi
functions and defaults to OrgEnv()
.
But, in the meantime: there is a hacky, but working way to solve it, so you don't have to wait for the fix. You can override parse_lines
function:
import orgparse
def parse_lines_patched(lines, filename):
from orgparse.node import OrgEnv, lines_to_chunks # added this line!
env = OrgEnv(filename=filename)
env.add_todo_keys(['TODO', 'WAITING'], ['DONE', 'CANCELED']) # added this line!
# parse into node of list (environment will be parsed)
nodelist = list(env.from_chunks(lines_to_chunks(lines)))
# parse headings (level, TODO, TAGs, and heading)
nodelist[0]._index = 0
for (i, node) in enumerate(nodelist[1:], 1): # nodes except root node
node._index = i
node._parse_pre()
env._nodes = nodelist
return nodelist[0] # root
orgparse.parse_lines = parse_lines_patched # overrid
After that it should work!
> orgparse.loads('* WAITING whatever').root.children[0].todo
'WAITING'
Let me know if it helps!
from orgparse.
Awesome, your workaround does the trick. Thanks!
I'd try my hands at a PR for that, anything to look out for?
from orgparse.
@schlagenhauf glad I could help!
PR would be cool! It's all CI tested, so should be straightforward without fear to break anything. If you add also add tests for custom todo keywords and add_todo_keys
logic here, I'd be grateful :) You can run tests locally via tox, although running pytest directly should work too.
from orgparse.
Related Issues (20)
- Date repeat HOT 5
- Bug in OrgDate.has_overlap
- Date parsing with timezone information HOT 2
- speedup parsing
- Invalid syntax when trying to use the library HOT 5
- orgparse.load() is broken for file-like objects HOT 3
- support names on tables HOT 1
- Support more Effort format in Properties HOT 2
- Repeated_tasks and logbook parsing HOT 4
- Minor difference in date objects parsed
- Support properties in OrgRootNode HOT 2
- Question: Why is `_special_comments['TITLE']` a list? HOT 1
- parsing of multiline properties HOT 1
- QUESTION: Reason about using `codecs.open()` HOT 2
- Move `tests` outside the package folder HOT 4
- Offer `CONTRIBUTE.md` (was: Unittest not running) HOT 3
- Providing OrgEnv to load() with pathlib.Path errors HOT 1
- Logbook drawer tags are not removed from body text HOT 1
- Non-existant date errors without context HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from orgparse.