Code Monkey home page Code Monkey logo

Comments (7)

zerwes avatar zerwes commented on July 29, 2024

Is this not what you expect?

>>> import hiyapyco
>>> yaml1="""
... yaml: 1
... saml: 0
... baml: 2
... """
>>> yaml2="""
... gaml: cool
... yaml: good
... saml: not working
... """
>>> conf = hiyapyco.load([yaml1, yaml2], method=hiyapyco.METHOD_MERGE)
>>> print(hiyapyco.dump(conf))
yaml: good
saml: not working
baml: 2
gaml: cool

>>> 

from hiyapyco.

vsraptor avatar vsraptor commented on July 29, 2024

why do i get something like this, see the brackets :


templates:
  utter_ask_answer:
  - {text: Type the answer to the question}
  utter_exercise_submit:
  - {text: finished}
  utter_process_answer:
  - {text: 'process answer : answer <=> expected_result'}

from hiyapyco.

zerwes avatar zerwes commented on July 29, 2024

can you provide me some reproducible code samples please?
I am unable to reproduce this.

>>> import hiyapyco
>>> c="""
... m:
... - a: A
...   b: BB
...   c: BABA
... - a: ABBA
...   b: BAAB
...   c: C
... - a: CACA
...   b: ACAC
...   c: 
...   - suba: aaa
...     subb: bbbb
...     subc: ccc
... """
>>> conf = hiyapyco.load([c])
>>> print(hiyapyco.dump(conf))
m:
- a: A
  b: BB
  c: BABA
- a: ABBA
  b: BAAB
  c: C
- a: CACA
  b: ACAC
  c:
  - suba: aaa
    subb: bbbb
    subc: ccc

>>> 
>>> c="""
... templates:
...   utter_ask_answer:
...   - {text: Type the answer to the question}
...   utter_exercise_submit:
...   - {text: finished}
...   utter_process_answer:
...   - {text: 'process answer : answer <=> expected_result'}
... """
>>> conf = hiyapyco.load([c])
>>> print(hiyapyco.dump(conf))
templates:
  utter_ask_answer:
  - text: Type the answer to the question
  utter_exercise_submit:
  - text: finished
  utter_process_answer:
  - text: 'process answer : answer <=> expected_result'
>>>

from hiyapyco.

vsraptor avatar vsraptor commented on July 29, 2024

Interesting .... here is what I get (even if I remove the brackets from the source) :
/and as you see I get this dump of data on .load() !!/

 In [6]:  c="""
   ...:  templates:
   ...:    utter_ask_answer:
   ...:    - {text: Type the answer to the question}
   ...:    utter_exercise_submit:
   ...:    - {text: finished}
   ...:    utter_process_answer:
   ...:    - {text: 'process answer : answer <=> expected_result'}
   ...:  """

 In [7]: conf = hiyapyco.load([c])
yamlfile: 
templates:
  utter_ask_answer:
  - {text: Type the answer to the question}
  utter_exercise_submit:
  - {text: finished}
  utter_process_answer:
  - {text: 'process answer : answer <=> expected_result'}
 ...
loading yaml doc from str ...
yaml data: OrderedDict([('templates', OrderedDict([('utter_ask_answer', [OrderedDict([('text', 'Type the answer to the question')])]), ('utter_exercise_submit', [OrderedDict([('text', 'finished')])]), ('utter_process_answer', [OrderedDict([('text', 'process answer : answer <=> expected_result')])])]))])

In [8]: print(hiyapyco.dump(conf))
templates:
  utter_ask_answer:
  - {text: Type the answer to the question}
  utter_exercise_submit:
  - {text: finished}
  utter_process_answer:
  - {text: 'process answer : answer <=> expected_result'}

from hiyapyco.

zerwes avatar zerwes commented on July 29, 2024

Can you please provide some information regarding:

  • OS
  • python interpreter and version
  • pyyaml aka. python-yaml version
  • hiyapyco version
  • everything else you consider valuable / noteworthy

Try to use the
usedefaultyamlloader=True arg while loading the yaml @ hiyapyco.load and see if there is a difference in the output

from hiyapyco.

vsraptor avatar vsraptor commented on July 29, 2024
# python --version
Python 2.7.15rc1
# pip show pyyaml
Name: PyYAML
Version: 3.10
# pip show hiyapyco
Name: HiYaPyCo
Version: 0.4.14

from hiyapyco.

zerwes avatar zerwes commented on July 29, 2024

use default_flow_style=False arg for dump
seems this is some default that changed in the pyyaml lib somewhere between 3.12 and 3.13 ...

>>> import hiyapyco
>>> c="""
... templates:
...   utter_ask_answer:
...   - {text: Type the answer to the question}
...   utter_exercise_submit:
...   - {text: finished}
...   utter_process_answer:
...   - {text: 'process answer : answer <=> expected_result'}
... """
>>> 
>>> conf = hiyapyco.load([c])
>>> print(hiyapyco.dump(conf))
templates:
  utter_ask_answer:
  - {text: Type the answer to the question}
  utter_exercise_submit:
  - {text: finished}
  utter_process_answer:
  - {text: 'process answer : answer <=> expected_result'}

>>> print(hiyapyco.dump(conf, default_flow_style=False))
templates:
  utter_ask_answer:
  - text: Type the answer to the question
  utter_exercise_submit:
  - text: finished
  utter_process_answer:
  - text: 'process answer : answer <=> expected_result'

from hiyapyco.

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.