diff --git a/README b/README index 840abf27bc01e46ea830f1ae23c4dc00cc4dcd70..038a78595f3a5ba136f3a79e14a2a8206b7f57ec 100644 --- a/README +++ b/README @@ -141,6 +141,15 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Change history -------------- +Version 2.22b (04/20/2016) + +- Fixed endless recursion that occurred while attempting to replace + attribute group names. Thanks to Bing Wang for reporting this and + for identifying and providing the XML schema that reproduced it. +- Fixed failure to clean up names containing special characters in + function generateBuildStandard_1. This was error was uncovered + when generating code from Bing Wang's schema. Thanks again Bing. + Version 2.22a (04/11/2016) - Added support for additional command line options to diff --git a/generateDS.html b/generateDS.html index 84e723e0484ec1f731d18c69e1e5cf7b7dcffa63..1dc3def6b9cbdaacfdf6355daedd0cf941d7aa7e 100644 --- a/generateDS.html +++ b/generateDS.html @@ -220,7 +220,7 @@ They are used by updateversion.py. --> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> -<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.22a</td> +<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.22b</td> </tr> </tbody> </table> @@ -229,7 +229,7 @@ They are used by updateversion.py. --> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> -<tr class="field"><th class="field-name">date:</th><td class="field-body">April 11, 2016</td> +<tr class="field"><th class="field-name">date:</th><td class="field-body">April 20, 2016</td> </tr> </tbody> </table> @@ -3171,7 +3171,7 @@ following among others:</p> <div class="footer"> <hr class="footer" /> <a class="reference external" href="generateDS.txt">View document source</a>. -Generated on: 2016-04-11 21:52 UTC. +Generated on: 2016-04-21 00:07 UTC. Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source. </div> diff --git a/generateDS.py b/generateDS.py index 89166d0eb26cb786da916813f02d2e1ec013607d..2be33c22d0844e9840e509475dda2ca8a72cfbc4 100755 --- a/generateDS.py +++ b/generateDS.py @@ -202,7 +202,7 @@ logging.disable(logging.INFO) # Do not modify the following VERSION comments. # Used by updateversion.py. ##VERSION## -VERSION = '2.22a' +VERSION = '2.22b' ##VERSION## if sys.version_info.major == 2: @@ -1235,6 +1235,11 @@ class XschemaElement(XschemaElementBase): if key is not None: attrGroup = AttributeGroups[key] for name in attrGroup.getKeys(): + if name == groupName: + err_msg('*** Error. Element {} attributeGroup {} ' + 'has endless recursion\n'.format( + self.getName(), groupName)) + return if (name in AttributeGroups or strip_namespace(name) in AttributeGroups): self.replace_attributeGroup_names_1(name) @@ -1243,8 +1248,9 @@ class XschemaElement(XschemaElementBase): self.attributeDefs[name] = attr self.attributeDefsList.append(name) else: - err_msg('*** Error. attributeGroup %s not defined.\n' % ( - groupName, )) + err_msg('*** Error. Element %s attributeGroup %s ' + 'not defined.\n' % ( + self.getName(), groupName, )) def __str__(self): s1 = '<XschemaElement name: "%s" type: "%s">' % \ @@ -3748,6 +3754,7 @@ def generateBuildStandard_1( name = mapName(name) else: name = mappedName + name = cleanupName(name) s1 = " self.%s.append(obj_)\n" % (name, ) else: substitutionGroup = child.getAttrs().get('substitutionGroup') @@ -3756,6 +3763,7 @@ def generateBuildStandard_1( name = mapName(name) else: name = mapName(headName) + name = cleanupName(name) s1 = " self.%s = obj_\n" % (name, ) wrt(s1) wrt(" obj_.original_tagname_ = '%s'\n" % (origName, )) diff --git a/generateDS.txt b/generateDS.txt index 8f1bf292fd09ca57c2f87bb7eacce9e044e99057..e3f097ebdfcb9e2d804d397637b983297661765a 100644 --- a/generateDS.txt +++ b/generateDS.txt @@ -12,7 +12,7 @@ generateDS -- Generate Data Structures from XML Schema .. version -:revision: 2.22a +:revision: 2.22b .. version diff --git a/generateds_gui_notes.html b/generateds_gui_notes.html index bc3f7d2c8705fd943d0a326b96048163235cd90e..2b700894173d4c34807ef6a73b506b9decf5763c 100644 --- a/generateds_gui_notes.html +++ b/generateds_gui_notes.html @@ -220,7 +220,7 @@ They are used by updateversion.py. --> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> -<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.22a</td> +<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.22b</td> </tr> </tbody> </table> @@ -229,7 +229,7 @@ They are used by updateversion.py. --> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> -<tr class="field"><th class="field-name">date:</th><td class="field-body">April 11, 2016</td> +<tr class="field"><th class="field-name">date:</th><td class="field-body">April 20, 2016</td> </tr> </tbody> </table> @@ -246,15 +246,33 @@ front end to generateDS.py.</td> </tr> </tbody> </table> +<div class="contents topic" id="contents"> +<p class="topic-title first">Contents</p> +<ul class="auto-toc simple"> +<li><a class="reference internal" href="#introduction" id="id1">1 Introduction</a></li> +<li><a class="reference internal" href="#requirements" id="id2">2 Requirements</a></li> +<li><a class="reference internal" href="#usage-notes" id="id3">3 Usage notes</a><ul class="auto-toc"> +<li><a class="reference internal" href="#what-it-does" id="id4">3.1 What it does</a></li> +<li><a class="reference internal" href="#how-to-use-it" id="id5">3.2 How to use it</a></li> +</ul> +</li> +<li><a class="reference internal" href="#internationalization" id="id6">4 Internationalization</a><ul class="auto-toc"> +<li><a class="reference internal" href="#preparation" id="id7">4.1 Preparation</a></li> +<li><a class="reference internal" href="#installation-and-setup" id="id8">4.2 Installation and setup</a></li> +<li><a class="reference internal" href="#additional-information" id="id9">4.3 Additional information</a></li> +</ul> +</li> +</ul> +</div> <div class="section" id="introduction"> -<h1>Introduction</h1> +<h1><a class="toc-backref" href="#id1">1 Introduction</a></h1> <p><tt class="docutils literal">generateds_gui.py</tt> provides a graphical front end for <tt class="docutils literal">generateDS.py</tt>. Some may find it easier to configure and to select and set options for <tt class="docutils literal">generateDS.py</tt> using this graphical application.</p> </div> <div class="section" id="requirements"> -<h1>Requirements</h1> +<h1><a class="toc-backref" href="#id2">2 Requirements</a></h1> <p>You will need Gtk support for Python in order to run <tt class="docutils literal">generateds_gui.py</tt>.</p> <p>You must run <tt class="docutils literal">generateds_gui.py</tt> under Python 3. Python 2 is not @@ -264,9 +282,9 @@ supported.</p> installed.</p> </div> <div class="section" id="usage-notes"> -<h1>Usage notes</h1> +<h1><a class="toc-backref" href="#id3">3 Usage notes</a></h1> <div class="section" id="what-it-does"> -<h2>What it does</h2> +<h2><a class="toc-backref" href="#id4">3.1 What it does</a></h2> <p>Here are some of the different ways that you can use <tt class="docutils literal">generateds_gui.py</tt>:</p> <ol class="arabic simple"> @@ -286,7 +304,7 @@ or to generate a command line.</li> </ol> </div> <div class="section" id="how-to-use-it"> -<h2>How to use it</h2> +<h2><a class="toc-backref" href="#id5">3.2 How to use it</a></h2> <p>You can get some help by running the following:</p> <pre class="literal-block"> $ ./generateds_gui.py --help @@ -328,6 +346,54 @@ you run <tt class="docutils literal">generateds_gui.py</tt>, use this option. A once <tt class="docutils literal">generateds_gui.py</tt> has been started, you can use the "Load session" item under the "File" menu.</dd> </dl> +</div> +</div> +<div class="section" id="internationalization"> +<h1><a class="toc-backref" href="#id6">4 Internationalization</a></h1> +<p><em>Note:</em> This work on internationalization for generateds_gui is +experimental and does not yet work.</p> +<div class="section" id="preparation"> +<h2><a class="toc-backref" href="#id7">4.1 Preparation</a></h2> +<p>Here is what I've done:</p> +<pre class="literal-block"> +$ cd generateds/gui/ +$ mkdir po +# Create the template file. +$ xgettext -k_ -kN_ -o po/generateds_gui.pot generateds_gui.glade +# Create a file for the translator. This one is for the Russian language. +$ msginit --locale=ru --input=generateds_gui.pot +</pre> +<p>And, after someone has added their translations (for example, to +<tt class="docutils literal">ru.po</tt>), we translate it to binary with the following command:</p> +<pre class="literal-block"> +$ msgfmt -o generateds_gui.mo ru.po +</pre> +<p>Finally, move the binary file to the appropriate directory under the +directory containing the executable (<tt class="docutils literal">generateds_gui.py</tt>). See +<a class="reference internal" href="#installation-and-setup">Installation and setup</a>.</p> +</div> +<div class="section" id="installation-and-setup"> +<h2><a class="toc-backref" href="#id8">4.2 Installation and setup</a></h2> +<p>Now we have to move the <tt class="docutils literal">.mo</tt> file where it will be used when we +run <tt class="docutils literal">generateds_gui.py</tt>. We place it in a sub-directory under the +location of <tt class="docutils literal">generateds_gui.py</tt> itself.</p> +<pre class="literal-block"> +$ cd /directory/containing/generateds_gui.py +$ mkdir locale +$ mkdir locale/ru +$ mkdir locale/ru/LC_MESSAGES +$ mv generateds_gui.mo locale/ru/LC_MESSAGES/ +</pre> +</div> +<div class="section" id="additional-information"> +<h2><a class="toc-backref" href="#id9">4.3 Additional information</a></h2> +<p>Here are some helpful references:</p> +<ul class="simple"> +<li><a class="reference external" href="https://en.wikipedia.org/wiki/Gettext">https://en.wikipedia.org/wiki/Gettext</a></li> +<li><a class="reference external" href="http://faq.pygtk.org/index.py?req=show&file=faq22.002.htp">http://faq.pygtk.org/index.py?req=show&file=faq22.002.htp</a></li> +<li><a class="reference external" href="http://www.servin.com/linux/GladeInternationalization.html">http://www.servin.com/linux/GladeInternationalization.html</a></li> +<li><a class="reference external" href="http://www.learningpython.com/2006/12/03/translating-your-pythonpygtk-application/">http://www.learningpython.com/2006/12/03/translating-your-pythonpygtk-application/</a></li> +</ul> <!-- vim:ft=rst: --> </div> </div> @@ -335,7 +401,7 @@ once <tt class="docutils literal">generateds_gui.py</tt> has been started, you c <div class="footer"> <hr class="footer" /> <a class="reference external" href="generateds_gui_notes.txt">View document source</a>. -Generated on: 2016-04-11 21:52 UTC. +Generated on: 2016-04-21 00:07 UTC. Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source. </div> diff --git a/generateds_gui_notes.txt b/generateds_gui_notes.txt index 6c816b9eb2418d443ea6acdfc4a00bda7abc00f9..656a1dbd0100b0701be034ce242551b177f65bda 100644 --- a/generateds_gui_notes.txt +++ b/generateds_gui_notes.txt @@ -12,7 +12,7 @@ GenerateDS GUI Notes .. version -:revision: 2.22a +:revision: 2.22b .. version @@ -28,6 +28,12 @@ GenerateDS GUI Notes :abstract: This document describes generateds_ui.py, the graphical front end to generateDS.py. +.. sectnum:: :depth: 4 + +.. contents:: + :depth: 4 + + Introduction ============== @@ -123,4 +129,60 @@ s, session once ``generateds_gui.py`` has been started, you can use the "Load session" item under the "File" menu. + +Internationalization +====================== + +*Note:* This work on internationalization for generateds_gui is +experimental and does not yet work. + +Preparation +------------- + +Here is what I've done:: + + $ cd generateds/gui/ + $ mkdir po + # Create the template file. + $ xgettext -k_ -kN_ -o po/generateds_gui.pot generateds_gui.glade + # Create a file for the translator. This one is for the Russian language. + $ msginit --locale=ru --input=generateds_gui.pot + +And, after someone has added their translations (for example, to +``ru.po``), we translate it to binary with the following command:: + + $ msgfmt -o generateds_gui.mo ru.po + +Finally, move the binary file to the appropriate directory under the +directory containing the executable (``generateds_gui.py``). See +`Installation and setup`_. + + +Installation and setup +------------------------ + +Now we have to move the ``.mo`` file where it will be used when we +run ``generateds_gui.py``. We place it in a sub-directory under the +location of ``generateds_gui.py`` itself. + +:: + + $ cd /directory/containing/generateds_gui.py + $ mkdir locale + $ mkdir locale/ru + $ mkdir locale/ru/LC_MESSAGES + $ mv generateds_gui.mo locale/ru/LC_MESSAGES/ + + +Additional information +------------------------ + +Here are some helpful references: + +- https://en.wikipedia.org/wiki/Gettext +- http://faq.pygtk.org/index.py?req=show&file=faq22.002.htp +- http://www.servin.com/linux/GladeInternationalization.html +- http://www.learningpython.com/2006/12/03/translating-your-pythonpygtk-application/ + + .. vim:ft=rst: diff --git a/gui/generateds_gui.py b/gui/generateds_gui.py index 1c958146b1765c54eccf338e47011a0a9c2f1645..da981e97a6e22e73fba3a493e8ef6b45b0cecf31 100755 --- a/gui/generateds_gui.py +++ b/gui/generateds_gui.py @@ -6,6 +6,8 @@ from configparser import ConfigParser from xml.parsers import expat import subprocess import re +import locale +import gettext if sys.version_info.major == 2: @@ -39,7 +41,7 @@ from libgenerateDS.gui import generateds_gui_session # Do not modify the following VERSION comments. # Used by updateversion.py. ##VERSION## -VERSION = '2.22a' +VERSION = '2.22b' ##VERSION## @@ -156,6 +158,7 @@ class GeneratedsGui(object): global Builder # Default values Builder = gtk.Builder() + Builder.set_translation_domain('generateds_gui') self.options = options # self.ui_spec_filename = ui_spec_filename self.filename = None @@ -1060,6 +1063,13 @@ def main(): capture_ui_names() if len(args) > 0: usage(parser) + # Set up for internationalization. + app_name = 'generateds_gui' + dir_name = 'locale' + locale.setlocale(locale.LC_ALL, '') + gettext.bindtextdomain(app_name, dir_name) + gettext.textdomain(app_name) + # Start the app. editor = GeneratedsGui(options) editor.main() diff --git a/librarytemplate_howto.html b/librarytemplate_howto.html index 43756f51ea4aecc501b965211f9b83b0be0e1741..303c08389161fab034283a94eda68e652f26164f 100644 --- a/librarytemplate_howto.html +++ b/librarytemplate_howto.html @@ -217,7 +217,7 @@ dkuhlman (at) davekuhlman (dot) org <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> -<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.22a</td> +<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.22b</td> </tr> </tbody> </table> @@ -226,7 +226,7 @@ dkuhlman (at) davekuhlman (dot) org <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> -<tr class="field"><th class="field-name">date:</th><td class="field-body">April 11, 2016</td> +<tr class="field"><th class="field-name">date:</th><td class="field-body">April 20, 2016</td> </tr> </tbody> </table> @@ -380,7 +380,7 @@ this command for your needs. For example, you may need to use <div class="footer"> <hr class="footer" /> <a class="reference external" href="librarytemplate_howto.txt">View document source</a>. -Generated on: 2016-04-11 21:52 UTC. +Generated on: 2016-04-21 00:07 UTC. Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source. </div> diff --git a/librarytemplate_howto.txt b/librarytemplate_howto.txt index a8e999284ae13c026f06d52977673890d365f538..f508d04fc3aa98992bb5195ac155f014199ee4c3 100644 --- a/librarytemplate_howto.txt +++ b/librarytemplate_howto.txt @@ -8,7 +8,7 @@ How to package a generateDS.py generated library .. version -:revision: 2.22a +:revision: 2.22b .. version diff --git a/process_includes.py b/process_includes.py index e60f2ec1d79f35c359b114663fe696d568491004..e9516b642046c9f543ad95a18f27ebf403a33234 100755 --- a/process_includes.py +++ b/process_includes.py @@ -40,7 +40,7 @@ except ImportError: # Do not modify the following VERSION comments. # Used by updateversion.py. ##VERSION## -VERSION = '2.22a' +VERSION = '2.22b' ##VERSION## CatalogDict = {} diff --git a/setup.py b/setup.py index 1c45b738415f87a723823f9eb71447f6df94965a..4468b677422382ef8cac69f5b5ed521f3ebab239 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup(name="generateDS", # Do not modify the following VERSION comments. # Used by updateversion.py. ##VERSION## - version="2.22a", + version="2.22b", ##VERSION## author="Dave Kuhlman", author_email="dkuhlman@davekuhlman.org", diff --git a/tutorial/generateds_tutorial.html b/tutorial/generateds_tutorial.html index 91dea5b78219cc093a976830e4ae51370ec5d86b..f0388da4973b316ee4bc8f5ec3e20e5b26426d76 100644 --- a/tutorial/generateds_tutorial.html +++ b/tutorial/generateds_tutorial.html @@ -219,7 +219,7 @@ They are used by updateversion.py. --> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> -<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.22a</td> +<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.22b</td> </tr> </tbody> </table> @@ -228,7 +228,7 @@ They are used by updateversion.py. --> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> -<tr class="field"><th class="field-name">date:</th><td class="field-body">April 11, 2016</td> +<tr class="field"><th class="field-name">date:</th><td class="field-body">April 20, 2016</td> </tr> </tbody> </table> @@ -1210,7 +1210,7 @@ named <tt class="docutils literal">garden_api.py</tt>, you can create an instanc <div class="footer"> <hr class="footer" /> <a class="reference external" href="generateds_tutorial.txt">View document source</a>. -Generated on: 2016-04-11 21:52 UTC. +Generated on: 2016-04-21 00:07 UTC. Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source. </div> diff --git a/tutorial/generateds_tutorial.txt b/tutorial/generateds_tutorial.txt index c6e47bef04774ce42608fea4d4b93632b819b8e9..284cd931754e522ba9ff00242368a3ea086a081d 100644 --- a/tutorial/generateds_tutorial.txt +++ b/tutorial/generateds_tutorial.txt @@ -11,7 +11,7 @@ generateDS -- Introduction and Tutorial .. version -:revision: 2.22a +:revision: 2.22b .. version diff --git a/tutorial/generateds_tutorial.zip b/tutorial/generateds_tutorial.zip index aef0372624e79e054389a38a3a5e636e1025d8ef..c4d2106650554582769f23f527c2ac60244d8ce8 100644 Binary files a/tutorial/generateds_tutorial.zip and b/tutorial/generateds_tutorial.zip differ