diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-09-28 10:21:25 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-09-28 10:21:25 +0200 |
commit | 4f3ca5f60f4de1aca6e3b9d7f30467ba0f724c27 (patch) | |
tree | d47e14dc637e15861e9ba7d65e5f4aae5d79df6d /engine/SCons/Tool/docbook | |
parent | 3765e33b76c51c81dd7bbbfacab0c4e76a1713cb (diff) | |
parent | 7c651e273c4db37f4babd91aaecf26800c50dd79 (diff) |
Updated version 3.0.0 from 'upstream/3.0.0'
with Debian dir f5f84710e04b09c178d76c96bcda7517932c0c17
Diffstat (limited to 'engine/SCons/Tool/docbook')
-rw-r--r-- | engine/SCons/Tool/docbook/__init__.py | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/engine/SCons/Tool/docbook/__init__.py b/engine/SCons/Tool/docbook/__init__.py index 83b3ecd..ed63784 100644 --- a/engine/SCons/Tool/docbook/__init__.py +++ b/engine/SCons/Tool/docbook/__init__.py @@ -10,7 +10,7 @@ selection method. """ # -# Copyright (c) 2001 - 2016 The SCons Foundation +# Copyright (c) 2001 - 2017 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -43,6 +43,8 @@ import SCons.Script import SCons.Tool import SCons.Util + +__debug_tool_location = False # Get full path to this script scriptpath = os.path.dirname(os.path.realpath(__file__)) @@ -157,6 +159,11 @@ def __create_output_dir(base_dir): # # Supported command line tools and their call "signature" # +xsltproc_com_priority = ['xsltproc', 'saxon', 'saxon-xslt', 'xalan'] + +# TODO: Set minimum version of saxon-xslt to be 8.x (lower than this only supports xslt 1.0. +# see: http://saxon.sourceforge.net/saxon6.5.5/ +# see: http://saxon.sourceforge.net/ xsltproc_com = {'xsltproc' : '$DOCBOOK_XSLTPROC $DOCBOOK_XSLTPROCFLAGS -o $TARGET $DOCBOOK_XSL $SOURCE', 'saxon' : '$DOCBOOK_XSLTPROC $DOCBOOK_XSLTPROCFLAGS -o $TARGET $DOCBOOK_XSL $SOURCE $DOCBOOK_XSLTPROCPARAMS', 'saxon-xslt' : '$DOCBOOK_XSLTPROC $DOCBOOK_XSLTPROCFLAGS -o $TARGET $DOCBOOK_XSL $SOURCE $DOCBOOK_XSLTPROCPARAMS', @@ -166,19 +173,27 @@ fop_com = {'fop' : '$DOCBOOK_FOP $DOCBOOK_FOPFLAGS -fo $SOURCE -pdf $TARGET', 'xep' : '$DOCBOOK_FOP $DOCBOOK_FOPFLAGS -valid -fo $SOURCE -pdf $TARGET', 'jw' : '$DOCBOOK_FOP $DOCBOOK_FOPFLAGS -f docbook -b pdf $SOURCE -o $TARGET'} -def __detect_cl_tool(env, chainkey, cdict): +def __detect_cl_tool(env, chainkey, cdict, cpriority=None): """ Helper function, picks a command line tool from the list and initializes its environment variables. """ if env.get(chainkey,'') == '': clpath = '' - for cltool in cdict: + + if cpriority is None: + cpriority = cdict.keys() + for cltool in cpriority: + if __debug_tool_location: + print("DocBook: Looking for %s"%cltool) clpath = env.WhereIs(cltool) if clpath: + if __debug_tool_location: + print("DocBook: Found:%s"%cltool) env[chainkey] = clpath if not env[chainkey + 'COM']: env[chainkey + 'COM'] = cdict[cltool] + break def _detect(env): """ @@ -192,10 +207,10 @@ def _detect(env): if ((not has_libxml2 and not has_lxml) or (prefer_xsltproc)): # Try to find the XSLT processors - __detect_cl_tool(env, 'DOCBOOK_XSLTPROC', xsltproc_com) + __detect_cl_tool(env, 'DOCBOOK_XSLTPROC', xsltproc_com, xsltproc_com_priority) __detect_cl_tool(env, 'DOCBOOK_XMLLINT', xmllint_com) - __detect_cl_tool(env, 'DOCBOOK_FOP', fop_com) + __detect_cl_tool(env, 'DOCBOOK_FOP', fop_com, ['fop','xep','jw']) # # Scanners @@ -335,7 +350,7 @@ def __build_lxml(target, source, env): result = transform(doc) try: - of = open(str(target[0]), "w") + of = open(str(target[0]), "wb") of.write(of.write(etree.tostring(result, pretty_print=True))) of.close() except: @@ -461,7 +476,7 @@ def DocbookEpub(env, target, source=None, *args, **kw): # Create xpath context xpath_context = doc.xpathNewContext() # Register namespaces - for key, val in nsmap.iteritems(): + for key, val in nsmap.items(): xpath_context.xpathRegisterNs(key, val) if hasattr(opf, 'xpathEval') and xpath_context: |