From 786fc16f4c05b2bf0ebc427a048eca4a496da233 Mon Sep 17 00:00:00 2001 From: nia Date: Fri, 19 Feb 2021 10:42:54 +0000 Subject: gnome-doc-utils: add Python 3 support, based on Fedora patches bump PKGREVISION --- textproc/gnome-doc-utils/Makefile | 12 +- textproc/gnome-doc-utils/PLIST | 2 +- textproc/gnome-doc-utils/distinfo | 9 +- .../patches/patch-xml2po_xml2po_____init____.py | 134 +++++++++++++++++++++ .../patches/patch-xml2po_xml2po_modes_docbook.py | 58 +++++++++ .../patches/patch-xml2po_xml2po_modes_gs.py | 18 +++ .../patches/patch-xml2po_xml2po_modes_mallard.py | 27 +++++ .../patches/patch-xml2po_xml2po_modes_ubuntu.py | 18 +++ .../patches/patch-xml2po_xml2po_modes_xhtml.py | 18 +++ .../patches/patch-xml2po_xml2po_xml2po.py.in | 76 ++++++++++++ 10 files changed, 362 insertions(+), 10 deletions(-) create mode 100644 textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_____init____.py create mode 100644 textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_modes_docbook.py create mode 100644 textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_modes_gs.py create mode 100644 textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_modes_mallard.py create mode 100644 textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_modes_ubuntu.py create mode 100644 textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_modes_xhtml.py create mode 100644 textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_xml2po.py.in diff --git a/textproc/gnome-doc-utils/Makefile b/textproc/gnome-doc-utils/Makefile index e6843b48783..fbb29e82be8 100644 --- a/textproc/gnome-doc-utils/Makefile +++ b/textproc/gnome-doc-utils/Makefile @@ -1,7 +1,7 @@ -# $NetBSD: Makefile,v 1.75 2020/12/04 20:45:44 nia Exp $ +# $NetBSD: Makefile,v 1.76 2021/02/19 10:42:54 nia Exp $ DISTNAME= gnome-doc-utils-0.20.10 -PKGREVISION= 7 +PKGREVISION= 8 CATEGORIES= textproc gnome MASTER_SITES= ${MASTER_SITE_GNOME:=sources/gnome-doc-utils/0.20/} EXTRACT_SUFX= .tar.xz @@ -12,12 +12,9 @@ COMMENT= Documentation utilities for the GNOME project LICENSE= gnu-gpl-v2 AND gnu-lgpl-v2.1 DEPENDS+= ${PYPKGPREFIX}-libxml2>=2.6.16:../../textproc/py-libxml2 -DEPENDS+= ${PYPKGPREFIX}-libxslt>=1.1.12:../../textproc/py-libxslt DEPENDS+= docbook-xml>=4.5:../../textproc/docbook-xml DEPENDS+= getopt-[0-9]*:../../misc/getopt -PYTHON_VERSIONS_ACCEPTED= 27 # py-libxslt - USE_TOOLS+= intltool pkg-config gmake gawk msgfmt bash:run GNU_CONFIGURE= YES MAKE_JOBS_SAFE= no @@ -35,7 +32,7 @@ SUBST_STAGE.getopt= pre-configure SUBST_FILES.getopt= tools/gnome-doc-tool.in SUBST_SED.getopt= "s|@GETOPT@|${LOCALBASE}/bin/getopt|g" -PY_PATCHPLIST= yes +PLIST_SUBST+= PYSITELIB=${PYSITELIB} BUILDLINK_API_DEPENDS.libxml2+= libxml2>=2.6.12 BUILDLINK_DEPMETHOD.libxslt= build @@ -44,8 +41,7 @@ BUILDLINK_DEPMETHOD.libxml2= build post-install: ${PY_COMPILE_ALL} ${DESTDIR}${PREFIX}/share/xml2po -.include "../../lang/python/application.mk" -.include "../../lang/python/extension.mk" +.include "../../lang/python/pyversion.mk" .include "../../textproc/libxml2/buildlink3.mk" .include "../../textproc/libxslt/buildlink3.mk" .include "../../textproc/xmlcatmgr/buildlink3.mk" diff --git a/textproc/gnome-doc-utils/PLIST b/textproc/gnome-doc-utils/PLIST index 7b4f05926ea..3480ad9f67d 100644 --- a/textproc/gnome-doc-utils/PLIST +++ b/textproc/gnome-doc-utils/PLIST @@ -1,4 +1,4 @@ -@comment $NetBSD: PLIST,v 1.19 2012/08/23 15:18:07 drochner Exp $ +@comment $NetBSD: PLIST,v 1.20 2021/02/19 10:42:54 nia Exp $ bin/gnome-doc-prepare bin/gnome-doc-tool bin/xml2po diff --git a/textproc/gnome-doc-utils/distinfo b/textproc/gnome-doc-utils/distinfo index 1214cffa971..63f0eb64fb7 100644 --- a/textproc/gnome-doc-utils/distinfo +++ b/textproc/gnome-doc-utils/distinfo @@ -1,7 +1,14 @@ -$NetBSD: distinfo,v 1.30 2020/03/11 12:38:06 wiz Exp $ +$NetBSD: distinfo,v 1.31 2021/02/19 10:42:54 nia Exp $ SHA1 (gnome-doc-utils-0.20.10.tar.xz) = 8320a30e1b7239aa33ba276da046090407a93bbf RMD160 (gnome-doc-utils-0.20.10.tar.xz) = 64fcdf0166c213b6bf5c872f583546b3a9a17bf4 SHA512 (gnome-doc-utils-0.20.10.tar.xz) = 1cb5e3b9ca9e45e6c551801e9c9c4aac725c2ce85238c230a4c70b36c90419886b921d8dd464df0643fc3bbb877df075abaa83a36d1609c5664960c31e11d151 Size (gnome-doc-utils-0.20.10.tar.xz) = 526700 bytes SHA1 (patch-aa) = 340bf8450a100a3d35d7bf1b411de081d3ebe776 +SHA1 (patch-xml2po_xml2po_____init____.py) = 8dd475fa87e5dcd5cfb6714f183525e0f6653313 +SHA1 (patch-xml2po_xml2po_modes_docbook.py) = 673b588d9d3a8fb493c7201e18363ec8b19ac7e6 +SHA1 (patch-xml2po_xml2po_modes_gs.py) = 5c7f65e46a33e847b88ac675e2ddc21031e2afde +SHA1 (patch-xml2po_xml2po_modes_mallard.py) = 06219084bcae7bfe2780726007c4421ed7ccd459 +SHA1 (patch-xml2po_xml2po_modes_ubuntu.py) = 9ad4bed8df6e476f048bdef42fc7cd40c07a8cd3 +SHA1 (patch-xml2po_xml2po_modes_xhtml.py) = d440dabcef7df1dc3eb74d0cb14e0c964b034d53 +SHA1 (patch-xml2po_xml2po_xml2po.py.in) = a564f3f1e766e0cabeb72ebfdddbc791c00b5836 diff --git a/textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_____init____.py b/textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_____init____.py new file mode 100644 index 00000000000..f07ac186f6f --- /dev/null +++ b/textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_____init____.py @@ -0,0 +1,134 @@ +$NetBSD: patch-xml2po_xml2po_____init____.py,v 1.1 2021/02/19 10:42:54 nia Exp $ + +Python 3 support. + +via Fedora and a million other Linux distributions: +https://src.fedoraproject.org/rpms/gnome-doc-utils/tree/rawhide + +--- xml2po/xml2po/__init__.py.orig 2011-08-04 14:36:03.000000000 +0000 ++++ xml2po/xml2po/__init__.py +@@ -86,14 +86,14 @@ class MessageOutput: + self.messages.append(t) + if spacepreserve: + self.nowrap[t] = True +- if t in self.linenos.keys(): ++ if t in list(self.linenos.keys()): + self.linenos[t].append((self.filename, tag, lineno)) + else: + self.linenos[t] = [ (self.filename, tag, lineno) ] + if (not self.do_translations) and comment and not t in self.comments: + self.comments[t] = comment + else: +- if t in self.linenos.keys(): ++ if t in list(self.linenos.keys()): + self.linenos[t].append((self.filename, tag, lineno)) + else: + self.linenos[t] = [ (self.filename, tag, lineno) ] +@@ -200,7 +200,7 @@ class XMLDocument(object): + tree = ctxt.doc() + newnode = tree.getRootElement() + except: +- print >> sys.stderr, """Error while normalizing string as XML:\n"%s"\n""" % (text) ++ print("""Error while normalizing string as XML:\n"%s"\n""" % (text), file=sys.stderr) + return text + + self.normalizeNode(newnode) +@@ -326,7 +326,7 @@ class XMLDocument(object): + pass + + content = '<%s>%s' % (starttag, text, endtag) +- tmp = tmp + content.encode('utf-8') ++ tmp = tmp + content + + newnode = None + try: +@@ -338,7 +338,7 @@ class XMLDocument(object): + pass + + if not newnode: +- print >> sys.stderr, """Error while parsing translation as XML:\n"%s"\n""" % (text.encode('utf-8')) ++ print("""Error while parsing translation as XML:\n"%s"\n""" % (text.encode('utf-8')), file=sys.stderr) + return + + newelem = newnode.getRootElement() +@@ -352,9 +352,10 @@ class XMLDocument(object): + + if node: + copy = newelem.copyNodeList() +- next = node.next ++ #next = node.next + node.replaceNode(newelem.copyNodeList()) +- node.next = next ++ #print(type(next)) ++ #node.next = next + + else: + # In practice, this happens with tags such as " " (only whitespace in between) +@@ -470,7 +471,7 @@ class XMLDocument(object): + + worth = self.worthOutputting(node) + if not translation: +- translation = outtxt.decode('utf-8') ++ translation = outtxt + if worth and self.app.options.get('mark_untranslated'): + node.setLang('C') + +@@ -577,8 +578,8 @@ class Main(object): + raise IOError("Unable to read file '%s'" % xmlfile) + try: + doc = XMLDocument(xmlfile, self) +- except Exception, e: +- print >> sys.stderr, "Unable to parse XML file '%s': %s" % (xmlfile, str(e)) ++ except Exception as e: ++ print("Unable to parse XML file '%s': %s" % (xmlfile, str(e)), file=sys.stderr) + sys.exit(1) + self.current_mode.preProcessXml(doc.doc, self.msg) + doc.generate_messages() +@@ -590,14 +591,14 @@ class Main(object): + raise IOError("Unable to read file '%s'" % xmlfile) + try: + doc = XMLDocument(xmlfile, self) +- except Exception, e: +- print >> sys.stderr, str(e) ++ except Exception as e: ++ print(str(e), file=sys.stderr) + sys.exit(1) + + try: + mfile = open(mofile, "rb") + except: +- print >> sys.stderr, "Can't open MO file '%s'." % (mofile) ++ print("Can't open MO file '%s'." % (mofile), file=sys.stderr) + self.gt = gettext.GNUTranslations(mfile) + self.gt.add_fallback(NoneTranslations()) + # Has preProcessXml use cases for merge? +@@ -619,16 +620,16 @@ class Main(object): + raise IOError("Unable to read file '%s'" % xmlfile) + try: + doc = XMLDocument(xmlfile, self) +- except Exception, e: +- print >> sys.stderr, str(e) ++ except Exception as e: ++ print(str(e), file=sys.stderr) + sys.exit(1) + doc.generate_messages() + + self.msg.translationsFollow() + try: + doc = XMLDocument(origxml, self) +- except Exception, e: +- print >> sys.stderr, str(e) ++ except Exception as e: ++ print(str(e), file=sys.stderr) + sys.exit(1) + doc.generate_messages() + self.output_po() +@@ -663,7 +664,7 @@ class Main(object): + if not text or text.strip() == '': + return text + if self.gt: +- res = self.gt.ugettext(text.decode('utf-8')) ++ res = self.gt.gettext(text) + return res + + return text diff --git a/textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_modes_docbook.py b/textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_modes_docbook.py new file mode 100644 index 00000000000..1a6917d366d --- /dev/null +++ b/textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_modes_docbook.py @@ -0,0 +1,58 @@ +$NetBSD: patch-xml2po_xml2po_modes_docbook.py,v 1.1 2021/02/19 10:42:54 nia Exp $ + +Python 3 support. + +via Fedora and a million other Linux distributions: +https://src.fedoraproject.org/rpms/gnome-doc-utils/tree/rawhide + +--- xml2po/xml2po/modes/docbook.py.orig 2011-01-10 16:08:10.000000000 +0000 ++++ xml2po/xml2po/modes/docbook.py +@@ -43,7 +43,7 @@ try: + except ImportError: + from md5 import new as md5_new + +-from basic import basicXmlMode ++from .basic import basicXmlMode + + class docbookXmlMode(basicXmlMode): + """Class for special handling of DocBook document types. +@@ -131,7 +131,7 @@ class docbookXmlMode(basicXmlMode): + hash = self._md5_for_file(fullpath) + else: + hash = "THIS FILE DOESN'T EXIST" +- print >>sys.stderr, "Warning: image file '%s' not found." % fullpath ++ print("Warning: image file '%s' not found." % fullpath, file=sys.stderr) + + msg.outputMessage("@@image: '%s'; md5=%s" % (attr, hash), node.lineNo(), + "When image changes, this message will be marked fuzzy or untranslated for you.\n"+ +@@ -184,7 +184,7 @@ class docbookXmlMode(basicXmlMode): + else: + ai.addChild(copy) + if match.group(3): +- copy.newChild(None, "year", match.group(3).encode('utf-8')) ++ copy.newChild(None, "year", match.group(3)) + if match.group(1) and match.group(2): + holder = match.group(1)+"(%s)" % match.group(2) + elif match.group(1): +@@ -193,15 +193,15 @@ class docbookXmlMode(basicXmlMode): + holder = match.group(2) + else: + holder = "???" +- copy.newChild(None, "holder", holder.encode('utf-8')) ++ copy.newChild(None, "holder", holder) + + # Perform some tests when ran standalone + if __name__ == '__main__': + test = docbookXmlMode() +- print "Ignored tags : " + repr(test.getIgnoredTags()) +- print "Final tags : " + repr(test.getFinalTags()) +- print "Space-preserve tags: " + repr(test.getSpacePreserveTags()) ++ print("Ignored tags : " + repr(test.getIgnoredTags())) ++ print("Final tags : " + repr(test.getFinalTags())) ++ print("Space-preserve tags: " + repr(test.getSpacePreserveTags())) + +- print "Credits from string: '%s'" % test.getStringForTranslators() +- print "Explanation for credits:\n\t'%s'" % test.getCommentForTranslators() ++ print("Credits from string: '%s'" % test.getStringForTranslators()) ++ print("Explanation for credits:\n\t'%s'" % test.getCommentForTranslators()) + diff --git a/textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_modes_gs.py b/textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_modes_gs.py new file mode 100644 index 00000000000..2b0f8de5e09 --- /dev/null +++ b/textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_modes_gs.py @@ -0,0 +1,18 @@ +$NetBSD: patch-xml2po_xml2po_modes_gs.py,v 1.1 2021/02/19 10:42:54 nia Exp $ + +Python 3 support. + +via Fedora and a million other Linux distributions: +https://src.fedoraproject.org/rpms/gnome-doc-utils/tree/rawhide + +--- xml2po/xml2po/modes/gs.py.orig 2010-12-13 16:14:07.000000000 +0000 ++++ xml2po/xml2po/modes/gs.py +@@ -20,7 +20,7 @@ + # Special case Gnome Summary + # + +-from basic import basicXmlMode ++from .basic import basicXmlMode + + class gsXmlMode(basicXmlMode): + """Abstract class for special handling of document types.""" diff --git a/textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_modes_mallard.py b/textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_modes_mallard.py new file mode 100644 index 00000000000..458295622bc --- /dev/null +++ b/textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_modes_mallard.py @@ -0,0 +1,27 @@ +$NetBSD: patch-xml2po_xml2po_modes_mallard.py,v 1.1 2021/02/19 10:42:54 nia Exp $ + +Python 3 support. + +via Fedora and a million other Linux distributions: +https://src.fedoraproject.org/rpms/gnome-doc-utils/tree/rawhide + +--- xml2po/xml2po/modes/mallard.py.orig 2011-01-10 16:08:50.000000000 +0000 ++++ xml2po/xml2po/modes/mallard.py +@@ -39,7 +39,7 @@ try: + except ImportError: + from md5 import new as md5_new + +-from basic import basicXmlMode ++from .basic import basicXmlMode + + class mallardXmlMode(basicXmlMode): + """Class for special handling of Mallard document types.""" +@@ -112,7 +112,7 @@ class mallardXmlMode(basicXmlMode): + hash = self._md5_for_file(fullpath) + else: + hash = "THIS FILE DOESN'T EXIST" +- print >>sys.stderr, "Warning: image file '%s' not found." % fullpath ++ print("Warning: image file '%s' not found." % fullpath, file=sys.stderr) + + msg.outputMessage("@@image: '%s'; md5=%s" % (attr, hash), node.lineNo(), + "When image changes, this message will be marked fuzzy or untranslated for you.\n"+ diff --git a/textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_modes_ubuntu.py b/textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_modes_ubuntu.py new file mode 100644 index 00000000000..2a6ccaa9eec --- /dev/null +++ b/textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_modes_ubuntu.py @@ -0,0 +1,18 @@ +$NetBSD: patch-xml2po_xml2po_modes_ubuntu.py,v 1.1 2021/02/19 10:42:54 nia Exp $ + +Python 3 support. + +via Fedora and a million other Linux distributions: +https://src.fedoraproject.org/rpms/gnome-doc-utils/tree/rawhide + +--- xml2po/xml2po/modes/ubuntu.py.orig 2010-12-13 16:14:07.000000000 +0000 ++++ xml2po/xml2po/modes/ubuntu.py +@@ -2,7 +2,7 @@ + + import libxml2 + +-from docbook import docbookXmlMode ++from .docbook import docbookXmlMode + + class ubuntuXmlMode (docbookXmlMode): + """Special-casing Ubuntu DocBook website documentation.""" diff --git a/textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_modes_xhtml.py b/textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_modes_xhtml.py new file mode 100644 index 00000000000..e93accc420a --- /dev/null +++ b/textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_modes_xhtml.py @@ -0,0 +1,18 @@ +$NetBSD: patch-xml2po_xml2po_modes_xhtml.py,v 1.1 2021/02/19 10:42:54 nia Exp $ + +Python 3 support. + +via Fedora and a million other Linux distributions: +https://src.fedoraproject.org/rpms/gnome-doc-utils/tree/rawhide + +--- xml2po/xml2po/modes/xhtml.py.orig 2010-12-13 16:14:07.000000000 +0000 ++++ xml2po/xml2po/modes/xhtml.py +@@ -21,7 +21,7 @@ + # This implements special instructions for handling XHTML documents + # in a better way, particularly to extract some attributes in HTML tags + +-from basic import basicXmlMode ++from .basic import basicXmlMode + + class xhtmlXmlMode(basicXmlMode): + """Class for special handling of XHTML document types.""" diff --git a/textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_xml2po.py.in b/textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_xml2po.py.in new file mode 100644 index 00000000000..4a35853fb93 --- /dev/null +++ b/textproc/gnome-doc-utils/patches/patch-xml2po_xml2po_xml2po.py.in @@ -0,0 +1,76 @@ +$NetBSD: patch-xml2po_xml2po_xml2po.py.in,v 1.1 2021/02/19 10:42:54 nia Exp $ + +Python 3 support. + +via Fedora and a million other Linux distributions: +https://src.fedoraproject.org/rpms/gnome-doc-utils/tree/rawhide + +--- xml2po/xml2po/xml2po.py.in.orig 2010-12-13 16:14:07.000000000 +0000 ++++ xml2po/xml2po/xml2po.py.in +@@ -41,9 +41,9 @@ NULL_STRING = '/dev/null' + if not os.path.exists('/dev/null'): NULL_STRING = 'NUL' + + def usage (with_help = False): +- print >> sys.stderr, "Usage: %s [OPTIONS] [XMLFILE]..." % (sys.argv[0]) ++ print("Usage: %s [OPTIONS] [XMLFILE]..." % (sys.argv[0]), file=sys.stderr) + if with_help: +- print >> sys.stderr, """ ++ print(""" + OPTIONS may be some of: + -a --automatic-tags Automatically decides if tags are to be considered + "final" or not +@@ -72,7 +72,7 @@ EXAMPLES: + using -p option for each XML file: + %(command)s -p de.po chapter1.xml > chapter1.de.xml + %(command)s -p de.po chapter2.xml > chapter2.de.xml +-""" % {'command': sys.argv[0]} ++""" % {'command': sys.argv[0]}, file=sys.stderr) + + + def main(argv): +@@ -82,7 +82,7 @@ def main(argv): + + name = os.path.join(os.path.dirname(__file__), '..') + if os.path.exists(os.path.join(name, 'tests')): +- print >> sys.stderr, 'Running from source folder, modifying PYTHONPATH' ++ print('Running from source folder, modifying PYTHONPATH', file=sys.stderr) + sys.path.insert(0, name) + + from xml2po import Main +@@ -142,14 +142,14 @@ def main(argv): + elif opt in ('-o', '--output'): + output = arg + elif opt in ('-v', '--version'): +- print VERSION ++ print(VERSION) + sys.exit(0) + elif opt in ('-h', '--help'): + usage(True) + sys.exit(0) + + if operation == 'update' and output != "-": +- print >> sys.stderr, "Option '-o' is not yet supported when updating translations directly. Ignoring this option." ++ print("Option '-o' is not yet supported when updating translations directly. Ignoring this option.", file=sys.stderr) + + # Treat remaining arguments as XML files + filenames = [] +@@ -159,16 +159,16 @@ def main(argv): + try: + xml2po_main = Main(default_mode, operation, output, options) + except IOError: +- print >> sys.stderr, "Error: cannot open file %s for writing." % (output) ++ print("Error: cannot open file %s for writing." % (output), file=sys.stderr) + sys.exit(5) + + if operation == 'merge': + if len(filenames) > 1: +- print >> sys.stderr, "Error: You can merge translations with only one XML file at a time." ++ print("Error: You can merge translations with only one XML file at a time.", file=sys.stderr) + sys.exit(2) + + if not mofile: +- print >> sys.stderr, "Error: You must specify MO file when merging translations." ++ print("Error: You must specify MO file when merging translations.", file=sys.stderr) + sys.exit(3) + + xml2po_main.merge(mofile, filenames[0]) -- cgit v1.2.3