even with one foot in the grave, switch this over to python3.

based on a patch from gentoo
This commit is contained in:
jasper 2020-06-09 07:19:28 +00:00
parent 6a32b16c8d
commit fb51636f98
9 changed files with 296 additions and 5 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.69 2020/06/09 07:14:46 jasper Exp $
# $OpenBSD: Makefile,v 1.70 2020/06/09 07:19:28 jasper Exp $
# This port does set MODGNOME_TOOLS=yelp on purpose: it would create a
# dependency on itself. We do not enforce dependency on x11/gnome/yelp
@ -8,7 +8,7 @@ COMMENT= collection of documentation utilities for the GNOME project
GNOME_PROJECT= gnome-doc-utils
GNOME_VERSION= 0.20.10
REVISION= 6
REVISION= 7
CATEGORIES= textproc
@ -18,6 +18,8 @@ PERMIT_PACKAGE= Yes
MODULES= lang/python \
x11/gnome
MODPY_VERSION =${MODPY_DEFAULT_VERSION_3}
BUILD_DEPENDS= textproc/docbook \
textproc/libxml,-python \
textproc/libxslt \

View File

@ -0,0 +1,83 @@
$OpenBSD: patch-xml2po_xml2po___init___py,v 1.1 2020/06/09 07:19:28 jasper Exp $
https://gitweb.gentoo.org/repo/gentoo.git/tree/app-text/gnome-doc-utils/files/gnome-doc-utils-0.20.10-python3.patch
Index: xml2po/xml2po/__init__.py
--- xml2po/xml2po/__init__.py.orig
+++ xml2po/xml2po/__init__.py
@@ -326,7 +326,7 @@ class XMLDocument(object):
pass
content = '<%s>%s</%s>' % (starttag, text, endtag)
- tmp = tmp + content.encode('utf-8')
+ tmp = tmp + content
newnode = None
try:
@@ -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 "<para> </para>" (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,7 +578,7 @@ class Main(object):
raise IOError("Unable to read file '%s'" % xmlfile)
try:
doc = XMLDocument(xmlfile, self)
- except Exception, e:
+ except Exception as e:
print >> sys.stderr, "Unable to parse XML file '%s': %s" % (xmlfile, str(e))
sys.exit(1)
self.current_mode.preProcessXml(doc.doc, self.msg)
@@ -590,7 +591,7 @@ class Main(object):
raise IOError("Unable to read file '%s'" % xmlfile)
try:
doc = XMLDocument(xmlfile, self)
- except Exception, e:
+ except Exception as e:
print >> sys.stderr, str(e)
sys.exit(1)
@@ -619,7 +620,7 @@ class Main(object):
raise IOError("Unable to read file '%s'" % xmlfile)
try:
doc = XMLDocument(xmlfile, self)
- except Exception, e:
+ except Exception as e:
print >> sys.stderr, str(e)
sys.exit(1)
doc.generate_messages()
@@ -627,7 +628,7 @@ class Main(object):
self.msg.translationsFollow()
try:
doc = XMLDocument(origxml, self)
- except Exception, e:
+ except Exception as e:
print >> sys.stderr, str(e)
sys.exit(1)
doc.generate_messages()
@@ -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

View File

@ -0,0 +1,47 @@
$OpenBSD: patch-xml2po_xml2po_modes_docbook_py,v 1.1 2020/06/09 07:19:28 jasper Exp $
https://gitweb.gentoo.org/repo/gentoo.git/tree/app-text/gnome-doc-utils/files/gnome-doc-utils-0.20.10-python3.patch
Index: xml2po/xml2po/modes/docbook.py
--- xml2po/xml2po/modes/docbook.py.orig
+++ xml2po/xml2po/modes/docbook.py
@@ -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, 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())

View File

@ -0,0 +1,16 @@
$OpenBSD: patch-xml2po_xml2po_modes_gs_py,v 1.1 2020/06/09 07:19:28 jasper Exp $
https://gitweb.gentoo.org/repo/gentoo.git/tree/app-text/gnome-doc-utils/files/gnome-doc-utils-0.20.10-python3.patch
Index: xml2po/xml2po/modes/gs.py
--- xml2po/xml2po/modes/gs.py.orig
+++ 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."""

View File

@ -0,0 +1,25 @@
$OpenBSD: patch-xml2po_xml2po_modes_mallard_py,v 1.1 2020/06/09 07:19:28 jasper Exp $
https://gitweb.gentoo.org/repo/gentoo.git/tree/app-text/gnome-doc-utils/files/gnome-doc-utils-0.20.10-python3.patch
Index: xml2po/xml2po/modes/mallard.py
--- xml2po/xml2po/modes/mallard.py.orig
+++ 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"+

View File

@ -0,0 +1,16 @@
$OpenBSD: patch-xml2po_xml2po_modes_ubuntu_py,v 1.1 2020/06/09 07:19:28 jasper Exp $
https://gitweb.gentoo.org/repo/gentoo.git/tree/app-text/gnome-doc-utils/files/gnome-doc-utils-0.20.10-python3.patch
Index: xml2po/xml2po/modes/ubuntu.py
--- xml2po/xml2po/modes/ubuntu.py.orig
+++ 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."""

View File

@ -0,0 +1,16 @@
$OpenBSD: patch-xml2po_xml2po_modes_xhtml_py,v 1.1 2020/06/09 07:19:28 jasper Exp $
https://gitweb.gentoo.org/repo/gentoo.git/tree/app-text/gnome-doc-utils/files/gnome-doc-utils-0.20.10-python3.patch
Index: xml2po/xml2po/modes/xhtml.py
--- xml2po/xml2po/modes/xhtml.py.orig
+++ 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."""

View File

@ -0,0 +1,74 @@
$OpenBSD: patch-xml2po_xml2po_xml2po_py_in,v 1.1 2020/06/09 07:19:28 jasper Exp $
https://gitweb.gentoo.org/repo/gentoo.git/tree/app-text/gnome-doc-utils/files/gnome-doc-utils-0.20.10-python3.patch
Index: xml2po/xml2po/xml2po.py.in
--- xml2po/xml2po/xml2po.py.in.orig
+++ 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])

View File

@ -1,4 +1,4 @@
@comment $OpenBSD: PLIST,v 1.20 2015/05/22 11:36:15 ajacoutot Exp $
@comment $OpenBSD: PLIST,v 1.21 2020/06/09 07:19:28 jasper Exp $
bin/gnome-doc-prepare
bin/gnome-doc-tool
bin/xml2po
@ -6,10 +6,20 @@ lib/python${MODPY_VERSION}/site-packages/xml2po/
lib/python${MODPY_VERSION}/site-packages/xml2po/__init__.py
lib/python${MODPY_VERSION}/site-packages/xml2po/__init__.pyc
lib/python${MODPY_VERSION}/site-packages/xml2po/__init__.pyo
${MODPY_COMMENT}lib/python${MODPY_VERSION}/site-packages/xml2po/${MODPY_PYCACHE}/
lib/python${MODPY_VERSION}/site-packages/xml2po/${MODPY_PYCACHE}__init__.${MODPY_PYC_MAGIC_TAG}pyc
lib/python${MODPY_VERSION}/site-packages/xml2po/modes/
lib/python${MODPY_VERSION}/site-packages/xml2po/modes/__init__.py
lib/python${MODPY_VERSION}/site-packages/xml2po/modes/__init__.pyc
lib/python${MODPY_VERSION}/site-packages/xml2po/modes/__init__.pyo
${MODPY_COMMENT}lib/python${MODPY_VERSION}/site-packages/xml2po/modes/${MODPY_PYCACHE}/
lib/python${MODPY_VERSION}/site-packages/xml2po/modes/${MODPY_PYCACHE}__init__.${MODPY_PYC_MAGIC_TAG}pyc
lib/python${MODPY_VERSION}/site-packages/xml2po/modes/${MODPY_PYCACHE}basic.${MODPY_PYC_MAGIC_TAG}pyc
lib/python${MODPY_VERSION}/site-packages/xml2po/modes/${MODPY_PYCACHE}docbook.${MODPY_PYC_MAGIC_TAG}pyc
lib/python${MODPY_VERSION}/site-packages/xml2po/modes/${MODPY_PYCACHE}gs.${MODPY_PYC_MAGIC_TAG}pyc
lib/python${MODPY_VERSION}/site-packages/xml2po/modes/${MODPY_PYCACHE}mallard.${MODPY_PYC_MAGIC_TAG}pyc
lib/python${MODPY_VERSION}/site-packages/xml2po/modes/${MODPY_PYCACHE}ubuntu.${MODPY_PYC_MAGIC_TAG}pyc
lib/python${MODPY_VERSION}/site-packages/xml2po/modes/${MODPY_PYCACHE}xhtml.${MODPY_PYC_MAGIC_TAG}pyc
lib/python${MODPY_VERSION}/site-packages/xml2po/modes/basic.py
lib/python${MODPY_VERSION}/site-packages/xml2po/modes/basic.pyc
lib/python${MODPY_VERSION}/site-packages/xml2po/modes/basic.pyo
@ -159,8 +169,6 @@ share/locale/ar/LC_MESSAGES/gnome-doc-utils.mo
share/locale/as/
share/locale/as/LC_MESSAGES/
share/locale/as/LC_MESSAGES/gnome-doc-utils.mo
share/locale/ast/
share/locale/ast/LC_MESSAGES/
share/locale/ast/LC_MESSAGES/gnome-doc-utils.mo
share/locale/be/LC_MESSAGES/gnome-doc-utils.mo
share/locale/be@latin/
@ -228,6 +236,8 @@ share/locale/kn/
share/locale/kn/LC_MESSAGES/
share/locale/kn/LC_MESSAGES/gnome-doc-utils.mo
share/locale/ko/LC_MESSAGES/gnome-doc-utils.mo
share/locale/lt/
share/locale/lt/LC_MESSAGES/
share/locale/lt/LC_MESSAGES/gnome-doc-utils.mo
share/locale/lv/LC_MESSAGES/gnome-doc-utils.mo
share/locale/mai/
@ -285,6 +295,8 @@ share/locale/ta/LC_MESSAGES/gnome-doc-utils.mo
share/locale/te/
share/locale/te/LC_MESSAGES/
share/locale/te/LC_MESSAGES/gnome-doc-utils.mo
share/locale/th/
share/locale/th/LC_MESSAGES/
share/locale/th/LC_MESSAGES/gnome-doc-utils.mo
share/locale/tr/LC_MESSAGES/gnome-doc-utils.mo
share/locale/ug/