/usr/share/mia-doctools/miaxml2man.py is in libmia-2.2-dev 2.2.7-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | #!/usr/bin/env python
#
# Copyright (c) Leipzig, Madrid 1999-2015 Gert Wollny
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# this program is used to translate the XML files obtained by running a mia-* program
# into a Unix man page.
import sys
import time
import calendar
import string
import htmlentitydefs
import re
sys.dont_write_bytecode = True
modules = {'miareadxml' : [0, '', 'none://miareadxml.py' ]
}
from miareadxml import parse_file
def get_date_string():
lt = time.localtime(time.time())
return "%d %s %d"% (lt.tm_mday, calendar.month_name[lt.tm_mon], lt.tm_year)
#taken from http://effbot.org/zone/re-sub.htm#unescape-html
def unescape(text):
def fixup(m):
text = m.group(0)
if text[:2] == "&#":
# character reference
try:
if text[:3] == "&#x":
return unichr(int(text[3:-1], 16))
else:
return unichr(int(text[2:-1]))
except ValueError:
pass
else:
# named entity
try:
text = unichr(htmlentitydefs.name2codepoint[text[1:-1]])
except KeyError:
pass
return text # leave as is
return re.sub("&#?\w+;", fixup, text)
def escape_dash(text):
return re.sub(r'-', r'\-', text)
def clean (text):
text = unescape(text)
return escape_dash(text)
def write_man_file(descr):
name = escape_dash(descr.name)
print ".TH %s 1 \"v%s\" \"USER COMMANDS\"" %(escape_dash(descr.name), descr.version)
print ".SH NAME"
print name,
print "\- %s" % (clean(descr.whatis))
print ".SH SYNOPSIS"
print ".B %s"% (clean(descr.basic_usage))
print ".SH DESCRIPTION"
print ".B %s"% (name)
print descr.description
print ".SH OPTIONS"
for g in descr.option_groups:
if len(g.name) > 0:
print ".SS %s"% (g.name)
print ".RS"
for o in g.options:
o.print_man()
print ".RE"
handlerkeys = descr.handlers.keys()
handlerkeys.sort()
for k in handlerkeys:
h = descr.handlers[k]
print ".SH PLUGINS: %s" % (h.name)
for p in h.plugins:
print ".TP 10"
print ".B %s" % p.name
if len(p.params) > 0:
print "%s, supported parameters are: " % (p.text)
print ".P"
for o in p.params:
print ".RS 14"
o.print_man()
print ".RE"
else:
print p.text
print ".P"
if not p.no_params_info:
print ".RS 14"
print "(no parameters)"
print ".RE"
if p.suffixes is not None:
print ".RS 14"
print "Recognized file extensions: ", p.suffixes
print ".RE"
print " "
if p.supported_types is not None:
print ".RS 14"
print "Supported element types: "
print ".RS 2"
print p.supported_types
print ".RE"
print " "
print ".RE"
if descr.Example.text is not None and len(descr.Example.text) > 0:
print ".SH EXAMPLE"
print clean(descr.Example.text)
for c in descr.Example.code:
print ".HP"
print "%s %s" % (name, clean(c.text))
print ".SH AUTHOR(s)"
print clean(descr.author)
print ".SH COPYRIGHT"
print """This software is Copyright (c) 1999\(hy2015 Leipzig, Germany and Madrid, Spain.
It comes with ABSOLUTELY NO WARRANTY and you may redistribute it under the terms of the GNU
GENERAL PUBLIC LICENSE Version 3 (or later). For more
information run the program with the option '\-\-copyright'."""
X=parse_file(sys.argv[1])
write_man_file(X)
|