Пример #1
0
# This file is used to generate a ReStructured Text table suitable for
# documentating the variable name changes. Its contents are meant to be
# inserted into doc/source/upgrade-guide/scripts.rst.

# As of right now, running this script and inserting the output into
# the file is manual.

from migrate_openstack_vars import VAR_MAPPINGS

# Print old/new values in each row, right aligned.
row_format = "| {:>40} | {:>40} |"

# For the line separators, move the dividing '+' sign over so it's aligned
# with the '|' in the rows.
divider_format = "+-{:->42}---{:->40}"
header_divide_format = "+={:=>42}==={:=>40}"


# Header info
print(divider_format.format('+', '+'))
print(row_format.format('Old Value', 'New Value'))
print(header_divide_format.format('+', '+'))

# If we just used the items method, we'd get an unsorted output.
keys = VAR_MAPPINGS.keys()
keys.sort()

for key in keys:
    print(row_format.format(key, VAR_MAPPINGS[key]))
    print(divider_format.format('+', '+'))