Comments (5)
Dear Maikol,
I am not the maintainer of orgparse but of Hyperorg. For the upcoming release Hyperorg will catch orgparse-related exceptions and won't stop the whole parsing process (Fixed #120 not yet released). But the one node won't get parsed and is lost.
I'd expect orgparse either to parse the date somehow, or provide context where the error happens. This is probably as easy as augmenting the
ValueError
with location info.
From my perspective as maintainer of Hyperorg I see no problem with orgparse raise an exception. orgparse is a parser and not more. I prefer orgparse being more strict about this. Also the error is quite clear described.
I see no need for a fix on the site of orgparse. Applications on higher level using packages like orgparse are responsible for handling such exceptions.
from orgparse.
I'm using hyperorg and I having a similar issue. The problem is that I don't where to look at to fix it.
$ hyperorg -v roam roam_html
INFO : Input from: roam
Traceback (most recent call last):
File "/Users/maikol/.local/bin/hyperorg", line 10, in <module>
sys.exit(main())
^^^^^^
File "/Users/maikol/Library/Application Support/pipx/venvs/hyperorg/lib/python3.12/site-packages/hyperorg/__main__.py", line 136, in main
node_count = reader.read_org_files()
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/maikol/Library/Application Support/pipx/venvs/hyperorg/lib/python3.12/site-packages/hyperorg/reader.py", line 105, in read_org_files
orgparse_nodes_list = self._orgparse_obj_from_input_dir()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/maikol/Library/Application Support/pipx/venvs/hyperorg/lib/python3.12/site-packages/hyperorg/reader.py", line 63, in _orgparse_obj_from_input_dir
result.append(orgparse.load(fp))
^^^^^^^^^^^^^^^^^
File "/Users/maikol/Library/Application Support/pipx/venvs/hyperorg/lib/python3.12/site-packages/orgparse/__init__.py", line 138, in load
return load(orgfile, env)
^^^^^^^^^^^^^^^^^^
File "/Users/maikol/Library/Application Support/pipx/venvs/hyperorg/lib/python3.12/site-packages/orgparse/__init__.py", line 146, in load
return loadi(all_lines, filename=filename, env=env)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/maikol/Library/Application Support/pipx/venvs/hyperorg/lib/python3.12/site-packages/orgparse/__init__.py", line 166, in loadi
return parse_lines(lines, filename=filename, env=env)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/maikol/Library/Application Support/pipx/venvs/hyperorg/lib/python3.12/site-packages/orgparse/node.py", line 1457, in parse_lines
node._parse_pre()
File "/Users/maikol/Library/Application Support/pipx/venvs/hyperorg/lib/python3.12/site-packages/orgparse/node.py", line 1144, in _parse_pre
self._body_lines = list(ilines)
^^^^^^^^^^^^
File "/Users/maikol/Library/Application Support/pipx/venvs/hyperorg/lib/python3.12/site-packages/orgparse/node.py", line 1193, in _iparse_timestamps
self._timestamps.extend(OrgDate.list_from_str(self._heading))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/maikol/Library/Application Support/pipx/venvs/hyperorg/lib/python3.12/site-packages/orgparse/date.py", line 471, in list_from_str
odate = cls(
^^^^
File "/Users/maikol/Library/Application Support/pipx/venvs/hyperorg/lib/python3.12/site-packages/orgparse/date.py", line 227, in __init__
self._start = self._to_date(start)
^^^^^^^^^^^^^^^^^^^^
File "/Users/maikol/Library/Application Support/pipx/venvs/hyperorg/lib/python3.12/site-packages/orgparse/date.py", line 238, in _to_date
return datetime.date(*date)
^^^^^^^^^^^^^^^^^^^^
ValueError: month must be in 1..12
from orgparse.
Yeah not sure what "somehow" would mean if the date is wrong, but agree the exception could be more descriptive and include the location information.
Another option is to have multiple "error policies", by default it would be strict and throw exceptions, but with a more defensive policy the user could specify, it could ignore the node or offending org block completely
from orgparse.
i would recommend to ask at emacs-orgmode mailing list for an advice.
I tested org-html-export-as-html
:
<2011-04-35 Sat>
becomes
<span class="timestamp-wrapper"><span class="timestamp"><2011-05-05 Do></span></span>
from orgparse.
<2011-04-35 Sat>
From Org mode syntax perspective, there is no requirement that timestsamp date represents a valid date.
Another question is how to interpret date/time that does not look like normal date.
As an implementation detail, Org mode uses Emacs time API, which uses POSIX mktime
.
As you can see in https://www.gnu.org/software/libc/manual/html_node/Broken_002ddown-Time.html, mktime
allows the year/month/day to be outside ranges - they will be normalized.
The same goes for time component. Something like <2011-04-01 26:00>
is a time at 2am on 2011-04-02. Note that this last representation is actually used in the wild.
from orgparse.
Related Issues (20)
- 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
- Extracting line numbers from org nodes? HOT 1
- How to access comments and properties in clocks (Loogbook entry)
- __version__ missing
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.