zziplib: Update to 0.13.70
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
_realname=zziplib
|
||||
pkgbase=mingw-w64-${_realname}
|
||||
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
|
||||
pkgver=0.13.69
|
||||
pkgrel=2
|
||||
pkgver=0.13.70
|
||||
pkgrel=1
|
||||
pkgdesc="A lightweight library that offers the ability to easily extract data from files archived in a single zip file (mingw-w64)"
|
||||
arch=('any')
|
||||
url="https://zziplib.sourceforge.io/"
|
||||
@@ -18,27 +18,21 @@ optdepends=("${MINGW_PACKAGE_PREFIX}-SDL: SDL_rwops for ZZipLib")
|
||||
options=('staticlibs' 'strip')
|
||||
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/gdraheim/zziplib/archive/v${pkgver}.tar.gz"
|
||||
"configure.patch"
|
||||
"python3.patch"
|
||||
"python3-more.patch")
|
||||
sha256sums=('846246d7cdeee405d8d21e2922c6e97f55f24ecbe3b6dcf5778073a88f120544'
|
||||
"fix-upstream-merge-hunk.patch")
|
||||
sha256sums=('a1457262d7a237dc50ce1f98ca57242bc714055ff81146f419ee53cdea1bf029'
|
||||
'892162a8535575891663607b8fb5e3be518e8293e9b0f22cf437b1d83a58b008'
|
||||
'67ac4be1ef78790c91488d61cb4cc3ca12905b8bc360ffbaf408b0c89cafbdd2'
|
||||
'bd642d92a35ebad6514400900098a110e05de336452cb6e5e84549bd84b86db5')
|
||||
'ef6da465673997df0fa08789a1e7d9e3809a543bd0d033c3b0bf7b4ccd662fbf')
|
||||
|
||||
prepare() {
|
||||
cd "${srcdir}/${_realname}-${pkgver}"
|
||||
|
||||
patch -Np1 -i ${srcdir}/configure.patch
|
||||
# This is the diff between the last release and current master for *.py
|
||||
patch -Np1 -i ${srcdir}/python3.patch
|
||||
# This is by me to make things actually work
|
||||
patch -Np1 -i ${srcdir}/python3-more.patch
|
||||
patch -Np1 -i ${srcdir}/fix-upstream-merge-hunk.patch
|
||||
|
||||
autoreconf -fiv
|
||||
}
|
||||
|
||||
build() {
|
||||
export PYTHON=${MINGW_PREFIX}/bin/python3
|
||||
export PYTHON=${MINGW_PREFIX}/bin/python
|
||||
export PERL=/usr/bin/perl
|
||||
mkdir -p "${srcdir}/build-${MINGW_CHOST}"
|
||||
cd "${srcdir}/build-${MINGW_CHOST}"
|
||||
|
||||
16
mingw-w64-zziplib/fix-upstream-merge-hunk.patch
Normal file
16
mingw-w64-zziplib/fix-upstream-merge-hunk.patch
Normal file
@@ -0,0 +1,16 @@
|
||||
--- zziplib-0.13.70/docs/zzipdoc/htm2dbk.py.orig 2020-04-25 22:23:05.627353100 +0300
|
||||
+++ zziplib-0.13.70/docs/zzipdoc/htm2dbk.py 2020-04-25 22:23:30.563121400 +0300
|
||||
@@ -146,13 +146,8 @@
|
||||
doc.filename = filename
|
||||
doc.add(f.read())
|
||||
f.close()
|
||||
-<<<<<<< HEAD
|
||||
- except IOError as e:
|
||||
- print >> sys.stderr, "can not open "+filename
|
||||
-=======
|
||||
except IOError:
|
||||
print("can not open "+filename, file=sys.stderr)
|
||||
->>>>>>> develop
|
||||
return doc.value()
|
||||
|
||||
def html2docbook(text):
|
||||
@@ -1,322 +0,0 @@
|
||||
diff -Nur zziplib-0.13.69/docs/zzipdoc.orig/commentmarkup.py zziplib-0.13.69/docs/zzipdoc/commentmarkup.py
|
||||
--- zziplib-0.13.69/docs/zzipdoc.orig/commentmarkup.py 2020-03-27 16:43:54.977560900 +0100
|
||||
+++ zziplib-0.13.69/docs/zzipdoc/commentmarkup.py 2020-03-27 16:45:09.617584400 +0100
|
||||
@@ -1,4 +1,4 @@
|
||||
-from match import Match
|
||||
+from .match import Match
|
||||
|
||||
def markup_link_syntax(text):
|
||||
""" markup the link-syntax ` => somewhere ` in the text block """
|
||||
diff -Nur zziplib-0.13.69/docs/zzipdoc.orig/dbk2htm.py zziplib-0.13.69/docs/zzipdoc/dbk2htm.py
|
||||
--- zziplib-0.13.69/docs/zzipdoc.orig/dbk2htm.py 2018-03-17 13:46:45.000000000 +0100
|
||||
+++ zziplib-0.13.69/docs/zzipdoc/dbk2htm.py 2020-03-27 16:48:33.767813900 +0100
|
||||
@@ -1,4 +1,4 @@
|
||||
-from match import Match
|
||||
+from .match import Match
|
||||
import string
|
||||
|
||||
class dbk2htm_conversion:
|
||||
diff -Nur zziplib-0.13.69/docs/zzipdoc.orig/docbookdocument.py zziplib-0.13.69/docs/zzipdoc/docbookdocument.py
|
||||
--- zziplib-0.13.69/docs/zzipdoc.orig/docbookdocument.py 2020-03-27 16:41:51.781269500 +0100
|
||||
+++ zziplib-0.13.69/docs/zzipdoc/docbookdocument.py 2020-03-27 16:51:53.669073400 +0100
|
||||
@@ -1,6 +1,6 @@
|
||||
#! /usr/bin/env python
|
||||
# -*- coding: UTF-8 -*-
|
||||
-from match import Match
|
||||
+from .match import Match
|
||||
|
||||
class DocbookDocument:
|
||||
""" binds some xml content page with additional markup - in this
|
||||
@@ -30,7 +30,7 @@
|
||||
def _xml_text(self, xml):
|
||||
""" accepts adapter objects with .xml_text() """
|
||||
try: return xml.xml_text()
|
||||
- except Exception as e: print "DocbookDocument/text", e; pass
|
||||
+ except Exception as e: print("DocbookDocument/text", e); pass
|
||||
return str(xml)
|
||||
def _fetch_rootnode(self, text):
|
||||
fetch = Match(r"^[^<>]*<(\w+)\b")
|
||||
@@ -47,7 +47,7 @@
|
||||
return filename
|
||||
def save(self, filename = None):
|
||||
filename = self._filename(filename)
|
||||
- print "writing '"+filename+"'"
|
||||
+ print("writing '"+filename+"'")
|
||||
if len(self.text) > 1:
|
||||
self.save_all(filename)
|
||||
else:
|
||||
@@ -58,12 +58,12 @@
|
||||
xml_text = self._xml_text(text)
|
||||
rootnode = self._fetch_rootnode(xml_text)
|
||||
doctype = self._xml_doctype(rootnode)
|
||||
- print >>fd, doctype
|
||||
- print >>fd, xml_text
|
||||
+ print(doctype, file=fd)
|
||||
+ print(xml_text, file=fd)
|
||||
fd.close()
|
||||
return True
|
||||
except IOError as e:
|
||||
- print "could not open '"+filename+"'file", e
|
||||
+ print("could not open '"+filename+"'file", e)
|
||||
return False
|
||||
def save_all(self, filename):
|
||||
assert len(self.text) > 1
|
||||
@@ -76,20 +76,20 @@
|
||||
else:
|
||||
rootnode = self.rootnode
|
||||
doctype = self._xml_doctype(rootnode)
|
||||
- print >>fd, doctype
|
||||
+ print(doctype, file=fd)
|
||||
title = self.get_title()
|
||||
if title and self.rootnode in self.has_title_child:
|
||||
- print >>fd, "<"+self.rootnode+'><title>'+title+'</title>'
|
||||
+ print("<"+self.rootnode+'><title>'+title+'</title>', file=fd)
|
||||
elif title:
|
||||
- print >>fd, "<"+self.rootnode+' id="'+title+'">'
|
||||
+ print("<"+self.rootnode+' id="'+title+'">', file=fd)
|
||||
else:
|
||||
- print >>fd, "<"+self.rootnode+'>'
|
||||
+ print("<"+self.rootnode+'>', file=fd)
|
||||
for text in self.text:
|
||||
text = self._xml_text(text)
|
||||
- print >>fd, text
|
||||
- print >>fd, "</"+self.rootnode+">"
|
||||
+ print(text, file=fd)
|
||||
+ print("</"+self.rootnode+">", file=fd)
|
||||
fd.close()
|
||||
return True
|
||||
except IOError as e:
|
||||
- print "could not open '"+filename+"'file", e
|
||||
+ print("could not open '"+filename+"'file", e)
|
||||
return False
|
||||
diff -Nur zziplib-0.13.69/docs/zzipdoc.orig/functionheader.py zziplib-0.13.69/docs/zzipdoc/functionheader.py
|
||||
--- zziplib-0.13.69/docs/zzipdoc.orig/functionheader.py 2018-03-17 13:46:45.000000000 +0100
|
||||
+++ zziplib-0.13.69/docs/zzipdoc/functionheader.py 2020-03-27 16:44:54.896848300 +0100
|
||||
@@ -1,4 +1,4 @@
|
||||
-from match import Match
|
||||
+from .match import Match
|
||||
|
||||
class FunctionHeader:
|
||||
""" parsing the comment block that is usually presented before
|
||||
diff -Nur zziplib-0.13.69/docs/zzipdoc.orig/functionlisthtmlpage.py zziplib-0.13.69/docs/zzipdoc/functionlisthtmlpage.py
|
||||
--- zziplib-0.13.69/docs/zzipdoc.orig/functionlisthtmlpage.py 2020-03-27 16:41:51.782276800 +0100
|
||||
+++ zziplib-0.13.69/docs/zzipdoc/functionlisthtmlpage.py 2020-03-27 16:45:40.325021000 +0100
|
||||
@@ -1,5 +1,5 @@
|
||||
-from options import *
|
||||
-from match import Match
|
||||
+from .options import *
|
||||
+from .match import Match
|
||||
|
||||
class FunctionListHtmlPage:
|
||||
""" The main part here is to create a TOC (table of contents) at the
|
||||
@@ -35,7 +35,7 @@
|
||||
head_text = entry.head_xml_text()
|
||||
body_text = entry.body_xml_text(name)
|
||||
if not head_text:
|
||||
- print "no head_text for", name
|
||||
+ print("no head_text for", name)
|
||||
return
|
||||
try:
|
||||
prespec = entry.head_get_prespec()
|
||||
@@ -102,7 +102,7 @@
|
||||
text &= (Match("(?s)<link>(\w+)</link>")
|
||||
>> (lambda x: self.resolve_internal(x.group(1))))
|
||||
if len(self.not_found_in_anchors):
|
||||
- print "not found in anchors: ", self.not_found_in_anchors
|
||||
+ print("not found in anchors: ", self.not_found_in_anchors)
|
||||
return (text & Match("(?s)<link>([^<>]*)</link>")
|
||||
>> "<code>\\1</code>")
|
||||
def resolve_external(self, func, sect):
|
||||
diff -Nur zziplib-0.13.69/docs/zzipdoc.orig/functionlistreference.py zziplib-0.13.69/docs/zzipdoc/functionlistreference.py
|
||||
--- zziplib-0.13.69/docs/zzipdoc.orig/functionlistreference.py 2018-03-17 13:46:45.000000000 +0100
|
||||
+++ zziplib-0.13.69/docs/zzipdoc/functionlistreference.py 2020-03-27 16:46:12.464598200 +0100
|
||||
@@ -1,7 +1,7 @@
|
||||
#! /usr/bin/env python
|
||||
# -*- coding: UTF-8 -*-
|
||||
-from match import Match
|
||||
-from htm2dbk import *
|
||||
+from .match import Match
|
||||
+from .htm2dbk import *
|
||||
|
||||
class FunctionListReference:
|
||||
""" Creating a docbook-style <reference> list of <refentry> parts
|
||||
@@ -19,7 +19,7 @@
|
||||
description = entry.body_xml_text(name)
|
||||
funcsynopsis = entry.head_xml_text()
|
||||
if not funcsynopsis:
|
||||
- print "no funcsynopsis for", name
|
||||
+ print("no funcsynopsis for", name)
|
||||
return
|
||||
if self.entry is None:
|
||||
self.entry = FunctionListRefEntry(entry, self.o)
|
||||
diff -Nur zziplib-0.13.69/docs/zzipdoc.orig/functionprototype.py zziplib-0.13.69/docs/zzipdoc/functionprototype.py
|
||||
--- zziplib-0.13.69/docs/zzipdoc.orig/functionprototype.py 2018-03-17 13:46:45.000000000 +0100
|
||||
+++ zziplib-0.13.69/docs/zzipdoc/functionprototype.py 2020-03-27 16:45:02.976858300 +0100
|
||||
@@ -1,4 +1,4 @@
|
||||
-from match import Match
|
||||
+from .match import Match
|
||||
|
||||
class FunctionPrototype:
|
||||
""" takes a single function prototype line (cut from some source file)
|
||||
diff -Nur zziplib-0.13.69/docs/zzipdoc.orig/htm2dbk.py zziplib-0.13.69/docs/zzipdoc/htm2dbk.py
|
||||
--- zziplib-0.13.69/docs/zzipdoc.orig/htm2dbk.py 2020-03-27 16:41:51.783765600 +0100
|
||||
+++ zziplib-0.13.69/docs/zzipdoc/htm2dbk.py 2020-03-27 16:47:11.103389500 +0100
|
||||
@@ -7,7 +7,7 @@
|
||||
present in the world of docbook-to-anything converters. """
|
||||
|
||||
from datetime import date
|
||||
-import match
|
||||
+from . import match
|
||||
import sys
|
||||
|
||||
m = match.Match
|
||||
@@ -147,7 +147,7 @@
|
||||
doc.add(f.read())
|
||||
f.close()
|
||||
except IOError as e:
|
||||
- print >> sys.stderr, "can not open "+filename
|
||||
+ print("can not open "+filename, file=sys.stderr)
|
||||
return doc.value()
|
||||
|
||||
def html2docbook(text):
|
||||
@@ -155,4 +155,4 @@
|
||||
return htm2dbk_conversion().convert2(text)
|
||||
|
||||
if __name__ == "__main__":
|
||||
- print htm2dbk_files(sys.argv[1:])
|
||||
+ print(htm2dbk_files(sys.argv[1:]))
|
||||
diff -Nur zziplib-0.13.69/docs/zzipdoc.orig/htmldocument.py zziplib-0.13.69/docs/zzipdoc/htmldocument.py
|
||||
--- zziplib-0.13.69/docs/zzipdoc.orig/htmldocument.py 2020-03-27 16:41:51.785145000 +0100
|
||||
+++ zziplib-0.13.69/docs/zzipdoc/htmldocument.py 2020-03-27 16:49:53.920431000 +0100
|
||||
@@ -1,6 +1,6 @@
|
||||
#! /usr/bin/env python
|
||||
# -*- coding: UTF-8 -*-
|
||||
-from match import Match
|
||||
+from .match import Match
|
||||
|
||||
class HtmlDocument:
|
||||
""" binds some html content page with additional markup - in this
|
||||
@@ -42,18 +42,18 @@
|
||||
try: return style.html_style()
|
||||
except Exception as e: ee = e; pass
|
||||
try: return style.xml_style()
|
||||
- except Exception as e: print "HtmlDocument/style", ee, e; pass
|
||||
+ except Exception as e: print("HtmlDocument/style", ee, e); pass
|
||||
try: return str(style)
|
||||
- except Exception as e: print "HtmlDocument/style", e; return ""
|
||||
+ except Exception as e: print("HtmlDocument/style", e); return ""
|
||||
def _html_text(self, html):
|
||||
""" accepts adapter objects with .html_text() and .xml_text() """
|
||||
ee = None
|
||||
try: return html.html_text()
|
||||
except Exception as e: ee = e; pass
|
||||
try: return html.xml_text()
|
||||
- except Exception as e: print "HtmlDocument/text", ee, e; pass
|
||||
+ except Exception as e: print("HtmlDocument/text", ee, e); pass
|
||||
try: return str(html)
|
||||
- except Exception as e: print "HtmlDocument/text", e; return " "
|
||||
+ except Exception as e: print("HtmlDocument/text", e); return " "
|
||||
def navigation(self):
|
||||
if self.navi:
|
||||
return self.navi
|
||||
@@ -103,15 +103,15 @@
|
||||
return filename
|
||||
def save(self, filename = None):
|
||||
filename = self._filename(filename)
|
||||
- print "writing '"+filename+"'"
|
||||
+ print("writing '"+filename+"'")
|
||||
try:
|
||||
fd = open(filename, "w")
|
||||
- print >>fd, self.html_header()
|
||||
+ print(self.html_header(), file=fd)
|
||||
for text in self.text:
|
||||
- print >>fd, self._html_text(text)
|
||||
- print >>fd, self.html_footer()
|
||||
+ print(self._html_text(text), file=fd)
|
||||
+ print(self.html_footer(), file=fd)
|
||||
fd.close()
|
||||
return True
|
||||
except IOError as e:
|
||||
- print "could not open '"+filename+"'file", e
|
||||
+ print("could not open '"+filename+"'file", e)
|
||||
return False
|
||||
diff -Nur zziplib-0.13.69/docs/zzipdoc.orig/match.py zziplib-0.13.69/docs/zzipdoc/match.py
|
||||
--- zziplib-0.13.69/docs/zzipdoc.orig/match.py 2020-03-27 16:41:51.799021400 +0100
|
||||
+++ zziplib-0.13.69/docs/zzipdoc/match.py 2020-03-27 16:48:13.357609400 +0100
|
||||
@@ -18,7 +18,7 @@
|
||||
MatchReplace.__call__(self, matching, template, count, flags)
|
||||
def __call__(self, matching, template = None, count = 0, flags = None):
|
||||
""" other than __init__ the template may be left off to be unchanged"""
|
||||
- if isinstance(count, basestring): # count/flags swapped over?
|
||||
+ if isinstance(count, str): # count/flags swapped over?
|
||||
flags = count; count = 0
|
||||
if isinstance(matching, Match):
|
||||
self.matching = matching
|
||||
@@ -57,7 +57,7 @@
|
||||
def __call__(self, pattern, flags = None):
|
||||
assert isinstance(pattern, str) or pattern is None
|
||||
assert isinstance(flags, str) or flags is None
|
||||
- str.__init__(self, pattern)
|
||||
+ str.__init__(self)
|
||||
self.replaced = 0 # set by subn() inside MatchReplace
|
||||
self.found = None # set by search() to a MatchObject
|
||||
self.pattern = pattern
|
||||
diff -Nur zziplib-0.13.69/docs/zzipdoc.orig/options.py zziplib-0.13.69/docs/zzipdoc/options.py
|
||||
--- zziplib-0.13.69/docs/zzipdoc.orig/options.py 2020-03-27 16:43:56.274426500 +0100
|
||||
+++ zziplib-0.13.69/docs/zzipdoc/options.py 2020-03-27 16:51:31.203008500 +0100
|
||||
@@ -3,13 +3,13 @@
|
||||
# @creator (C) 2003 Guido U. Draheim
|
||||
# @license http://creativecommons.org/licenses/by-nc-sa/2.0/de/
|
||||
|
||||
-from match import Match
|
||||
+from .match import Match
|
||||
|
||||
# use as o.optionname to check for commandline options.
|
||||
class Options:
|
||||
var = {}
|
||||
def __getattr__(self, name):
|
||||
- if not self.var.has_key(name): return None
|
||||
+ if name not in self.var: return None
|
||||
return self.var[name]
|
||||
def __setattr__(self, name, value):
|
||||
self.var[name] = value
|
||||
diff -Nur zziplib-0.13.69/docs/zzipdoc.orig/textfileheader.py zziplib-0.13.69/docs/zzipdoc/textfileheader.py
|
||||
--- zziplib-0.13.69/docs/zzipdoc.orig/textfileheader.py 2018-03-17 13:46:45.000000000 +0100
|
||||
+++ zziplib-0.13.69/docs/zzipdoc/textfileheader.py 2020-03-27 16:44:46.583362100 +0100
|
||||
@@ -1,4 +1,4 @@
|
||||
-from match import Match
|
||||
+from .match import Match
|
||||
|
||||
class TextFileHeader:
|
||||
""" scan for a comment block at the source file start and fill the
|
||||
@@ -17,7 +17,7 @@
|
||||
x = Match()
|
||||
text = self.textfile.get_src_text()
|
||||
if not text:
|
||||
- print "nonexistent file:", self.textfile.get_filename()
|
||||
+ print("nonexistent file:", self.textfile.get_filename())
|
||||
return False
|
||||
if text & x(r"(?s)[/][*]+(\s(?:.(?!\*\/))*.)\*\/"
|
||||
r"(?:\s*\#(?:define|ifdef|endif)[ ]*\S*[ ]*\S*)*"
|
||||
--- zziplib-0.13.69/docs/zzipdoc/match.py.orig 2018-03-17 13:46:45.000000000 +0100
|
||||
+++ zziplib-0.13.69/docs/zzipdoc/match.py 2020-03-27 16:41:02.379001800 +0100
|
||||
@@ -90,14 +90,14 @@
|
||||
if __name__ == "__main__":
|
||||
# matching:
|
||||
if "foo" & Match("oo"):
|
||||
- print "oo"
|
||||
+ print("oo")
|
||||
x = Match()
|
||||
if "foo" & x("(o+)"):
|
||||
- print x[1]
|
||||
+ print(x[1])
|
||||
# replacing:
|
||||
y = "fooboo" & Match("oo") >> "ee"
|
||||
- print y
|
||||
+ print(y)
|
||||
r = Match("oo") >> "ee"
|
||||
- print "fooboo" & r
|
||||
+ print("fooboo" & r)
|
||||
s = MatchReplace("oo", "ee")
|
||||
- print "fooboo" & s
|
||||
+ print("fooboo" & s)
|
||||
@@ -1,813 +0,0 @@
|
||||
diff -Nur zziplib-0.13.69/docs/dbk2man.py zziplib-master/docs/dbk2man.py
|
||||
--- zziplib-0.13.69/docs/dbk2man.py 2018-03-17 13:46:45.000000000 +0100
|
||||
+++ zziplib-master/docs/dbk2man.py 2019-08-04 20:00:21.000000000 +0200
|
||||
@@ -1,4 +1,6 @@
|
||||
#! /usr/bin/python
|
||||
+from __future__ import print_function
|
||||
+
|
||||
""" Converts an xml-file with docbook elements into troff manual pages.
|
||||
The conversion uses etree expecting <refentry> elements in the input.
|
||||
The output goes to a multiple files in manX/* subdirectories.
|
||||
@@ -9,22 +11,52 @@
|
||||
import logging
|
||||
import os.path
|
||||
import re
|
||||
+import collections
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
logg = logging.getLogger("dbk2man")
|
||||
|
||||
+def esc(text):
|
||||
+ text = str(text)
|
||||
+ text = text.replace(".", "\\&.")
|
||||
+ text = text.replace("-", "\\-")
|
||||
+ return text
|
||||
+def unescape(text):
|
||||
+ text = str(text)
|
||||
+ text = text.replace('<', '<')
|
||||
+ text = text.replace('>', '>')
|
||||
+ text = text.replace('"', '"')
|
||||
+ text = text.replace('&', '&')
|
||||
+ return text
|
||||
+def htm(text):
|
||||
+ text = str(text)
|
||||
+ text = text.replace('&', '&')
|
||||
+ text = text.replace('<', '<')
|
||||
+ text = text.replace('>', '>')
|
||||
+ text = text.replace('"', '"')
|
||||
+ return text
|
||||
+def mailhref(text):
|
||||
+ return re.sub("<([^<>]*@[^<>]*)>",
|
||||
+ lambda x: '<<a href="mailto:%s">%s</a>>' % (x.group(1), x.group(1)),
|
||||
+ text)
|
||||
+
|
||||
+OverviewEntry = collections.namedtuple("OverviewEntry", ["manpage", "manvolnum", "refpurpose"])
|
||||
+
|
||||
def parse_docbook(filename):
|
||||
tree = ET.parse(filename)
|
||||
return tree.getroot()
|
||||
|
||||
-def dbk2man(filename, subdirectory = "."):
|
||||
- root = parse_docbook(filename)
|
||||
- return docbook2man(root, subdirectory)
|
||||
+def dbk2(man, filenames, subdirectory = "."):
|
||||
+ for filename in filenames:
|
||||
+ root = parse_docbook(filename)
|
||||
+ overview = docbook2(man, root, subdirectory)
|
||||
+ overview2(man, overview, subdirectory, filename)
|
||||
|
||||
-def docbook2man(root, subdirectory = "."):
|
||||
+def docbook2(man, root, subdirectory = "."):
|
||||
if root.tag != "reference":
|
||||
logg.warning("no <reference> found, not a docbook file?")
|
||||
logg.warning("found <%s> instead", root.tag)
|
||||
+ overview = {}
|
||||
title = ""
|
||||
for refentry in root:
|
||||
if refentry.tag == 'title':
|
||||
@@ -34,21 +66,12 @@
|
||||
logg.warning("no <refentry> list found, not a docbook file?")
|
||||
logg.warning("found <%s> instead", refentry.tag)
|
||||
continue
|
||||
- refentry2man(refentry, subdirectory, title)
|
||||
+ overviewref = refentry2(man, refentry, subdirectory, title)
|
||||
+ for filename, overviewentry in overviewref.items():
|
||||
+ overview[filename] = overviewentry
|
||||
+ return overview
|
||||
|
||||
-def esc(text):
|
||||
- text = text.replace(".", "\\&.")
|
||||
- text = text.replace("-", "\\-")
|
||||
- return text
|
||||
-def unescape(text):
|
||||
- text = text.replace('<', '<')
|
||||
- text = text.replace('>', '>')
|
||||
- text = text.replace('"', '"')
|
||||
- text = text.replace('&', '&')
|
||||
- return text
|
||||
-
|
||||
-
|
||||
-def refentryinfo2(refentry, title):
|
||||
+def refentryinfo2(man, refentry, title):
|
||||
date, productname, manvolnum, refentrytitle = "", "", "", ""
|
||||
section = refentry.find("refentryinfo")
|
||||
if section is not None:
|
||||
@@ -62,24 +85,38 @@
|
||||
if found is not None: refentrytitle = found.text
|
||||
found = section.find("manvolnum")
|
||||
if found is not None: manvolnum = found.text
|
||||
- header = []
|
||||
- if refentrytitle:
|
||||
- header += [ refentrytitle ]
|
||||
- if manvolnum:
|
||||
- header += [ manvolnum ]
|
||||
- if date:
|
||||
- header += [ date ]
|
||||
- if productname:
|
||||
- header += [ productname ]
|
||||
- if title:
|
||||
- header += [ title ]
|
||||
- if header:
|
||||
+ if man:
|
||||
+ header = []
|
||||
+ if refentrytitle:
|
||||
+ header += [ refentrytitle ]
|
||||
+ if manvolnum:
|
||||
+ header += [ manvolnum ]
|
||||
+ if date:
|
||||
+ header += [ date ]
|
||||
+ if productname:
|
||||
+ header += [ productname ]
|
||||
+ if title:
|
||||
+ header += [ title ]
|
||||
+ if not header:
|
||||
+ logg.warning("no <refmeta> found")
|
||||
+ return ""
|
||||
text = '.TH ' + " ".join([ '"%s"' % esc(part) for part in header])
|
||||
return text + "\n"
|
||||
- logg.warning("no <refmeta> found")
|
||||
- return ""
|
||||
+ else:
|
||||
+ text = "<html><head><title>"
|
||||
+ if productname or title:
|
||||
+ text += "%s: " % htm(productname or title)
|
||||
+ text += htm(refentrytitle)
|
||||
+ if manvolnum:
|
||||
+ text += "(%s)" % htm(manvolnum)
|
||||
+ text += "</title>"
|
||||
+ text += "\n" + '<meta name="product" content="%s" />' % htm(productname or title)
|
||||
+ text += "\n" + '<meta name="refentry" content="%s" />' % htm(refentrytitle)
|
||||
+ text += "\n" + '<meta name="manvolnum" content="%s" />' % htm(manvolnum)
|
||||
+ text += "\n" + '<meta name="date" content="%s" />' % htm(date)
|
||||
+ return text + "\n</head><body>\n"
|
||||
|
||||
-def refentrytitle2(refentry, title = ""):
|
||||
+def refentrytitle2(man, refentry, title = ""):
|
||||
refentrytitle = ""
|
||||
section = refentry.find("refmeta")
|
||||
if section is not None:
|
||||
@@ -95,89 +132,170 @@
|
||||
refname = found.text
|
||||
if refname not in refentries:
|
||||
refentries.append(refname)
|
||||
- if refentrytitle:
|
||||
+ if not refentrytitle:
|
||||
+ logg.warning("no <refentrytitle> found")
|
||||
+ return ""
|
||||
+ elif man:
|
||||
text = '.SH "NAME"' + "\n"
|
||||
text += "" + esc(", ".join(refentries))
|
||||
text += " " + esc("-")
|
||||
text += " " + esc(refpurpose)
|
||||
return text + "\n"
|
||||
- logg.warning("no <refentrytitle> found")
|
||||
- return ""
|
||||
-
|
||||
+ else:
|
||||
+ text = '<h3>Name</h3>' + "\n"
|
||||
+ text += "<p>" + htm(", ".join(refentries))
|
||||
+ text += " " + htm("-")
|
||||
+ text += " " + htm(refpurpose)
|
||||
+ text += "</p>"
|
||||
+ return text + "\n"
|
||||
|
||||
-def refsynopsisdiv2(refentry, title = ""):
|
||||
- section = refentry.find("refsynopsisdiv")
|
||||
- if section is not None:
|
||||
- text = '.SH "SYNOPSIS"' + "\n"
|
||||
- text += ".sp\n"
|
||||
- text += ".nf\n"
|
||||
- for funcsynopsis in section.findall("funcsynopsis"):
|
||||
- funcsynopsisinfo = ""
|
||||
- found = funcsynopsis.find("funcsynopsisinfo")
|
||||
- if found is not None: funcsynopsisinfo = found.text
|
||||
- if funcsynopsisinfo:
|
||||
- for info in funcsynopsisinfo.split("\n"):
|
||||
- text += '.B "%s"' % esc(info)
|
||||
- text += "\n"
|
||||
- text += ".sp" + "\n"
|
||||
- else:
|
||||
- logg.debug("no <funcsynopsisinfo> found")
|
||||
- logg.debug("\n%s", ET.tostring(funcsynopsis))
|
||||
- funcs = 0
|
||||
- for funcprototype in funcsynopsis.findall("funcprototype"):
|
||||
- item = ET.tostring(funcprototype)
|
||||
- item = item.replace("<funcprototype>","")
|
||||
- item = item.replace("</funcprototype>","")
|
||||
- if False:
|
||||
- item = item.replace("\n", " ")
|
||||
- item = item.replace("<funcdef>","")
|
||||
- item = item.replace("</funcdef>","")
|
||||
- item = item.replace("<paramdef>",'<def>')
|
||||
- item = item.replace("</paramdef>",'<def>')
|
||||
- items = item.split("<def>")
|
||||
- text += '.BI %s' % " ".join(['"%s"' % part for part in items if part])
|
||||
- else:
|
||||
- item = item.replace("<funcdef>","")
|
||||
- item = re.sub(r"([_\w]+)</funcdef>", lambda x: "\\fI%s\\fR" % x.group(1), item)
|
||||
- item = item.replace("<paramdef>",'')
|
||||
- item = item.replace("</paramdef>",'')
|
||||
- text += item
|
||||
+def refsynopsisdiv2(man, refentry, title = ""):
|
||||
+ refsynopsisdiv = refentry.find("refsynopsisdiv")
|
||||
+ if refsynopsisdiv is None:
|
||||
+ logg.warning("no <resynopsisdiv> found")
|
||||
+ return ""
|
||||
+ if man:
|
||||
+ return refsynopsisdiv2man(refsynopsisdiv, title)
|
||||
+ else:
|
||||
+ return refsynopsisdiv2htm(refsynopsisdiv, title)
|
||||
+
|
||||
+def refsynopsisdiv2man(refsynopsisdiv, title = ""):
|
||||
+ text = '.SH "SYNOPSIS"' + "\n"
|
||||
+ text += ".sp\n"
|
||||
+ text += ".nf\n"
|
||||
+ for funcsynopsis in refsynopsisdiv.findall("funcsynopsis"):
|
||||
+ funcsynopsisinfo = ""
|
||||
+ found = funcsynopsis.find("funcsynopsisinfo")
|
||||
+ if found is not None: funcsynopsisinfo = found.text
|
||||
+ if funcsynopsisinfo:
|
||||
+ for info in funcsynopsisinfo.split("\n"):
|
||||
+ text += '.B "%s"' % esc(info)
|
||||
text += "\n"
|
||||
- funcs += 1
|
||||
- if not funcs:
|
||||
- logg.warning("no <funcprototype> found")
|
||||
- logg.warning("\n%s", ET.tostring(funcsynopsis))
|
||||
- text += ".fi" + "\n"
|
||||
text += ".sp" + "\n"
|
||||
- return text
|
||||
- logg.warning("no <resynopsidiv> found")
|
||||
- return ""
|
||||
+ else:
|
||||
+ logg.debug("no <funcsynopsisinfo> found")
|
||||
+ logg.debug("\n%s", ET.tostring(funcsynopsis))
|
||||
+ funcs = 0
|
||||
+ for funcprototype in funcsynopsis.findall("funcprototype"):
|
||||
+ item = ET.tostring(funcprototype)
|
||||
+ item = str(item)
|
||||
+ item = item.replace("<funcprototype>","")
|
||||
+ item = item.replace("</funcprototype>","")
|
||||
+ if False:
|
||||
+ item = item.replace("\n", " ")
|
||||
+ item = item.replace("<funcdef>","")
|
||||
+ item = item.replace("</funcdef>","")
|
||||
+ item = item.replace("<paramdef>",'<def>')
|
||||
+ item = item.replace("</paramdef>",'<def>')
|
||||
+ items = item.split("<def>")
|
||||
+ text += '.BI %s' % " ".join(['"%s"' % part for part in items if part])
|
||||
+ else:
|
||||
+ item = item.replace("<funcdef>","")
|
||||
+ item = re.sub(r"([_\w]+)</funcdef>", lambda x: "\\fI%s\\fR" % x.group(1), item)
|
||||
+ item = item.replace("<paramdef>",'')
|
||||
+ item = item.replace("</paramdef>",'')
|
||||
+ text += item
|
||||
+ text += "\n"
|
||||
+ funcs += 1
|
||||
+ if not funcs:
|
||||
+ logg.warning("no <funcprototype> found")
|
||||
+ logg.warning("\n%s", ET.tostring(funcsynopsis))
|
||||
+ text += ".fi" + "\n"
|
||||
+ text += ".sp" + "\n"
|
||||
+ return text
|
||||
|
||||
-def refsections2(refentry, title = ""):
|
||||
+def refsynopsisdiv2htm(refsynopsisdiv, title = ""):
|
||||
+ text = '<h3>Synopsis</h3>' + "\n"
|
||||
+ text += '<pre>' + "\n"
|
||||
+ for funcsynopsis in refsynopsisdiv.findall("funcsynopsis"):
|
||||
+ funcsynopsisinfo = ""
|
||||
+ found = funcsynopsis.find("funcsynopsisinfo")
|
||||
+ if found is not None: funcsynopsisinfo = found.text
|
||||
+ if funcsynopsisinfo:
|
||||
+ for info in funcsynopsisinfo.split("\n"):
|
||||
+ text += '<b>%s</b>' % htm(info)
|
||||
+ text += "\n"
|
||||
+ text += "\n"
|
||||
+ else:
|
||||
+ logg.debug("no <funcsynopsisinfo> found")
|
||||
+ logg.debug("\n%s", ET.tostring(funcsynopsis))
|
||||
+ funcs = 0
|
||||
+ for funcprototype in funcsynopsis.findall("funcprototype"):
|
||||
+ item = ET.tostring(funcprototype)
|
||||
+ item = str(item)
|
||||
+ item = item.replace("<funcprototype>","")
|
||||
+ item = item.replace("</funcprototype>","")
|
||||
+ item = item.replace("<funcdef>","")
|
||||
+ item = re.sub(r"([_\w]+)</funcdef>", lambda x: "<b>%s</b>" % x.group(1), item)
|
||||
+ item = item.replace("<paramdef>",'')
|
||||
+ item = item.replace("</paramdef>",'')
|
||||
+ text += item
|
||||
+ text += "\n"
|
||||
+ funcs += 1
|
||||
+ if not funcs:
|
||||
+ logg.warning("no <funcprototype> found")
|
||||
+ logg.warning("\n%s", ET.tostring(funcsynopsis))
|
||||
+ text += "</pre>" + "\n"
|
||||
+ return text
|
||||
+
|
||||
+def refsections2(man, refentry, title = ""):
|
||||
text = ""
|
||||
for refsect in refentry.findall("refsect1"):
|
||||
- head = refsect.find("title")
|
||||
- if head is not None:
|
||||
- text += '.SH "%s"' % (esc(head.text.upper()))
|
||||
- text += "\n"
|
||||
- for para in list(refsect):
|
||||
- if para.tag == 'title':
|
||||
- continue
|
||||
- if para.tag == 'para':
|
||||
- text += cleanpara(para) + "\n"
|
||||
+ if man:
|
||||
+ text += refsect2man(refsect, title)
|
||||
+ text += ".sp\n"
|
||||
+ else:
|
||||
+ text += refsect2htm(refsect, title)
|
||||
+ return text
|
||||
+
|
||||
+
|
||||
+def refsect2man(refsect, title = ""):
|
||||
+ text = ""
|
||||
+ head = refsect.find("title")
|
||||
+ if head is not None:
|
||||
+ text += '.SH "%s"' % (esc(head.text.upper()))
|
||||
+ text += "\n"
|
||||
+ for para in list(refsect):
|
||||
+ if para.tag == 'title':
|
||||
+ continue
|
||||
+ if para.tag == 'para':
|
||||
+ text += para2man(para) + "\n"
|
||||
+ text += ".sp\n"
|
||||
+ continue
|
||||
+ if para.tag == 'itemizedlist':
|
||||
+ for item in list(para):
|
||||
+ text += para2man(item) + "\n"
|
||||
text += ".sp\n"
|
||||
- continue
|
||||
- if para.tag == 'itemizedlist':
|
||||
- for item in list(para):
|
||||
- text += cleanpara(item) + "\n"
|
||||
- text += ".sp\n"
|
||||
- continue
|
||||
- logg.warning("unknown para <%s>", para.tag)
|
||||
- text += ".sp\n"
|
||||
+ continue
|
||||
+ logg.warning("unknown para <%s>", para.tag)
|
||||
+ return text
|
||||
+
|
||||
+def refsect2htm(refsect, title = ""):
|
||||
+ text = ""
|
||||
+ head = refsect.find("title")
|
||||
+ if head is not None:
|
||||
+ text += '<h3>%s</h3>' % htm(head.text)
|
||||
+ text += "\n"
|
||||
+ for para in list(refsect):
|
||||
+ if para.tag == 'title':
|
||||
+ continue
|
||||
+ if para.tag == 'para':
|
||||
+ text += "<p>" + para2htm(para)
|
||||
+ text += "</p>" + "\n"
|
||||
+ continue
|
||||
+ if para.tag == 'itemizedlist':
|
||||
+ text += "<ul>" + "\n"
|
||||
+ for item in list(para):
|
||||
+ text += "<li><p>" + para2htm(item)
|
||||
+ text += "</p></li>" + "\n"
|
||||
+ text += "</ul>" + "\n"
|
||||
+ continue
|
||||
+ logg.warning("unknown para <%s>", para.tag)
|
||||
return text
|
||||
|
||||
-def cleanpara(para):
|
||||
+def para2man(para):
|
||||
item = unescape(ET.tostring(para))
|
||||
+ item = str(item)
|
||||
item = item.replace("\n", " ")
|
||||
item = item.replace(" ", " ")
|
||||
item = item.replace(" ", " ")
|
||||
@@ -193,24 +311,53 @@
|
||||
item = item.replace("</literal>", "\\fP")
|
||||
return item
|
||||
|
||||
-def styleinfo():
|
||||
- styles = []
|
||||
- styles += [ ".ie \\n(.g .ds Aq \\(aq" ]
|
||||
- styles += [ ".el .ds Aq " ] # http://bugs.debian.org/507673
|
||||
- styles += [ ".nh" ] # disable hyphenation
|
||||
- styles += [ ".ad l" ] # align left, no justification
|
||||
- return "".join([ "%s\n" % part for part in styles ])
|
||||
+def para2htm(para):
|
||||
+ item = unescape(ET.tostring(para))
|
||||
+ item = str(item)
|
||||
+ item = item.replace("\n", " ")
|
||||
+ item = item.replace(" ", " ")
|
||||
+ item = item.replace(" ", " ")
|
||||
+ item = item.replace(" ", " ")
|
||||
+ item = item.replace(" ", " ")
|
||||
+ item = item.replace("<listitem>", "")
|
||||
+ item = item.replace("</listitem>", "")
|
||||
+ item = item.replace("<para>", "")
|
||||
+ item = item.replace("</para>", "")
|
||||
+ item = item.replace("<function>", "<em><code>")
|
||||
+ item = item.replace("</function>", "</code></em>")
|
||||
+ item = item.replace("<literal>", "<code>")
|
||||
+ item = item.replace("</literal>", "</code>")
|
||||
+ item = mailhref(item)
|
||||
+ return item
|
||||
+
|
||||
+def styleinfo2(man):
|
||||
+ if man:
|
||||
+ styles = []
|
||||
+ styles += [ ".ie \\n(.g .ds Aq \\(aq" ]
|
||||
+ styles += [ ".el .ds Aq " ] # http://bugs.debian.org/507673
|
||||
+ styles += [ ".nh" ] # disable hyphenation
|
||||
+ styles += [ ".ad l" ] # align left, no justification
|
||||
+ return "".join([ "%s\n" % part for part in styles ])
|
||||
+ else:
|
||||
+ return ""
|
||||
+
|
||||
+def refends2(man):
|
||||
+ if man:
|
||||
+ return ""
|
||||
+ else:
|
||||
+ return "</body></html>" + "\n"
|
||||
|
||||
-def refentry2man(refentry, subdirectory = ".", title = ""):
|
||||
+def refentry2(man, refentry, subdirectory = ".", title = ""):
|
||||
if refentry.tag != "refentry":
|
||||
logg.warning("no <refentry> found, not a docbook file?")
|
||||
logg.warning("found <%s> instead", refentry.tag)
|
||||
text = ""
|
||||
- text += refentryinfo2(refentry, title)
|
||||
- text += styleinfo()
|
||||
- text += refentrytitle2(refentry, title)
|
||||
- text += refsynopsisdiv2(refentry)
|
||||
- text += refsections2(refentry)
|
||||
+ text += refentryinfo2(man, refentry, title)
|
||||
+ text += styleinfo2(man)
|
||||
+ text += refentrytitle2(man, refentry, title)
|
||||
+ text += refsynopsisdiv2(man, refentry)
|
||||
+ text += refsections2(man, refentry)
|
||||
+ text += refends2(man)
|
||||
|
||||
### write the files
|
||||
refentrytitle = ""
|
||||
@@ -221,24 +368,70 @@
|
||||
if found is not None: refentrytitle = found.text
|
||||
found = section.find("manvolnum")
|
||||
if found is not None: manvolnum = found.text
|
||||
- written = 0
|
||||
+ #
|
||||
+ refpurpose = ""
|
||||
section = refentry.find("refnamediv")
|
||||
- for refname in section.findall("refname"):
|
||||
- if not refentrytitle:
|
||||
- refentrytitle = refname.text
|
||||
- manpage = refname.text
|
||||
- filename = "%s/man%s/%s.%s" % (subdirectory, manvolnum, manpage, manvolnum)
|
||||
- if manpage != refentrytitle:
|
||||
- manpagetext = ".so %s.%s\n" % (refentrytitle, manvolnum)
|
||||
- writefile(filename, manpagetext)
|
||||
- else:
|
||||
- manpagetext = text
|
||||
+ if not section:
|
||||
+ logg.warning("no <refnamediv> found in <refentry> for '%s', bad docbook?", refentrytitle)
|
||||
+ if not refentrytitle: raise Exception("not even a refentrytitle")
|
||||
+ manpages = [ refentrytitle ]
|
||||
+ else:
|
||||
+ manpages = [ refname.text for refname in section.findall("refname") ]
|
||||
+ found = section.find("refpurpose")
|
||||
+ if found is not None: refpurpose = found.text
|
||||
+ #
|
||||
+ overview = {}
|
||||
+ if man:
|
||||
+ written = 0
|
||||
+ for manpage in manpages:
|
||||
+ if not refentrytitle:
|
||||
+ refentrytitle = manpage
|
||||
+ filename = "%s/man%s/%s.%s" % (subdirectory, manvolnum, manpage, manvolnum)
|
||||
+ if manpage != refentrytitle:
|
||||
+ manpagetext = ".so %s.%s\n" % (refentrytitle, manvolnum)
|
||||
+ writefile(filename, manpagetext)
|
||||
+ else:
|
||||
+ manpagetext = text
|
||||
+ writefile(filename, manpagetext)
|
||||
+ written += 1
|
||||
+ overview[filename] = OverviewEntry(manpage, manvolnum, refpurpose)
|
||||
+ if not written:
|
||||
+ manpage = refentrytitle
|
||||
+ filename = "%s/man%s/%s.%s" % (subdirectory, manvolnum, manpage, manvolnum)
|
||||
writefile(filename, manpagetext)
|
||||
- written += 1
|
||||
- if not written:
|
||||
+ overview[filename] = OverviewEntry(manpage, manvolnum, refpurpose)
|
||||
+ else:
|
||||
manpage = refentrytitle
|
||||
- filename = "%s/man%s/%s.%s" % (subdirectory, manvolnum, manpage, manvolnum)
|
||||
- writefile(filename, manpagetext)
|
||||
+ filename = "%s/%s.%s.%s" % (subdirectory, manpage, manvolnum, "html")
|
||||
+ writefile(filename, text)
|
||||
+ overview[filename] = OverviewEntry(manpage, manvolnum, refpurpose)
|
||||
+ #
|
||||
+ return overview
|
||||
+
|
||||
+def splitname(filename):
|
||||
+ base = os.path.basename(filename)
|
||||
+ name, ext = os.path.splitext(base)
|
||||
+ return name
|
||||
+
|
||||
+def overview2(man, overview, subdirectory, docbook_filename):
|
||||
+ if not man:
|
||||
+ overview2htm(overview, subdirectory, docbook_filename)
|
||||
+
|
||||
+def overview2htm(overview, subdirectory, docbook_filename):
|
||||
+ basename = splitname(docbook_filename)
|
||||
+ text = "<html><head><title>%s %s</title>\n" % (htm(basename), htm("overview"))
|
||||
+ text += "</head><body>\n"
|
||||
+ text += "<h3>%s %s</h3>\n" % (htm(basename), htm("overview"))
|
||||
+ text += "<ul>\n"
|
||||
+ for filename in sorted(overview):
|
||||
+ entry = overview[filename]
|
||||
+ subdir_filename = os.path.basename(filename)
|
||||
+ text += '<li><a href="%s">%s</a> - %s</li>' % (subdir_filename, entry.manpage, htm(entry.refpurpose))
|
||||
+ text += "\n"
|
||||
+ text += "</ul>\n"
|
||||
+ text += "</body></html>\n"
|
||||
+ filename = "%s/%s.%s" % (subdirectory, basename, "html")
|
||||
+ writefile(filename, text)
|
||||
|
||||
def writefile(filename, manpagetext):
|
||||
dirname = os.path.dirname(filename)
|
||||
@@ -252,11 +445,17 @@
|
||||
if __name__ == "__main__":
|
||||
from optparse import OptionParser
|
||||
_o = OptionParser("%prog [options] docbookfiles...")
|
||||
- _o.add_option("-d","--into", metavar="DIR", default=".",
|
||||
+ _o.add_option("-o","--into", metavar="DIR", default=".",
|
||||
help="specify base directory for output [%default]")
|
||||
+ _o.add_option("-t","--make", metavar="DIR", default="man",
|
||||
+ help="make 'man'/'html' output pages [%default]")
|
||||
_o.add_option("-v","--verbose", action="count", default=0,
|
||||
help="increase logging level [%default]")
|
||||
opt, args = _o.parse_args()
|
||||
logging.basicConfig(level = max(0, logging.WARNING - 10 * opt.verbose))
|
||||
- for arg in args:
|
||||
- dbk2man(arg, opt.into)
|
||||
+ # ensure commandline is compatible with "xmlto -o DIR TYPE INPUTFILE"
|
||||
+ make = opt.make
|
||||
+ if args and args[0] in ("man", "html"):
|
||||
+ make = args[0]
|
||||
+ args = args[1:]
|
||||
+ dbk2(make == 'man', args, opt.into)
|
||||
diff -Nur zziplib-0.13.69/docs/make-doc.py zziplib-master/docs/make-doc.py
|
||||
--- zziplib-0.13.69/docs/make-doc.py 2018-03-17 13:46:45.000000000 +0100
|
||||
+++ zziplib-master/docs/make-doc.py 2019-08-04 20:00:21.000000000 +0200
|
||||
@@ -215,7 +215,7 @@
|
||||
#else
|
||||
try:
|
||||
input = open(name, "r")
|
||||
- except IOError, error:
|
||||
+ except IOError as error:
|
||||
warn(#...... (scan_options) ...............
|
||||
"can not open input file: "+name, error)
|
||||
continue
|
||||
@@ -524,7 +524,7 @@
|
||||
# and finally print the html-formatted output
|
||||
try:
|
||||
F = open(o.libhtmlfile, "w")
|
||||
-except IOError, error:
|
||||
+except IOError as error:
|
||||
warn(# ............. open(o.libhtmlfile, "w") ..............
|
||||
"can not open html output file: "+o.libhtmlfile, error)
|
||||
else:
|
||||
@@ -987,7 +987,7 @@
|
||||
|
||||
try:
|
||||
F = open(o.docbookfile,"w")
|
||||
-except IOError, error:
|
||||
+except IOError as error:
|
||||
warn("can not open docbook output file: "+o.docbookfile, error)
|
||||
else:
|
||||
print >> F, doctype, '<reference><title>Manual Pages</title>'
|
||||
@@ -1009,7 +1009,7 @@
|
||||
# _____________________________________________________________________
|
||||
try:
|
||||
F = open( o.dumpdocfile, "w")
|
||||
-except IOError, error:
|
||||
+except IOError as error:
|
||||
warn ("can not open"+o.dumpdocfile,error)
|
||||
else:
|
||||
for func in function_list:
|
||||
diff -Nur zziplib-0.13.69/docs/makedocs.py zziplib-master/docs/makedocs.py
|
||||
--- zziplib-0.13.69/docs/makedocs.py 2018-03-17 13:46:45.000000000 +0100
|
||||
+++ zziplib-master/docs/makedocs.py 2019-08-04 20:00:21.000000000 +0200
|
||||
@@ -1,3 +1,4 @@
|
||||
+from __future__ import print_function
|
||||
import sys
|
||||
from zzipdoc.match import *
|
||||
from zzipdoc.options import *
|
||||
@@ -37,7 +38,7 @@
|
||||
return None
|
||||
def print_list_mainheader(self):
|
||||
for t_fileheader in self.headers:
|
||||
- print t_fileheader.get_filename(), t_fileheader.src_mainheader()
|
||||
+ print (t_fileheader.get_filename(), t_fileheader.src_mainheader())
|
||||
|
||||
class PerFunctionEntry:
|
||||
def __init__(self, header, comment, prototype):
|
||||
@@ -66,10 +67,10 @@
|
||||
functionprototype) ]
|
||||
def print_list_titleline(self):
|
||||
for funcheader in self.headers:
|
||||
- print funcheader.get_filename(), "[=>]", funcheader.get_titleline()
|
||||
+ print (funcheader.get_filename(), "[=>]", funcheader.get_titleline())
|
||||
def print_list_name(self):
|
||||
for funcheader in self.prototypes:
|
||||
- print funcheader.get_filename(), "[>>]", funcheader.get_name()
|
||||
+ print (funcheader.get_filename(), "[>>]", funcheader.get_name())
|
||||
|
||||
class PerFunctionFamilyEntry:
|
||||
def __init__(self, leader):
|
||||
@@ -141,7 +142,7 @@
|
||||
entry.add(func) # the first
|
||||
self.entries += [ entry ]
|
||||
else:
|
||||
- print "head function '"+name+" has no entry"
|
||||
+ print ("head function '"+name+" has no entry")
|
||||
for func in self.functions:
|
||||
name = func.get_name()
|
||||
if name in self.retarget:
|
||||
@@ -150,14 +151,14 @@
|
||||
if entry is not None:
|
||||
entry.add(func) # will not add duplicates
|
||||
else:
|
||||
- print "into function '"+name+" has no entry"
|
||||
+ print ("into function '"+name+" has no entry")
|
||||
def print_list_name(self):
|
||||
for family in self.entries:
|
||||
name = family.get_name()
|
||||
- print name, ":",
|
||||
+ print (name, ":", end = " ")
|
||||
for item in family.functions:
|
||||
- print item.get_name(), ",",
|
||||
- print ""
|
||||
+ print (item.get_name(), ",", end = " ")
|
||||
+ print ("")
|
||||
class HtmlManualPageAdapter:
|
||||
def __init__(self, entry):
|
||||
""" usually takes a PerFunctionEntry """
|
||||
diff -Nur zziplib-0.13.69/docs/zzipdoc/commentmarkup.py zziplib-master/docs/zzipdoc/commentmarkup.py
|
||||
--- zziplib-0.13.69/docs/zzipdoc/commentmarkup.py 2018-03-17 13:46:45.000000000 +0100
|
||||
+++ zziplib-master/docs/zzipdoc/commentmarkup.py 2019-08-04 20:00:21.000000000 +0200
|
||||
@@ -31,7 +31,7 @@
|
||||
comment = self.header.comment
|
||||
try:
|
||||
comment = self.header.get_otherlines()
|
||||
- except Exception, e:
|
||||
+ except Exception as e:
|
||||
pass
|
||||
mode = ""
|
||||
text = ""
|
||||
diff -Nur zziplib-0.13.69/docs/zzipdoc/docbookdocument.py zziplib-master/docs/zzipdoc/docbookdocument.py
|
||||
--- zziplib-0.13.69/docs/zzipdoc/docbookdocument.py 2018-03-17 13:46:45.000000000 +0100
|
||||
+++ zziplib-master/docs/zzipdoc/docbookdocument.py 2019-08-04 20:00:21.000000000 +0200
|
||||
@@ -23,14 +23,14 @@
|
||||
def get_title(self):
|
||||
if self.title: return title
|
||||
try: return self.text[0].get_title()
|
||||
- except Exception, e: pass
|
||||
+ except Exception as e: pass
|
||||
return self.title
|
||||
def _xml_doctype(self, rootnode):
|
||||
return "<!DOCTYPE "+rootnode+self.docbook_dtd+">"
|
||||
def _xml_text(self, xml):
|
||||
""" accepts adapter objects with .xml_text() """
|
||||
try: return xml.xml_text()
|
||||
- except Exception, e: print "DocbookDocument/text", e; pass
|
||||
+ except Exception as e: print "DocbookDocument/text", e; pass
|
||||
return str(xml)
|
||||
def _fetch_rootnode(self, text):
|
||||
fetch = Match(r"^[^<>]*<(\w+)\b")
|
||||
@@ -62,7 +62,7 @@
|
||||
print >>fd, xml_text
|
||||
fd.close()
|
||||
return True
|
||||
- except IOError, e:
|
||||
+ except IOError as e:
|
||||
print "could not open '"+filename+"'file", e
|
||||
return False
|
||||
def save_all(self, filename):
|
||||
@@ -90,6 +90,6 @@
|
||||
print >>fd, "</"+self.rootnode+">"
|
||||
fd.close()
|
||||
return True
|
||||
- except IOError, e:
|
||||
+ except IOError as e:
|
||||
print "could not open '"+filename+"'file", e
|
||||
return False
|
||||
diff -Nur zziplib-0.13.69/docs/zzipdoc/functionlisthtmlpage.py zziplib-master/docs/zzipdoc/functionlisthtmlpage.py
|
||||
--- zziplib-0.13.69/docs/zzipdoc/functionlisthtmlpage.py 2018-03-17 13:46:45.000000000 +0100
|
||||
+++ zziplib-master/docs/zzipdoc/functionlisthtmlpage.py 2019-08-04 20:00:21.000000000 +0200
|
||||
@@ -43,7 +43,7 @@
|
||||
callspec = entry.head_get_callspec()
|
||||
head_text = ("<code><b><function>"+namespec+"</function></b>"
|
||||
+callspec+" : "+prespec+"</code>")
|
||||
- except Exception, e:
|
||||
+ except Exception as e:
|
||||
pass
|
||||
try:
|
||||
extraline = ""
|
||||
@@ -56,7 +56,7 @@
|
||||
'<em><small>'+filename+'</small></em>'+
|
||||
'</td></table>')
|
||||
body_text = extraline + body_text
|
||||
- except Exception, e:
|
||||
+ except Exception as e:
|
||||
pass
|
||||
def link(text):
|
||||
return (text & Match("<function>(\w*)</function>")
|
||||
diff -Nur zziplib-0.13.69/docs/zzipdoc/htm2dbk.py zziplib-master/docs/zzipdoc/htm2dbk.py
|
||||
--- zziplib-0.13.69/docs/zzipdoc/htm2dbk.py 2018-03-17 13:46:45.000000000 +0100
|
||||
+++ zziplib-master/docs/zzipdoc/htm2dbk.py 2019-08-04 20:00:21.000000000 +0200
|
||||
@@ -146,7 +146,7 @@
|
||||
doc.filename = filename
|
||||
doc.add(f.read())
|
||||
f.close()
|
||||
- except IOError, e:
|
||||
+ except IOError as e:
|
||||
print >> sys.stderr, "can not open "+filename
|
||||
return doc.value()
|
||||
|
||||
diff -Nur zziplib-0.13.69/docs/zzipdoc/htmldocument.py zziplib-master/docs/zzipdoc/htmldocument.py
|
||||
--- zziplib-0.13.69/docs/zzipdoc/htmldocument.py 2018-03-17 13:46:45.000000000 +0100
|
||||
+++ zziplib-master/docs/zzipdoc/htmldocument.py 2019-08-04 20:00:21.000000000 +0200
|
||||
@@ -29,31 +29,31 @@
|
||||
def get_title(self):
|
||||
if self.title: return self.title
|
||||
try: return self.text[0].get_title()
|
||||
- except Exception, e: pass
|
||||
+ except Exception as e: pass
|
||||
return self.title
|
||||
def _html_meta(self, meta):
|
||||
""" accepts adapter objects with .html_meta() """
|
||||
try: return meta.html_meta()
|
||||
- except Exception, e: pass
|
||||
+ except Exception as e: pass
|
||||
return str(meta)
|
||||
def _html_style(self, style):
|
||||
""" accepts adapter objects with .html_style() and .xml_style() """
|
||||
ee = None
|
||||
try: return style.html_style()
|
||||
- except Exception, e: ee = e; pass
|
||||
+ except Exception as e: ee = e; pass
|
||||
try: return style.xml_style()
|
||||
- except Exception, e: print "HtmlDocument/style", ee, e; pass
|
||||
+ except Exception as e: print "HtmlDocument/style", ee, e; pass
|
||||
try: return str(style)
|
||||
- except Exception, e: print "HtmlDocument/style", e; return ""
|
||||
+ except Exception as e: print "HtmlDocument/style", e; return ""
|
||||
def _html_text(self, html):
|
||||
""" accepts adapter objects with .html_text() and .xml_text() """
|
||||
ee = None
|
||||
try: return html.html_text()
|
||||
- except Exception, e: ee = e; pass
|
||||
+ except Exception as e: ee = e; pass
|
||||
try: return html.xml_text()
|
||||
- except Exception, e: print "HtmlDocument/text", ee, e; pass
|
||||
+ except Exception as e: print "HtmlDocument/text", ee, e; pass
|
||||
try: return str(html)
|
||||
- except Exception, e: print "HtmlDocument/text", e; return " "
|
||||
+ except Exception as e: print "HtmlDocument/text", e; return " "
|
||||
def navigation(self):
|
||||
if self.navi:
|
||||
return self.navi
|
||||
@@ -63,7 +63,7 @@
|
||||
self.navi = fd.read()
|
||||
fd.close()
|
||||
return self.navi
|
||||
- except Exception, e:
|
||||
+ except Exception as e:
|
||||
pass
|
||||
return None
|
||||
def html_header(self):
|
||||
@@ -112,6 +112,6 @@
|
||||
print >>fd, self.html_footer()
|
||||
fd.close()
|
||||
return True
|
||||
- except IOError, e:
|
||||
+ except IOError as e:
|
||||
print "could not open '"+filename+"'file", e
|
||||
return False
|
||||
diff -Nur zziplib-0.13.69/docs/zzipdoc/textfile.py zziplib-master/docs/zzipdoc/textfile.py
|
||||
--- zziplib-0.13.69/docs/zzipdoc/textfile.py 2018-03-17 13:46:45.000000000 +0100
|
||||
+++ zziplib-master/docs/zzipdoc/textfile.py 2019-08-04 20:00:21.000000000 +0200
|
||||
@@ -17,7 +17,7 @@
|
||||
self.src_text = fd.read()
|
||||
fd.close()
|
||||
return True
|
||||
- except IOError, e:
|
||||
+ except IOError as e:
|
||||
pass
|
||||
return False
|
||||
def assert_src_text(self):
|
||||
|
||||
Reference in New Issue
Block a user