summaryrefslogtreecommitdiff
path: root/src/mailman/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/commands')
-rw-r--r--src/mailman/commands/cli_conf.py27
-rw-r--r--src/mailman/commands/docs/conf.rst34
2 files changed, 19 insertions, 42 deletions
diff --git a/src/mailman/commands/cli_conf.py b/src/mailman/commands/cli_conf.py
index 55f63c712..7fe9fce7d 100644
--- a/src/mailman/commands/cli_conf.py
+++ b/src/mailman/commands/cli_conf.py
@@ -65,19 +65,12 @@ class Conf:
key-values pair from any section matching the given key will be
displayed.
"""))
- command_parser.add_argument(
- '-t', '--sort',
- default=False, action='store_true',
- help=_('Sort the output by sections and keys.'))
def _get_value(self, section, key):
return getattr(getattr(config, section), key)
- def _sections(self, sort_p):
- sections = config.schema._section_schemas
- if sort_p:
- sections = sorted(sections)
- return sections
+ def _sections(self):
+ return sorted(config.schema._section_schemas)
def _print_full_syntax(self, section, key, value, output):
print('[{}] {}: {}'.format(section, key, value), file=output)
@@ -88,10 +81,8 @@ class Conf:
def _show_section_error(self, section):
self.parser.error('No such section: {}'.format(section))
- def _print_values_for_section(self, section, output, sort_p):
- current_section = getattr(config, section)
- if sort_p:
- current_section = sorted(current_section)
+ def _print_values_for_section(self, section, output):
+ current_section = sorted(getattr(config, section))
for key in current_section:
self._print_full_syntax(section, key,
self._get_value(section, key), output)
@@ -106,7 +97,6 @@ class Conf:
# Process the command, ignoring the closing of the output file.
section = args.section
key = args.key
- sort_p = args.sort
# Case 1: Both section and key are given, so we can directly look up
# the value.
if section is not None and key is not None:
@@ -119,12 +109,12 @@ class Conf:
# Case 2: Section is given, key is not given.
elif section is not None and key is None:
if self._section_exists(section):
- self._print_values_for_section(section, output, sort_p)
+ self._print_values_for_section(section, output)
else:
self._show_section_error(section)
# Case 3: Section is not given, key is given.
elif section is None and key is not None:
- for current_section in self._sections(sort_p):
+ for current_section in self._sections():
# We have to ensure that the current section actually exists
# and that it contains the given key.
if (self._section_exists(current_section) and
@@ -137,13 +127,12 @@ class Conf:
# Case 4: Neither section nor key are given, just display all the
# sections and their corresponding key/value pairs.
elif section is None and key is None:
- for current_section in self._sections(sort_p):
+ for current_section in self._sections():
# However, we have to make sure that the current sections and
# key which are being looked up actually exist before trying
# to print them.
if self._section_exists(current_section):
- self._print_values_for_section(
- current_section, output, sort_p)
+ self._print_values_for_section(current_section, output)
def process(self, args):
"""See `ICLISubCommand`."""
diff --git a/src/mailman/commands/docs/conf.rst b/src/mailman/commands/docs/conf.rst
index 2f708edc5..0ff5064bb 100644
--- a/src/mailman/commands/docs/conf.rst
+++ b/src/mailman/commands/docs/conf.rst
@@ -14,7 +14,6 @@ a specific key-value pair, or several key-value pairs.
... key = None
... section = None
... output = None
- ... sort = False
>>> from mailman.commands.cli_conf import Conf
>>> command = Conf()
@@ -22,9 +21,9 @@ To get a list of all key-value pairs of any section, you need to call the
command without any options.
>>> command.process(FakeArgs)
- [logging.archiver] path: mailman.log
+ [antispam] header_checks:
...
- [passwords] password_length: 8
+ [logging.bounce] level: info
...
[mailman] site_owner: noreply@example.com
...
@@ -33,9 +32,9 @@ You can list all the key-value pairs of a specific section.
>>> FakeArgs.section = 'shell'
>>> command.process(FakeArgs)
- [shell] use_ipython: no
[shell] banner: Welcome to the GNU Mailman shell
[shell] prompt: >>>
+ [shell] use_ipython: no
You can also pass a key and display all key-value pairs matching the given
key, along with the names of the corresponding sections.
@@ -44,20 +43,20 @@ key, along with the names of the corresponding sections.
>>> FakeArgs.key = 'path'
>>> command.process(FakeArgs)
[logging.archiver] path: mailman.log
- [logging.locks] path: mailman.log
- [logging.mischief] path: mailman.log
+ [logging.bounce] path: bounce.log
[logging.config] path: mailman.log
- [logging.error] path: mailman.log
- [logging.smtp] path: smtp.log
[logging.database] path: mailman.log
+ [logging.debug] path: debug.log
+ [logging.error] path: mailman.log
+ [logging.fromusenet] path: mailman.log
[logging.http] path: mailman.log
+ [logging.locks] path: mailman.log
+ [logging.mischief] path: mailman.log
[logging.root] path: mailman.log
- [logging.fromusenet] path: mailman.log
- [logging.bounce] path: bounce.log
- [logging.vette] path: mailman.log
[logging.runner] path: mailman.log
+ [logging.smtp] path: smtp.log
[logging.subscribe] path: mailman.log
- [logging.debug] path: debug.log
+ [logging.vette] path: mailman.log
If you specify both a section and a key, you will get the corresponding value.
@@ -66,16 +65,5 @@ If you specify both a section and a key, you will get the corresponding value.
>>> command.process(FakeArgs)
noreply@example.com
-You can also sort the output. The output is first sorted by section, then by
-key.
-
- >>> FakeArgs.key = None
- >>> FakeArgs.section = 'shell'
- >>> FakeArgs.sort = True
- >>> command.process(FakeArgs)
- [shell] banner: Welcome to the GNU Mailman shell
- [shell] prompt: >>>
- [shell] use_ipython: no
-
.. _`Postfix command postconf(1)`: http://www.postfix.org/postconf.1.html