diff options
Diffstat (limited to 'src/msec/help_draksec.py')
-rwxr-xr-x | src/msec/help_draksec.py | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/msec/help_draksec.py b/src/msec/help_draksec.py new file mode 100755 index 0000000..48f0df0 --- /dev/null +++ b/src/msec/help_draksec.py @@ -0,0 +1,74 @@ +#!/usr/bin/python +# +# This script creates DrakSec help strings from libmsec code docstrings. +# + +import sys +import imp +import inspect +import re + +import config +from libmsec import MSEC, Log + +help_perl_file = 'help.pm' +help_python_file = 'help.py' + +header_perl = '''package security::help; +# !! THIS FILE WAS AUTO-GENERATED BY draksec_help.py !! +# !! DO NOT MODIFY HERE, MODIFY IN THE *MSEC* CVS !! + +use strict; +use common; + +our %help = ( +''' + +header_python = '''# libmsec documentation for python. + +import gettext + +# localization +try: + cat = gettext.Catalog('msec') + _ = cat.gettext +except IOError: + _ = str + +HELP = { +''' + +footer_perl = '''); +''' + +footer_python = '''} +''' + +### strings used in the rewritting +function_str_perl = ''''%s' => N("%s"), +''' + +function_str_python = ''' + '%s': _("%s"), ''' + +help_perl = open(help_perl_file, "w") +help_python = open(help_python_file, "w") + +# process all configuration parameters +log = Log(log_syslog=False, log_file=False) +msec = MSEC(log) + +print >>help_perl, header_perl +print >>help_python, header_python + +for variable in config.SETTINGS: + callback, params = config.SETTINGS[variable] + func = msec.get_action(callback) + if func: + print >>help_perl, function_str_perl % (variable, func.__doc__.strip()) + print >>help_python, function_str_python % (variable, func.__doc__.strip()) + +print >>help_perl, footer_perl +print >>help_python, footer_python + +# draksec_help.py ends here |