Code Monkey home page Code Monkey logo

Comments (3)

mixmastamyk avatar mixmastamyk commented on August 28, 2024 1

Also related, it does not support a list at the root of the document:

>>> parse_string('''
... - one
... - two
... - three
... ''')
Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
  File "/usr/local/lib/python3.5/dist-packages/poyo/parser.py", line 241, in parse_string
    return parser()
  File "/usr/local/lib/python3.5/dist-packages/poyo/parser.py", line 234, in __call__
    match = self.find_match()
  File "/usr/local/lib/python3.5/dist-packages/poyo/parser.py", line 224, in find_match
    ''.format(self.source[self.pos:])
poyo.exceptions.NoMatchException: None of the known patterns match for …

PyYaml:

>>> from yaml import safe_load
>>> safe_load('''
... - one
... - two
... - three
... ''')
['one', 'two', 'three']

from poyo.

hackebrot avatar hackebrot commented on August 28, 2024

Hi @timonwong, thank you for raising this issue! 🙇

I am currently very busy with working on pytest related things, so I'm not sure if or when I'll get to this. I'd love to see a PR from you on this though. So please feel free to give it a go and let me know if you need help.

Raphael

from poyo.

tolidano avatar tolidano commented on August 28, 2024

I know this is very late, but I'm interested in using a single-file 0-dependency version of this library (which I will happily contribute back). One of the only issues preventing me from using it is this issue where a list item cannot be a section.

I would appreciate any pointers you can provide to help allow this modification. I started by looking here:

_LIST_VALUE = (
     _BLANK
     + r"-"
     + _BLANK
     + r"('.*?'|\".*?\"|[^#\n]+?)"
     + _INLINE_COMMENT
     + _OPT_NEWLINE
 )
 _LIST_ITEM = _BLANK_LINE + r"|" + _COMMENT + r"|" + _LIST_VALUE

 _LIST = _SECTION + r"(?P<items>(?:" + _LIST_ITEM + r")*" + _LIST_VALUE + r")"

I believe that what I'll want to do is modify the _LIST_VALUE definition in some way, so I tried various iterations on:

     _BLANK
     + r"-"
     + _BLANK
     + _MULTILINE_SECTION
     #+ r"('.*?'|\".*?\"|[^#\n]+?)"
     #+ _INLINE_COMMENT
     + _OPT_NEWLINE

Using _MULTILINE_STR or _MULTILINE_SECTION but always running into duplicate group definition errors.

Do you have any quick and dirty ideas how I might capture this properly?
Even if I can just get the entire representation after the dash and space as a single string, I would be able to just feed that back into parse_string and get that part of the dictionary, which I would be happy to do (even outside the initial parser run).

I will continue to tinker, but any assistance greatly appreciated.

from poyo.

Related Issues (19)

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.