aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Lepied <flepied@mandriva.com>2002-02-02 05:20:07 +0000
committerFrederic Lepied <flepied@mandriva.com>2002-02-02 05:20:07 +0000
commit6876e18970ce9cfb00f40e11d81bb005badeaafb (patch)
tree4acdc183df6b0138fbce919345caba85751cecc9
parentf760fbeedb13012a26afba66c4c7b9d1ffce3a17 (diff)
downloadmsec-6876e18970ce9cfb00f40e11d81bb005badeaafb.tar
msec-6876e18970ce9cfb00f40e11d81bb005badeaafb.tar.gz
msec-6876e18970ce9cfb00f40e11d81bb005badeaafb.tar.bz2
msec-6876e18970ce9cfb00f40e11d81bb005badeaafb.tar.xz
msec-6876e18970ce9cfb00f40e11d81bb005badeaafb.zip
first version
-rwxr-xr-xshare/man.py66
1 files changed, 66 insertions, 0 deletions
diff --git a/share/man.py b/share/man.py
new file mode 100755
index 0000000..ad17a36
--- /dev/null
+++ b/share/man.py
@@ -0,0 +1,66 @@
+#!/usr/bin/python
+#---------------------------------------------------------------
+# Project : Mandrake 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 "Mandrake Linux"
+.SH NAME
+mseclib
+.SH SYNOPSIS
+.nf
+.B from mseclib import *
+.B function1()
+.B function2(arg1)
+.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.
+'''
+
+footer = '''.RE
+.SH "SEE ALSO"
+msec(8)
+.SH AUTHORS
+Frederic Lepied <flepied@mandrakesoft.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