aboutsummaryrefslogtreecommitdiffstats
path: root/src/msec/help_draksec.py
blob: 48f0df0a5552be758f840eec4f4389becdeb595f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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