diff options
author | Jenkins <jenkins@review.openstack.org> | 2014-12-04 17:18:28 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2014-12-04 17:18:28 +0000 |
commit | 125711997eb3d9fd6894463b1c8513181e215e7c (patch) | |
tree | f50a74f9f596015ff42aead70a100e3610dd42c4 | |
parent | 5b5df642f0b9f6f7c50a25e15290bb531b72c1d0 (diff) | |
parent | b5f14ce99d84e7e0f5dada4f4da427bbf2472c54 (diff) | |
download | oslo-config-125711997eb3d9fd6894463b1c8513181e215e7c.tar.gz |
Merge "Refactored help string generation"
-rw-r--r-- | oslo/config/generator.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/oslo/config/generator.py b/oslo/config/generator.py index e18ed1e..93594e0 100644 --- a/oslo/config/generator.py +++ b/oslo/config/generator.py @@ -160,6 +160,20 @@ class _OptFormatter(object): self.output_file = output_file or sys.stdout self.wrap_width = wrap_width + def _format_help(self, help_text): + """Format the help for a group or option to the output file. + + :param help_text: The text of the help string + """ + if self.wrap_width is not None and self.wrap_width > 0: + lines = [textwrap.fill(help_text, + self.wrap_width, + initial_indent='# ', + subsequent_indent='# ') + '\n'] + else: + lines = ['# ' + help_text + '\n'] + return lines + def format(self, opt): """Format a description of an option to the output file. @@ -171,13 +185,7 @@ class _OptFormatter(object): opt_type = self._TYPE_DESCRIPTIONS.get(type(opt), 'unknown type') help_text = u'%s(%s)' % (opt.help + ' ' if opt.help else '', opt_type) - if self.wrap_width is not None and self.wrap_width > 0: - lines = [textwrap.fill(help_text, - self.wrap_width, - initial_indent='# ', - subsequent_indent='# ') + '\n'] - else: - lines = ['# ' + help_text + '\n'] + lines = self._format_help(help_text) for d in opt.deprecated_opts: lines.append('# Deprecated group/name - [%s]/%s\n' % |