-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Non-existant date errors without context #62
Comments
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 |
Dear Maikol,
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. |
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. |
i would recommend to ask at emacs-orgmode mailing list for an advice. I tested
becomes
|
From Org mode syntax perspective, there is no requirement that timestsamp date represents a valid date. As an implementation detail, Org mode uses Emacs time API, which uses POSIX The same goes for time component. Something like |
2011-04-31
is not a valid date, april only has 30 days.testcase:
leads to:
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.The text was updated successfully, but these errors were encountered: