Handle blank lines followed by comment in nic conversion script

Currently if a blank line is followed by a comment the 'last_non_comment_spaces'
variable gets reset, which results in the comment line not being indented.
This just ignores blank lines so that 'last_non_comment_spaces' isn't reset
and the comment line is properly indented.

Closes-Bug: 1779191
Change-Id: I286da578c42df24242ba38df12d42c8a8fdd4a4f
This commit is contained in:
Bob Fournier 2018-06-28 14:19:22 -04:00 committed by Dan Sneddon
parent c7b10fe834
commit f997e3da60
2 changed files with 8 additions and 0 deletions

View File

@ -0,0 +1,5 @@
---
fixes:
- This fixes an issue with the yaml-nic-config-2-script.py script
that converts old-style nic config files to new-style. It now handles
blank lines followed by a comment line.

View File

@ -49,6 +49,9 @@ def to_commented_yaml(filename):
with open(filename, 'r') as f: with open(filename, 'r') as f:
comment_count = 0 comment_count = 0
for line in f: for line in f:
# skip blank line
if line.isspace():
continue;
char_count = 0 char_count = 0
spaces = '' spaces = ''
for char in line: for char in line: