karlicoss / orgparse

Python module for reading Emacs org-mode files
https://orgparse.readthedocs.org
BSD 2-Clause "Simplified" License
371 stars 43 forks source link

Invalid syntax when trying to use the library #31

Closed hbalp closed 3 years ago

hbalp commented 3 years ago

I just installed your library as documented using 'pip install orgparser' and then tried to import 'load' and 'loads' from orgparser in a python shell. It fails with the following syntax error message:

In [3]: from orgparse import load, loads
Traceback (most recent call last):

File "/usr/local/lib/python3.5/dist-packages/IPython/core/interactiveshell.py", line 3296, in run_code exec(code_obj, self.user_global_ns, self.user_ns)

File "", line 1, in from orgparse import load, loads

File "/usr/local/lib/python3.5/dist-packages/orgparse/init.py", line 112, in from .node import parse_lines, OrgNode # todo basenode??

File "/usr/local/lib/python3.5/dist-packages/orgparse/node.py", line 16 chunk: List[str] = [] ^ SyntaxError: invalid syntax

karlicoss commented 3 years ago

Hi! Right, so the reason is that you're using python3.5, and I've recently had to drop support for python < 3.6. (just updated release notes for that, so thanks for spotting! https://github.com/karlicoss/orgparse/releases/tag/v0.2.0)

If you can't/don't want to update your python version now, you can use pip install --force-reinstall 'orgparse=0.1.4' to install the previous version which should work with python3.5. Let me know if that helps!

hbalp commented 3 years ago

Many thanks ! I decided to upgrade my python version to 3.9.0 and it works well now. I would also been interested in a capacity to serialize back the org nodes into an org file, as you experiment with inorganic.

karlicoss commented 3 years ago

Glad it worked! If guess you want to load something with orgparse, modify and then serialize back? It's not directly supported, at least yet, but:

hbalp commented 3 years ago

Yes, I see. It can help for the moment... And why not merging orgparse with orger ?

karlicoss commented 3 years ago

And why not merging orgparse with orger

Mainly because they are serve pretty different purposes at the moment, so better keep it separate for simplicity. The kind of org-mode rendering orger is doing is very specific (i.e. list hierarchies), and to justify integration with orgparse it would need to be more general purpose so both libraries could somehow benefit from it