diff options
author | Romain Francoise <rfrancoise@debian.org> | 2014-04-15 19:35:31 +0200 |
---|---|---|
committer | Romain Francoise <rfrancoise@debian.org> | 2014-04-15 19:35:31 +0200 |
commit | df40590dead5696facf9943f46e222a5e831286d (patch) | |
tree | d701325b24c0e1c5676fa9cb8ed959254dd4367a /conf/format-options.py | |
parent | 91b54afb0421705a4fb9d990d813007cd45bc2ce (diff) | |
parent | c5ebfc7b9c16551fe825dc1d79c3f7e2f096f6c9 (diff) | |
download | vyos-strongswan-df40590dead5696facf9943f46e222a5e831286d.tar.gz vyos-strongswan-df40590dead5696facf9943f46e222a5e831286d.zip |
Merge tag 'upstream/5.1.3'
Upstream version 5.1.3
* tag 'upstream/5.1.3':
Import upstream version 5.1.3
Diffstat (limited to 'conf/format-options.py')
-rwxr-xr-x | conf/format-options.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/conf/format-options.py b/conf/format-options.py index 04afed6d6..fc6e6e1fd 100755 --- a/conf/format-options.py +++ b/conf/format-options.py @@ -54,6 +54,7 @@ import sys import re from textwrap import TextWrapper from optparse import OptionParser +from operator import attrgetter class ConfigOption: """Representing a configuration option or described section in strongswan.conf""" @@ -67,9 +68,7 @@ class ConfigOption: self.options = [] def __cmp__(self, other): - if self.section == other.section: - return cmp(self.name, other.name) - return 1 if self.section else -1 + return cmp(self.name, other.name) def add_paragraph(self): """Adds a new paragraph to the description""" @@ -246,7 +245,7 @@ class ConfFormatter: self.__print_description(section, indent) print '{0}{1}{2} {{'.format(self.__indent * indent, comment, section.name) print - for o in section.options: + for o in sorted(section.options, key=attrgetter('section')): if o.section: self.__print_section(o, indent + 1, section.commented) else: @@ -258,7 +257,7 @@ class ConfFormatter: """Print a list of options""" if not options: return - for option in options: + for option in sorted(options, key=attrgetter('section')): if option.section: self.__print_section(option, 0, False) else: |