blob: 7859ed8d1e5d444947e20a9ccd501c3e80c43388 (
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
|
#!/usr/bin/python
#---------------------------------------------------------------
# Project : Mandriva Linux
# Module : share
# File : man.py
# Version : $Id$
# Author : Frederic Lepied
# Created On : Sat Jan 26 17:38:39 2002
# Purpose : loads a python module and creates a man page from
# the doc strings of the functions.
#---------------------------------------------------------------
import sys
import imp
import inspect
header = '''.ds q \N'34'
.TH mseclib 3 V0 msec "Mandriva Linux"
.SH NAME
mseclib
.SH SYNOPSIS
.nf
.B from mseclib import *
.B function1(yes)
.B function2(ignore)
.fi
.SH DESCRIPTION
.B mseclib
is a python library to access the function used by the msec program. This functions can be used
in /etc/security/msec/level.local to override the behaviour of the msec program or in standalone
scripts. The first argument of the functions takes a value of 1 or 0 or -1 (or yes/no/ignore)
except when specified otherwise.
'''
footer = '''.RE
.SH "SEE ALSO"
msec(8)
.SH AUTHORS
Frederic Lepied <flepied@mandriva.com>
'''
### strings used in the rewritting
function_str = '''
.TP 4
.B \\fI%s%s\\fP
%s
'''
### code
modulename = sys.argv[1]
module = __import__(modulename)
sys.stdout.write(header)
for f in inspect.getmembers(module, inspect.isfunction):
(args, varargs, varkw, locals) = inspect.getargspec(f[1])
doc = f[1].__doc__
if doc and len(doc) > 2:
doc = doc[2:]
argspec = inspect.formatargspec(args, varargs, varkw, locals)
s = function_str % (f[0], argspec, doc)
sys.stdout.write(s)
sys.stdout.write(footer)
# man.py ends here
|