-
Notifications
You must be signed in to change notification settings - Fork 1
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
Consider Sequence Support? #12
Comments
Thanks @rainydew ! Indeed Before going further on how to improve |
I just had a look, import yaml
class Hero:
def __init__(self, name, hp, sp):
self.name = name
self.hp = hp
self.sp = sp
def __repr__(self):
return "%s(name=%r, hp=%r, sp=%r)" % (self.__class__.__name__, self.name, self.hp, self.sp)
yaml.load("""
!!python/object:__main__.Hero
- Welthyr Syxgon
- 1200
- 0
""") fails with
|
Same with scalar:
raises
|
Hi @rainydew , the feature should now be available in yamlable version 1.1.0 |
hi @smarie sorry quite busy recently, thanks a lot for improving and i will try soon~ |
hi @smarie thanks it works wonderful and can do lots of work with python IDE like pycharm... (for tag hint and auto complete it can make lots of function and be very flexible, can use as DSL) |
Super cool ! Thanks @rainydew for the feedback |
When parsing Ice (mapping, to dict), everything works well. However YamlAble doesn't have a handler to handle sequence yet, it will cause
`
E:\Python36\python.exe C:/Users/Administrator/AppData/Roaming/JetBrains/PyCharm2020.1/scratches/test_scratch.py
here () {'k': 1, 'v': 2}
Traceback (most recent call last):
File "C:/Users/Administrator/AppData/Roaming/JetBrains/PyCharm2020.1/scratches/test_scratch.py", line 31, in
data = yaml.safe_load(file)
File "E:\Python36\lib\site-packages\yaml_init_.py", line 162, in safe_load
return load(stream, SafeLoader)
File "E:\Python36\lib\site-packages\yaml_init_.py", line 114, in load
return loader.get_single_data()
File "E:\Python36\lib\site-packages\yaml\constructor.py", line 51, in get_single_data
return self.construct_document(node)
File "E:\Python36\lib\site-packages\yaml\constructor.py", line 60, in construct_document
for dummy in generator:
File "E:\Python36\lib\site-packages\yaml\constructor.py", line 408, in construct_yaml_seq
data.extend(self.construct_sequence(node))
File "E:\Python36\lib\site-packages\yaml\constructor.py", line 130, in construct_sequence
for child in node.value]
File "E:\Python36\lib\site-packages\yaml\constructor.py", line 130, in
for child in node.value]
File "E:\Python36\lib\site-packages\yaml\constructor.py", line 100, in construct_object
data = constructor(self, node)
File "E:\Python36\lib\site-packages\yamlable\yaml_objects.py", line 115, in from_yaml
constructor_args = read_yaml_node_as_dict(loader, node)
File "E:\Python36\lib\site-packages\yamlable\base.py", line 210, in read_yaml_node_as_dict
loader.flatten_mapping(node)
File "E:\Python36\lib\site-packages\yaml\constructor.py", line 184, in flatten_mapping
key_node, value_node = node.value[index]
TypeError: 'ScalarNode' object is not iterable
`
Maybe a type router to call constructor in different ways is better?
The text was updated successfully, but these errors were encountered: