Giter VIP home page Giter VIP logo

Comments (5)

buhtz avatar buhtz commented on May 29, 2024 1

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.

maikol-solis avatar maikol-solis commented on May 29, 2024

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.

karlicoss avatar karlicoss commented on May 29, 2024

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.

buhtz avatar buhtz commented on May 29, 2024

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">&lt;2011-05-05 Do&gt;</span></span>

from orgparse.

yantar92 avatar yantar92 commented on May 29, 2024

<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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.