1 # Copyright (C) 2006-2015 by the Free Software Foundation, Inc.
3 # This file is part of GNU Mailman.
5 # GNU Mailman is free software: you can redistribute it and/or modify it under
6 # the terms of the GNU General Public License as published by the Free
7 # Software Foundation, either version 3 of the License, or (at your option)
10 # GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 # You should have received a copy of the GNU General Public License along with
16 # GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
23 from mailman
.configuration
import config
24 from mailman
.core
.i18n
import _
25 from mailman
.version
import MAILMAN_VERSION
28 # List of names never to show even if --verbose
29 NEVER_SHOW
= ['__builtins__', '__doc__']
34 parser
= optparse
.OptionParser(version
=MAILMAN_VERSION
,
36 %%prog [options] [pattern ...]
38 Show the values of various Defaults.py/mailman.cfg variables.
39 If one or more patterns are given, show only those variables
40 whose names match a pattern"""))
41 parser
.add_option('-v', '--verbose',
42 default
=False, action
='store_true',
44 "Show all configuration names, not just 'settings'."))
45 parser
.add_option('-i', '--ignorecase',
46 default
=False, action
='store_true',
47 help=_("Match patterns case-insensitively."))
48 parser
.add_option('-C', '--config',
49 help=_('Alternative configuration file to use'))
50 opts
, args
= parser
.parse_args()
51 return parser
, opts
, args
56 parser
, opts
, args
= parseargs()
64 patterns
.append(re
.compile(pattern
, flag
))
66 pp
= pprint
.PrettyPrinter(indent
=4)
67 config
.load(opts
.config
)
68 names
= config
.__dict
__.keys()
71 if name
in NEVER_SHOW
:
74 if name
.startswith('_') or re
.search('[a-z]', name
):
78 for pattern
in patterns
:
79 if pattern
.search(name
):
84 value
= config
.__dict
__[name
]
85 if isinstance(value
, str):
86 if re
.search('\n', value
):
87 print '%s = """%s"""' %(name
, value
)
89 print "%s = '%s'" % (name
, value
)
96 if __name__
== '__main__':