14 Commits

Author SHA1 Message Date
Sean McGinnis
1704aa624a
Raise YAML compliance to 1.2
The YAML 1.2 spec was released in 2009. It's probably been enough time
that it's safe to move to it.

The only issue for out YAML usage was 1.2 dropped the use of Yes, No, On,
and Off as valid boolean values.

Change-Id: I608e09d219379e00cca15c5ff165bb63aecfe9f2
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2019-07-31 09:34:38 -05:00
Jean-Philippe Evrard
2cb8f99ad9 Force certain indenting style
Maybe not the best approach, but makes the new-release cli
output similar to what we used to do.

Change-Id: I1a5aa4293ed674d029affbd123d7f75001b827f0
2019-07-24 17:00:30 +02:00
Sean McGinnis
b6ca269386
Switch to ruamel for yaml handling
The Ruamel library has better support for modifying YAML while keeping
things like comments. This updates our yamlutil module to use
ruamel.yaml instead of PyYAML.

Story: 2002908
Task: 22880

Change-Id: I4ac66c9e3e40780b588377c1dfe42511eed231a3
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2019-07-08 11:40:11 -05:00
Thierry Carrez
fde014c987 No longer create longlines with edit-deliverables
That was a constant paper cut for me: every time someone uses
edit-deliverables it may result in release highlights being
reformatted to create lines over 80 char. You can see that
happening at:

https://review.openstack.org/#/c/650911/1/deliverables/rocky/cloudkitty.yaml

where it messes up perfectly-good yaml and turns it into 88-char-long
lines.

I experimented with various settings (you would think width=80 would
do, but no). Forcing dump width at 66 characters seems to produce the
desired results.

Change-Id: I83934a0f7d6eeaec47b5dcb1a6bfb8c53ed65799
2019-04-11 13:43:06 +02:00
Doug Hellmann
63291dbd84 do not let yamlutils emit alias references
We want the canonical data files to have repeated information to make
it easy for human readers to understand the content, so do not emit
aliases to blocks of repeated data.

Change-Id: Ib6bf3f3683fae2edb94910bea86971e591b5b87c
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2017-08-01 16:51:03 -04:00
Doug Hellmann
032675e6b4 fix typos in yamlutils
Change-Id: Icdb2504cae46cd804cb40c2163ae399cdafdcaaf
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2017-08-01 16:42:39 -04:00
Doug Hellmann
4891bea8c5 standardize indentation at 2 spaces
Update the linter rules to require 2 spaces. Update our dumper to emit
2 spaces.

Change-Id: Idef3574021845bccfc92c75425bc0f40b32b0026
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2017-07-31 17:26:33 -04:00
Doug Hellmann
541797fc47 do not add line wraps to text when reformatting
Change-Id: I2c5e167b3a0d6cf29fcabdee7619d672e0d24bd3
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2017-07-31 17:11:03 -04:00
Doug Hellmann
04f903f7a0 use yes/no for boolean values in reformatter
The default is to use true/false but most of our data is already yes/no.

Change-Id: I9b6573e8e5a7c4acd0d33a9cf0790b58d4e60662
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2017-07-31 17:11:03 -04:00
Doug Hellmann
2248abb4e1 ensure version numbers always have quotes
Update the reformatter to always put quotes around strings that look
like they are numbers. A value like x.y.z is clearly not a float so
the library does the right thing but x.y seems like a float so it
leaves the quotes off, then later when we parse the file again we get
a number not a string.

Change-Id: I6126f59d09d169a2dde1cdffcecd15f8c65c2e65
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2017-07-31 17:11:03 -04:00
Doug Hellmann
25ea1d8ecd fix format-yaml to work with python 3
Change-Id: I48717815536a4e31fbac799f7fc7743ff8bc3c4d
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2017-07-31 17:11:02 -04:00
loooosy
26147887eb Replace six.iteritems() with .items()
1.As mentioned in [1], we should avoid using
six.iteritems to achieve iterators. We can
use dict.items instead, as it will return
iterators in PY3 as well. And dict.items/keys
will more readable. 2.In py2, the performance
about list should be negligible, see the link [2].
[1] https://wiki.openstack.org/wiki/Python3
[2] http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html

Change-Id: I83997d0c43826c9d5b06a72d93365e8e9b4587af
2017-04-05 17:51:02 +08:00
Joshua Harlow
167e228d27 Don't try to re-wrap things that already have newlines
When a string is found (and about to be output) that
already has newlines in it (say it was read in previously)
we shouldn't be trying to reformat that string when
writing it back out; so avoid doing this by searching for
existing newlines and not re-wrapping things when they
already exist.

Change-Id: Ic310677314172f46b360c90197539993eb5bcc99
2016-06-13 11:41:53 -07:00
Joshua Harlow
9c1ac3dace Add a yamlutils file and a reformatting command
Do note this will lose comments, if pyyaml ever supports
not losing those then this can avoid losing those.

Change-Id: I4b26362f7cab42eb40804751c86d9145490c78d9
2016-05-16 21:45:40 -07:00