conf: Order settings in man page alphabetically
For the config snippets the options are now explicitly ordered before subsections.
This commit is contained in:
parent
1766ede330
commit
9fa7b03769
|
@ -54,6 +54,7 @@ import sys
|
||||||
import re
|
import re
|
||||||
from textwrap import TextWrapper
|
from textwrap import TextWrapper
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
from operator import attrgetter
|
||||||
|
|
||||||
class ConfigOption:
|
class ConfigOption:
|
||||||
"""Representing a configuration option or described section in strongswan.conf"""
|
"""Representing a configuration option or described section in strongswan.conf"""
|
||||||
|
@ -67,9 +68,7 @@ class ConfigOption:
|
||||||
self.options = []
|
self.options = []
|
||||||
|
|
||||||
def __cmp__(self, other):
|
def __cmp__(self, other):
|
||||||
if self.section == other.section:
|
return cmp(self.name, other.name)
|
||||||
return cmp(self.name, other.name)
|
|
||||||
return 1 if self.section else -1
|
|
||||||
|
|
||||||
def add_paragraph(self):
|
def add_paragraph(self):
|
||||||
"""Adds a new paragraph to the description"""
|
"""Adds a new paragraph to the description"""
|
||||||
|
@ -246,7 +245,7 @@ class ConfFormatter:
|
||||||
self.__print_description(section, indent)
|
self.__print_description(section, indent)
|
||||||
print '{0}{1}{2} {{'.format(self.__indent * indent, comment, section.name)
|
print '{0}{1}{2} {{'.format(self.__indent * indent, comment, section.name)
|
||||||
print
|
print
|
||||||
for o in section.options:
|
for o in sorted(section.options, key=attrgetter('section')):
|
||||||
if o.section:
|
if o.section:
|
||||||
self.__print_section(o, indent + 1, section.commented)
|
self.__print_section(o, indent + 1, section.commented)
|
||||||
else:
|
else:
|
||||||
|
@ -258,7 +257,7 @@ class ConfFormatter:
|
||||||
"""Print a list of options"""
|
"""Print a list of options"""
|
||||||
if not options:
|
if not options:
|
||||||
return
|
return
|
||||||
for option in options:
|
for option in sorted(options, key=attrgetter('section')):
|
||||||
if option.section:
|
if option.section:
|
||||||
self.__print_section(option, 0, False)
|
self.__print_section(option, 0, False)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue