Comments (3)
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.
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.
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)
- List values
- Does Poyo need a `safe_parse()` method? HOT 7
- Can't seem to parse what ruamel.yaml dumps
- LIST pattern silently eats away anything between nonsibling LIST_ITEM patterns HOT 2
- Null values
- keys are not trimmed HOT 2
- Move poyo to cookiecutter organization
- Reformat code base with black
- Convert rst files to md
- The parser fails to parse YAML file starting with "---" HOT 3
- Trailing space causes an irrelevant error
- Escape sequences are not handled in strings
- Migrate CI to GitHub Actions 🤖
- Archive project 👋
- Thanks! HOT 1
- Add flake8 settings to repo HOT 1
- YAML file with comment on the first line of child container cannot be parsed HOT 3
- ValueError when parsing config. HOT 3
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 poyo.