summaryrefslogtreecommitdiff
path: root/oslo_policy/generator.py
diff options
context:
space:
mode:
authorSujitha <sujitha.neti@intel.com>2017-03-03 18:56:06 +0000
committerSujitha <sujitha.neti@intel.com>2017-03-06 23:02:50 +0000
commit8ca44b38bdaf49636e1b6fddeda63845aaa26c95 (patch)
tree115dc0716f37d2b8851e90423f415658fe6ee7ec /oslo_policy/generator.py
parent3c3261c072390a81c33641ce5f8ee79970c040dc (diff)
downloadoslo-policy-8ca44b38bdaf49636e1b6fddeda63845aaa26c95.tar.gz
Allow multiline descriptions for RuleDefaults1.20.0
Multiline descriptions are not displayed properly in the generated sample file because of the wrapper used. This patch changes the formatting of help text by wrapping each line. Change-Id: Ic19a06189caa0002458881c543c63c7540e301de
Diffstat (limited to 'oslo_policy/generator.py')
-rw-r--r--oslo_policy/generator.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/oslo_policy/generator.py b/oslo_policy/generator.py
index 5cbfd6a..c4d4ee3 100644
--- a/oslo_policy/generator.py
+++ b/oslo_policy/generator.py
@@ -85,10 +85,19 @@ def _format_help_text(description):
if not description:
return '#'
- return textwrap.fill(description, 70, initial_indent='# ',
- subsequent_indent='# ',
- break_long_words=False,
- replace_whitespace=False)
+ lines = description.splitlines()
+ formatted_lines = []
+ # wrap each line to support multi line descriptions
+ for line in lines:
+ if not line:
+ formatted_lines.append('#')
+ else:
+ formatted_lines.append(textwrap.fill(line, 70,
+ initial_indent='# ',
+ subsequent_indent='# ',
+ break_long_words=False,
+ replace_whitespace=False))
+ return "\n".join(formatted_lines)
def _format_rule_default_yaml(default, include_help=True):