<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div name="messageBodySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;">This looks like a solution, yes. Thanks.
<div><br /></div>
<div>@Oleg, please take a look. Maybe we really decided to add a new yaml lib too early.</div>
<div><br /></div>
<div><br /></div>
</div>
<div name="messageSignatureSection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;"><br />
<div class="matchFont">Renat</div>
</div>
<div name="messageReplySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;">On 15 Feb 2019, 00:16 +0700, Ben Nemec <openstack@nemebean.com>, wrote:<br />
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #1abc9c;"><br />
<br />
On 2/14/19 10:46 AM, Oleg Ovcharuk wrote:<br />
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #e67e22;">Matthew, we use not only load, but also dump. We can't use custom<br />
constructor and default representer - the output will be terrible.<br />
This custom constructor contains about 50 lines of code, representer<br />
would have a similar count. Also, we should think about compatibility<br />
with Python 2.7, 3.x and about it's performance.<br />
Summary, we would have about 150 lines of code, which is just copy-paste<br />
from `yamlloader` library.<br />
IMHO, it is better to use existing solutions.<br /></blockquote>
<br />
You don't need a complex representer to dump OrderedDicts. It can be<br />
done in about three lines:<br />
https://github.com/cybertron/tripleo-scripts/blob/105381d4f080394e68a40327c398d32eb9f4f580/net_processing.py#L302<br />
<br />
That's the code I used when I wanted to dump dicts in a particular<br />
order. Once you add the representer OrderedDicts are handled as you<br />
would expect.<br />
<br />
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #e67e22;"><br />
чт, 14 февр. 2019 г. в 19:14, Matthew Thode <mthode@mthode.org<br />
<mailto:mthode@mthode.org>>:<br />
<br />
On 19-02-14 16:58:49, Oleg Ovcharuk wrote:<br />
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #3498db;">Hi! Can you please add yamlloader library to global requirements?<br />
https://pypi.org/project/yamlloader/<br />
<br />
It provides ability to preserve key order in dicts, it supports<br /></blockquote>
either<br />
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #3498db;">python 2.7 and python 3.x, it provides better performance than<br /></blockquote>
built-in<br />
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #3498db;">functions.<br />
Thank you.<br /></blockquote>
<br />
I'd like to know a little more about why we need this, yaml as a spec<br />
itself doesn't guarantee order so order should be stored somewhere else.<br />
<br />
If all you need is ordereddict support something like this may be better<br />
then adding yet another lib.<br />
<br />
https://gist.github.com/enaeseth/844388<br />
<br />
--<br />
Matthew Thode<br />
<br /></blockquote>
<br /></blockquote>
</div>
</body>
</html>