change propose-library-branches to use yamlutils

We now have a way to preserve the order and other general formatting
settings when rewriting a YAML file, so use it instead of tacking a
blob of text onto the end of the file.

Change-Id: Icd3a6a4d75e3e86acbec66503f4b99951460c2f7
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann
2018-01-24 14:26:57 -05:00
parent 5d7d357c8f
commit 59e1013777

View File

@@ -26,13 +26,6 @@ from openstack_releases import defaults
from openstack_releases import yamlutils
BRANCH_TEMPLATE = """
branches:
- name: stable/{series}
location: {version}
"""
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
@@ -125,11 +118,9 @@ def main():
continue
latest_release = releases[-1]
# NOTE(dhellmann): PyYAML doesn't preserve layout when you
# write the data back out, so do the formatting ourselves.
new_block = BRANCH_TEMPLATE.format(
version=latest_release['version'],
series=args.series,
).strip() + '\n'
with open(filename, 'a') as f:
f.write(new_block)
deliverable_data['branches'].append({
'name': 'stable/' + args.series,
'location': latest_release['version'],
})
with open(filename, 'w', encoding='utf-8') as f:
f.write(yamlutils.dumps(deliverable_data))