Re: unmarshalling using yaml.dump doesn't maintain proper format (PyYAML)
Kirill Simonov <xi-RCSp1WnSyaseIZ0/[email protected]>
| Newsgroups | gmane.text.yaml.general |
|---|---|
| Message-ID | <[email protected]> |
On 10/29/2012 06:31 PM, Zippy Zeppoli wrote:
> I'm trying to only print the following:
> grains:
> roles:
> - webserver
> - php
> environment: X
>
> Not the entire document.
>
Well, it doesn't print the entire document, it prints
environment: X
roles: [webserver, php]
which is an exact representation of the value of
configDict['__instance']['grains']. To get an output like above, try
dumping a dictionary:
{"grains": configDict[webserver, php]}
> I still haven't figured out how to print a part of the document only.
Thanks,
Kirill
>
> On Tue, Oct 23, 2012 at 7:09 PM, Kirill Simonov <xi-RCSp1WnSyaseIZ0/[email protected]
> <mailto:xi-RCSp1WnSyaseIZ0/[email protected]>> wrote:
>
> The output looks correct to me. What output do you expect?
>
> Thanks,
> Kirill
>
>
> On 10/23/2012 03:45 PM, Zippy Zeppoli wrote:
>
> Hi list,
> I am using the PyYAML implementation for yaml (They don't have
> their own
> mailing list, so I'm bringing this question here. I hope some
> folks are
> familiar with it and can assist.
>
> I have the following yaml doc:
> ---
> instance:
> id: i-1234567
> saltId: APPSRV-X
> grains:
> roles:
> - webserver
> - php
> environment: X
>
> I then try to dump it from one file to another, there are
> multiple yaml
> docs in this file, and I am picking one doc and copying it to
> another
> file basically.
>
> Here is the code I used to do it:
> https://gist.github.com/__3941410 <https://gist.github.com/3941410>
>
> This is the resulting output:
>
> id: APPSRV-X
> environment: X
> roles: [webserver, php]
>
> For some reason it doesn't maintain it's structure, and I cannot
> figure
> out how to keep it.
>
> I tried changing the line with
> yaml.dump(configDict['__instance']['grains'],
> TEST_CONFIG_FILE)
>
>
> to
> yaml.dump(configDict['__instance']['id'],
> TEST_CONFIG_FILE)
>
>
> and the output get's even stranger:
> id: APPSRV-X
> i-1234567
> ...
>
> any help is appreciated.
>
>
> ------------------------------__------------------------------__------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn___sfd2d_oct
> <http://p.sf.net/sfu/appdyn_sfd2d_oct>
>
>
>
> _________________________________________________
> Yaml-core mailing list
> [email protected]__net
> <mailto:[email protected]>
> https://lists.sourceforge.net/__lists/listinfo/yaml-core
> <https://lists.sourceforge.net/lists/listinfo/yaml-core>
>
>
>
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct