#!/usr/bin/python3 # # 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' help_wiki_file = 'help.wiki' 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: gettext.install('msec') except IOError: _ = str HELP = { ''' footer_perl = '''); ''' header_wiki = '''The following functionality is supported by MSEC: ''' footer_wiki = ''' ''' header_python = '''# libmsec documentation for python. import gettext # localization try: gettext.install('msec') except IOError: _ = str HELP = { ''' footer_python = '''} ''' ### strings used in the rewritting function_str_perl = ''''%s' => N("%s"), ''' function_str_python = ''' '%s': _("%s"), ''' function_str_wiki = ''';%s: %s ''' help_perl = open(help_perl_file, "w") help_python = open(help_python_file, "w") help_wiki = open(help_wiki_file, "w") # process all configuration parameters log = Log(log_syslog=False, log_file=False) msec = MSEC(log, plugins='plugins') print(header_perl, file=help_perl) print(header_python, file=help_python) print(header_wiki, file=help_wiki) for variable in config.SETTINGS: callback, params = config.SETTINGS[variable] func = msec.get_action(callback) if func: print(function_str_perl % (variable, func.__doc__.strip()), file=help_perl) print(function_str_python % (variable, func.__doc__.strip()), file=help_python) print(function_str_wiki % (variable, func.__doc__.strip()), file=help_wiki) print(footer_perl, file=help_perl) print(footer_python, file=help_python) print(footer_wiki, file=help_wiki) # draksec_help.py ends here