ExportPDF

Changeset

0:bb07949085d1
2013-10-31 Paul Boddie raw files shortlog changelog graph An export action for MoinMoin producing PDF documents for wiki pages.
README.txt (file) actions/ExportPDF.py (file) docs/COPYING.txt (file) docs/LICENCE.txt (file)
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/README.txt	Thu Oct 31 23:46:00 2013 +0100
     1.3 @@ -0,0 +1,100 @@
     1.4 +Introduction
     1.5 +------------
     1.6 +
     1.7 +The ExportPDF action enables the export of MoinMoin wiki pages as PDF
     1.8 +documents using XSLT, DocBook and XSL-FO external tools.
     1.9 +
    1.10 +Installation
    1.11 +------------
    1.12 +
    1.13 +The following configuration settings are present in the ExportPDF.py module:
    1.14 +
    1.15 +XSLT_PROCESSOR              Path to the xsltproc program
    1.16 +FO_PROCESSOR                Path to the fop program
    1.17 +DOCBOOK_STYLESHEET_BASE     Path to the directory containing DocBook resources
    1.18 +
    1.19 +Another setting that should not need modifying is the following:
    1.20 +
    1.21 +DOCBOOK_TO_FO_STYLESHEET    Relative path to the docbook.xsl stylesheet file
    1.22 +                            from the DOCBOOK_STYLESHEET_BASE path (putting
    1.23 +                            them together should reference the file with an
    1.24 +                            absolute path)
    1.25 +
    1.26 +Once configured, copy the ExportPDF.py module into your wiki's actions
    1.27 +directory.
    1.28 +
    1.29 +With moinsetup and a suitable configuration file (see "Recommended Software"
    1.30 +below), you can perform this last step as follows, with $EPDIR referring to
    1.31 +the ExportPDF distribution directory:
    1.32 +
    1.33 +  python moinsetup.py -f moinsetup.cfg -m install_actions $EPDIR/actions
    1.34 +
    1.35 +Basic Usage
    1.36 +-----------
    1.37 +
    1.38 +Select the ExportPDF action from the actions menu; a PDF document should be
    1.39 +offered for download.
    1.40 +
    1.41 +Recommended Software
    1.42 +--------------------
    1.43 +
    1.44 +See the "Dependencies" section below for essential software.
    1.45 +
    1.46 +The moinsetup tool is recommended for installation since it aims to support
    1.47 +all versions of MoinMoin that are supported for use with this software.
    1.48 +
    1.49 +See the following page for information on moinsetup:
    1.50 +
    1.51 +http://moinmo.in/ScriptMarket/moinsetup
    1.52 +
    1.53 +Dependencies
    1.54 +------------
    1.55 +
    1.56 +The ExportPDF action has the following basic dependencies:
    1.57 +
    1.58 +Packages                    Release Information
    1.59 +--------                    -------------------
    1.60 +
    1.61 +xsltproc                    Tested with 1.1.26
    1.62 +                            Debian package: xsltproc
    1.63 +                            Source: http://www.xmlsoft.org/XSLT.html
    1.64 +
    1.65 +Apache FOP                  Tested with 1.0
    1.66 +                            Debian package: fop
    1.67 +                            Source: http://xmlgraphics.apache.org/fop/
    1.68 +
    1.69 +DocBook XSL                 Tested with 1.76.1
    1.70 +                            Debian package: docbook-xsl
    1.71 +                            Source: http://docbook.sourceforge.net/
    1.72 +
    1.73 +Java                        Tested with a Java 6 runtime
    1.74 +                            Debian package: openjdk-6-jre-headless
    1.75 +                            Source: http://www.oracle.com/technetwork/java/index.html
    1.76 +
    1.77 +The Java dependency is unfortunate and would ideally be avoided by using
    1.78 +something other than Apache FOP.
    1.79 +
    1.80 +Contact, Copyright and Licence Information
    1.81 +------------------------------------------
    1.82 +
    1.83 +See the following Web page for more information about this work:
    1.84 +
    1.85 +http://moinmo.in/ActionMarket/ExportPDF
    1.86 +
    1.87 +The author of this packaging of the original work can be contacted at the
    1.88 +following e-mail address:
    1.89 +
    1.90 +paul@boddie.org.uk
    1.91 +
    1.92 +Copyright and licence information can be found in the docs directory - see
    1.93 +docs/COPYING.txt and docs/LICENCE.txt for more information.
    1.94 +
    1.95 +Release Procedures
    1.96 +------------------
    1.97 +
    1.98 +Update the actions/ExportPDF.py __version__ attribute.
    1.99 +Change the version number and package filename/directory in the documentation.
   1.100 +Update the release notes (see above).
   1.101 +Tag, export.
   1.102 +Archive, upload.
   1.103 +Update the ActionMarket and ActionMarket/ExportPDF page.
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/actions/ExportPDF.py	Thu Oct 31 23:46:00 2013 +0100
     2.3 @@ -0,0 +1,180 @@
     2.4 +# -*- coding: iso-8859-1 -*-
     2.5 +"""
     2.6 +    MoinMoin - Export as PDF action
     2.7 +
     2.8 +    @copyright: 2013 by Paul Boddie <paul@boddie.org.uk>
     2.9 +    @license: GNU GPL (v2 or later), see COPYING.txt for details.
    2.10 +"""
    2.11 +
    2.12 +from MoinMoin.action import ActionBase
    2.13 +from MoinMoin.wikiutil import escape
    2.14 +from MoinSupport import ActionSupport, escattr, getFormatterClass, formatText, get_send_headers
    2.15 +from os.path import join
    2.16 +import subprocess
    2.17 +
    2.18 +__version__ = "0.1"
    2.19 +
    2.20 +Dependencies = ['page']
    2.21 +
    2.22 +# Configuration settings.
    2.23 +
    2.24 +XSLT_PROCESSOR              = "/usr/bin/xsltproc"
    2.25 +FO_PROCESSOR                = "/usr/bin/fop"
    2.26 +DOCBOOK_STYLESHEET_BASE     = "/usr/share/xml/docbook/stylesheet"
    2.27 +
    2.28 +# Tool settings.
    2.29 +
    2.30 +DOCBOOK_TO_FO_STYLESHEET    = "docbook-xsl/fo/docbook.xsl"
    2.31 +
    2.32 +# NOTE: From docbook-xsl/fo/param.xsl.
    2.33 +
    2.34 +paper_sizes = [
    2.35 +    "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "A10",
    2.36 +    "B0", "B1", "B2", "B3", "B4", "B5", "B6", "B7", "B8", "B9", "B10",
    2.37 +    "C0", "C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9", "C10",
    2.38 +    "A4landscape", "USletter", "USlandscape", "4A0", "2A0",
    2.39 +    ]
    2.40 +
    2.41 +paper_size_labels = {
    2.42 +    "A4landscape" : "A4 landscape",
    2.43 +    "USletter" : "US letter",
    2.44 +    "USlandscape" : "US landscape",
    2.45 +    "4A0" : "Quadruple A0",
    2.46 +    "2A0" : "Double A0"
    2.47 +    }
    2.48 +
    2.49 +class ExportPDF(ActionBase, ActionSupport):
    2.50 +
    2.51 +    "Export the current page as PDF."
    2.52 +
    2.53 +    def get_form_html(self, buttons_html):
    2.54 +
    2.55 +        "Return the action's form incorporating the 'buttons_html'."
    2.56 +
    2.57 +        _ = self._
    2.58 +        request = self.request
    2.59 +        form = self.get_form()
    2.60 +
    2.61 +        paper_size = form.get("paper-size", ["A4"])[0]
    2.62 +
    2.63 +        paper_size_options = []
    2.64 +
    2.65 +        for size in paper_sizes:
    2.66 +            paper_size_options.append('<option value="%s" %s>%s</option>' % (
    2.67 +                escattr(size), self._get_selected(size, paper_size),
    2.68 +                escape(_(paper_size_labels.get(size) or size))
    2.69 +                ))
    2.70 +
    2.71 +        d = {
    2.72 +            "paper_size_label"      : escape(_("Paper size")),
    2.73 +            "paper_size_options"    : u"".join(paper_size_options),
    2.74 +            "buttons_html"          : buttons_html,
    2.75 +            }
    2.76 +
    2.77 +        return u"""\
    2.78 +<table>
    2.79 +    <tr>
    2.80 +        <td class="label"><label>%(paper_size_label)s</label></td>
    2.81 +        <td><select name="paper-size">%(paper_size_options)s</select></td>
    2.82 +    </tr>
    2.83 +    <tr>
    2.84 +        <td></td>
    2.85 +        <td class="buttons">%(buttons_html)s</td>
    2.86 +    </tr>
    2.87 +</table>
    2.88 +""" % d
    2.89 +
    2.90 +    def do_action(self):
    2.91 +
    2.92 +        "Attempt to post a comment."
    2.93 +
    2.94 +        _ = self._
    2.95 +        request = self.request
    2.96 +        form = self.get_form()
    2.97 +        page = self.page
    2.98 +
    2.99 +        paper_size = form.get("paper-size", [""])[0]
   2.100 +
   2.101 +        if not paper_size in paper_sizes:
   2.102 +            return 0, _("A paper size must be chosen.")
   2.103 +
   2.104 +        # Get the page in DocBook format.
   2.105 +
   2.106 +        fmt = getFormatterClass(request, "text_docbook")(request)
   2.107 +        fmt.setPage(page)
   2.108 +
   2.109 +        # The DocBook formatter needs to pretend a full document is being made.
   2.110 +
   2.111 +        page_as_docbook = []
   2.112 +        append = page_as_docbook.append
   2.113 +
   2.114 +        append(fmt.startDocument(page.page_name))
   2.115 +        append(fmt.startContent())
   2.116 +        append(formatText(page.get_raw_body(), request, fmt, inhibit_p=False).encode("utf-8"))
   2.117 +        append(fmt.endContent())
   2.118 +        append(fmt.endDocument())
   2.119 +
   2.120 +        # Send the DocBook XML to the XSLT processor.
   2.121 +
   2.122 +        p1 = subprocess.Popen([
   2.123 +            XSLT_PROCESSOR,
   2.124 +            "-stringparam", "fop1.extensions", "1",
   2.125 +            "--stringparam", "paper.type", paper_size,
   2.126 +            join(DOCBOOK_STYLESHEET_BASE, DOCBOOK_TO_FO_STYLESHEET),
   2.127 +            "-"
   2.128 +            ],
   2.129 +            shell=False,
   2.130 +            stdin=subprocess.PIPE,
   2.131 +            stdout=subprocess.PIPE,
   2.132 +            stderr=subprocess.PIPE)
   2.133 +
   2.134 +        p1.stdin.write("".join(page_as_docbook))
   2.135 +        p1.stdin.close()
   2.136 +
   2.137 +        # Pipe the XML-FO output to the FO processor.
   2.138 +
   2.139 +        p2 = subprocess.Popen([
   2.140 +            FO_PROCESSOR,
   2.141 +            "-fo", "-",
   2.142 +            "-pdf", "-",
   2.143 +            ],
   2.144 +            shell=False,
   2.145 +            stdin=p1.stdout,
   2.146 +            stdout=subprocess.PIPE,
   2.147 +            stderr=subprocess.PIPE)
   2.148 +
   2.149 +        out, err = p2.communicate()
   2.150 +
   2.151 +        retcode = p1.wait()
   2.152 +
   2.153 +        if retcode != 0:
   2.154 +            return 0, err
   2.155 +
   2.156 +        retcode = p2.wait()
   2.157 +
   2.158 +        if retcode != 0:
   2.159 +            return 0, err
   2.160 +
   2.161 +        send_headers = get_send_headers(request)
   2.162 +        headers = ["Content-Type: application/pdf"]
   2.163 +        send_headers(headers)
   2.164 +        request.write(out)
   2.165 +
   2.166 +        return 1, None
   2.167 +
   2.168 +    def render_success(self, msg, msgtype=None):
   2.169 +
   2.170 +        """
   2.171 +        Render neither 'msg' nor 'msgtype' since a resource has already been
   2.172 +        produced.
   2.173 +        NOTE: msgtype is optional because MoinMoin 1.5.x does not support it.
   2.174 +        """
   2.175 +
   2.176 +        pass
   2.177 +
   2.178 +# Action invocation function.
   2.179 +
   2.180 +def execute(pagename, request):
   2.181 +    ExportPDF(pagename, request).render()
   2.182 +
   2.183 +# vim: tabstop=4 expandtab shiftwidth=4
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/docs/COPYING.txt	Thu Oct 31 23:46:00 2013 +0100
     3.3 @@ -0,0 +1,19 @@
     3.4 +Licence Agreement
     3.5 +-----------------
     3.6 +
     3.7 +Copyright (C) 2013 Paul Boddie <paul@boddie.org.uk>
     3.8 +
     3.9 +This software is free software; you can redistribute it and/or
    3.10 +modify it under the terms of the GNU General Public License as
    3.11 +published by the Free Software Foundation; either version 2 of
    3.12 +the License, or (at your option) any later version.
    3.13 +
    3.14 +This software is distributed in the hope that it will be useful,
    3.15 +but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.16 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3.17 +GNU General Public License for more details.
    3.18 +
    3.19 +You should have received a copy of the GNU General Public
    3.20 +License along with this library; see the file LICENCE.txt
    3.21 +If not, write to the Free Software Foundation, Inc.,
    3.22 +51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/docs/LICENCE.txt	Thu Oct 31 23:46:00 2013 +0100
     4.3 @@ -0,0 +1,339 @@
     4.4 +		    GNU GENERAL PUBLIC LICENSE
     4.5 +		       Version 2, June 1991
     4.6 +
     4.7 + Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
     4.8 + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
     4.9 + Everyone is permitted to copy and distribute verbatim copies
    4.10 + of this license document, but changing it is not allowed.
    4.11 +
    4.12 +			    Preamble
    4.13 +
    4.14 +  The licenses for most software are designed to take away your
    4.15 +freedom to share and change it.  By contrast, the GNU General Public
    4.16 +License is intended to guarantee your freedom to share and change free
    4.17 +software--to make sure the software is free for all its users.  This
    4.18 +General Public License applies to most of the Free Software
    4.19 +Foundation's software and to any other program whose authors commit to
    4.20 +using it.  (Some other Free Software Foundation software is covered by
    4.21 +the GNU Lesser General Public License instead.)  You can apply it to
    4.22 +your programs, too.
    4.23 +
    4.24 +  When we speak of free software, we are referring to freedom, not
    4.25 +price.  Our General Public Licenses are designed to make sure that you
    4.26 +have the freedom to distribute copies of free software (and charge for
    4.27 +this service if you wish), that you receive source code or can get it
    4.28 +if you want it, that you can change the software or use pieces of it
    4.29 +in new free programs; and that you know you can do these things.
    4.30 +
    4.31 +  To protect your rights, we need to make restrictions that forbid
    4.32 +anyone to deny you these rights or to ask you to surrender the rights.
    4.33 +These restrictions translate to certain responsibilities for you if you
    4.34 +distribute copies of the software, or if you modify it.
    4.35 +
    4.36 +  For example, if you distribute copies of such a program, whether
    4.37 +gratis or for a fee, you must give the recipients all the rights that
    4.38 +you have.  You must make sure that they, too, receive or can get the
    4.39 +source code.  And you must show them these terms so they know their
    4.40 +rights.
    4.41 +
    4.42 +  We protect your rights with two steps: (1) copyright the software, and
    4.43 +(2) offer you this license which gives you legal permission to copy,
    4.44 +distribute and/or modify the software.
    4.45 +
    4.46 +  Also, for each author's protection and ours, we want to make certain
    4.47 +that everyone understands that there is no warranty for this free
    4.48 +software.  If the software is modified by someone else and passed on, we
    4.49 +want its recipients to know that what they have is not the original, so
    4.50 +that any problems introduced by others will not reflect on the original
    4.51 +authors' reputations.
    4.52 +
    4.53 +  Finally, any free program is threatened constantly by software
    4.54 +patents.  We wish to avoid the danger that redistributors of a free
    4.55 +program will individually obtain patent licenses, in effect making the
    4.56 +program proprietary.  To prevent this, we have made it clear that any
    4.57 +patent must be licensed for everyone's free use or not licensed at all.
    4.58 +
    4.59 +  The precise terms and conditions for copying, distribution and
    4.60 +modification follow.
    4.61 +
    4.62 +		    GNU GENERAL PUBLIC LICENSE
    4.63 +   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
    4.64 +
    4.65 +  0. This License applies to any program or other work which contains
    4.66 +a notice placed by the copyright holder saying it may be distributed
    4.67 +under the terms of this General Public License.  The "Program", below,
    4.68 +refers to any such program or work, and a "work based on the Program"
    4.69 +means either the Program or any derivative work under copyright law:
    4.70 +that is to say, a work containing the Program or a portion of it,
    4.71 +either verbatim or with modifications and/or translated into another
    4.72 +language.  (Hereinafter, translation is included without limitation in
    4.73 +the term "modification".)  Each licensee is addressed as "you".
    4.74 +
    4.75 +Activities other than copying, distribution and modification are not
    4.76 +covered by this License; they are outside its scope.  The act of
    4.77 +running the Program is not restricted, and the output from the Program
    4.78 +is covered only if its contents constitute a work based on the
    4.79 +Program (independent of having been made by running the Program).
    4.80 +Whether that is true depends on what the Program does.
    4.81 +
    4.82 +  1. You may copy and distribute verbatim copies of the Program's
    4.83 +source code as you receive it, in any medium, provided that you
    4.84 +conspicuously and appropriately publish on each copy an appropriate
    4.85 +copyright notice and disclaimer of warranty; keep intact all the
    4.86 +notices that refer to this License and to the absence of any warranty;
    4.87 +and give any other recipients of the Program a copy of this License
    4.88 +along with the Program.
    4.89 +
    4.90 +You may charge a fee for the physical act of transferring a copy, and
    4.91 +you may at your option offer warranty protection in exchange for a fee.
    4.92 +
    4.93 +  2. You may modify your copy or copies of the Program or any portion
    4.94 +of it, thus forming a work based on the Program, and copy and
    4.95 +distribute such modifications or work under the terms of Section 1
    4.96 +above, provided that you also meet all of these conditions:
    4.97 +
    4.98 +    a) You must cause the modified files to carry prominent notices
    4.99 +    stating that you changed the files and the date of any change.
   4.100 +
   4.101 +    b) You must cause any work that you distribute or publish, that in
   4.102 +    whole or in part contains or is derived from the Program or any
   4.103 +    part thereof, to be licensed as a whole at no charge to all third
   4.104 +    parties under the terms of this License.
   4.105 +
   4.106 +    c) If the modified program normally reads commands interactively
   4.107 +    when run, you must cause it, when started running for such
   4.108 +    interactive use in the most ordinary way, to print or display an
   4.109 +    announcement including an appropriate copyright notice and a
   4.110 +    notice that there is no warranty (or else, saying that you provide
   4.111 +    a warranty) and that users may redistribute the program under
   4.112 +    these conditions, and telling the user how to view a copy of this
   4.113 +    License.  (Exception: if the Program itself is interactive but
   4.114 +    does not normally print such an announcement, your work based on
   4.115 +    the Program is not required to print an announcement.)
   4.116 +
   4.117 +These requirements apply to the modified work as a whole.  If
   4.118 +identifiable sections of that work are not derived from the Program,
   4.119 +and can be reasonably considered independent and separate works in
   4.120 +themselves, then this License, and its terms, do not apply to those
   4.121 +sections when you distribute them as separate works.  But when you
   4.122 +distribute the same sections as part of a whole which is a work based
   4.123 +on the Program, the distribution of the whole must be on the terms of
   4.124 +this License, whose permissions for other licensees extend to the
   4.125 +entire whole, and thus to each and every part regardless of who wrote it.
   4.126 +
   4.127 +Thus, it is not the intent of this section to claim rights or contest
   4.128 +your rights to work written entirely by you; rather, the intent is to
   4.129 +exercise the right to control the distribution of derivative or
   4.130 +collective works based on the Program.
   4.131 +
   4.132 +In addition, mere aggregation of another work not based on the Program
   4.133 +with the Program (or with a work based on the Program) on a volume of
   4.134 +a storage or distribution medium does not bring the other work under
   4.135 +the scope of this License.
   4.136 +
   4.137 +  3. You may copy and distribute the Program (or a work based on it,
   4.138 +under Section 2) in object code or executable form under the terms of
   4.139 +Sections 1 and 2 above provided that you also do one of the following:
   4.140 +
   4.141 +    a) Accompany it with the complete corresponding machine-readable
   4.142 +    source code, which must be distributed under the terms of Sections
   4.143 +    1 and 2 above on a medium customarily used for software interchange; or,
   4.144 +
   4.145 +    b) Accompany it with a written offer, valid for at least three
   4.146 +    years, to give any third party, for a charge no more than your
   4.147 +    cost of physically performing source distribution, a complete
   4.148 +    machine-readable copy of the corresponding source code, to be
   4.149 +    distributed under the terms of Sections 1 and 2 above on a medium
   4.150 +    customarily used for software interchange; or,
   4.151 +
   4.152 +    c) Accompany it with the information you received as to the offer
   4.153 +    to distribute corresponding source code.  (This alternative is
   4.154 +    allowed only for noncommercial distribution and only if you
   4.155 +    received the program in object code or executable form with such
   4.156 +    an offer, in accord with Subsection b above.)
   4.157 +
   4.158 +The source code for a work means the preferred form of the work for
   4.159 +making modifications to it.  For an executable work, complete source
   4.160 +code means all the source code for all modules it contains, plus any
   4.161 +associated interface definition files, plus the scripts used to
   4.162 +control compilation and installation of the executable.  However, as a
   4.163 +special exception, the source code distributed need not include
   4.164 +anything that is normally distributed (in either source or binary
   4.165 +form) with the major components (compiler, kernel, and so on) of the
   4.166 +operating system on which the executable runs, unless that component
   4.167 +itself accompanies the executable.
   4.168 +
   4.169 +If distribution of executable or object code is made by offering
   4.170 +access to copy from a designated place, then offering equivalent
   4.171 +access to copy the source code from the same place counts as
   4.172 +distribution of the source code, even though third parties are not
   4.173 +compelled to copy the source along with the object code.
   4.174 +
   4.175 +  4. You may not copy, modify, sublicense, or distribute the Program
   4.176 +except as expressly provided under this License.  Any attempt
   4.177 +otherwise to copy, modify, sublicense or distribute the Program is
   4.178 +void, and will automatically terminate your rights under this License.
   4.179 +However, parties who have received copies, or rights, from you under
   4.180 +this License will not have their licenses terminated so long as such
   4.181 +parties remain in full compliance.
   4.182 +
   4.183 +  5. You are not required to accept this License, since you have not
   4.184 +signed it.  However, nothing else grants you permission to modify or
   4.185 +distribute the Program or its derivative works.  These actions are
   4.186 +prohibited by law if you do not accept this License.  Therefore, by
   4.187 +modifying or distributing the Program (or any work based on the
   4.188 +Program), you indicate your acceptance of this License to do so, and
   4.189 +all its terms and conditions for copying, distributing or modifying
   4.190 +the Program or works based on it.
   4.191 +
   4.192 +  6. Each time you redistribute the Program (or any work based on the
   4.193 +Program), the recipient automatically receives a license from the
   4.194 +original licensor to copy, distribute or modify the Program subject to
   4.195 +these terms and conditions.  You may not impose any further
   4.196 +restrictions on the recipients' exercise of the rights granted herein.
   4.197 +You are not responsible for enforcing compliance by third parties to
   4.198 +this License.
   4.199 +
   4.200 +  7. If, as a consequence of a court judgment or allegation of patent
   4.201 +infringement or for any other reason (not limited to patent issues),
   4.202 +conditions are imposed on you (whether by court order, agreement or
   4.203 +otherwise) that contradict the conditions of this License, they do not
   4.204 +excuse you from the conditions of this License.  If you cannot
   4.205 +distribute so as to satisfy simultaneously your obligations under this
   4.206 +License and any other pertinent obligations, then as a consequence you
   4.207 +may not distribute the Program at all.  For example, if a patent
   4.208 +license would not permit royalty-free redistribution of the Program by
   4.209 +all those who receive copies directly or indirectly through you, then
   4.210 +the only way you could satisfy both it and this License would be to
   4.211 +refrain entirely from distribution of the Program.
   4.212 +
   4.213 +If any portion of this section is held invalid or unenforceable under
   4.214 +any particular circumstance, the balance of the section is intended to
   4.215 +apply and the section as a whole is intended to apply in other
   4.216 +circumstances.
   4.217 +
   4.218 +It is not the purpose of this section to induce you to infringe any
   4.219 +patents or other property right claims or to contest validity of any
   4.220 +such claims; this section has the sole purpose of protecting the
   4.221 +integrity of the free software distribution system, which is
   4.222 +implemented by public license practices.  Many people have made
   4.223 +generous contributions to the wide range of software distributed
   4.224 +through that system in reliance on consistent application of that
   4.225 +system; it is up to the author/donor to decide if he or she is willing
   4.226 +to distribute software through any other system and a licensee cannot
   4.227 +impose that choice.
   4.228 +
   4.229 +This section is intended to make thoroughly clear what is believed to
   4.230 +be a consequence of the rest of this License.
   4.231 +
   4.232 +  8. If the distribution and/or use of the Program is restricted in
   4.233 +certain countries either by patents or by copyrighted interfaces, the
   4.234 +original copyright holder who places the Program under this License
   4.235 +may add an explicit geographical distribution limitation excluding
   4.236 +those countries, so that distribution is permitted only in or among
   4.237 +countries not thus excluded.  In such case, this License incorporates
   4.238 +the limitation as if written in the body of this License.
   4.239 +
   4.240 +  9. The Free Software Foundation may publish revised and/or new versions
   4.241 +of the General Public License from time to time.  Such new versions will
   4.242 +be similar in spirit to the present version, but may differ in detail to
   4.243 +address new problems or concerns.
   4.244 +
   4.245 +Each version is given a distinguishing version number.  If the Program
   4.246 +specifies a version number of this License which applies to it and "any
   4.247 +later version", you have the option of following the terms and conditions
   4.248 +either of that version or of any later version published by the Free
   4.249 +Software Foundation.  If the Program does not specify a version number of
   4.250 +this License, you may choose any version ever published by the Free Software
   4.251 +Foundation.
   4.252 +
   4.253 +  10. If you wish to incorporate parts of the Program into other free
   4.254 +programs whose distribution conditions are different, write to the author
   4.255 +to ask for permission.  For software which is copyrighted by the Free
   4.256 +Software Foundation, write to the Free Software Foundation; we sometimes
   4.257 +make exceptions for this.  Our decision will be guided by the two goals
   4.258 +of preserving the free status of all derivatives of our free software and
   4.259 +of promoting the sharing and reuse of software generally.
   4.260 +
   4.261 +			    NO WARRANTY
   4.262 +
   4.263 +  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
   4.264 +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
   4.265 +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
   4.266 +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
   4.267 +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
   4.268 +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
   4.269 +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
   4.270 +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
   4.271 +REPAIR OR CORRECTION.
   4.272 +
   4.273 +  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
   4.274 +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
   4.275 +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
   4.276 +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
   4.277 +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
   4.278 +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
   4.279 +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
   4.280 +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
   4.281 +POSSIBILITY OF SUCH DAMAGES.
   4.282 +
   4.283 +		     END OF TERMS AND CONDITIONS
   4.284 +
   4.285 +	    How to Apply These Terms to Your New Programs
   4.286 +
   4.287 +  If you develop a new program, and you want it to be of the greatest
   4.288 +possible use to the public, the best way to achieve this is to make it
   4.289 +free software which everyone can redistribute and change under these terms.
   4.290 +
   4.291 +  To do so, attach the following notices to the program.  It is safest
   4.292 +to attach them to the start of each source file to most effectively
   4.293 +convey the exclusion of warranty; and each file should have at least
   4.294 +the "copyright" line and a pointer to where the full notice is found.
   4.295 +
   4.296 +    <one line to give the program's name and a brief idea of what it does.>
   4.297 +    Copyright (C) <year>  <name of author>
   4.298 +
   4.299 +    This program is free software; you can redistribute it and/or modify
   4.300 +    it under the terms of the GNU General Public License as published by
   4.301 +    the Free Software Foundation; either version 2 of the License, or
   4.302 +    (at your option) any later version.
   4.303 +
   4.304 +    This program is distributed in the hope that it will be useful,
   4.305 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   4.306 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   4.307 +    GNU General Public License for more details.
   4.308 +
   4.309 +    You should have received a copy of the GNU General Public License along
   4.310 +    with this program; if not, write to the Free Software Foundation, Inc.,
   4.311 +    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
   4.312 +
   4.313 +Also add information on how to contact you by electronic and paper mail.
   4.314 +
   4.315 +If the program is interactive, make it output a short notice like this
   4.316 +when it starts in an interactive mode:
   4.317 +
   4.318 +    Gnomovision version 69, Copyright (C) year name of author
   4.319 +    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
   4.320 +    This is free software, and you are welcome to redistribute it
   4.321 +    under certain conditions; type `show c' for details.
   4.322 +
   4.323 +The hypothetical commands `show w' and `show c' should show the appropriate
   4.324 +parts of the General Public License.  Of course, the commands you use may
   4.325 +be called something other than `show w' and `show c'; they could even be
   4.326 +mouse-clicks or menu items--whatever suits your program.
   4.327 +
   4.328 +You should also get your employer (if you work as a programmer) or your
   4.329 +school, if any, to sign a "copyright disclaimer" for the program, if
   4.330 +necessary.  Here is a sample; alter the names:
   4.331 +
   4.332 +  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
   4.333 +  `Gnomovision' (which makes passes at compilers) written by James Hacker.
   4.334 +
   4.335 +  <signature of Ty Coon>, 1 April 1989
   4.336 +  Ty Coon, President of Vice
   4.337 +
   4.338 +This General Public License does not permit incorporating your program into
   4.339 +proprietary programs.  If your program is a subroutine library, you may
   4.340 +consider it more useful to permit linking proprietary applications with the
   4.341 +library.  If this is what you want to do, use the GNU Lesser General
   4.342 +Public License instead of this License.