From 47d45663984f0f8e81c5a6eb8e06d854400c3749 Mon Sep 17 00:00:00 2001
From: dkuhlman <none@none>
Date: Tue, 13 Aug 2013 15:31:19 -0700
Subject: [PATCH] Fixes preliminary to v. 2.11a

---
 README                    |   7 ++-
 generateDS.html           |  18 ++++---
 generateDS.py             | 110 ++++++++++++++++++++------------------
 generateDS.txt            |  16 +++---
 librarytemplate_howto.txt |   2 +-
 process_includes.py       |   2 +-
 setup.py                  |   2 +-
 7 files changed, 87 insertions(+), 70 deletions(-)

diff --git a/README b/README
index bebd349..a3d9317 100644
--- a/README
+++ b/README
@@ -141,13 +141,18 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 Change history
 --------------
 
-Version 2.11a (08/06/2013)
+Version 2.11a (08/14/2013)
 - Added ability to use XML catalog to find included/imported
   schemas.  Thanks to George David for implementing this
   enhancement.
 - Added ability to pick up the target namespace and its prefix, then
   use them in calling the export functions from the parse functions.
   Thanks to George David for suggesting this.
+- Several fixes to formatting date and floats during export.  Thanks
+  to Domenico Mangleri for catching and fixing these.
+- The information about minOccurs and maxOccurs in the generateDS
+  document (generateDS.txt) was misleading or wrong.  Edited it.
+  Thanks to Rinat Yangurazov for catching this.
 
 Version 2.10b (07/22/2013)
 - Changed flag for generating getters and setters.  Removed flag
diff --git a/generateDS.html b/generateDS.html
index c1467a8..cb22a44 100644
--- a/generateDS.html
+++ b/generateDS.html
@@ -225,7 +225,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">June 19, 2013</td>
+<tr class="field"><th class="field-name">date:</th><td class="field-body">August 13, 2013</td>
 </tr>
 </tbody>
 </table>
@@ -308,7 +308,7 @@ to process the contents of an XML document.</td>
 <li><a class="reference internal" href="#xsd-enumeration-support" id="id45">11.2&nbsp;&nbsp;&nbsp;xsd:enumeration support</a></li>
 <li><a class="reference internal" href="#xsd-union-support" id="id46">11.3&nbsp;&nbsp;&nbsp;xsd:union support</a></li>
 <li><a class="reference internal" href="#extended-xsd-choice-support" id="id47">11.4&nbsp;&nbsp;&nbsp;Extended xsd:choice support</a></li>
-<li><a class="reference internal" href="#minoccurs-attribute-support" id="id48">11.5&nbsp;&nbsp;&nbsp;minOccurs attribute support</a></li>
+<li><a class="reference internal" href="#arity-minoccurs-maxoccurs-etc" id="id48">11.5&nbsp;&nbsp;&nbsp;Arity, minOccurs, maxOccurs, etc</a></li>
 <li><a class="reference internal" href="#more-thorough-content-type-and-base-type-resolution" id="id49">11.6&nbsp;&nbsp;&nbsp;More thorough content type and base type resolution</a></li>
 <li><a class="reference internal" href="#making-top-level-simpletypes-available-from-xschemahandler" id="id50">11.7&nbsp;&nbsp;&nbsp;Making top level simpleTypes available from XschemaHandler</a></li>
 <li><a class="reference internal" href="#namespaces-inserting-namespace-definition-in-exported-documents" id="id51">11.8&nbsp;&nbsp;&nbsp;Namespaces -- inserting namespace definition in exported documents</a></li>
@@ -1630,12 +1630,14 @@ supported in <tt class="docutils literal">generateDS.py</tt>:</p>
 &lt;/xsd:element&gt;
 </pre>
 </div>
-<div class="section" id="minoccurs-attribute-support">
-<h2><a class="toc-backref" href="#id48">11.5&nbsp;&nbsp;&nbsp;minOccurs attribute support</a></h2>
-<p>Some applications require the availability of the &quot;minOccurs&quot;
-attribute in addition to the previous minimal support of
-&quot;optionality&quot;.  This is available through the <tt class="docutils literal">getMinOccurs</tt>
-method (which follows the style of the existing API).</p>
+<div class="section" id="arity-minoccurs-maxoccurs-etc">
+<h2><a class="toc-backref" href="#id48">11.5&nbsp;&nbsp;&nbsp;Arity, minOccurs, maxOccurs, etc</a></h2>
+<p>Some applications require information about the &quot;minOccurs&quot; and
+&quot;maxOccurs&quot; attributes in the XML Schema.  Some of that information
+can be obtained by using the --member-specs= (list|dict) command line
+option, then looking at the <tt class="docutils literal">member_data_items_</tt> class variable
+that it generates in each data representation class.  In particular,
+look at the <tt class="docutils literal">get_container</tt> method (from class <tt class="docutils literal">MemberSpec_</tt>).</p>
 </div>
 <div class="section" id="more-thorough-content-type-and-base-type-resolution">
 <h2><a class="toc-backref" href="#id49">11.6&nbsp;&nbsp;&nbsp;More thorough content type and base type resolution</a></h2>
diff --git a/generateDS.py b/generateDS.py
index d2b744f..0bb604a 100755
--- a/generateDS.py
+++ b/generateDS.py
@@ -168,7 +168,7 @@ logging.disable(logging.INFO)
 # Do not modify the following VERSION comments.
 # Used by updateversion.py.
 ##VERSION##
-VERSION = '2.10b'
+VERSION = '2.11a'
 ##VERSION##
 
 GenerateProperties = 0
@@ -4282,7 +4282,7 @@ except ImportError, exp:
                     raise_parse_error(node, 'Requires sequence of integers')
             return input_data
         def gds_format_float(self, input_data, input_name=''):
-            return '%%f' %% input_data
+            return ('%%.15f' %% input_data).rstrip('0')
         def gds_validate_float(self, input_data, node, input_name=''):
             return input_data
         def gds_format_float_list(self, input_data, input_name=''):
@@ -4366,7 +4366,7 @@ except ImportError, exp:
         def gds_parse_datetime(cls, input_data):
             tz = None
             if input_data[-1] == 'Z':
-                tz = GeneratedsSuper._FixedOffsetTZ(0, 'GMT')
+                tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')
                 input_data = input_data[:-1]
             else:
                 results = GeneratedsSuper.tzoff_pattern.search(input_data)
@@ -4417,7 +4417,7 @@ except ImportError, exp:
         def gds_parse_date(cls, input_data):
             tz = None
             if input_data[-1] == 'Z':
-                tz = GeneratedsSuper._FixedOffsetTZ(0, 'GMT')
+                tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')
                 input_data = input_data[:-1]
             else:
                 results = GeneratedsSuper.tzoff_pattern.search(input_data)
@@ -4468,7 +4468,7 @@ except ImportError, exp:
         def gds_parse_time(cls, input_data):
             tz = None
             if input_data[-1] == 'Z':
-                tz = GeneratedsSuper._FixedOffsetTZ(0, 'GMT')
+                tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')
                 input_data = input_data[:-1]
             else:
                 results = GeneratedsSuper.tzoff_pattern.search(input_data)
@@ -4813,7 +4813,7 @@ def get_root_tag(node):
     return tag, rootClass
 
 
-def parse(inFileName):
+def parse(inFileName, silence=False):
     doc = parsexml_(inFileName)
     rootNode = doc.getroot()
     rootTag, rootClass = get_root_tag(rootNode)
@@ -4824,15 +4824,16 @@ def parse(inFileName):
     rootObj.build(rootNode)
     # Enable Python to collect the space used by the DOM.
     doc = None
-#silence#    sys.stdout.write('<?xml version="1.0" ?>\\n')
-#silence#    rootObj.export(
-#silence#        sys.stdout, 0, name_=rootTag,
-#silence#        namespacedef_='%(namespacedef)s',
-#silence#        pretty_print=True)
+#silence#    if not silence:
+#silence#        sys.stdout.write('<?xml version="1.0" ?>\\n')
+#silence#        rootObj.export(
+#silence#            sys.stdout, 0, name_=rootTag,
+#silence#            namespacedef_='%(namespacedef)s',
+#silence#            pretty_print=True)
     return rootObj
 
 
-def parseEtree(inFileName):
+def parseEtree(inFileName, silence=False):
     doc = parsexml_(inFileName)
     rootNode = doc.getroot()
     rootTag, rootClass = get_root_tag(rootNode)
@@ -4846,15 +4847,16 @@ def parseEtree(inFileName):
     mapping = {}
     rootElement = rootObj.to_etree(None, name_=rootTag, mapping_=mapping)
     reverse_mapping = rootObj.gds_reverse_node_mapping(mapping)
-#silence#    content = etree_.tostring(
-#silence#        rootElement, pretty_print=True,
-#silence#        xml_declaration=True, encoding="utf-8")
-#silence#    sys.stdout.write(content)
-#silence#    sys.stdout.write('\\n')
+#silence#    if not silence:
+#silence#        content = etree_.tostring(
+#silence#            rootElement, pretty_print=True,
+#silence#            xml_declaration=True, encoding="utf-8")
+#silence#        sys.stdout.write(content)
+#silence#        sys.stdout.write('\\n')
     return rootObj, rootElement, mapping, reverse_mapping
 
 
-def parseString(inString):
+def parseString(inString, silence=False):
     from StringIO import StringIO
     doc = parsexml_(StringIO(inString))
     rootNode = doc.getroot()
@@ -4866,14 +4868,15 @@ def parseString(inString):
     rootObj.build(rootNode)
     # Enable Python to collect the space used by the DOM.
     doc = None
-#silence#    sys.stdout.write('<?xml version="1.0" ?>\\n')
-#silence#    rootObj.export(
-#silence#        sys.stdout, 0, name_="%(name)s",
-#silence#        namespacedef_='%(namespacedef)s')
+#silence#    if not silence:
+#silence#        sys.stdout.write('<?xml version="1.0" ?>\\n')
+#silence#        rootObj.export(
+#silence#            sys.stdout, 0, name_="%(name)s",
+#silence#            namespacedef_='%(namespacedef)s')
     return rootObj
 
 
-def parseLiteral(inFileName):
+def parseLiteral(inFileName, silence=False):
     doc = parsexml_(inFileName)
     rootNode = doc.getroot()
     rootTag, rootClass = get_root_tag(rootNode)
@@ -4884,11 +4887,12 @@ def parseLiteral(inFileName):
     rootObj.build(rootNode)
     # Enable Python to collect the space used by the DOM.
     doc = None
-#silence#    sys.stdout.write('#from %(module_name)s import *\\n\\n')
-#silence#    sys.stdout.write('import %(module_name)s as model_\\n\\n')
-#silence#    sys.stdout.write('rootObj = model_.rootTag(\\n')
-#silence#    rootObj.exportLiteral(sys.stdout, 0, name_=rootTag)
-#silence#    sys.stdout.write(')\\n')
+#silence#    if not silence:
+#silence#        sys.stdout.write('#from %(module_name)s import *\\n\\n')
+#silence#        sys.stdout.write('import %(module_name)s as model_\\n\\n')
+#silence#        sys.stdout.write('rootObj = model_.rootTag(\\n')
+#silence#        rootObj.exportLiteral(sys.stdout, 0, name_=rootTag)
+#silence#        sys.stdout.write(')\\n')
     return rootObj
 
 
@@ -5247,7 +5251,7 @@ def get_root_tag(node):
     return tag, rootClass
 
 
-def parse(inFilename):
+def parse(inFilename, silence=False):
     doc = parsexml_(inFilename)
     rootNode = doc.getroot()
     rootTag, rootClass = get_root_tag(rootNode)
@@ -5258,15 +5262,16 @@ def parse(inFilename):
     rootObj.build(rootNode)
     # Enable Python to collect the space used by the DOM.
     doc = None
-#silence#    sys.stdout.write('<?xml version="1.0" ?>\\n')
-#silence#    rootObj.export(
-#silence#        sys.stdout, 0, name_=rootTag,
-#silence#        namespacedef_='%(namespacedef)s',
-#silence#        pretty_print=True)
+#silence#    if not silence:
+#silence#        sys.stdout.write('<?xml version="1.0" ?>\\n')
+#silence#        rootObj.export(
+#silence#            sys.stdout, 0, name_=rootTag,
+#silence#            namespacedef_='%(namespacedef)s',
+#silence#            pretty_print=True)
     return rootObj
 
 
-def parseEtree(inFilename):
+def parseEtree(inFilename, silence=False):
     doc = parsexml_(inFilename)
     rootNode = doc.getroot()
     rootTag, rootClass = get_root_tag(rootNode)
@@ -5280,15 +5285,16 @@ def parseEtree(inFilename):
     mapping = {}
     rootElement = rootObj.to_etree(None, name_=rootTag, mapping_=mapping)
     reverse_mapping = rootObj.gds_reverse_node_mapping(mapping)
-#silence#    content = etree_.tostring(
-#silence#        rootElement, pretty_print=True,
-#silence#        xml_declaration=True, encoding="utf-8")
-#silence#    sys.stdout.write(content)
-#silence#    sys.stdout.write('\\n')
+#silence#    if not silence:
+#silence#        content = etree_.tostring(
+#silence#            rootElement, pretty_print=True,
+#silence#            xml_declaration=True, encoding="utf-8")
+#silence#        sys.stdout.write(content)
+#silence#        sys.stdout.write('\\n')
     return rootObj, rootElement, mapping, reverse_mapping
 
 
-def parseString(inString):
+def parseString(inString, silence=False):
     from StringIO import StringIO
     doc = parsexml_(StringIO(inString))
     rootNode = doc.getroot()
@@ -5300,14 +5306,15 @@ def parseString(inString):
     rootObj.build(rootNode)
     # Enable Python to collect the space used by the DOM.
     doc = None
-#silence#    sys.stdout.write('<?xml version="1.0" ?>\\n')
-#silence#    rootObj.export(
-#silence#        sys.stdout, 0, name_=rootTag,
-#silence#        namespacedef_='%(namespacedef)s')
+#silence#    if not silence:
+#silence#        sys.stdout.write('<?xml version="1.0" ?>\\n')
+#silence#        rootObj.export(
+#silence#            sys.stdout, 0, name_=rootTag,
+#silence#            namespacedef_='%(namespacedef)s')
     return rootObj
 
 
-def parseLiteral(inFilename):
+def parseLiteral(inFilename, silence=False):
     doc = parsexml_(inFilename)
     rootNode = doc.getroot()
     roots = get_root_tag(rootNode)
@@ -5318,11 +5325,12 @@ def parseLiteral(inFilename):
     rootObj.build(rootNode)
     # Enable Python to collect the space used by the DOM.
     doc = None
-#silence#    sys.stdout.write('#from %(super)s import *\\n\\n')
-#silence#    sys.stdout.write('import %(super)s as model_\\n\\n')
-#silence#    sys.stdout.write('rootObj = model_.%(cleanname)s(\\n')
-#silence#    rootObj.exportLiteral(sys.stdout, 0, name_="%(cleanname)s")
-#silence#    sys.stdout.write(')\\n')
+#silence#    if not silence:
+#silence#        sys.stdout.write('#from %(super)s import *\\n\\n')
+#silence#        sys.stdout.write('import %(super)s as model_\\n\\n')
+#silence#        sys.stdout.write('rootObj = model_.%(cleanname)s(\\n')
+#silence#        rootObj.exportLiteral(sys.stdout, 0, name_="%(cleanname)s")
+#silence#        sys.stdout.write(')\\n')
     return rootObj
 
 
diff --git a/generateDS.txt b/generateDS.txt
index e1134f2..c783b14 100644
--- a/generateDS.txt
+++ b/generateDS.txt
@@ -11,7 +11,7 @@ generateDS -- Generate Data Structures from XML Schema
 
 .. version
 
-:revision: 2.10b
+:revision: 2.11a
 
 .. version
 
@@ -1427,13 +1427,15 @@ supported in ``generateDS.py``::
     </xsd:element>
 
 
-minOccurs attribute support
----------------------------
+Arity, minOccurs, maxOccurs, etc
+--------------------------------
 
-Some applications require the availability of the "minOccurs"
-attribute in addition to the previous minimal support of
-"optionality".  This is available through the ``getMinOccurs``
-method (which follows the style of the existing API).
+Some applications require information about the "minOccurs" and
+"maxOccurs" attributes in the XML Schema.  Some of that information
+can be obtained by using the --member-specs= (list|dict) command line
+option, then looking at the ``member_data_items_`` class variable
+that it generates in each data representation class.  In particular,
+look at the ``get_container`` method (from class ``MemberSpec_``).
 
 
 More thorough content type and base type resolution
diff --git a/librarytemplate_howto.txt b/librarytemplate_howto.txt
index 4e3c1aa..ce569da 100644
--- a/librarytemplate_howto.txt
+++ b/librarytemplate_howto.txt
@@ -8,7 +8,7 @@ How to package a generateDS.py generated library
 
 .. version
 
-:revision: 2.10b
+:revision: 2.11a
 
 .. version
 
diff --git a/process_includes.py b/process_includes.py
index e30e7af..c0f3107 100755
--- a/process_includes.py
+++ b/process_includes.py
@@ -30,7 +30,7 @@ from lxml import etree
 # Do not modify the following VERSION comments.
 # Used by updateversion.py.
 ##VERSION##
-VERSION = '2.10b'
+VERSION = '2.11a'
 ##VERSION##
 
 Namespaces = {'xs': 'http://www.w3.org/2001/XMLSchema'}
diff --git a/setup.py b/setup.py
index 2a4bbe9..73d8a01 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.10b",
+    version="2.11a",
 ##VERSION##
     author="Dave Kuhlman",
     author_email="dkuhlman@rexx.com",
-- 
GitLab