def _str_option_desc(self, sectname, sect): """Get the option description strings for sect/sectname.""" wrapper = textwrapper.TextWrapper(initial_indent='#' + ' ' * 5, subsequent_indent='#' + ' ' * 5) lines = [] if not getattr(sect, 'descriptions', None): return lines for optname, option in sect.items(): lines.append('#') typestr = ' ({})'.format(option.typ.__class__.__name__) lines.append("# {}{}:".format(optname, typestr)) try: desc = self.sections[sectname].descriptions[optname] except KeyError: log.config.exception("No description for {}.{}!".format( sectname, optname)) continue for descline in desc.splitlines(): lines += wrapper.wrap(descline) valid_values = option.typ.valid_values if valid_values is not None: if valid_values.descriptions: for val in valid_values: desc = valid_values.descriptions[val] lines += wrapper.wrap(" {}: {}".format(val, desc)) else: lines += wrapper.wrap("Valid values: {}".format( ', '.join(valid_values))) lines += wrapper.wrap("Default: {}".format( option.values['default'])) return lines
def test_default_args(): wrapper = textwrapper.TextWrapper() assert wrapper.width == 72 assert not wrapper.replace_whitespace assert not wrapper.break_long_words assert not wrapper.break_on_hyphens assert wrapper.initial_indent == '# ' assert wrapper.subsequent_indent == '# '
def _str_section_desc(self, sectname): """Get the section description string for sectname.""" wrapper = textwrapper.TextWrapper() lines = [] seclines = configdata.SECTION_DESC[sectname].splitlines() for secline in seclines: if 'http://' in secline or 'https://' in secline: lines.append('# ' + secline) else: lines += wrapper.wrap(secline) return lines
def test_custom_args(): wrapper = textwrapper.TextWrapper(drop_whitespace=False) assert wrapper.width == 72 assert not wrapper.drop_whitespace