Update the metadata tool (#18765)

* Latest spreadsheet version uses different fields for support.
* Format the metadata to be a little nicer (multiple lines)
pull/18776/head
Toshio Kuratomi 8 years ago committed by GitHub
parent dc23667cc2
commit c53b73228f

@ -5,7 +5,7 @@ import csv
import os import os
import sys import sys
from distutils.version import StrictVersion from distutils.version import StrictVersion
from pprint import pprint from pprint import pformat, pprint
import yaml import yaml
@ -267,9 +267,18 @@ def remove_metadata(module_data, start_line, start_col, end_line, end_col):
def insert_metadata(module_data, new_metadata, insertion_line, targets=('ANSIBLE_METADATA',)): def insert_metadata(module_data, new_metadata, insertion_line, targets=('ANSIBLE_METADATA',)):
"""Insert a new set of metadata at a specified line""" """Insert a new set of metadata at a specified line"""
new_line = '{} = {}'.format(' = '.join(targets), new_metadata) assignments = ' = '.join(targets)
lines = module_data.split('\n') pretty_metadata = pformat(new_metadata, width=1).split('\n')
lines.insert(insertion_line, new_line)
new_lines = []
new_lines.append('{} = {}'.format(assignments, pretty_metadata[0]))
if len(pretty_metadata) > 1:
for line in pretty_metadata[1:]:
new_lines.append('{}{}'.format(' ' * (len(assignments) - 1 + len(' = {')), line))
old_lines = module_data.split('\n')
lines = old_lines[:insertion_line] + new_lines + [''] + old_lines[insertion_line:]
return '\n'.join(lines) return '\n'.join(lines)
@ -293,15 +302,15 @@ def parse_assigned_metadata_initial(csvfile):
for record in csv.reader(f): for record in csv.reader(f):
module = record[0] module = record[0]
if record[11] == 'core': if record[12] == 'core':
supported_by = 'core' supported_by = 'core'
elif record[11] == 'curated': elif record[12] == 'curated':
supported_by = 'committer' supported_by = 'committer'
elif record[11] == 'community': elif record[12] == 'community':
supported_by = 'community' supported_by = 'community'
else: else:
raise Exception('Module record has no supported_by field: %s' % record) print('Module %s has no supported_by field. Using community' % record[0])
#supported_by = 'community' supported_by = 'community'
status = [] status = []
if record[6]: if record[6]:

Loading…
Cancel
Save