From c6333c0b95b3cad014e2201580a2c066cb26d763 Mon Sep 17 00:00:00 2001 From: Dave Kuhlman <dkuhlman@davekuhlman.org> Date: Mon, 15 Feb 2016 15:34:09 -0800 Subject: [PATCH] Modified code generation so that generated code will run under Py 2 and Py 3. --- README | 7 ++ generateDS.html | 15 +-- generateDS.py | 146 ++++++++++------------- generateDS.txt | 13 +- librarytemplate_howto.html | 6 +- tests/OnePer/oneperType00_1One.py | 14 ++- tests/OnePer/oneperType00_2One.py | 14 ++- tests/OnePer/oneperType01_1One.py | 18 ++- tests/OnePer/oneperType01_2One.py | 18 ++- tests/OnePer/oneperType02_1One.py | 18 ++- tests/OnePer/oneperType02_2One.py | 18 ++- tests/OnePer/oneperType03_1One.py | 18 ++- tests/OnePer/oneperType03_2One.py | 18 ++- tests/abstract_type1_sup.py | 14 ++- tests/abstract_type2_sup.py | 14 ++- tests/annotations1_sup.py | 20 +++- tests/annotations2_sup.py | 20 +++- tests/anonymous_type1_sup.py | 20 +++- tests/anonymous_type2_sup.py | 20 +++- tests/anysimpletype1_sup.py | 16 ++- tests/anysimpletype2_sup.py | 16 ++- tests/anywildcard1_sup.py | 24 ++-- tests/anywildcard2_sup.py | 24 ++-- tests/attr_groups1_sup.py | 22 +++- tests/attr_groups2_sup.py | 22 +++- tests/cdata1_sup.py | 16 ++- tests/cdata2_sup.py | 16 ++- tests/cleanupname1_sup.py | 24 ++-- tests/cleanupname2_sup.py | 24 ++-- tests/defaults_cases1_out.xml | 16 +++ tests/defaults_cases1_sub.py | 49 ++++---- tests/defaults_cases1_sup.py | 71 ++++++----- tests/defaults_cases2_out.xml | 16 +++ tests/defaults_cases2_sub.py | 49 ++++---- tests/defaults_cases2_sup.py | 71 ++++++----- tests/defaults_coverage1_sup.py | 46 ++++--- tests/defaults_coverage2_sup.py | 46 ++++--- tests/extensions1_sup.py | 56 +++++---- tests/extensions2_sup.py | 56 +++++---- tests/mapcleanname1_sup.py | 28 +++-- tests/mapcleanname2_sup.py | 28 +++-- tests/nested_def1_sup.py | 22 +++- tests/nested_def2_sup.py | 22 +++- tests/out1_sup.py | 104 ++++++++-------- tests/out2_sup.py | 104 ++++++++-------- tests/people_procincl1_sup.py | 78 ++++++------ tests/people_procincl2_sup.py | 78 ++++++------ tests/prefix_classname1_sup.py | 74 +++++++----- tests/prefix_classname2_sup.py | 74 +++++++----- tests/recursive_simpletype1_sup.py | 18 ++- tests/recursive_simpletype2_sup.py | 18 ++- tests/reference_simpletype1_sup.py | 14 ++- tests/reference_simpletype2_sup.py | 14 ++- tests/simplecontent_restriction1_sup.py | 34 ++++-- tests/simplecontent_restriction2_sup.py | 34 ++++-- tests/simpletype_memberspecs1_sup.py | 22 +++- tests/simpletype_memberspecs2_sup.py | 22 +++- tests/simpletypes_other1_sup.py | 34 ++++-- tests/simpletypes_other2_sup.py | 34 ++++-- tests/test.py | 2 +- tests/to_etree1_sup.py | 22 +++- tests/to_etree2_sup.py | 22 +++- tests/validate_simpletypes1_sup.py | 26 ++-- tests/validate_simpletypes1_warnings.txt | 34 +++--- tests/validate_simpletypes2_sup.py | 26 ++-- tests/validate_simpletypes2_warnings.txt | 34 +++--- tutorial/generateds_tutorial.html | 6 +- tutorial/generateds_tutorial.zip | Bin 48764 -> 48769 bytes 68 files changed, 1342 insertions(+), 797 deletions(-) diff --git a/README b/README index f3dd65e..0cbb735 100644 --- a/README +++ b/README @@ -141,6 +141,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Change history -------------- +Version 2.19b (02/16/2016) + +- Modified generated code so that it will run under both Python 2 + and Python 3. There is no longer any need to generate different + code for Python 2 and Python 3. If fact, the "--py3" command line + option has been removed. + Version 2.19a (02/08/2016) - Added the ability to generate code that can run under Python 3. diff --git a/generateDS.html b/generateDS.html index b85250c..f956893 100644 --- a/generateDS.html +++ b/generateDS.html @@ -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">February 06, 2016</td> +<tr class="field"><th class="field-name">date:</th><td class="field-body">February 15, 2016</td> </tr> </tbody> </table> @@ -437,6 +437,9 @@ process the contents of the XML file. The user can also generate and extend multiple subclass files which use a single, common superclass file, thus implementing a number of different processes on the same XML document type.</p> +<p><tt class="docutils literal">generateDS.py</tt> can be run under either Python 2 or Python 3. The +generated Python code (both superclass and subclass modules) can be +run under either Python 2 or Python 3.</p> <p>This document explains (1) how to use <tt class="docutils literal">generateDS.py</tt>; (2) how to use the Python code and data structures that it generates; and (3) how to modify the generated code for special purposes.</p> @@ -634,7 +637,6 @@ Options: distribution. --fix-type-names="oldname1:newname1;oldname2:newname2;..." Fix up (replace) complex type names. - --py3 Generate code for Python 3. --version Print version and exit. Usage example: @@ -915,13 +917,6 @@ $ generateDS.py --fix-type-names="type1:type1Aux" $ generateDS.py --fix-type-names="type1;type2:type2Repl" </pre> </dd> -<dt>py3</dt> -<dd>Generate code for Python 3; the default is to generate code for -Python 2. Generate code that will run under (and will have the -same behavior under) Python 3. You can, later, determine -whether a file was generated for Python 2 or Python 3 by looking -at the comments containing command line options near the top of -the file.</dd> <dt>version</dt> <dd>Print out the current version of <tt class="docutils literal">generateDS.py</tt> and immediately exit.</dd> @@ -3176,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-02-07 01:15 UTC. +Generated on: 2016-02-15 23:30 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 1237b5b..2fe477f 100755 --- a/generateDS.py +++ b/generateDS.py @@ -107,7 +107,6 @@ Options: distribution. --fix-type-names="oldname1:newname1;oldname2:newname2;..." Fix up (replace) complex type names. - --py3 Generate code for Python 3. --version Print version and exit. Usage example: @@ -206,6 +205,11 @@ logging.disable(logging.INFO) VERSION = '2.19a' ##VERSION## +if sys.version_info.major == 2: + BaseStrType = basestring +else: + BaseStrType = str + GenerateProperties = 0 UseGetterSetter = 'new' UseOldSimpleTypeValidators = False @@ -270,7 +274,6 @@ SingleFileOutput = True OutputDirectory = None ModuleSuffix = "" PreserveCdataTags = False -GeneratePy3 = False SchemaToPythonTypeMap = {} @@ -1964,24 +1967,25 @@ def generateExportFn_1(wrt, child, name, namespace, fill): fill, mappedName, default, )) wrt('%s showIndent(outfile, level, pretty_print)\n' % fill) # fixlist - encoding = '' if GeneratePy3 else '.encode(ExternalEncoding)' if (child.getSimpleType() in SimpleTypeDict and SimpleTypeDict[child.getSimpleType()].isListType()): s1 = "%s outfile.write('<%%s%s>%%s</%%s%s>%%s' %% " \ - "(namespace_, self.gds_format_string(quote_xml" \ - "(' '.join(self.%s))%s, " \ - "input_name='%s'), namespace_, eol_))\n" % \ - (fill, name, name, mappedName, encoding, name, ) + "(namespace_, self.gds_encode(self.gds_format_string(" \ + "quote_xml" \ + "(' '.join(self.%s)), " \ + "input_name='%s')), namespace_, eol_))\n" % \ + (fill, name, name, mappedName, name, ) else: namespace = 'namespace_' if child.prefix and 'ref' in child.attrs: namespace = "'%s:'" % child.prefix s1 = "%s outfile.write('<%%s%s>%%s</%%s%s>%%s' %% " \ - "(%s, self.gds_format_string(quote_xml(self.%s)%s, " \ - "input_name='%s'), " \ + "(%s, self.gds_encode(self.gds_format_string(" \ + "quote_xml(self.%s), " \ + "input_name='%s')), " \ "%s, eol_))\n" % \ (fill, name, name, namespace, mappedName, - encoding, name, namespace, ) + name, namespace, ) wrt(s1) elif (child_type in IntegerType or child_type == PositiveIntegerType or @@ -2127,11 +2131,11 @@ def generateExportFn_2(wrt, child, name, namespace, fill): child_type == TokenType or child_type in DateTimeGroupType): wrt('%s showIndent(outfile, level, pretty_print)\n' % fill) - encoding = '' if GeneratePy3 else '.encode(ExternalEncoding)' wrt("%s outfile.write('<%%s%s>%%s</%%s%s>%%s' %% " - "(namespace_, self.gds_format_string(quote_xml(%s_)" - "%s, input_name='%s'), namespace_, eol_))\n" % - (fill, name, name, cleanName, encoding, name,)) + "(namespace_, self.gds_encode(self.gds_format_string(" + "quote_xml(%s_), " + "input_name='%s')), namespace_, eol_))\n" % + (fill, name, name, cleanName, name,)) elif (child_type in IntegerType or child_type == PositiveIntegerType or child_type == NonPositiveIntegerType or @@ -2269,20 +2273,19 @@ def generateExportFn_3(wrt, child, name, namespace, fill): fill, mappedName, default, )) wrt('%s showIndent(outfile, level, pretty_print)\n' % fill) # fixlist - encoding = '' if GeneratePy3 else '.encode(ExternalEncoding)' if (child.getSimpleType() in SimpleTypeDict and SimpleTypeDict[child.getSimpleType()].isListType()): s1 = "%s outfile.write('<%%s%s>%%s</%%s%s>%%s' %% " \ - "(namespace_, self.gds_format_string(" \ - "quote_xml(' '.join(self.%s))%s, " \ - "input_name='%s'), namespace_, eol_))\n" % \ - (fill, name, name, mappedName, encoding, name, ) + "(namespace_, self.gds_encode(self.gds_format_string(" \ + "quote_xml(' '.join(self.%s)), " \ + "input_name='%s')), namespace_, eol_))\n" % \ + (fill, name, name, mappedName, name, ) else: s1 = "%s outfile.write('<%%s%s>%%s</%%s%s>%%s' %% " \ - "(namespace_, self.gds_format_string(" \ - "quote_xml(self.%s)%s, " \ - "input_name='%s'), namespace_, eol_))\n" % \ - (fill, name, name, mappedName, encoding, name, ) + "(namespace_, self.gds_encode(self.gds_format_string(" \ + "quote_xml(self.%s), " \ + "input_name='%s')), namespace_, eol_))\n" % \ + (fill, name, name, mappedName, name, ) wrt(s1) elif (child_type in IntegerType or child_type == PositiveIntegerType or @@ -2648,12 +2651,11 @@ def generateExportAttributes(wrt, element, hasAttributes): attrDefType in IDTypes or attrDefType == TokenType or attrDefType in DateTimeGroupType): - encoding = '' if GeneratePy3 else '.encode(ExternalEncoding)' s1 = '''%s outfile.write(' %s=%%s' %% ''' \ - '''(self.gds_format_string(quote_attrib(''' \ - '''self.%s)%s, ''' \ - '''input_name='%s'), ))\n''' % \ - (indent, orig_name, cleanName, encoding, name, ) + '''(self.gds_encode(self.gds_format_string(quote_attrib(''' \ + '''self.%s), ''' \ + '''input_name='%s')), ))\n''' % \ + (indent, orig_name, cleanName, name, ) elif (attrDefType in IntegerType or attrDefType == PositiveIntegerType or attrDefType == NonPositiveIntegerType or @@ -2820,11 +2822,10 @@ def generateExportFn(wrt, prefix, element, namespace, nameSpacesDef): if element.getSimpleContent(): wrt(" outfile.write('>')\n") if not element.isMixed(): - encoding = '' if GeneratePy3 else '.encode(ExternalEncoding)' wrt(" outfile.write((quote_xml(self.valueOf_) " "if type(self.valueOf_) is str else " - "str(self.valueOf_))%s)\n" % ( - encoding, )) + "self.gds_encode(str(self.valueOf_))))\n" + ) else: wrt(" outfile.write('>%s' % (eol_, ))\n") wrt(" self.exportChildren(outfile, level + 1, " @@ -2945,21 +2946,20 @@ def generateExportLiteralFn_1(wrt, child, name, fill): childType == TokenType or childType in DateTimeGroupType): wrt('%s showIndent(outfile, level)\n' % fill) - encoding = '' if GeneratePy3 else '.encode(ExternalEncoding)' if (child.getSimpleType() in SimpleTypeDict and SimpleTypeDict[child.getSimpleType()].isListType()): wrt("%s if self.%s:\n" % (fill, mappedName, )) wrt("%s outfile.write('%s=%%s,\\n' %% " - "quote_python(' '.join(self.%s))" - "%s) \n" % + "self.gds_encode(quote_python(' '.join(self.%s)))" + ") \n" % (fill, mappedName, mappedName, encoding, )) wrt("%s else:\n" % (fill, )) wrt("%s outfile.write('%s=None,\\n')\n" % (fill, mappedName, )) else: wrt("%s outfile.write('%s=%%s,\\n' %% " - "quote_python(self.%s)%s)\n" % - (fill, mappedName, mappedName, encoding, )) + "self.gds_encode(quote_python(self.%s)))\n" % + (fill, mappedName, mappedName, )) elif (childType in IntegerType or childType == PositiveIntegerType or childType == NonPositiveIntegerType or @@ -3020,10 +3020,9 @@ def generateExportLiteralFn_2(wrt, child, name, fill): elif (childType in StringType or childType == TokenType or childType in DateTimeGroupType): - encoding = '' if GeneratePy3 else '.encode(ExternalEncoding)' wrt('%s showIndent(outfile, level)\n' % fill) - wrt("%s outfile.write('%%s,\\n' %% quote_python(%s_)" - "%s)\n" % (fill, name, encoding, )) + wrt("%s outfile.write('%%s,\\n' %% self.gds_encode(" + "quote_python(%s_)))\n" % (fill, name, )) elif (childType in IntegerType or childType == PositiveIntegerType or childType == NonPositiveIntegerType or @@ -4105,30 +4104,21 @@ def generateCtor(wrt, prefix, element): mbrname = name attrType = attrDef.getType() if attrType == DateTimeType: - if GeneratePy3: - wrt(" if isinstance(%s, str):\n" % (mbrname, )) - else: - wrt(" if isinstance(%s, basestring):\n" % (mbrname, )) + wrt(" if isinstance(%s, BaseStrType_):\n" % (mbrname, )) wrt(" initvalue_ = datetime_.datetime.strptime(" "%s, '%%Y-%%m-%%dT%%H:%%M:%%S')\n" % (mbrname, )) wrt(" else:\n") wrt(" initvalue_ = %s\n" % (mbrname, )) wrt(" self.%s = initvalue_\n" % (name, )) elif attrType == DateType: - if GeneratePy3: - wrt(" if isinstance(%s, str):\n" % (mbrname, )) - else: - wrt(" if isinstance(%s, basestring):\n" % (mbrname, )) + wrt(" if isinstance(%s, BaseStrType_):\n" % (mbrname, )) wrt(" initvalue_ = datetime_.datetime.strptime(" "%s, '%%Y-%%m-%%d').date()\n" % (mbrname, )) wrt(" else:\n") wrt(" initvalue_ = %s\n" % (mbrname, )) wrt(" self.%s = initvalue_\n" % (name, )) elif attrType == TimeType: - if GeneratePy3: - wrt(" if isinstance(%s, str):\n" % (mbrname, )) - else: - wrt(" if isinstance(%s, basestring):\n" % (mbrname, )) + wrt(" if isinstance(%s, BaseStrType_):\n" % (mbrname, )) wrt(" initvalue_ = datetime_.datetime.strptime(" "%s, '%%H:%%M:%%S').time()\n" % (mbrname, )) wrt(" else:\n") @@ -4157,10 +4147,7 @@ def generateCtor(wrt, prefix, element): else: wrt(' self.anytypeobjs_ = anytypeobjs_\n') elif childType == DateTimeType and child.getMaxOccurs() <= 1: - if GeneratePy3: - wrt(" if isinstance(%s, str):\n" % (mbrname, )) - else: - wrt(" if isinstance(%s, basestring):\n" % (mbrname, )) + wrt(" if isinstance(%s, BaseStrType_):\n" % (mbrname, )) wrt(" initvalue_ = datetime_.datetime.strptime(" "%s, '%%Y-%%m-%%dT%%H:%%M:%%S')\n" % (mbrname, )) wrt(" else:\n") @@ -4170,10 +4157,7 @@ def generateCtor(wrt, prefix, element): else: wrt(" self.%s = initvalue_\n" % (name, )) elif childType == DateType and child.getMaxOccurs() <= 1: - if GeneratePy3: - wrt(" if isinstance(%s, str):\n" % (mbrname, )) - else: - wrt(" if isinstance(%s, basestring):\n" % (mbrname, )) + wrt(" if isinstance(%s, BaseStrType_):\n" % (mbrname, )) wrt(" initvalue_ = datetime_.datetime.strptime(" "%s, '%%Y-%%m-%%d').date()\n" % (mbrname, )) wrt(" else:\n") @@ -4183,10 +4167,7 @@ def generateCtor(wrt, prefix, element): else: wrt(" self.%s = initvalue_\n" % (name, )) elif childType == TimeType and child.getMaxOccurs() <= 1: - if GeneratePy3: - wrt(" if isinstance(%s, str):\n" % (mbrname, )) - else: - wrt(" if isinstance(%s, basestring):\n" % (mbrname, )) + wrt(" if isinstance(%s, BaseStrType_):\n" % (mbrname, )) wrt(" initvalue_ = datetime_.datetime.strptime(" "%s, '%%H:%%M:%%S').time()\n" % (mbrname, )) wrt(" else:\n") @@ -4936,6 +4917,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -5255,6 +5240,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): {gds_reverse_node_mapping_text} + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -5600,20 +5591,12 @@ def generateHeader(wrt, prefix, options, args, externalImports): else: preserve_cdata_tags_pat = "" preserve_cdata_get_text = Preserve_cdata_get_all_text2 - if GeneratePy3: - gds_reverse_node_mapping_text = \ - "return dict(((v, k) for k, v in mapping.items()))" - quote_xml_text = \ - "s1 = (isinstance(inStr, str) and inStr or '%s' % inStr)" - quote_attrib_text = \ - "s1 = (isinstance(inStr, str) and inStr or '%s' % inStr)" - else: - gds_reverse_node_mapping_text = \ - "return dict(((v, k) for k, v in mapping.iteritems()))" - quote_xml_text = \ - "s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr)" - quote_attrib_text = \ - "s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr)" + gds_reverse_node_mapping_text = \ + "return dict(((v, k) for k, v in mapping.iteritems()))" + quote_xml_text = \ + "s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr)" + quote_attrib_text = \ + "s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr)" s1 = TEMPLATE_HEADER.format( tstamp=tstamp, version=version, @@ -6808,7 +6791,7 @@ def main(): ExportWrite, ExportEtree, ExportLiteral, \ FixTypeNames, SingleFileOutput, OutputDirectory, \ ModuleSuffix, UseOldSimpleTypeValidators, \ - PreserveCdataTags, CleanupNameList, GeneratePy3 + PreserveCdataTags, CleanupNameList outputText = True args = sys.argv[1:] try: @@ -6826,7 +6809,6 @@ def main(): 'one-file-per-xsd', 'output-directory=', 'module-suffix=', 'use-old-simpletype-validators', 'preserve-cdata-tags', 'cleanup-name-list=', - 'py3', ]) except getopt.GetoptError: usage() @@ -7003,8 +6985,8 @@ def main(): if sys.version_info.major == 2: if (type(cleanup_pair) not in (list, tuple) or len(cleanup_pair) != 2 or - not isinstance(cleanup_pair[0], basestring) or - not isinstance(cleanup_pair[1], basestring)): + not isinstance(cleanup_pair[0], BaseStrType) or + not isinstance(cleanup_pair[1], BaseStrType)): raise RuntimeError( 'Option --cleanup-name-list contains ' 'invalid element.') @@ -7024,8 +7006,6 @@ def main(): 'Option --cleanup-name-list contains invalid ' 'pattern "%s".' % cleanup_pair[0]) - elif option[0] == '--py3': - GeneratePy3 = True if showVersion: print('generateDS.py version %s' % VERSION) diff --git a/generateDS.txt b/generateDS.txt index bba23bb..9845a81 100644 --- a/generateDS.txt +++ b/generateDS.txt @@ -100,6 +100,10 @@ and extend multiple subclass files which use a single, common superclass file, thus implementing a number of different processes on the same XML document type. +``generateDS.py`` can be run under either Python 2 or Python 3. The +generated Python code (both superclass and subclass modules) can be +run under either Python 2 or Python 3. + This document explains (1) how to use ``generateDS.py``; (2) how to use the Python code and data structures that it generates; and (3) how to modify the generated code for special purposes. @@ -325,7 +329,6 @@ Here is the usage message displayed by ``generateDS.py``:: distribution. --fix-type-names="oldname1:newname1;oldname2:newname2;..." Fix up (replace) complex type names. - --py3 Generate code for Python 3. --version Print version and exit. Usage example: @@ -633,14 +636,6 @@ fix-type-names="oldname1:newname1;oldname2:newname2;..." Fix up $ generateDS.py --fix-type-names="type1:type1Aux" $ generateDS.py --fix-type-names="type1;type2:type2Repl" -py3 - Generate code for Python 3. Generate code that will run under - (and will have the same behavior under) Python 3 (instead of - Python 2). You can, later, determine whether a file was - generated for Python 2 or Python 3 by looking at the comments - containing command line options near the top of the file. The - default is to generate code for Python 2. - version Print out the current version of ``generateDS.py`` and immediately exit. diff --git a/librarytemplate_howto.html b/librarytemplate_howto.html index 7b71469..ce78796 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.18a</td> +<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.19a</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">December 16, 2015</td> +<tr class="field"><th class="field-name">date:</th><td class="field-body">February 08, 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: 2015-12-16 20:55 UTC. +Generated on: 2016-02-08 18:02 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/tests/OnePer/oneperType00_1One.py b/tests/OnePer/oneperType00_1One.py index d504860..3a361bb 100644 --- a/tests/OnePer/oneperType00_1One.py +++ b/tests/OnePer/oneperType00_1One.py @@ -34,6 +34,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -353,6 +357,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -407,7 +417,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -429,7 +439,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') diff --git a/tests/OnePer/oneperType00_2One.py b/tests/OnePer/oneperType00_2One.py index d504860..3a361bb 100644 --- a/tests/OnePer/oneperType00_2One.py +++ b/tests/OnePer/oneperType00_2One.py @@ -34,6 +34,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -353,6 +357,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -407,7 +417,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -429,7 +439,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') diff --git a/tests/OnePer/oneperType01_1One.py b/tests/OnePer/oneperType01_1One.py index 93f9e63..73c443d 100644 --- a/tests/OnePer/oneperType01_1One.py +++ b/tests/OnePer/oneperType01_1One.py @@ -34,6 +34,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -353,6 +357,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -407,7 +417,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -429,7 +439,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -695,7 +705,7 @@ class oneperType01_1(GeneratedsSuper): eol_ = '' if self.username is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%susername>%s</%susername>%s' % (namespace_, self.gds_format_string(quote_xml(self.username).encode(ExternalEncoding), input_name='username'), namespace_, eol_)) + outfile.write('<%susername>%s</%susername>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.username), input_name='username')), namespace_, eol_)) if self.inner01 is not None: self.inner01.export(outfile, level, namespace_, name_='inner01', pretty_print=pretty_print) def build(self, node): @@ -776,7 +786,7 @@ class oneperType01_2(GeneratedsSuper): eol_ = '' if self.userdescription is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%suserdescription>%s</%suserdescription>%s' % (namespace_, self.gds_format_string(quote_xml(self.userdescription).encode(ExternalEncoding), input_name='userdescription'), namespace_, eol_)) + outfile.write('<%suserdescription>%s</%suserdescription>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.userdescription), input_name='userdescription')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) diff --git a/tests/OnePer/oneperType01_2One.py b/tests/OnePer/oneperType01_2One.py index 93f9e63..73c443d 100644 --- a/tests/OnePer/oneperType01_2One.py +++ b/tests/OnePer/oneperType01_2One.py @@ -34,6 +34,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -353,6 +357,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -407,7 +417,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -429,7 +439,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -695,7 +705,7 @@ class oneperType01_1(GeneratedsSuper): eol_ = '' if self.username is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%susername>%s</%susername>%s' % (namespace_, self.gds_format_string(quote_xml(self.username).encode(ExternalEncoding), input_name='username'), namespace_, eol_)) + outfile.write('<%susername>%s</%susername>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.username), input_name='username')), namespace_, eol_)) if self.inner01 is not None: self.inner01.export(outfile, level, namespace_, name_='inner01', pretty_print=pretty_print) def build(self, node): @@ -776,7 +786,7 @@ class oneperType01_2(GeneratedsSuper): eol_ = '' if self.userdescription is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%suserdescription>%s</%suserdescription>%s' % (namespace_, self.gds_format_string(quote_xml(self.userdescription).encode(ExternalEncoding), input_name='userdescription'), namespace_, eol_)) + outfile.write('<%suserdescription>%s</%suserdescription>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.userdescription), input_name='userdescription')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) diff --git a/tests/OnePer/oneperType02_1One.py b/tests/OnePer/oneperType02_1One.py index d477ece..339dabe 100644 --- a/tests/OnePer/oneperType02_1One.py +++ b/tests/OnePer/oneperType02_1One.py @@ -34,6 +34,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -353,6 +357,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -407,7 +417,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -429,7 +439,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -695,7 +705,7 @@ class oneperType02_1(GeneratedsSuper): eol_ = '' if self.clientname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sclientname>%s</%sclientname>%s' % (namespace_, self.gds_format_string(quote_xml(self.clientname).encode(ExternalEncoding), input_name='clientname'), namespace_, eol_)) + outfile.write('<%sclientname>%s</%sclientname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.clientname), input_name='clientname')), namespace_, eol_)) if self.inner01 is not None: self.inner01.export(outfile, level, namespace_, name_='inner01', pretty_print=pretty_print) def build(self, node): @@ -776,7 +786,7 @@ class oneperType02_2(GeneratedsSuper): eol_ = '' if self.clientdescription is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sclientdescription>%s</%sclientdescription>%s' % (namespace_, self.gds_format_string(quote_xml(self.clientdescription).encode(ExternalEncoding), input_name='clientdescription'), namespace_, eol_)) + outfile.write('<%sclientdescription>%s</%sclientdescription>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.clientdescription), input_name='clientdescription')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) diff --git a/tests/OnePer/oneperType02_2One.py b/tests/OnePer/oneperType02_2One.py index d477ece..339dabe 100644 --- a/tests/OnePer/oneperType02_2One.py +++ b/tests/OnePer/oneperType02_2One.py @@ -34,6 +34,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -353,6 +357,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -407,7 +417,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -429,7 +439,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -695,7 +705,7 @@ class oneperType02_1(GeneratedsSuper): eol_ = '' if self.clientname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sclientname>%s</%sclientname>%s' % (namespace_, self.gds_format_string(quote_xml(self.clientname).encode(ExternalEncoding), input_name='clientname'), namespace_, eol_)) + outfile.write('<%sclientname>%s</%sclientname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.clientname), input_name='clientname')), namespace_, eol_)) if self.inner01 is not None: self.inner01.export(outfile, level, namespace_, name_='inner01', pretty_print=pretty_print) def build(self, node): @@ -776,7 +786,7 @@ class oneperType02_2(GeneratedsSuper): eol_ = '' if self.clientdescription is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sclientdescription>%s</%sclientdescription>%s' % (namespace_, self.gds_format_string(quote_xml(self.clientdescription).encode(ExternalEncoding), input_name='clientdescription'), namespace_, eol_)) + outfile.write('<%sclientdescription>%s</%sclientdescription>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.clientdescription), input_name='clientdescription')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) diff --git a/tests/OnePer/oneperType03_1One.py b/tests/OnePer/oneperType03_1One.py index 3dc877e..809e00c 100644 --- a/tests/OnePer/oneperType03_1One.py +++ b/tests/OnePer/oneperType03_1One.py @@ -34,6 +34,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -353,6 +357,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -407,7 +417,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -429,7 +439,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -695,7 +705,7 @@ class oneperType03_1(GeneratedsSuper): eol_ = '' if self.helpername is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%shelpername>%s</%shelpername>%s' % (namespace_, self.gds_format_string(quote_xml(self.helpername).encode(ExternalEncoding), input_name='helpername'), namespace_, eol_)) + outfile.write('<%shelpername>%s</%shelpername>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.helpername), input_name='helpername')), namespace_, eol_)) if self.inner01 is not None: self.inner01.export(outfile, level, namespace_, name_='inner01', pretty_print=pretty_print) def build(self, node): @@ -776,7 +786,7 @@ class oneperType03_2(GeneratedsSuper): eol_ = '' if self.helperdescription is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%shelperdescription>%s</%shelperdescription>%s' % (namespace_, self.gds_format_string(quote_xml(self.helperdescription).encode(ExternalEncoding), input_name='helperdescription'), namespace_, eol_)) + outfile.write('<%shelperdescription>%s</%shelperdescription>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.helperdescription), input_name='helperdescription')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) diff --git a/tests/OnePer/oneperType03_2One.py b/tests/OnePer/oneperType03_2One.py index 3dc877e..809e00c 100644 --- a/tests/OnePer/oneperType03_2One.py +++ b/tests/OnePer/oneperType03_2One.py @@ -34,6 +34,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -353,6 +357,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -407,7 +417,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -429,7 +439,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -695,7 +705,7 @@ class oneperType03_1(GeneratedsSuper): eol_ = '' if self.helpername is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%shelpername>%s</%shelpername>%s' % (namespace_, self.gds_format_string(quote_xml(self.helpername).encode(ExternalEncoding), input_name='helpername'), namespace_, eol_)) + outfile.write('<%shelpername>%s</%shelpername>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.helpername), input_name='helpername')), namespace_, eol_)) if self.inner01 is not None: self.inner01.export(outfile, level, namespace_, name_='inner01', pretty_print=pretty_print) def build(self, node): @@ -776,7 +786,7 @@ class oneperType03_2(GeneratedsSuper): eol_ = '' if self.helperdescription is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%shelperdescription>%s</%shelperdescription>%s' % (namespace_, self.gds_format_string(quote_xml(self.helperdescription).encode(ExternalEncoding), input_name='helperdescription'), namespace_, eol_)) + outfile.write('<%shelperdescription>%s</%shelperdescription>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.helperdescription), input_name='helperdescription')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) diff --git a/tests/abstract_type1_sup.py b/tests/abstract_type1_sup.py index d4fc7d3..d8510ae 100644 --- a/tests/abstract_type1_sup.py +++ b/tests/abstract_type1_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') diff --git a/tests/abstract_type2_sup.py b/tests/abstract_type2_sup.py index d4fc7d3..d8510ae 100644 --- a/tests/abstract_type2_sup.py +++ b/tests/abstract_type2_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') diff --git a/tests/annotations1_sup.py b/tests/annotations1_sup.py index 5069103..6071f59 100644 --- a/tests/annotations1_sup.py +++ b/tests/annotations1_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -697,7 +707,7 @@ class document1Type(GeneratedsSuper): eol_ = '' if self.comments is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%scomments>%s</%scomments>%s' % (namespace_, self.gds_format_string(quote_xml(self.comments).encode(ExternalEncoding), input_name='comments'), namespace_, eol_)) + outfile.write('<%scomments>%s</%scomments>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.comments), input_name='comments')), namespace_, eol_)) if self.otherdoc is not None: self.otherdoc.export(outfile, level, namespace_, name_='otherdoc', pretty_print=pretty_print) def build(self, node): @@ -791,7 +801,7 @@ class document2Type(GeneratedsSuper): eol_ = '' if self.comments is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%scomments>%s</%scomments>%s' % (namespace_, self.gds_format_string(quote_xml(self.comments).encode(ExternalEncoding), input_name='comments'), namespace_, eol_)) + outfile.write('<%scomments>%s</%scomments>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.comments), input_name='comments')), namespace_, eol_)) if self.rating is not None: showIndent(outfile, level, pretty_print) outfile.write('<%srating>%s</%srating>%s' % (namespace_, self.gds_format_integer(self.rating, input_name='rating'), namespace_, eol_)) @@ -889,7 +899,7 @@ class document3Type(GeneratedsSuper): eol_ = '' if self.comments is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%scomments>%s</%scomments>%s' % (namespace_, self.gds_format_string(quote_xml(self.comments).encode(ExternalEncoding), input_name='comments'), namespace_, eol_)) + outfile.write('<%scomments>%s</%scomments>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.comments), input_name='comments')), namespace_, eol_)) if self.rating is not None: showIndent(outfile, level, pretty_print) outfile.write('<%srating>%s</%srating>%s' % (namespace_, self.gds_format_integer(self.rating, input_name='rating'), namespace_, eol_)) diff --git a/tests/annotations2_sup.py b/tests/annotations2_sup.py index 5069103..6071f59 100644 --- a/tests/annotations2_sup.py +++ b/tests/annotations2_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -697,7 +707,7 @@ class document1Type(GeneratedsSuper): eol_ = '' if self.comments is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%scomments>%s</%scomments>%s' % (namespace_, self.gds_format_string(quote_xml(self.comments).encode(ExternalEncoding), input_name='comments'), namespace_, eol_)) + outfile.write('<%scomments>%s</%scomments>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.comments), input_name='comments')), namespace_, eol_)) if self.otherdoc is not None: self.otherdoc.export(outfile, level, namespace_, name_='otherdoc', pretty_print=pretty_print) def build(self, node): @@ -791,7 +801,7 @@ class document2Type(GeneratedsSuper): eol_ = '' if self.comments is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%scomments>%s</%scomments>%s' % (namespace_, self.gds_format_string(quote_xml(self.comments).encode(ExternalEncoding), input_name='comments'), namespace_, eol_)) + outfile.write('<%scomments>%s</%scomments>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.comments), input_name='comments')), namespace_, eol_)) if self.rating is not None: showIndent(outfile, level, pretty_print) outfile.write('<%srating>%s</%srating>%s' % (namespace_, self.gds_format_integer(self.rating, input_name='rating'), namespace_, eol_)) @@ -889,7 +899,7 @@ class document3Type(GeneratedsSuper): eol_ = '' if self.comments is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%scomments>%s</%scomments>%s' % (namespace_, self.gds_format_string(quote_xml(self.comments).encode(ExternalEncoding), input_name='comments'), namespace_, eol_)) + outfile.write('<%scomments>%s</%scomments>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.comments), input_name='comments')), namespace_, eol_)) if self.rating is not None: showIndent(outfile, level, pretty_print) outfile.write('<%srating>%s</%srating>%s' % (namespace_, self.gds_format_integer(self.rating, input_name='rating'), namespace_, eol_)) diff --git a/tests/anonymous_type1_sup.py b/tests/anonymous_type1_sup.py index 107e6d6..9aed0df 100644 --- a/tests/anonymous_type1_sup.py +++ b/tests/anonymous_type1_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -795,7 +805,7 @@ class FooType1(GeneratedsSuper): eol_ = '' if self.FooType is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sFooType>%s</%sFooType>%s' % (namespace_, self.gds_format_string(quote_xml(self.FooType).encode(ExternalEncoding), input_name='FooType'), namespace_, eol_)) + outfile.write('<%sFooType>%s</%sFooType>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.FooType), input_name='FooType')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -879,7 +889,7 @@ class BarType2(GeneratedsSuper): eol_ = '' if self.BarType is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sBarType>%s</%sBarType>%s' % (namespace_, self.gds_format_string(quote_xml(self.BarType).encode(ExternalEncoding), input_name='BarType'), namespace_, eol_)) + outfile.write('<%sBarType>%s</%sBarType>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.BarType), input_name='BarType')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -963,7 +973,7 @@ class BazType3(GeneratedsSuper): eol_ = '' if self.BazType is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sBazType>%s</%sBazType>%s' % (namespace_, self.gds_format_string(quote_xml(self.BazType).encode(ExternalEncoding), input_name='BazType'), namespace_, eol_)) + outfile.write('<%sBazType>%s</%sBazType>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.BazType), input_name='BazType')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) diff --git a/tests/anonymous_type2_sup.py b/tests/anonymous_type2_sup.py index 107e6d6..9aed0df 100644 --- a/tests/anonymous_type2_sup.py +++ b/tests/anonymous_type2_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -795,7 +805,7 @@ class FooType1(GeneratedsSuper): eol_ = '' if self.FooType is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sFooType>%s</%sFooType>%s' % (namespace_, self.gds_format_string(quote_xml(self.FooType).encode(ExternalEncoding), input_name='FooType'), namespace_, eol_)) + outfile.write('<%sFooType>%s</%sFooType>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.FooType), input_name='FooType')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -879,7 +889,7 @@ class BarType2(GeneratedsSuper): eol_ = '' if self.BarType is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sBarType>%s</%sBarType>%s' % (namespace_, self.gds_format_string(quote_xml(self.BarType).encode(ExternalEncoding), input_name='BarType'), namespace_, eol_)) + outfile.write('<%sBarType>%s</%sBarType>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.BarType), input_name='BarType')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -963,7 +973,7 @@ class BazType3(GeneratedsSuper): eol_ = '' if self.BazType is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sBazType>%s</%sBazType>%s' % (namespace_, self.gds_format_string(quote_xml(self.BazType).encode(ExternalEncoding), input_name='BazType'), namespace_, eol_)) + outfile.write('<%sBazType>%s</%sBazType>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.BazType), input_name='BazType')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) diff --git a/tests/anysimpletype1_sup.py b/tests/anysimpletype1_sup.py index 2499ac8..4dd47d7 100644 --- a/tests/anysimpletype1_sup.py +++ b/tests/anysimpletype1_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -761,7 +771,7 @@ class cimAnySimpleType(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='cimAnySimpleType') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='cimAnySimpleType', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: diff --git a/tests/anysimpletype2_sup.py b/tests/anysimpletype2_sup.py index 2499ac8..4dd47d7 100644 --- a/tests/anysimpletype2_sup.py +++ b/tests/anysimpletype2_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -761,7 +771,7 @@ class cimAnySimpleType(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='cimAnySimpleType') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='cimAnySimpleType', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: diff --git a/tests/anywildcard1_sup.py b/tests/anywildcard1_sup.py index 6a3fd36..a67df98 100644 --- a/tests/anywildcard1_sup.py +++ b/tests/anywildcard1_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -699,7 +709,7 @@ class PlantType_single(GeneratedsSuper): eol_ = '' if self.name is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_format_string(quote_xml(self.name).encode(ExternalEncoding), input_name='name'), namespace_, eol_)) + outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.name), input_name='name')), namespace_, eol_)) if self.description is not None: self.description.export(outfile, level, namespace_, name_='description', pretty_print=pretty_print) if self.anytypeobjs_ is not None: @@ -801,7 +811,7 @@ class PlantType_multiple(GeneratedsSuper): eol_ = '' if self.name is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_format_string(quote_xml(self.name).encode(ExternalEncoding), input_name='name'), namespace_, eol_)) + outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.name), input_name='name')), namespace_, eol_)) if self.description is not None: self.description.export(outfile, level, namespace_, name_='description', pretty_print=pretty_print) for obj_ in self.anytypeobjs_: @@ -894,10 +904,10 @@ class DescriptionType(GeneratedsSuper): eol_ = '' if self.name is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_format_string(quote_xml(self.name).encode(ExternalEncoding), input_name='name'), namespace_, eol_)) + outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.name), input_name='name')), namespace_, eol_)) if self.size is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%ssize>%s</%ssize>%s' % (namespace_, self.gds_format_string(quote_xml(self.size).encode(ExternalEncoding), input_name='size'), namespace_, eol_)) + outfile.write('<%ssize>%s</%ssize>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.size), input_name='size')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -981,7 +991,7 @@ class CatalogType(GeneratedsSuper): eol_ = '' if self.name is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_format_string(quote_xml(self.name).encode(ExternalEncoding), input_name='name'), namespace_, eol_)) + outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.name), input_name='name')), namespace_, eol_)) if self.catagory is not None: showIndent(outfile, level, pretty_print) outfile.write('<%scatagory>%s</%scatagory>%s' % (namespace_, self.gds_format_integer(self.catagory, input_name='catagory'), namespace_, eol_)) diff --git a/tests/anywildcard2_sup.py b/tests/anywildcard2_sup.py index 6a3fd36..a67df98 100644 --- a/tests/anywildcard2_sup.py +++ b/tests/anywildcard2_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -699,7 +709,7 @@ class PlantType_single(GeneratedsSuper): eol_ = '' if self.name is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_format_string(quote_xml(self.name).encode(ExternalEncoding), input_name='name'), namespace_, eol_)) + outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.name), input_name='name')), namespace_, eol_)) if self.description is not None: self.description.export(outfile, level, namespace_, name_='description', pretty_print=pretty_print) if self.anytypeobjs_ is not None: @@ -801,7 +811,7 @@ class PlantType_multiple(GeneratedsSuper): eol_ = '' if self.name is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_format_string(quote_xml(self.name).encode(ExternalEncoding), input_name='name'), namespace_, eol_)) + outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.name), input_name='name')), namespace_, eol_)) if self.description is not None: self.description.export(outfile, level, namespace_, name_='description', pretty_print=pretty_print) for obj_ in self.anytypeobjs_: @@ -894,10 +904,10 @@ class DescriptionType(GeneratedsSuper): eol_ = '' if self.name is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_format_string(quote_xml(self.name).encode(ExternalEncoding), input_name='name'), namespace_, eol_)) + outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.name), input_name='name')), namespace_, eol_)) if self.size is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%ssize>%s</%ssize>%s' % (namespace_, self.gds_format_string(quote_xml(self.size).encode(ExternalEncoding), input_name='size'), namespace_, eol_)) + outfile.write('<%ssize>%s</%ssize>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.size), input_name='size')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -981,7 +991,7 @@ class CatalogType(GeneratedsSuper): eol_ = '' if self.name is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_format_string(quote_xml(self.name).encode(ExternalEncoding), input_name='name'), namespace_, eol_)) + outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.name), input_name='name')), namespace_, eol_)) if self.catagory is not None: showIndent(outfile, level, pretty_print) outfile.write('<%scatagory>%s</%scatagory>%s' % (namespace_, self.gds_format_integer(self.catagory, input_name='catagory'), namespace_, eol_)) diff --git a/tests/attr_groups1_sup.py b/tests/attr_groups1_sup.py index d038363..3a65b3f 100644 --- a/tests/attr_groups1_sup.py +++ b/tests/attr_groups1_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -718,19 +728,19 @@ class GetUserReq(GeneratedsSuper): outfile.write(' sequence="%s"' % self.gds_format_integer(self.sequence, input_name='sequence')) if self.value01 is not None and 'value01' not in already_processed: already_processed.add('value01') - outfile.write(' value01=%s' % (self.gds_format_string(quote_attrib(self.value01).encode(ExternalEncoding), input_name='value01'), )) + outfile.write(' value01=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.value01), input_name='value01')), )) if self.value02 is not None and 'value02' not in already_processed: already_processed.add('value02') outfile.write(' value02="%s"' % self.gds_format_integer(self.value02, input_name='value02')) if self.value03 is not None and 'value03' not in already_processed: already_processed.add('value03') - outfile.write(' value03=%s' % (self.gds_format_string(quote_attrib(self.value03).encode(ExternalEncoding), input_name='value03'), )) + outfile.write(' value03=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.value03), input_name='value03')), )) if self.value04 is not None and 'value04' not in already_processed: already_processed.add('value04') outfile.write(' value04="%s"' % self.gds_format_integer(self.value04, input_name='value04')) if self.value05 is not None and 'value05' not in already_processed: already_processed.add('value05') - outfile.write(' value05=%s' % (self.gds_format_string(quote_attrib(self.value05).encode(ExternalEncoding), input_name='value05'), )) + outfile.write(' value05=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.value05), input_name='value05')), )) if self.value06 is not None and 'value06' not in already_processed: already_processed.add('value06') outfile.write(' value06="%s"' % self.gds_format_integer(self.value06, input_name='value06')) @@ -744,7 +754,7 @@ class GetUserReq(GeneratedsSuper): eol_ = '' if self.returnedTags is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sreturnedTags>%s</%sreturnedTags>%s' % (namespace_, self.gds_format_string(quote_xml(self.returnedTags).encode(ExternalEncoding), input_name='returnedTags'), namespace_, eol_)) + outfile.write('<%sreturnedTags>%s</%sreturnedTags>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.returnedTags), input_name='returnedTags')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) diff --git a/tests/attr_groups2_sup.py b/tests/attr_groups2_sup.py index d038363..3a65b3f 100644 --- a/tests/attr_groups2_sup.py +++ b/tests/attr_groups2_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -718,19 +728,19 @@ class GetUserReq(GeneratedsSuper): outfile.write(' sequence="%s"' % self.gds_format_integer(self.sequence, input_name='sequence')) if self.value01 is not None and 'value01' not in already_processed: already_processed.add('value01') - outfile.write(' value01=%s' % (self.gds_format_string(quote_attrib(self.value01).encode(ExternalEncoding), input_name='value01'), )) + outfile.write(' value01=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.value01), input_name='value01')), )) if self.value02 is not None and 'value02' not in already_processed: already_processed.add('value02') outfile.write(' value02="%s"' % self.gds_format_integer(self.value02, input_name='value02')) if self.value03 is not None and 'value03' not in already_processed: already_processed.add('value03') - outfile.write(' value03=%s' % (self.gds_format_string(quote_attrib(self.value03).encode(ExternalEncoding), input_name='value03'), )) + outfile.write(' value03=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.value03), input_name='value03')), )) if self.value04 is not None and 'value04' not in already_processed: already_processed.add('value04') outfile.write(' value04="%s"' % self.gds_format_integer(self.value04, input_name='value04')) if self.value05 is not None and 'value05' not in already_processed: already_processed.add('value05') - outfile.write(' value05=%s' % (self.gds_format_string(quote_attrib(self.value05).encode(ExternalEncoding), input_name='value05'), )) + outfile.write(' value05=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.value05), input_name='value05')), )) if self.value06 is not None and 'value06' not in already_processed: already_processed.add('value06') outfile.write(' value06="%s"' % self.gds_format_integer(self.value06, input_name='value06')) @@ -744,7 +754,7 @@ class GetUserReq(GeneratedsSuper): eol_ = '' if self.returnedTags is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sreturnedTags>%s</%sreturnedTags>%s' % (namespace_, self.gds_format_string(quote_xml(self.returnedTags).encode(ExternalEncoding), input_name='returnedTags'), namespace_, eol_)) + outfile.write('<%sreturnedTags>%s</%sreturnedTags>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.returnedTags), input_name='returnedTags')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) diff --git a/tests/cdata1_sup.py b/tests/cdata1_sup.py index fb1228a..4815129 100644 --- a/tests/cdata1_sup.py +++ b/tests/cdata1_sup.py @@ -34,6 +34,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -353,6 +357,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -407,7 +417,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -429,7 +439,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -770,7 +780,7 @@ class cdataType(GeneratedsSuper): eol_ = '' if self.script is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sscript>%s</%sscript>%s' % (namespace_, self.gds_format_string(quote_xml(self.script).encode(ExternalEncoding), input_name='script'), namespace_, eol_)) + outfile.write('<%sscript>%s</%sscript>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.script), input_name='script')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) diff --git a/tests/cdata2_sup.py b/tests/cdata2_sup.py index fb1228a..4815129 100644 --- a/tests/cdata2_sup.py +++ b/tests/cdata2_sup.py @@ -34,6 +34,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -353,6 +357,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -407,7 +417,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -429,7 +439,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -770,7 +780,7 @@ class cdataType(GeneratedsSuper): eol_ = '' if self.script is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sscript>%s</%sscript>%s' % (namespace_, self.gds_format_string(quote_xml(self.script).encode(ExternalEncoding), input_name='script'), namespace_, eol_)) + outfile.write('<%sscript>%s</%sscript>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.script), input_name='script')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) diff --git a/tests/cleanupname1_sup.py b/tests/cleanupname1_sup.py index 38b495b..9d3b8c8 100644 --- a/tests/cleanupname1_sup.py +++ b/tests/cleanupname1_sup.py @@ -34,6 +34,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -353,6 +357,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -407,7 +417,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -429,7 +439,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -812,7 +822,7 @@ class data1Kind(GeneratedsSuper): eol_ = '' if self.content1 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%scontent1>%s</%scontent1>%s' % (namespace_, self.gds_format_string(quote_xml(self.content1).encode(ExternalEncoding), input_name='content1'), namespace_, eol_)) + outfile.write('<%scontent1>%s</%scontent1>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.content1), input_name='content1')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -886,7 +896,7 @@ class MlassData2(GeneratedsSuper): eol_ = '' if self.content1 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%scontent1>%s</%scontent1>%s' % (namespace_, self.gds_format_string(quote_xml(self.content1).encode(ExternalEncoding), input_name='content1'), namespace_, eol_)) + outfile.write('<%scontent1>%s</%scontent1>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.content1), input_name='content1')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -960,7 +970,7 @@ class RealTypeData3(GeneratedsSuper): eol_ = '' if self.content1 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%scontent1>%s</%scontent1>%s' % (namespace_, self.gds_format_string(quote_xml(self.content1).encode(ExternalEncoding), input_name='content1'), namespace_, eol_)) + outfile.write('<%scontent1>%s</%scontent1>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.content1), input_name='content1')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -1034,7 +1044,7 @@ class MMMMMMdataKind(GeneratedsSuper): eol_ = '' if self.content1 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%scontent1>%s</%scontent1>%s' % (namespace_, self.gds_format_string(quote_xml(self.content1).encode(ExternalEncoding), input_name='content1'), namespace_, eol_)) + outfile.write('<%scontent1>%s</%scontent1>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.content1), input_name='content1')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -1108,7 +1118,7 @@ class dataTypeNNNMNNN(GeneratedsSuper): eol_ = '' if self.content1 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%scontent1>%s</%scontent1>%s' % (namespace_, self.gds_format_string(quote_xml(self.content1).encode(ExternalEncoding), input_name='content1'), namespace_, eol_)) + outfile.write('<%scontent1>%s</%scontent1>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.content1), input_name='content1')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) diff --git a/tests/cleanupname2_sup.py b/tests/cleanupname2_sup.py index 38b495b..9d3b8c8 100644 --- a/tests/cleanupname2_sup.py +++ b/tests/cleanupname2_sup.py @@ -34,6 +34,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -353,6 +357,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -407,7 +417,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -429,7 +439,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -812,7 +822,7 @@ class data1Kind(GeneratedsSuper): eol_ = '' if self.content1 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%scontent1>%s</%scontent1>%s' % (namespace_, self.gds_format_string(quote_xml(self.content1).encode(ExternalEncoding), input_name='content1'), namespace_, eol_)) + outfile.write('<%scontent1>%s</%scontent1>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.content1), input_name='content1')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -886,7 +896,7 @@ class MlassData2(GeneratedsSuper): eol_ = '' if self.content1 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%scontent1>%s</%scontent1>%s' % (namespace_, self.gds_format_string(quote_xml(self.content1).encode(ExternalEncoding), input_name='content1'), namespace_, eol_)) + outfile.write('<%scontent1>%s</%scontent1>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.content1), input_name='content1')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -960,7 +970,7 @@ class RealTypeData3(GeneratedsSuper): eol_ = '' if self.content1 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%scontent1>%s</%scontent1>%s' % (namespace_, self.gds_format_string(quote_xml(self.content1).encode(ExternalEncoding), input_name='content1'), namespace_, eol_)) + outfile.write('<%scontent1>%s</%scontent1>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.content1), input_name='content1')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -1034,7 +1044,7 @@ class MMMMMMdataKind(GeneratedsSuper): eol_ = '' if self.content1 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%scontent1>%s</%scontent1>%s' % (namespace_, self.gds_format_string(quote_xml(self.content1).encode(ExternalEncoding), input_name='content1'), namespace_, eol_)) + outfile.write('<%scontent1>%s</%scontent1>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.content1), input_name='content1')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -1108,7 +1118,7 @@ class dataTypeNNNMNNN(GeneratedsSuper): eol_ = '' if self.content1 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%scontent1>%s</%scontent1>%s' % (namespace_, self.gds_format_string(quote_xml(self.content1).encode(ExternalEncoding), input_name='content1'), namespace_, eol_)) + outfile.write('<%scontent1>%s</%scontent1>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.content1), input_name='content1')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) diff --git a/tests/defaults_cases1_out.xml b/tests/defaults_cases1_out.xml index e69de29..58064fb 100644 --- a/tests/defaults_cases1_out.xml +++ b/tests/defaults_cases1_out.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" ?> +<defaults> + <default1> + <normal02>a new value 1</normal02> + <default02>a new value 2</default02> + <normal03>55.659999999999997</normal03> + <normal04>6.677000e+01</normal04> + <default03>77.879999999999995</default03> + <default04>8.899000e+01</default04> + </default1> + <default2 attrdefault01="xyz"/> + <default2/> + <default2/> + <default2 attrnormal01="wxy"/> + <default2 attrnormal02="89"/> +</defaults> diff --git a/tests/defaults_cases1_sub.py b/tests/defaults_cases1_sub.py index ad19fc6..3e60267 100644 --- a/tests/defaults_cases1_sub.py +++ b/tests/defaults_cases1_sub.py @@ -6,7 +6,6 @@ # Command line options: # ('--no-dates', '') # ('--no-versions', '') -# ('--silence', '') # ('--member-specs', 'list') # ('-f', '') # ('-o', 'tests/defaults_cases2_sup.py') @@ -17,7 +16,7 @@ # tests/defaults_cases.xsd # # Command line: -# generateDS.py --no-dates --no-versions --silence --member-specs="list" -f -o "tests/defaults_cases2_sup.py" -s "tests/defaults_cases2_sub.py" --super="defaults_cases2_sup" tests/defaults_cases.xsd +# generateDS.py --no-dates --no-versions --member-specs="list" -f -o "tests/defaults_cases2_sup.py" -s "tests/defaults_cases2_sub.py" --super="defaults_cases2_sup" tests/defaults_cases.xsd # # Current working directory (os.getcwd()): # generateds @@ -89,12 +88,12 @@ def parse(inFilename, silence=False): rootObj.build(rootNode) # Enable Python to collect the space used by the DOM. doc = None -## if not silence: -## sys.stdout.write('<?xml version="1.0" ?>\n') -## rootObj.export( -## sys.stdout, 0, name_=rootTag, -## namespacedef_='', -## pretty_print=True) + if not silence: + sys.stdout.write('<?xml version="1.0" ?>\n') + rootObj.export( + sys.stdout, 0, name_=rootTag, + namespacedef_='', + pretty_print=True) return rootObj @@ -113,12 +112,12 @@ def parseEtree(inFilename, silence=False): mapping = {} rootElement = rootObj.to_etree(None, name_=rootTag, mapping_=mapping) reverse_mapping = rootObj.gds_reverse_node_mapping(mapping) -## if not silence: -## content = etree_.tostring( -## rootElement, pretty_print=True, -## xml_declaration=True, encoding="utf-8") -## sys.stdout.write(content) -## sys.stdout.write('\n') + if not silence: + content = etree_.tostring( + rootElement, pretty_print=True, + xml_declaration=True, encoding="utf-8") + sys.stdout.write(content) + sys.stdout.write('\n') return rootObj, rootElement, mapping, reverse_mapping @@ -135,11 +134,11 @@ def parseString(inString, silence=False): rootObj.build(rootNode) # Enable Python to collect the space used by the DOM. doc = None -## if not silence: -## sys.stdout.write('<?xml version="1.0" ?>\n') -## rootObj.export( -## sys.stdout, 0, name_=rootTag, -## namespacedef_='') + if not silence: + sys.stdout.write('<?xml version="1.0" ?>\n') + rootObj.export( + sys.stdout, 0, name_=rootTag, + namespacedef_='') return rootObj @@ -155,12 +154,12 @@ def parseLiteral(inFilename, silence=False): rootObj.build(rootNode) # Enable Python to collect the space used by the DOM. doc = None -## if not silence: -## sys.stdout.write('#from defaults_cases2_sup import *\n\n') -## sys.stdout.write('import defaults_cases2_sup as model_\n\n') -## sys.stdout.write('rootObj = model_.rootClass(\n') -## rootObj.exportLiteral(sys.stdout, 0, name_=rootTag) -## sys.stdout.write(')\n') + if not silence: + sys.stdout.write('#from defaults_cases2_sup import *\n\n') + sys.stdout.write('import defaults_cases2_sup as model_\n\n') + sys.stdout.write('rootObj = model_.rootClass(\n') + rootObj.exportLiteral(sys.stdout, 0, name_=rootTag) + sys.stdout.write(')\n') return rootObj diff --git a/tests/defaults_cases1_sup.py b/tests/defaults_cases1_sup.py index 3f73c5d..d9f5a13 100644 --- a/tests/defaults_cases1_sup.py +++ b/tests/defaults_cases1_sup.py @@ -7,7 +7,6 @@ # Command line options: # ('--no-dates', '') # ('--no-versions', '') -# ('--silence', '') # ('--member-specs', 'list') # ('-f', '') # ('-o', 'tests/defaults_cases2_sup.py') @@ -18,7 +17,7 @@ # tests/defaults_cases.xsd # # Command line: -# generateDS.py --no-dates --no-versions --silence --member-specs="list" -f -o "tests/defaults_cases2_sup.py" -s "tests/defaults_cases2_sub.py" --super="defaults_cases2_sup" tests/defaults_cases.xsd +# generateDS.py --no-dates --no-versions --member-specs="list" -f -o "tests/defaults_cases2_sup.py" -s "tests/defaults_cases2_sub.py" --super="defaults_cases2_sup" tests/defaults_cases.xsd # # Current working directory (os.getcwd()): # generateds @@ -33,6 +32,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +355,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +415,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +437,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -825,13 +834,13 @@ class DefaultType1(GeneratedsSuper): outfile.write('<%snormal01>%s</%snormal01>%s' % (namespace_, self.gds_format_integer(self.normal01, input_name='normal01'), namespace_, eol_)) if self.normal02 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%snormal02>%s</%snormal02>%s' % (namespace_, self.gds_format_string(quote_xml(self.normal02).encode(ExternalEncoding), input_name='normal02'), namespace_, eol_)) + outfile.write('<%snormal02>%s</%snormal02>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.normal02), input_name='normal02')), namespace_, eol_)) if self.default01 != 23: showIndent(outfile, level, pretty_print) outfile.write('<%sdefault01>%s</%sdefault01>%s' % (namespace_, self.gds_format_integer(self.default01, input_name='default01'), namespace_, eol_)) if self.default02 != "Peach": showIndent(outfile, level, pretty_print) - outfile.write('<%sdefault02>%s</%sdefault02>%s' % (namespace_, self.gds_format_string(quote_xml(self.default02).encode(ExternalEncoding), input_name='default02'), namespace_, eol_)) + outfile.write('<%sdefault02>%s</%sdefault02>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.default02), input_name='default02')), namespace_, eol_)) if self.normal03 is not None: showIndent(outfile, level, pretty_print) outfile.write('<%snormal03>%s</%snormal03>%s' % (namespace_, self.gds_format_float(self.normal03, input_name='normal03'), namespace_, eol_)) @@ -974,13 +983,13 @@ class DefaultType2(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='DefaultType2'): if self.attrdefault01 != "abcd" and 'attrdefault01' not in already_processed: already_processed.add('attrdefault01') - outfile.write(' attrdefault01=%s' % (self.gds_format_string(quote_attrib(self.attrdefault01).encode(ExternalEncoding), input_name='attrdefault01'), )) + outfile.write(' attrdefault01=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.attrdefault01), input_name='attrdefault01')), )) if self.attrdefault02 != 14 and 'attrdefault02' not in already_processed: already_processed.add('attrdefault02') outfile.write(' attrdefault02="%s"' % self.gds_format_integer(self.attrdefault02, input_name='attrdefault02')) if self.attrnormal01 is not None and 'attrnormal01' not in already_processed: already_processed.add('attrnormal01') - outfile.write(' attrnormal01=%s' % (self.gds_format_string(quote_attrib(self.attrnormal01).encode(ExternalEncoding), input_name='attrnormal01'), )) + outfile.write(' attrnormal01=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.attrnormal01), input_name='attrnormal01')), )) if self.attrnormal02 is not None and 'attrnormal02' not in already_processed: already_processed.add('attrnormal02') outfile.write(' attrnormal02="%s"' % self.gds_format_integer(self.attrnormal02, input_name='attrnormal02')) @@ -1058,12 +1067,12 @@ def parse(inFileName, silence=False): rootObj.build(rootNode) # Enable Python to collect the space used by the DOM. doc = None -## if not silence: -## sys.stdout.write('<?xml version="1.0" ?>\n') -## rootObj.export( -## sys.stdout, 0, name_=rootTag, -## namespacedef_='', -## pretty_print=True) + if not silence: + sys.stdout.write('<?xml version="1.0" ?>\n') + rootObj.export( + sys.stdout, 0, name_=rootTag, + namespacedef_='', + pretty_print=True) return rootObj @@ -1082,12 +1091,12 @@ def parseEtree(inFileName, silence=False): mapping = {} rootElement = rootObj.to_etree(None, name_=rootTag, mapping_=mapping) reverse_mapping = rootObj.gds_reverse_node_mapping(mapping) -## if not silence: -## content = etree_.tostring( -## rootElement, pretty_print=True, -## xml_declaration=True, encoding="utf-8") -## sys.stdout.write(content) -## sys.stdout.write('\n') + if not silence: + content = etree_.tostring( + rootElement, pretty_print=True, + xml_declaration=True, encoding="utf-8") + sys.stdout.write(content) + sys.stdout.write('\n') return rootObj, rootElement, mapping, reverse_mapping @@ -1104,11 +1113,11 @@ def parseString(inString, silence=False): rootObj.build(rootNode) # Enable Python to collect the space used by the DOM. doc = None -## if not silence: -## sys.stdout.write('<?xml version="1.0" ?>\n') -## rootObj.export( -## sys.stdout, 0, name_=rootTag, -## namespacedef_='') + if not silence: + sys.stdout.write('<?xml version="1.0" ?>\n') + rootObj.export( + sys.stdout, 0, name_=rootTag, + namespacedef_='') return rootObj @@ -1124,12 +1133,12 @@ def parseLiteral(inFileName, silence=False): rootObj.build(rootNode) # Enable Python to collect the space used by the DOM. doc = None -## if not silence: -## sys.stdout.write('#from defaults_cases2_sup import *\n\n') -## sys.stdout.write('import defaults_cases2_sup as model_\n\n') -## sys.stdout.write('rootObj = model_.rootClass(\n') -## rootObj.exportLiteral(sys.stdout, 0, name_=rootTag) -## sys.stdout.write(')\n') + if not silence: + sys.stdout.write('#from defaults_cases2_sup import *\n\n') + sys.stdout.write('import defaults_cases2_sup as model_\n\n') + sys.stdout.write('rootObj = model_.rootClass(\n') + rootObj.exportLiteral(sys.stdout, 0, name_=rootTag) + sys.stdout.write(')\n') return rootObj diff --git a/tests/defaults_cases2_out.xml b/tests/defaults_cases2_out.xml index e69de29..58064fb 100644 --- a/tests/defaults_cases2_out.xml +++ b/tests/defaults_cases2_out.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" ?> +<defaults> + <default1> + <normal02>a new value 1</normal02> + <default02>a new value 2</default02> + <normal03>55.659999999999997</normal03> + <normal04>6.677000e+01</normal04> + <default03>77.879999999999995</default03> + <default04>8.899000e+01</default04> + </default1> + <default2 attrdefault01="xyz"/> + <default2/> + <default2/> + <default2 attrnormal01="wxy"/> + <default2 attrnormal02="89"/> +</defaults> diff --git a/tests/defaults_cases2_sub.py b/tests/defaults_cases2_sub.py index ad19fc6..3e60267 100644 --- a/tests/defaults_cases2_sub.py +++ b/tests/defaults_cases2_sub.py @@ -6,7 +6,6 @@ # Command line options: # ('--no-dates', '') # ('--no-versions', '') -# ('--silence', '') # ('--member-specs', 'list') # ('-f', '') # ('-o', 'tests/defaults_cases2_sup.py') @@ -17,7 +16,7 @@ # tests/defaults_cases.xsd # # Command line: -# generateDS.py --no-dates --no-versions --silence --member-specs="list" -f -o "tests/defaults_cases2_sup.py" -s "tests/defaults_cases2_sub.py" --super="defaults_cases2_sup" tests/defaults_cases.xsd +# generateDS.py --no-dates --no-versions --member-specs="list" -f -o "tests/defaults_cases2_sup.py" -s "tests/defaults_cases2_sub.py" --super="defaults_cases2_sup" tests/defaults_cases.xsd # # Current working directory (os.getcwd()): # generateds @@ -89,12 +88,12 @@ def parse(inFilename, silence=False): rootObj.build(rootNode) # Enable Python to collect the space used by the DOM. doc = None -## if not silence: -## sys.stdout.write('<?xml version="1.0" ?>\n') -## rootObj.export( -## sys.stdout, 0, name_=rootTag, -## namespacedef_='', -## pretty_print=True) + if not silence: + sys.stdout.write('<?xml version="1.0" ?>\n') + rootObj.export( + sys.stdout, 0, name_=rootTag, + namespacedef_='', + pretty_print=True) return rootObj @@ -113,12 +112,12 @@ def parseEtree(inFilename, silence=False): mapping = {} rootElement = rootObj.to_etree(None, name_=rootTag, mapping_=mapping) reverse_mapping = rootObj.gds_reverse_node_mapping(mapping) -## if not silence: -## content = etree_.tostring( -## rootElement, pretty_print=True, -## xml_declaration=True, encoding="utf-8") -## sys.stdout.write(content) -## sys.stdout.write('\n') + if not silence: + content = etree_.tostring( + rootElement, pretty_print=True, + xml_declaration=True, encoding="utf-8") + sys.stdout.write(content) + sys.stdout.write('\n') return rootObj, rootElement, mapping, reverse_mapping @@ -135,11 +134,11 @@ def parseString(inString, silence=False): rootObj.build(rootNode) # Enable Python to collect the space used by the DOM. doc = None -## if not silence: -## sys.stdout.write('<?xml version="1.0" ?>\n') -## rootObj.export( -## sys.stdout, 0, name_=rootTag, -## namespacedef_='') + if not silence: + sys.stdout.write('<?xml version="1.0" ?>\n') + rootObj.export( + sys.stdout, 0, name_=rootTag, + namespacedef_='') return rootObj @@ -155,12 +154,12 @@ def parseLiteral(inFilename, silence=False): rootObj.build(rootNode) # Enable Python to collect the space used by the DOM. doc = None -## if not silence: -## sys.stdout.write('#from defaults_cases2_sup import *\n\n') -## sys.stdout.write('import defaults_cases2_sup as model_\n\n') -## sys.stdout.write('rootObj = model_.rootClass(\n') -## rootObj.exportLiteral(sys.stdout, 0, name_=rootTag) -## sys.stdout.write(')\n') + if not silence: + sys.stdout.write('#from defaults_cases2_sup import *\n\n') + sys.stdout.write('import defaults_cases2_sup as model_\n\n') + sys.stdout.write('rootObj = model_.rootClass(\n') + rootObj.exportLiteral(sys.stdout, 0, name_=rootTag) + sys.stdout.write(')\n') return rootObj diff --git a/tests/defaults_cases2_sup.py b/tests/defaults_cases2_sup.py index 3f73c5d..d9f5a13 100644 --- a/tests/defaults_cases2_sup.py +++ b/tests/defaults_cases2_sup.py @@ -7,7 +7,6 @@ # Command line options: # ('--no-dates', '') # ('--no-versions', '') -# ('--silence', '') # ('--member-specs', 'list') # ('-f', '') # ('-o', 'tests/defaults_cases2_sup.py') @@ -18,7 +17,7 @@ # tests/defaults_cases.xsd # # Command line: -# generateDS.py --no-dates --no-versions --silence --member-specs="list" -f -o "tests/defaults_cases2_sup.py" -s "tests/defaults_cases2_sub.py" --super="defaults_cases2_sup" tests/defaults_cases.xsd +# generateDS.py --no-dates --no-versions --member-specs="list" -f -o "tests/defaults_cases2_sup.py" -s "tests/defaults_cases2_sub.py" --super="defaults_cases2_sup" tests/defaults_cases.xsd # # Current working directory (os.getcwd()): # generateds @@ -33,6 +32,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +355,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +415,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +437,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -825,13 +834,13 @@ class DefaultType1(GeneratedsSuper): outfile.write('<%snormal01>%s</%snormal01>%s' % (namespace_, self.gds_format_integer(self.normal01, input_name='normal01'), namespace_, eol_)) if self.normal02 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%snormal02>%s</%snormal02>%s' % (namespace_, self.gds_format_string(quote_xml(self.normal02).encode(ExternalEncoding), input_name='normal02'), namespace_, eol_)) + outfile.write('<%snormal02>%s</%snormal02>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.normal02), input_name='normal02')), namespace_, eol_)) if self.default01 != 23: showIndent(outfile, level, pretty_print) outfile.write('<%sdefault01>%s</%sdefault01>%s' % (namespace_, self.gds_format_integer(self.default01, input_name='default01'), namespace_, eol_)) if self.default02 != "Peach": showIndent(outfile, level, pretty_print) - outfile.write('<%sdefault02>%s</%sdefault02>%s' % (namespace_, self.gds_format_string(quote_xml(self.default02).encode(ExternalEncoding), input_name='default02'), namespace_, eol_)) + outfile.write('<%sdefault02>%s</%sdefault02>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.default02), input_name='default02')), namespace_, eol_)) if self.normal03 is not None: showIndent(outfile, level, pretty_print) outfile.write('<%snormal03>%s</%snormal03>%s' % (namespace_, self.gds_format_float(self.normal03, input_name='normal03'), namespace_, eol_)) @@ -974,13 +983,13 @@ class DefaultType2(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='DefaultType2'): if self.attrdefault01 != "abcd" and 'attrdefault01' not in already_processed: already_processed.add('attrdefault01') - outfile.write(' attrdefault01=%s' % (self.gds_format_string(quote_attrib(self.attrdefault01).encode(ExternalEncoding), input_name='attrdefault01'), )) + outfile.write(' attrdefault01=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.attrdefault01), input_name='attrdefault01')), )) if self.attrdefault02 != 14 and 'attrdefault02' not in already_processed: already_processed.add('attrdefault02') outfile.write(' attrdefault02="%s"' % self.gds_format_integer(self.attrdefault02, input_name='attrdefault02')) if self.attrnormal01 is not None and 'attrnormal01' not in already_processed: already_processed.add('attrnormal01') - outfile.write(' attrnormal01=%s' % (self.gds_format_string(quote_attrib(self.attrnormal01).encode(ExternalEncoding), input_name='attrnormal01'), )) + outfile.write(' attrnormal01=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.attrnormal01), input_name='attrnormal01')), )) if self.attrnormal02 is not None and 'attrnormal02' not in already_processed: already_processed.add('attrnormal02') outfile.write(' attrnormal02="%s"' % self.gds_format_integer(self.attrnormal02, input_name='attrnormal02')) @@ -1058,12 +1067,12 @@ def parse(inFileName, silence=False): rootObj.build(rootNode) # Enable Python to collect the space used by the DOM. doc = None -## if not silence: -## sys.stdout.write('<?xml version="1.0" ?>\n') -## rootObj.export( -## sys.stdout, 0, name_=rootTag, -## namespacedef_='', -## pretty_print=True) + if not silence: + sys.stdout.write('<?xml version="1.0" ?>\n') + rootObj.export( + sys.stdout, 0, name_=rootTag, + namespacedef_='', + pretty_print=True) return rootObj @@ -1082,12 +1091,12 @@ def parseEtree(inFileName, silence=False): mapping = {} rootElement = rootObj.to_etree(None, name_=rootTag, mapping_=mapping) reverse_mapping = rootObj.gds_reverse_node_mapping(mapping) -## if not silence: -## content = etree_.tostring( -## rootElement, pretty_print=True, -## xml_declaration=True, encoding="utf-8") -## sys.stdout.write(content) -## sys.stdout.write('\n') + if not silence: + content = etree_.tostring( + rootElement, pretty_print=True, + xml_declaration=True, encoding="utf-8") + sys.stdout.write(content) + sys.stdout.write('\n') return rootObj, rootElement, mapping, reverse_mapping @@ -1104,11 +1113,11 @@ def parseString(inString, silence=False): rootObj.build(rootNode) # Enable Python to collect the space used by the DOM. doc = None -## if not silence: -## sys.stdout.write('<?xml version="1.0" ?>\n') -## rootObj.export( -## sys.stdout, 0, name_=rootTag, -## namespacedef_='') + if not silence: + sys.stdout.write('<?xml version="1.0" ?>\n') + rootObj.export( + sys.stdout, 0, name_=rootTag, + namespacedef_='') return rootObj @@ -1124,12 +1133,12 @@ def parseLiteral(inFileName, silence=False): rootObj.build(rootNode) # Enable Python to collect the space used by the DOM. doc = None -## if not silence: -## sys.stdout.write('#from defaults_cases2_sup import *\n\n') -## sys.stdout.write('import defaults_cases2_sup as model_\n\n') -## sys.stdout.write('rootObj = model_.rootClass(\n') -## rootObj.exportLiteral(sys.stdout, 0, name_=rootTag) -## sys.stdout.write(')\n') + if not silence: + sys.stdout.write('#from defaults_cases2_sup import *\n\n') + sys.stdout.write('import defaults_cases2_sup as model_\n\n') + sys.stdout.write('rootObj = model_.rootClass(\n') + rootObj.exportLiteral(sys.stdout, 0, name_=rootTag) + sys.stdout.write(')\n') return rootObj diff --git a/tests/defaults_coverage1_sup.py b/tests/defaults_coverage1_sup.py index 8dac990..4cb45d6 100644 --- a/tests/defaults_coverage1_sup.py +++ b/tests/defaults_coverage1_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -754,32 +764,32 @@ class DefaultType1(GeneratedsSuper): self.default05a = default05a self.default05b = default05b self.normal05 = normal05 - if isinstance(default06, basestring): + if isinstance(default06, BaseStrType_): initvalue_ = datetime_.datetime.strptime(default06, '%Y-%m-%d').date() else: initvalue_ = default06 self.default06 = initvalue_ - if isinstance(normal06, basestring): + if isinstance(normal06, BaseStrType_): initvalue_ = datetime_.datetime.strptime(normal06, '%Y-%m-%d').date() else: initvalue_ = normal06 self.normal06 = initvalue_ - if isinstance(default07, basestring): + if isinstance(default07, BaseStrType_): initvalue_ = datetime_.datetime.strptime(default07, '%H:%M:%S').time() else: initvalue_ = default07 self.default07 = initvalue_ - if isinstance(normal07, basestring): + if isinstance(normal07, BaseStrType_): initvalue_ = datetime_.datetime.strptime(normal07, '%Y-%m-%d').date() else: initvalue_ = normal07 self.normal07 = initvalue_ - if isinstance(default08, basestring): + if isinstance(default08, BaseStrType_): initvalue_ = datetime_.datetime.strptime(default08, '%Y-%m-%dT%H:%M:%S') else: initvalue_ = default08 self.default08 = initvalue_ - if isinstance(normal08, basestring): + if isinstance(normal08, BaseStrType_): initvalue_ = datetime_.datetime.strptime(normal08, '%Y-%m-%dT%H:%M:%S') else: initvalue_ = normal08 @@ -885,10 +895,10 @@ class DefaultType1(GeneratedsSuper): outfile.write('<%snormal01>%s</%snormal01>%s' % (namespace_, self.gds_format_integer(self.normal01, input_name='normal01'), namespace_, eol_)) if self.default02 != "Peach": showIndent(outfile, level, pretty_print) - outfile.write('<%sdefault02>%s</%sdefault02>%s' % (namespace_, self.gds_format_string(quote_xml(self.default02).encode(ExternalEncoding), input_name='default02'), namespace_, eol_)) + outfile.write('<%sdefault02>%s</%sdefault02>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.default02), input_name='default02')), namespace_, eol_)) if self.normal02 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%snormal02>%s</%snormal02>%s' % (namespace_, self.gds_format_string(quote_xml(self.normal02).encode(ExternalEncoding), input_name='normal02'), namespace_, eol_)) + outfile.write('<%snormal02>%s</%snormal02>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.normal02), input_name='normal02')), namespace_, eol_)) if self.default03 != 23.45: showIndent(outfile, level, pretty_print) outfile.write('<%sdefault03>%s</%sdefault03>%s' % (namespace_, self.gds_format_float(self.default03, input_name='default03'), namespace_, eol_)) @@ -1086,32 +1096,32 @@ class DefaultType2(GeneratedsSuper): self.default05a = default05a self.default05b = default05b self.normal05 = normal05 - if isinstance(default06, basestring): + if isinstance(default06, BaseStrType_): initvalue_ = datetime_.datetime.strptime(default06, '%Y-%m-%d').date() else: initvalue_ = default06 self.default06 = initvalue_ - if isinstance(normal06, basestring): + if isinstance(normal06, BaseStrType_): initvalue_ = datetime_.datetime.strptime(normal06, '%Y-%m-%d').date() else: initvalue_ = normal06 self.normal06 = initvalue_ - if isinstance(default07, basestring): + if isinstance(default07, BaseStrType_): initvalue_ = datetime_.datetime.strptime(default07, '%H:%M:%S').time() else: initvalue_ = default07 self.default07 = initvalue_ - if isinstance(normal07, basestring): + if isinstance(normal07, BaseStrType_): initvalue_ = datetime_.datetime.strptime(normal07, '%Y-%m-%d').date() else: initvalue_ = normal07 self.normal07 = initvalue_ - if isinstance(default08, basestring): + if isinstance(default08, BaseStrType_): initvalue_ = datetime_.datetime.strptime(default08, '%Y-%m-%dT%H:%M:%S') else: initvalue_ = default08 self.default08 = initvalue_ - if isinstance(normal08, basestring): + if isinstance(normal08, BaseStrType_): initvalue_ = datetime_.datetime.strptime(normal08, '%Y-%m-%dT%H:%M:%S') else: initvalue_ = normal08 @@ -1217,10 +1227,10 @@ class DefaultType2(GeneratedsSuper): outfile.write('<%snormal01>%s</%snormal01>%s' % (namespace_, self.gds_format_integer(self.normal01, input_name='normal01'), namespace_, eol_)) if self.default02 != "Peach": showIndent(outfile, level, pretty_print) - outfile.write('<%sdefault02>%s</%sdefault02>%s' % (namespace_, self.gds_format_string(quote_xml(self.default02).encode(ExternalEncoding), input_name='default02'), namespace_, eol_)) + outfile.write('<%sdefault02>%s</%sdefault02>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.default02), input_name='default02')), namespace_, eol_)) if self.normal02 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%snormal02>%s</%snormal02>%s' % (namespace_, self.gds_format_string(quote_xml(self.normal02).encode(ExternalEncoding), input_name='normal02'), namespace_, eol_)) + outfile.write('<%snormal02>%s</%snormal02>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.normal02), input_name='normal02')), namespace_, eol_)) if self.default03 != 23.45: showIndent(outfile, level, pretty_print) outfile.write('<%sdefault03>%s</%sdefault03>%s' % (namespace_, self.gds_format_float(self.default03, input_name='default03'), namespace_, eol_)) diff --git a/tests/defaults_coverage2_sup.py b/tests/defaults_coverage2_sup.py index 8dac990..4cb45d6 100644 --- a/tests/defaults_coverage2_sup.py +++ b/tests/defaults_coverage2_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -754,32 +764,32 @@ class DefaultType1(GeneratedsSuper): self.default05a = default05a self.default05b = default05b self.normal05 = normal05 - if isinstance(default06, basestring): + if isinstance(default06, BaseStrType_): initvalue_ = datetime_.datetime.strptime(default06, '%Y-%m-%d').date() else: initvalue_ = default06 self.default06 = initvalue_ - if isinstance(normal06, basestring): + if isinstance(normal06, BaseStrType_): initvalue_ = datetime_.datetime.strptime(normal06, '%Y-%m-%d').date() else: initvalue_ = normal06 self.normal06 = initvalue_ - if isinstance(default07, basestring): + if isinstance(default07, BaseStrType_): initvalue_ = datetime_.datetime.strptime(default07, '%H:%M:%S').time() else: initvalue_ = default07 self.default07 = initvalue_ - if isinstance(normal07, basestring): + if isinstance(normal07, BaseStrType_): initvalue_ = datetime_.datetime.strptime(normal07, '%Y-%m-%d').date() else: initvalue_ = normal07 self.normal07 = initvalue_ - if isinstance(default08, basestring): + if isinstance(default08, BaseStrType_): initvalue_ = datetime_.datetime.strptime(default08, '%Y-%m-%dT%H:%M:%S') else: initvalue_ = default08 self.default08 = initvalue_ - if isinstance(normal08, basestring): + if isinstance(normal08, BaseStrType_): initvalue_ = datetime_.datetime.strptime(normal08, '%Y-%m-%dT%H:%M:%S') else: initvalue_ = normal08 @@ -885,10 +895,10 @@ class DefaultType1(GeneratedsSuper): outfile.write('<%snormal01>%s</%snormal01>%s' % (namespace_, self.gds_format_integer(self.normal01, input_name='normal01'), namespace_, eol_)) if self.default02 != "Peach": showIndent(outfile, level, pretty_print) - outfile.write('<%sdefault02>%s</%sdefault02>%s' % (namespace_, self.gds_format_string(quote_xml(self.default02).encode(ExternalEncoding), input_name='default02'), namespace_, eol_)) + outfile.write('<%sdefault02>%s</%sdefault02>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.default02), input_name='default02')), namespace_, eol_)) if self.normal02 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%snormal02>%s</%snormal02>%s' % (namespace_, self.gds_format_string(quote_xml(self.normal02).encode(ExternalEncoding), input_name='normal02'), namespace_, eol_)) + outfile.write('<%snormal02>%s</%snormal02>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.normal02), input_name='normal02')), namespace_, eol_)) if self.default03 != 23.45: showIndent(outfile, level, pretty_print) outfile.write('<%sdefault03>%s</%sdefault03>%s' % (namespace_, self.gds_format_float(self.default03, input_name='default03'), namespace_, eol_)) @@ -1086,32 +1096,32 @@ class DefaultType2(GeneratedsSuper): self.default05a = default05a self.default05b = default05b self.normal05 = normal05 - if isinstance(default06, basestring): + if isinstance(default06, BaseStrType_): initvalue_ = datetime_.datetime.strptime(default06, '%Y-%m-%d').date() else: initvalue_ = default06 self.default06 = initvalue_ - if isinstance(normal06, basestring): + if isinstance(normal06, BaseStrType_): initvalue_ = datetime_.datetime.strptime(normal06, '%Y-%m-%d').date() else: initvalue_ = normal06 self.normal06 = initvalue_ - if isinstance(default07, basestring): + if isinstance(default07, BaseStrType_): initvalue_ = datetime_.datetime.strptime(default07, '%H:%M:%S').time() else: initvalue_ = default07 self.default07 = initvalue_ - if isinstance(normal07, basestring): + if isinstance(normal07, BaseStrType_): initvalue_ = datetime_.datetime.strptime(normal07, '%Y-%m-%d').date() else: initvalue_ = normal07 self.normal07 = initvalue_ - if isinstance(default08, basestring): + if isinstance(default08, BaseStrType_): initvalue_ = datetime_.datetime.strptime(default08, '%Y-%m-%dT%H:%M:%S') else: initvalue_ = default08 self.default08 = initvalue_ - if isinstance(normal08, basestring): + if isinstance(normal08, BaseStrType_): initvalue_ = datetime_.datetime.strptime(normal08, '%Y-%m-%dT%H:%M:%S') else: initvalue_ = normal08 @@ -1217,10 +1227,10 @@ class DefaultType2(GeneratedsSuper): outfile.write('<%snormal01>%s</%snormal01>%s' % (namespace_, self.gds_format_integer(self.normal01, input_name='normal01'), namespace_, eol_)) if self.default02 != "Peach": showIndent(outfile, level, pretty_print) - outfile.write('<%sdefault02>%s</%sdefault02>%s' % (namespace_, self.gds_format_string(quote_xml(self.default02).encode(ExternalEncoding), input_name='default02'), namespace_, eol_)) + outfile.write('<%sdefault02>%s</%sdefault02>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.default02), input_name='default02')), namespace_, eol_)) if self.normal02 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%snormal02>%s</%snormal02>%s' % (namespace_, self.gds_format_string(quote_xml(self.normal02).encode(ExternalEncoding), input_name='normal02'), namespace_, eol_)) + outfile.write('<%snormal02>%s</%snormal02>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.normal02), input_name='normal02')), namespace_, eol_)) if self.default03 != 23.45: showIndent(outfile, level, pretty_print) outfile.write('<%sdefault03>%s</%sdefault03>%s' % (namespace_, self.gds_format_float(self.default03, input_name='default03'), namespace_, eol_)) diff --git a/tests/extensions1_sup.py b/tests/extensions1_sup.py index 896e1b3..1521f63 100644 --- a/tests/extensions1_sup.py +++ b/tests/extensions1_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -679,7 +689,7 @@ class SpecialDate(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='SpecialDate') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='SpecialDate', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -687,7 +697,7 @@ class SpecialDate(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='SpecialDate'): if self.SpecialProperty is not None and 'SpecialProperty' not in already_processed: already_processed.add('SpecialProperty') - outfile.write(' SpecialProperty=%s' % (self.gds_format_string(quote_attrib(self.SpecialProperty).encode(ExternalEncoding), input_name='SpecialProperty'), )) + outfile.write(' SpecialProperty=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.SpecialProperty), input_name='SpecialProperty')), )) def exportChildren(self, outfile, level, namespace_='', name_='SpecialDate', fromsubclass_=False, pretty_print=True): pass def build(self, node): @@ -754,7 +764,7 @@ class ExtremeDate(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='ExtremeDate') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='ExtremeDate', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -762,7 +772,7 @@ class ExtremeDate(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='ExtremeDate'): if self.ExtremeProperty is not None and 'ExtremeProperty' not in already_processed: already_processed.add('ExtremeProperty') - outfile.write(' ExtremeProperty=%s' % (self.gds_format_string(quote_attrib(self.ExtremeProperty).encode(ExternalEncoding), input_name='ExtremeProperty'), )) + outfile.write(' ExtremeProperty=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.ExtremeProperty), input_name='ExtremeProperty')), )) def exportChildren(self, outfile, level, namespace_='', name_='ExtremeDate', fromsubclass_=False, pretty_print=True): pass def build(self, node): @@ -829,7 +839,7 @@ class singleExtremeDate(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='singleExtremeDate') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='singleExtremeDate', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -837,7 +847,7 @@ class singleExtremeDate(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='singleExtremeDate'): if self.ExtremeProperty is not None and 'ExtremeProperty' not in already_processed: already_processed.add('ExtremeProperty') - outfile.write(' ExtremeProperty=%s' % (self.gds_format_string(quote_attrib(self.ExtremeProperty).encode(ExternalEncoding), input_name='ExtremeProperty'), )) + outfile.write(' ExtremeProperty=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.ExtremeProperty), input_name='ExtremeProperty')), )) def exportChildren(self, outfile, level, namespace_='', name_='singleExtremeDate', fromsubclass_=False, pretty_print=True): pass def build(self, node): @@ -1037,7 +1047,7 @@ class simpleFactoidType(GeneratedsSuper): eol_ = '' if self.relation is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%srelation>%s</%srelation>%s' % (namespace_, self.gds_format_string(quote_xml(self.relation).encode(ExternalEncoding), input_name='relation'), namespace_, eol_)) + outfile.write('<%srelation>%s</%srelation>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.relation), input_name='relation')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -1235,7 +1245,7 @@ class BaseType(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='BaseType') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='BaseType', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -1243,10 +1253,10 @@ class BaseType(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='BaseType'): if self.BaseProperty1 is not None and 'BaseProperty1' not in already_processed: already_processed.add('BaseProperty1') - outfile.write(' BaseProperty1=%s' % (self.gds_format_string(quote_attrib(self.BaseProperty1).encode(ExternalEncoding), input_name='BaseProperty1'), )) + outfile.write(' BaseProperty1=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.BaseProperty1), input_name='BaseProperty1')), )) if self.BaseProperty2 is not None and 'BaseProperty2' not in already_processed: already_processed.add('BaseProperty2') - outfile.write(' BaseProperty2=%s' % (self.gds_format_string(quote_attrib(self.BaseProperty2).encode(ExternalEncoding), input_name='BaseProperty2'), )) + outfile.write(' BaseProperty2=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.BaseProperty2), input_name='BaseProperty2')), )) if self.extensiontype_ is not None and 'xsi:type' not in already_processed: already_processed.add('xsi:type') outfile.write(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"') @@ -1331,7 +1341,7 @@ class DerivedType(BaseType): self.exportAttributes(outfile, level, already_processed, namespace_, name_='DerivedType') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='DerivedType', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -1340,10 +1350,10 @@ class DerivedType(BaseType): super(DerivedType, self).exportAttributes(outfile, level, already_processed, namespace_, name_='DerivedType') if self.DerivedProperty1 is not None and 'DerivedProperty1' not in already_processed: already_processed.add('DerivedProperty1') - outfile.write(' DerivedProperty1=%s' % (self.gds_format_string(quote_attrib(self.DerivedProperty1).encode(ExternalEncoding), input_name='DerivedProperty1'), )) + outfile.write(' DerivedProperty1=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.DerivedProperty1), input_name='DerivedProperty1')), )) if self.DerivedProperty2 is not None and 'DerivedProperty2' not in already_processed: already_processed.add('DerivedProperty2') - outfile.write(' DerivedProperty2=%s' % (self.gds_format_string(quote_attrib(self.DerivedProperty2).encode(ExternalEncoding), input_name='DerivedProperty2'), )) + outfile.write(' DerivedProperty2=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.DerivedProperty2), input_name='DerivedProperty2')), )) def exportChildren(self, outfile, level, namespace_='', name_='DerivedType', fromsubclass_=False, pretty_print=True): super(DerivedType, self).exportChildren(outfile, level, namespace_, name_, True, pretty_print=pretty_print) pass @@ -1416,7 +1426,7 @@ class MyInteger(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='MyInteger') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='MyInteger', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -1424,7 +1434,7 @@ class MyInteger(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='MyInteger'): if self.MyAttr is not None and 'MyAttr' not in already_processed: already_processed.add('MyAttr') - outfile.write(' MyAttr=%s' % (self.gds_format_string(quote_attrib(self.MyAttr).encode(ExternalEncoding), input_name='MyAttr'), )) + outfile.write(' MyAttr=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.MyAttr), input_name='MyAttr')), )) def exportChildren(self, outfile, level, namespace_='', name_='MyInteger', fromsubclass_=False, pretty_print=True): pass def build(self, node): @@ -1491,7 +1501,7 @@ class MyBoolean(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='MyBoolean') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='MyBoolean', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -1499,7 +1509,7 @@ class MyBoolean(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='MyBoolean'): if self.MyAttr is not None and 'MyAttr' not in already_processed: already_processed.add('MyAttr') - outfile.write(' MyAttr=%s' % (self.gds_format_string(quote_attrib(self.MyAttr).encode(ExternalEncoding), input_name='MyAttr'), )) + outfile.write(' MyAttr=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.MyAttr), input_name='MyAttr')), )) def exportChildren(self, outfile, level, namespace_='', name_='MyBoolean', fromsubclass_=False, pretty_print=True): pass def build(self, node): @@ -1566,7 +1576,7 @@ class MyFloat(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='MyFloat') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='MyFloat', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -1574,7 +1584,7 @@ class MyFloat(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='MyFloat'): if self.MyAttr is not None and 'MyAttr' not in already_processed: already_processed.add('MyAttr') - outfile.write(' MyAttr=%s' % (self.gds_format_string(quote_attrib(self.MyAttr).encode(ExternalEncoding), input_name='MyAttr'), )) + outfile.write(' MyAttr=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.MyAttr), input_name='MyAttr')), )) def exportChildren(self, outfile, level, namespace_='', name_='MyFloat', fromsubclass_=False, pretty_print=True): pass def build(self, node): @@ -1641,7 +1651,7 @@ class MyDouble(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='MyDouble') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='MyDouble', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -1649,7 +1659,7 @@ class MyDouble(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='MyDouble'): if self.MyAttr is not None and 'MyAttr' not in already_processed: already_processed.add('MyAttr') - outfile.write(' MyAttr=%s' % (self.gds_format_string(quote_attrib(self.MyAttr).encode(ExternalEncoding), input_name='MyAttr'), )) + outfile.write(' MyAttr=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.MyAttr), input_name='MyAttr')), )) def exportChildren(self, outfile, level, namespace_='', name_='MyDouble', fromsubclass_=False, pretty_print=True): pass def build(self, node): diff --git a/tests/extensions2_sup.py b/tests/extensions2_sup.py index 896e1b3..1521f63 100644 --- a/tests/extensions2_sup.py +++ b/tests/extensions2_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -679,7 +689,7 @@ class SpecialDate(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='SpecialDate') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='SpecialDate', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -687,7 +697,7 @@ class SpecialDate(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='SpecialDate'): if self.SpecialProperty is not None and 'SpecialProperty' not in already_processed: already_processed.add('SpecialProperty') - outfile.write(' SpecialProperty=%s' % (self.gds_format_string(quote_attrib(self.SpecialProperty).encode(ExternalEncoding), input_name='SpecialProperty'), )) + outfile.write(' SpecialProperty=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.SpecialProperty), input_name='SpecialProperty')), )) def exportChildren(self, outfile, level, namespace_='', name_='SpecialDate', fromsubclass_=False, pretty_print=True): pass def build(self, node): @@ -754,7 +764,7 @@ class ExtremeDate(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='ExtremeDate') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='ExtremeDate', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -762,7 +772,7 @@ class ExtremeDate(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='ExtremeDate'): if self.ExtremeProperty is not None and 'ExtremeProperty' not in already_processed: already_processed.add('ExtremeProperty') - outfile.write(' ExtremeProperty=%s' % (self.gds_format_string(quote_attrib(self.ExtremeProperty).encode(ExternalEncoding), input_name='ExtremeProperty'), )) + outfile.write(' ExtremeProperty=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.ExtremeProperty), input_name='ExtremeProperty')), )) def exportChildren(self, outfile, level, namespace_='', name_='ExtremeDate', fromsubclass_=False, pretty_print=True): pass def build(self, node): @@ -829,7 +839,7 @@ class singleExtremeDate(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='singleExtremeDate') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='singleExtremeDate', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -837,7 +847,7 @@ class singleExtremeDate(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='singleExtremeDate'): if self.ExtremeProperty is not None and 'ExtremeProperty' not in already_processed: already_processed.add('ExtremeProperty') - outfile.write(' ExtremeProperty=%s' % (self.gds_format_string(quote_attrib(self.ExtremeProperty).encode(ExternalEncoding), input_name='ExtremeProperty'), )) + outfile.write(' ExtremeProperty=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.ExtremeProperty), input_name='ExtremeProperty')), )) def exportChildren(self, outfile, level, namespace_='', name_='singleExtremeDate', fromsubclass_=False, pretty_print=True): pass def build(self, node): @@ -1037,7 +1047,7 @@ class simpleFactoidType(GeneratedsSuper): eol_ = '' if self.relation is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%srelation>%s</%srelation>%s' % (namespace_, self.gds_format_string(quote_xml(self.relation).encode(ExternalEncoding), input_name='relation'), namespace_, eol_)) + outfile.write('<%srelation>%s</%srelation>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.relation), input_name='relation')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -1235,7 +1245,7 @@ class BaseType(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='BaseType') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='BaseType', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -1243,10 +1253,10 @@ class BaseType(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='BaseType'): if self.BaseProperty1 is not None and 'BaseProperty1' not in already_processed: already_processed.add('BaseProperty1') - outfile.write(' BaseProperty1=%s' % (self.gds_format_string(quote_attrib(self.BaseProperty1).encode(ExternalEncoding), input_name='BaseProperty1'), )) + outfile.write(' BaseProperty1=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.BaseProperty1), input_name='BaseProperty1')), )) if self.BaseProperty2 is not None and 'BaseProperty2' not in already_processed: already_processed.add('BaseProperty2') - outfile.write(' BaseProperty2=%s' % (self.gds_format_string(quote_attrib(self.BaseProperty2).encode(ExternalEncoding), input_name='BaseProperty2'), )) + outfile.write(' BaseProperty2=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.BaseProperty2), input_name='BaseProperty2')), )) if self.extensiontype_ is not None and 'xsi:type' not in already_processed: already_processed.add('xsi:type') outfile.write(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"') @@ -1331,7 +1341,7 @@ class DerivedType(BaseType): self.exportAttributes(outfile, level, already_processed, namespace_, name_='DerivedType') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='DerivedType', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -1340,10 +1350,10 @@ class DerivedType(BaseType): super(DerivedType, self).exportAttributes(outfile, level, already_processed, namespace_, name_='DerivedType') if self.DerivedProperty1 is not None and 'DerivedProperty1' not in already_processed: already_processed.add('DerivedProperty1') - outfile.write(' DerivedProperty1=%s' % (self.gds_format_string(quote_attrib(self.DerivedProperty1).encode(ExternalEncoding), input_name='DerivedProperty1'), )) + outfile.write(' DerivedProperty1=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.DerivedProperty1), input_name='DerivedProperty1')), )) if self.DerivedProperty2 is not None and 'DerivedProperty2' not in already_processed: already_processed.add('DerivedProperty2') - outfile.write(' DerivedProperty2=%s' % (self.gds_format_string(quote_attrib(self.DerivedProperty2).encode(ExternalEncoding), input_name='DerivedProperty2'), )) + outfile.write(' DerivedProperty2=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.DerivedProperty2), input_name='DerivedProperty2')), )) def exportChildren(self, outfile, level, namespace_='', name_='DerivedType', fromsubclass_=False, pretty_print=True): super(DerivedType, self).exportChildren(outfile, level, namespace_, name_, True, pretty_print=pretty_print) pass @@ -1416,7 +1426,7 @@ class MyInteger(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='MyInteger') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='MyInteger', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -1424,7 +1434,7 @@ class MyInteger(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='MyInteger'): if self.MyAttr is not None and 'MyAttr' not in already_processed: already_processed.add('MyAttr') - outfile.write(' MyAttr=%s' % (self.gds_format_string(quote_attrib(self.MyAttr).encode(ExternalEncoding), input_name='MyAttr'), )) + outfile.write(' MyAttr=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.MyAttr), input_name='MyAttr')), )) def exportChildren(self, outfile, level, namespace_='', name_='MyInteger', fromsubclass_=False, pretty_print=True): pass def build(self, node): @@ -1491,7 +1501,7 @@ class MyBoolean(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='MyBoolean') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='MyBoolean', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -1499,7 +1509,7 @@ class MyBoolean(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='MyBoolean'): if self.MyAttr is not None and 'MyAttr' not in already_processed: already_processed.add('MyAttr') - outfile.write(' MyAttr=%s' % (self.gds_format_string(quote_attrib(self.MyAttr).encode(ExternalEncoding), input_name='MyAttr'), )) + outfile.write(' MyAttr=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.MyAttr), input_name='MyAttr')), )) def exportChildren(self, outfile, level, namespace_='', name_='MyBoolean', fromsubclass_=False, pretty_print=True): pass def build(self, node): @@ -1566,7 +1576,7 @@ class MyFloat(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='MyFloat') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='MyFloat', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -1574,7 +1584,7 @@ class MyFloat(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='MyFloat'): if self.MyAttr is not None and 'MyAttr' not in already_processed: already_processed.add('MyAttr') - outfile.write(' MyAttr=%s' % (self.gds_format_string(quote_attrib(self.MyAttr).encode(ExternalEncoding), input_name='MyAttr'), )) + outfile.write(' MyAttr=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.MyAttr), input_name='MyAttr')), )) def exportChildren(self, outfile, level, namespace_='', name_='MyFloat', fromsubclass_=False, pretty_print=True): pass def build(self, node): @@ -1641,7 +1651,7 @@ class MyDouble(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='MyDouble') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='MyDouble', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -1649,7 +1659,7 @@ class MyDouble(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='MyDouble'): if self.MyAttr is not None and 'MyAttr' not in already_processed: already_processed.add('MyAttr') - outfile.write(' MyAttr=%s' % (self.gds_format_string(quote_attrib(self.MyAttr).encode(ExternalEncoding), input_name='MyAttr'), )) + outfile.write(' MyAttr=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.MyAttr), input_name='MyAttr')), )) def exportChildren(self, outfile, level, namespace_='', name_='MyDouble', fromsubclass_=False, pretty_print=True): pass def build(self, node): diff --git a/tests/mapcleanname1_sup.py b/tests/mapcleanname1_sup.py index 1903d38..f156ff5 100644 --- a/tests/mapcleanname1_sup.py +++ b/tests/mapcleanname1_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -710,7 +720,7 @@ class complex_type01(GeneratedsSuper): eol_ = '' if self.string_value01 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sstring_value01>%s</%sstring_value01>%s' % (namespace_, self.gds_format_string(quote_xml(self.string_value01).encode(ExternalEncoding), input_name='string_value01'), namespace_, eol_)) + outfile.write('<%sstring_value01>%s</%sstring_value01>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.string_value01), input_name='string_value01')), namespace_, eol_)) for integer_value01_ in self.integer_value01: showIndent(outfile, level, pretty_print) outfile.write('<%sinteger_value01>%s</%sinteger_value01>%s' % (namespace_, self.gds_format_integer(integer_value01_, input_name='integer_value01'), namespace_, eol_)) @@ -836,7 +846,7 @@ class complex_type02(GeneratedsSuper): eol_ = '' if self.string_value02 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sstring_value02>%s</%sstring_value02>%s' % (namespace_, self.gds_format_string(quote_xml(self.string_value02).encode(ExternalEncoding), input_name='string_value02'), namespace_, eol_)) + outfile.write('<%sstring_value02>%s</%sstring_value02>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.string_value02), input_name='string_value02')), namespace_, eol_)) for integer_value02_ in self.integer_value02: showIndent(outfile, level, pretty_print) outfile.write('<%sinteger_value02>%s</%sinteger_value02>%s' % (namespace_, self.gds_format_integer(integer_value02_, input_name='integer_value02'), namespace_, eol_)) @@ -954,7 +964,7 @@ class complex_type03(complex_type02): eol_ = '' if self.string_value03 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sstring_value03>%s</%sstring_value03>%s' % (namespace_, self.gds_format_string(quote_xml(self.string_value03).encode(ExternalEncoding), input_name='string_value03'), namespace_, eol_)) + outfile.write('<%sstring_value03>%s</%sstring_value03>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.string_value03), input_name='string_value03')), namespace_, eol_)) for integer_value03_ in self.integer_value03: showIndent(outfile, level, pretty_print) outfile.write('<%sinteger_value03>%s</%sinteger_value03>%s' % (namespace_, self.gds_format_integer(integer_value03_, input_name='integer_value03'), namespace_, eol_)) @@ -1074,7 +1084,7 @@ class type_(GeneratedsSuper): eol_ = '' if self.string_value02 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sstring_value02>%s</%sstring_value02>%s' % (namespace_, self.gds_format_string(quote_xml(self.string_value02).encode(ExternalEncoding), input_name='string_value02'), namespace_, eol_)) + outfile.write('<%sstring_value02>%s</%sstring_value02>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.string_value02), input_name='string_value02')), namespace_, eol_)) for integer_value02_ in self.integer_value02: showIndent(outfile, level, pretty_print) outfile.write('<%sinteger_value02>%s</%sinteger_value02>%s' % (namespace_, self.gds_format_integer(integer_value02_, input_name='integer_value02'), namespace_, eol_)) @@ -1192,7 +1202,7 @@ class complex_type04(type_): eol_ = '' if self.string_value03 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sstring_value03>%s</%sstring_value03>%s' % (namespace_, self.gds_format_string(quote_xml(self.string_value03).encode(ExternalEncoding), input_name='string_value03'), namespace_, eol_)) + outfile.write('<%sstring_value03>%s</%sstring_value03>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.string_value03), input_name='string_value03')), namespace_, eol_)) for integer_value03_ in self.integer_value03: showIndent(outfile, level, pretty_print) outfile.write('<%sinteger_value03>%s</%sinteger_value03>%s' % (namespace_, self.gds_format_integer(integer_value03_, input_name='integer_value03'), namespace_, eol_)) @@ -1312,7 +1322,7 @@ class build_(GeneratedsSuper): eol_ = '' if self.string_value02 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sstring_value02>%s</%sstring_value02>%s' % (namespace_, self.gds_format_string(quote_xml(self.string_value02).encode(ExternalEncoding), input_name='string_value02'), namespace_, eol_)) + outfile.write('<%sstring_value02>%s</%sstring_value02>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.string_value02), input_name='string_value02')), namespace_, eol_)) for integer_value02_ in self.integer_value02: showIndent(outfile, level, pretty_print) outfile.write('<%sinteger_value02>%s</%sinteger_value02>%s' % (namespace_, self.gds_format_integer(integer_value02_, input_name='integer_value02'), namespace_, eol_)) @@ -1430,7 +1440,7 @@ class complex_type05(build_): eol_ = '' if self.string_value03 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sstring_value03>%s</%sstring_value03>%s' % (namespace_, self.gds_format_string(quote_xml(self.string_value03).encode(ExternalEncoding), input_name='string_value03'), namespace_, eol_)) + outfile.write('<%sstring_value03>%s</%sstring_value03>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.string_value03), input_name='string_value03')), namespace_, eol_)) for integer_value03_ in self.integer_value03: showIndent(outfile, level, pretty_print) outfile.write('<%sinteger_value03>%s</%sinteger_value03>%s' % (namespace_, self.gds_format_integer(integer_value03_, input_name='integer_value03'), namespace_, eol_)) diff --git a/tests/mapcleanname2_sup.py b/tests/mapcleanname2_sup.py index 1903d38..f156ff5 100644 --- a/tests/mapcleanname2_sup.py +++ b/tests/mapcleanname2_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -710,7 +720,7 @@ class complex_type01(GeneratedsSuper): eol_ = '' if self.string_value01 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sstring_value01>%s</%sstring_value01>%s' % (namespace_, self.gds_format_string(quote_xml(self.string_value01).encode(ExternalEncoding), input_name='string_value01'), namespace_, eol_)) + outfile.write('<%sstring_value01>%s</%sstring_value01>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.string_value01), input_name='string_value01')), namespace_, eol_)) for integer_value01_ in self.integer_value01: showIndent(outfile, level, pretty_print) outfile.write('<%sinteger_value01>%s</%sinteger_value01>%s' % (namespace_, self.gds_format_integer(integer_value01_, input_name='integer_value01'), namespace_, eol_)) @@ -836,7 +846,7 @@ class complex_type02(GeneratedsSuper): eol_ = '' if self.string_value02 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sstring_value02>%s</%sstring_value02>%s' % (namespace_, self.gds_format_string(quote_xml(self.string_value02).encode(ExternalEncoding), input_name='string_value02'), namespace_, eol_)) + outfile.write('<%sstring_value02>%s</%sstring_value02>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.string_value02), input_name='string_value02')), namespace_, eol_)) for integer_value02_ in self.integer_value02: showIndent(outfile, level, pretty_print) outfile.write('<%sinteger_value02>%s</%sinteger_value02>%s' % (namespace_, self.gds_format_integer(integer_value02_, input_name='integer_value02'), namespace_, eol_)) @@ -954,7 +964,7 @@ class complex_type03(complex_type02): eol_ = '' if self.string_value03 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sstring_value03>%s</%sstring_value03>%s' % (namespace_, self.gds_format_string(quote_xml(self.string_value03).encode(ExternalEncoding), input_name='string_value03'), namespace_, eol_)) + outfile.write('<%sstring_value03>%s</%sstring_value03>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.string_value03), input_name='string_value03')), namespace_, eol_)) for integer_value03_ in self.integer_value03: showIndent(outfile, level, pretty_print) outfile.write('<%sinteger_value03>%s</%sinteger_value03>%s' % (namespace_, self.gds_format_integer(integer_value03_, input_name='integer_value03'), namespace_, eol_)) @@ -1074,7 +1084,7 @@ class type_(GeneratedsSuper): eol_ = '' if self.string_value02 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sstring_value02>%s</%sstring_value02>%s' % (namespace_, self.gds_format_string(quote_xml(self.string_value02).encode(ExternalEncoding), input_name='string_value02'), namespace_, eol_)) + outfile.write('<%sstring_value02>%s</%sstring_value02>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.string_value02), input_name='string_value02')), namespace_, eol_)) for integer_value02_ in self.integer_value02: showIndent(outfile, level, pretty_print) outfile.write('<%sinteger_value02>%s</%sinteger_value02>%s' % (namespace_, self.gds_format_integer(integer_value02_, input_name='integer_value02'), namespace_, eol_)) @@ -1192,7 +1202,7 @@ class complex_type04(type_): eol_ = '' if self.string_value03 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sstring_value03>%s</%sstring_value03>%s' % (namespace_, self.gds_format_string(quote_xml(self.string_value03).encode(ExternalEncoding), input_name='string_value03'), namespace_, eol_)) + outfile.write('<%sstring_value03>%s</%sstring_value03>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.string_value03), input_name='string_value03')), namespace_, eol_)) for integer_value03_ in self.integer_value03: showIndent(outfile, level, pretty_print) outfile.write('<%sinteger_value03>%s</%sinteger_value03>%s' % (namespace_, self.gds_format_integer(integer_value03_, input_name='integer_value03'), namespace_, eol_)) @@ -1312,7 +1322,7 @@ class build_(GeneratedsSuper): eol_ = '' if self.string_value02 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sstring_value02>%s</%sstring_value02>%s' % (namespace_, self.gds_format_string(quote_xml(self.string_value02).encode(ExternalEncoding), input_name='string_value02'), namespace_, eol_)) + outfile.write('<%sstring_value02>%s</%sstring_value02>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.string_value02), input_name='string_value02')), namespace_, eol_)) for integer_value02_ in self.integer_value02: showIndent(outfile, level, pretty_print) outfile.write('<%sinteger_value02>%s</%sinteger_value02>%s' % (namespace_, self.gds_format_integer(integer_value02_, input_name='integer_value02'), namespace_, eol_)) @@ -1430,7 +1440,7 @@ class complex_type05(build_): eol_ = '' if self.string_value03 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sstring_value03>%s</%sstring_value03>%s' % (namespace_, self.gds_format_string(quote_xml(self.string_value03).encode(ExternalEncoding), input_name='string_value03'), namespace_, eol_)) + outfile.write('<%sstring_value03>%s</%sstring_value03>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.string_value03), input_name='string_value03')), namespace_, eol_)) for integer_value03_ in self.integer_value03: showIndent(outfile, level, pretty_print) outfile.write('<%sinteger_value03>%s</%sinteger_value03>%s' % (namespace_, self.gds_format_integer(integer_value03_, input_name='integer_value03'), namespace_, eol_)) diff --git a/tests/nested_def1_sup.py b/tests/nested_def1_sup.py index 901d61a..a5060b8 100644 --- a/tests/nested_def1_sup.py +++ b/tests/nested_def1_sup.py @@ -32,6 +32,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -351,6 +355,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -405,7 +415,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -427,7 +437,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -919,10 +929,10 @@ class inner_001(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='inner_001'): if self.attrA1 is not None and 'attrA1' not in already_processed: already_processed.add('attrA1') - outfile.write(' attrA1=%s' % (self.gds_format_string(quote_attrib(self.attrA1).encode(ExternalEncoding), input_name='attrA1'), )) + outfile.write(' attrA1=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.attrA1), input_name='attrA1')), )) if self.attrA2 is not None and 'attrA2' not in already_processed: already_processed.add('attrA2') - outfile.write(' attrA2=%s' % (self.gds_format_string(quote_attrib(self.attrA2).encode(ExternalEncoding), input_name='attrA2'), )) + outfile.write(' attrA2=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.attrA2), input_name='attrA2')), )) def exportChildren(self, outfile, level, namespace_='', name_='inner_001', fromsubclass_=False, pretty_print=True): pass def build(self, node): @@ -999,10 +1009,10 @@ class inner_002(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='inner_002'): if self.attrB1 is not None and 'attrB1' not in already_processed: already_processed.add('attrB1') - outfile.write(' attrB1=%s' % (self.gds_format_string(quote_attrib(self.attrB1).encode(ExternalEncoding), input_name='attrB1'), )) + outfile.write(' attrB1=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.attrB1), input_name='attrB1')), )) if self.attrB2 is not None and 'attrB2' not in already_processed: already_processed.add('attrB2') - outfile.write(' attrB2=%s' % (self.gds_format_string(quote_attrib(self.attrB2).encode(ExternalEncoding), input_name='attrB2'), )) + outfile.write(' attrB2=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.attrB2), input_name='attrB2')), )) def exportChildren(self, outfile, level, namespace_='', name_='inner_002', fromsubclass_=False, pretty_print=True): pass def build(self, node): diff --git a/tests/nested_def2_sup.py b/tests/nested_def2_sup.py index 901d61a..a5060b8 100644 --- a/tests/nested_def2_sup.py +++ b/tests/nested_def2_sup.py @@ -32,6 +32,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -351,6 +355,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -405,7 +415,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -427,7 +437,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -919,10 +929,10 @@ class inner_001(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='inner_001'): if self.attrA1 is not None and 'attrA1' not in already_processed: already_processed.add('attrA1') - outfile.write(' attrA1=%s' % (self.gds_format_string(quote_attrib(self.attrA1).encode(ExternalEncoding), input_name='attrA1'), )) + outfile.write(' attrA1=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.attrA1), input_name='attrA1')), )) if self.attrA2 is not None and 'attrA2' not in already_processed: already_processed.add('attrA2') - outfile.write(' attrA2=%s' % (self.gds_format_string(quote_attrib(self.attrA2).encode(ExternalEncoding), input_name='attrA2'), )) + outfile.write(' attrA2=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.attrA2), input_name='attrA2')), )) def exportChildren(self, outfile, level, namespace_='', name_='inner_001', fromsubclass_=False, pretty_print=True): pass def build(self, node): @@ -999,10 +1009,10 @@ class inner_002(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='inner_002'): if self.attrB1 is not None and 'attrB1' not in already_processed: already_processed.add('attrB1') - outfile.write(' attrB1=%s' % (self.gds_format_string(quote_attrib(self.attrB1).encode(ExternalEncoding), input_name='attrB1'), )) + outfile.write(' attrB1=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.attrB1), input_name='attrB1')), )) if self.attrB2 is not None and 'attrB2' not in already_processed: already_processed.add('attrB2') - outfile.write(' attrB2=%s' % (self.gds_format_string(quote_attrib(self.attrB2).encode(ExternalEncoding), input_name='attrB2'), )) + outfile.write(' attrB2=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.attrB2), input_name='attrB2')), )) def exportChildren(self, outfile, level, namespace_='', name_='inner_002', fromsubclass_=False, pretty_print=True): pass def build(self, node): diff --git a/tests/out1_sup.py b/tests/out1_sup.py index 6f52bae..c3ecddf 100644 --- a/tests/out1_sup.py +++ b/tests/out1_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -1187,7 +1197,7 @@ class person(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='person'): if self.value is not None and 'value' not in already_processed: already_processed.add('value') - outfile.write(' value=%s' % (self.gds_format_string(quote_attrib(self.value).encode(ExternalEncoding), input_name='value'), )) + outfile.write(' value=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.value), input_name='value')), )) if self.id is not None and 'id' not in already_processed: already_processed.add('id') outfile.write(' id="%s"' % self.gds_format_integer(self.id, input_name='id')) @@ -1196,10 +1206,10 @@ class person(GeneratedsSuper): outfile.write(' ratio="%s"' % self.gds_format_float(self.ratio, input_name='ratio')) if self.fruit is not None and 'fruit' not in already_processed: already_processed.add('fruit') - outfile.write(' fruit=%s' % (self.gds_format_string(quote_attrib(self.fruit).encode(ExternalEncoding), input_name='fruit'), )) + outfile.write(' fruit=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.fruit), input_name='fruit')), )) if self.vegetable is not None and 'vegetable' not in already_processed: already_processed.add('vegetable') - outfile.write(' vegetable=%s' % (self.gds_format_string(quote_attrib(self.vegetable).encode(ExternalEncoding), input_name='vegetable'), )) + outfile.write(' vegetable=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.vegetable), input_name='vegetable')), )) if self.extensiontype_ is not None and 'xsi:type' not in already_processed: already_processed.add('xsi:type') outfile.write(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"') @@ -1211,10 +1221,10 @@ class person(GeneratedsSuper): eol_ = '' if self.name is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_format_string(quote_xml(self.name).encode(ExternalEncoding), input_name='name'), namespace_, eol_)) + outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.name), input_name='name')), namespace_, eol_)) for interest_ in self.interest: showIndent(outfile, level, pretty_print) - outfile.write('<%sinterest>%s</%sinterest>%s' % (namespace_, self.gds_format_string(quote_xml(interest_).encode(ExternalEncoding), input_name='interest'), namespace_, eol_)) + outfile.write('<%sinterest>%s</%sinterest>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(interest_), input_name='interest')), namespace_, eol_)) if self.category is not None: showIndent(outfile, level, pretty_print) outfile.write('<%scategory>%s</%scategory>%s' % (namespace_, self.gds_format_integer(self.category, input_name='category'), namespace_, eol_)) @@ -1224,7 +1234,7 @@ class person(GeneratedsSuper): promoter_.export(outfile, level, namespace_, name_='promoter', pretty_print=pretty_print) if self.description is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sdescription>%s</%sdescription>%s' % (namespace_, self.gds_format_string(quote_xml(self.description).encode(ExternalEncoding), input_name='description'), namespace_, eol_)) + outfile.write('<%sdescription>%s</%sdescription>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.description), input_name='description')), namespace_, eol_)) def exportLiteral(self, outfile, level, name_='person'): level += 1 already_processed = set() @@ -1255,13 +1265,13 @@ class person(GeneratedsSuper): def exportLiteralChildren(self, outfile, level, name_): if self.name is not None: showIndent(outfile, level) - outfile.write('name=%s,\n' % quote_python(self.name).encode(ExternalEncoding)) + outfile.write('name=%s,\n' % self.gds_encode(quote_python(self.name))) showIndent(outfile, level) outfile.write('interest=[\n') level += 1 for interest_ in self.interest: showIndent(outfile, level) - outfile.write('%s,\n' % quote_python(interest_).encode(ExternalEncoding)) + outfile.write('%s,\n' % self.gds_encode(quote_python(interest_))) level -= 1 showIndent(outfile, level) outfile.write('],\n') @@ -1294,7 +1304,7 @@ class person(GeneratedsSuper): outfile.write('],\n') if self.description is not None: showIndent(outfile, level) - outfile.write('description=%s,\n' % quote_python(self.description).encode(ExternalEncoding)) + outfile.write('description=%s,\n' % self.gds_encode(quote_python(self.description))) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -1450,12 +1460,12 @@ class programmer(person): self.elnonposint = elnonposint self.elnegint = elnegint self.elnonnegint = elnonnegint - if isinstance(eldate, basestring): + if isinstance(eldate, BaseStrType_): initvalue_ = datetime_.datetime.strptime(eldate, '%Y-%m-%d').date() else: initvalue_ = eldate self.eldate = initvalue_ - if isinstance(eldatetime, basestring): + if isinstance(eldatetime, BaseStrType_): initvalue_ = datetime_.datetime.strptime(eldatetime, '%Y-%m-%dT%H:%M:%S') else: initvalue_ = eldatetime @@ -1569,10 +1579,10 @@ class programmer(person): super(programmer, self).exportAttributes(outfile, level, already_processed, namespace_, name_='programmer') if self.language is not None and 'language' not in already_processed: already_processed.add('language') - outfile.write(' language=%s' % (self.gds_format_string(quote_attrib(self.language).encode(ExternalEncoding), input_name='language'), )) + outfile.write(' language=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.language), input_name='language')), )) if self.area is not None and 'area' not in already_processed: already_processed.add('area') - outfile.write(' area=%s' % (self.gds_format_string(quote_attrib(self.area).encode(ExternalEncoding), input_name='area'), )) + outfile.write(' area=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.area), input_name='area')), )) if self.attrposint is not None and 'attrposint' not in already_processed: already_processed.add('attrposint') outfile.write(' attrposint="%s"' % self.gds_format_integer(self.attrposint, input_name='attrposint')) @@ -1597,7 +1607,7 @@ class programmer(person): eol_ = '' if self.email is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%semail>%s</%semail>%s' % (namespace_, self.gds_format_string(quote_xml(self.email).encode(ExternalEncoding), input_name='email'), namespace_, eol_)) + outfile.write('<%semail>%s</%semail>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.email), input_name='email')), namespace_, eol_)) if self.elposint is not None: showIndent(outfile, level, pretty_print) outfile.write('<%selposint>%s</%selposint>%s' % (namespace_, self.gds_format_integer(self.elposint, input_name='elposint'), namespace_, eol_)) @@ -1618,7 +1628,7 @@ class programmer(person): outfile.write('<%seldatetime>%s</%seldatetime>%s' % (namespace_, self.gds_format_datetime(self.eldatetime, input_name='eldatetime'), namespace_, eol_)) if self.eltoken is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%seltoken>%s</%seltoken>%s' % (namespace_, self.gds_format_string(quote_xml(self.eltoken).encode(ExternalEncoding), input_name='eltoken'), namespace_, eol_)) + outfile.write('<%seltoken>%s</%seltoken>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.eltoken), input_name='eltoken')), namespace_, eol_)) if self.elshort is not None: showIndent(outfile, level, pretty_print) outfile.write('<%selshort>%s</%selshort>%s' % (namespace_, self.gds_format_integer(self.elshort, input_name='elshort'), namespace_, eol_)) @@ -1629,7 +1639,7 @@ class programmer(person): self.elparam.export(outfile, level, namespace_, name_='elparam', pretty_print=pretty_print) if self.elarraytypes is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%selarraytypes>%s</%selarraytypes>%s' % (namespace_, self.gds_format_string(quote_xml(self.elarraytypes).encode(ExternalEncoding), input_name='elarraytypes'), namespace_, eol_)) + outfile.write('<%selarraytypes>%s</%selarraytypes>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.elarraytypes), input_name='elarraytypes')), namespace_, eol_)) def exportLiteral(self, outfile, level, name_='programmer'): level += 1 already_processed = set() @@ -1666,7 +1676,7 @@ class programmer(person): super(programmer, self).exportLiteralChildren(outfile, level, name_) if self.email is not None: showIndent(outfile, level) - outfile.write('email=%s,\n' % quote_python(self.email).encode(ExternalEncoding)) + outfile.write('email=%s,\n' % self.gds_encode(quote_python(self.email))) if self.elposint is not None: showIndent(outfile, level) outfile.write('elposint=%d,\n' % self.elposint) @@ -1687,7 +1697,7 @@ class programmer(person): outfile.write('eldatetime=model_.GeneratedsSuper.gds_parse_datetime("%s"),\n' % self.gds_format_datetime(self.eldatetime, input_name='eldatetime')) if self.eltoken is not None: showIndent(outfile, level) - outfile.write('eltoken=%s,\n' % quote_python(self.eltoken).encode(ExternalEncoding)) + outfile.write('eltoken=%s,\n' % self.gds_encode(quote_python(self.eltoken))) if self.elshort is not None: showIndent(outfile, level) outfile.write('elshort=%d,\n' % self.elshort) @@ -1702,7 +1712,7 @@ class programmer(person): outfile.write('),\n') if self.elarraytypes is not None: showIndent(outfile, level) - outfile.write('elarraytypes=%s,\n' % quote_python(self.elarraytypes).encode(ExternalEncoding)) + outfile.write('elarraytypes=%s,\n' % self.gds_encode(quote_python(self.elarraytypes))) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -1963,7 +1973,7 @@ class param(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='param') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='param', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -1971,7 +1981,7 @@ class param(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='param'): if self.id is not None and 'id' not in already_processed: already_processed.add('id') - outfile.write(' id=%s' % (self.gds_format_string(quote_attrib(self.id).encode(ExternalEncoding), input_name='id'), )) + outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), )) if self.name is not None and 'name' not in already_processed: already_processed.add('name') outfile.write(' name=%s' % (quote_attrib(self.name), )) @@ -1983,10 +1993,10 @@ class param(GeneratedsSuper): outfile.write(' flow=%s' % (quote_attrib(self.flow), )) if self.semantic is not None and 'semantic' not in already_processed: already_processed.add('semantic') - outfile.write(' semantic=%s' % (self.gds_format_string(quote_attrib(self.semantic).encode(ExternalEncoding), input_name='semantic'), )) + outfile.write(' semantic=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.semantic), input_name='semantic')), )) if self.type_ is not None and 'type_' not in already_processed: already_processed.add('type_') - outfile.write(' type=%s' % (self.gds_format_string(quote_attrib(self.type_).encode(ExternalEncoding), input_name='type'), )) + outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), )) def exportChildren(self, outfile, level, namespace_='', name_='param', fromsubclass_=False, pretty_print=True): pass def exportLiteral(self, outfile, level, name_='param'): @@ -2166,7 +2176,7 @@ class python_programmer(programmer): super(python_programmer, self).exportAttributes(outfile, level, already_processed, namespace_, name_='python-programmer') if self.nick_name is not None and 'nick_name' not in already_processed: already_processed.add('nick_name') - outfile.write(' nick-name=%s' % (self.gds_format_string(quote_attrib(self.nick_name).encode(ExternalEncoding), input_name='nick-name'), )) + outfile.write(' nick-name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.nick_name), input_name='nick-name')), )) def exportChildren(self, outfile, level, namespace_='', name_='python-programmer', fromsubclass_=False, pretty_print=True): super(python_programmer, self).exportChildren(outfile, level, namespace_, name_, True, pretty_print=pretty_print) if pretty_print: @@ -2175,7 +2185,7 @@ class python_programmer(programmer): eol_ = '' if self.favorite_editor is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfavorite-editor>%s</%sfavorite-editor>%s' % (namespace_, self.gds_format_string(quote_xml(self.favorite_editor).encode(ExternalEncoding), input_name='favorite-editor'), namespace_, eol_)) + outfile.write('<%sfavorite-editor>%s</%sfavorite-editor>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.favorite_editor), input_name='favorite-editor')), namespace_, eol_)) def exportLiteral(self, outfile, level, name_='python-programmer'): level += 1 already_processed = set() @@ -2192,7 +2202,7 @@ class python_programmer(programmer): super(python_programmer, self).exportLiteralChildren(outfile, level, name_) if self.favorite_editor is not None: showIndent(outfile, level) - outfile.write('favorite_editor=%s,\n' % quote_python(self.favorite_editor).encode(ExternalEncoding)) + outfile.write('favorite_editor=%s,\n' % self.gds_encode(quote_python(self.favorite_editor))) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -2322,10 +2332,10 @@ class java_programmer(programmer): super(java_programmer, self).exportAttributes(outfile, level, already_processed, namespace_, name_='java-programmer') if self.nick_name is not None and 'nick_name' not in already_processed: already_processed.add('nick_name') - outfile.write(' nick-name=%s' % (self.gds_format_string(quote_attrib(self.nick_name).encode(ExternalEncoding), input_name='nick-name'), )) + outfile.write(' nick-name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.nick_name), input_name='nick-name')), )) if self.status is not None and 'status' not in already_processed: already_processed.add('status') - outfile.write(' status=%s' % (self.gds_format_string(quote_attrib(self.status).encode(ExternalEncoding), input_name='status'), )) + outfile.write(' status=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.status), input_name='status')), )) def exportChildren(self, outfile, level, namespace_='', name_='java-programmer', fromsubclass_=False, pretty_print=True): super(java_programmer, self).exportChildren(outfile, level, namespace_, name_, True, pretty_print=pretty_print) if pretty_print: @@ -2334,7 +2344,7 @@ class java_programmer(programmer): eol_ = '' if self.favorite_editor is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfavorite-editor>%s</%sfavorite-editor>%s' % (namespace_, self.gds_format_string(quote_xml(self.favorite_editor).encode(ExternalEncoding), input_name='favorite-editor'), namespace_, eol_)) + outfile.write('<%sfavorite-editor>%s</%sfavorite-editor>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.favorite_editor), input_name='favorite-editor')), namespace_, eol_)) def exportLiteral(self, outfile, level, name_='java-programmer'): level += 1 already_processed = set() @@ -2355,7 +2365,7 @@ class java_programmer(programmer): super(java_programmer, self).exportLiteralChildren(outfile, level, name_) if self.favorite_editor is not None: showIndent(outfile, level) - outfile.write('favorite_editor=%s,\n' % quote_python(self.favorite_editor).encode(ExternalEncoding)) + outfile.write('favorite_editor=%s,\n' % self.gds_encode(quote_python(self.favorite_editor))) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -2499,10 +2509,10 @@ class agent(GeneratedsSuper): eol_ = '' if self.firstname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_format_string(quote_xml(self.firstname).encode(ExternalEncoding), input_name='firstname'), namespace_, eol_)) + outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.firstname), input_name='firstname')), namespace_, eol_)) if self.lastname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_format_string(quote_xml(self.lastname).encode(ExternalEncoding), input_name='lastname'), namespace_, eol_)) + outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.lastname), input_name='lastname')), namespace_, eol_)) if self.priority is not None: showIndent(outfile, level, pretty_print) outfile.write('<%spriority>%s</%spriority>%s' % (namespace_, self.gds_format_float(self.priority, input_name='priority'), namespace_, eol_)) @@ -2519,10 +2529,10 @@ class agent(GeneratedsSuper): def exportLiteralChildren(self, outfile, level, name_): if self.firstname is not None: showIndent(outfile, level) - outfile.write('firstname=%s,\n' % quote_python(self.firstname).encode(ExternalEncoding)) + outfile.write('firstname=%s,\n' % self.gds_encode(quote_python(self.firstname))) if self.lastname is not None: showIndent(outfile, level) - outfile.write('lastname=%s,\n' % quote_python(self.lastname).encode(ExternalEncoding)) + outfile.write('lastname=%s,\n' % self.gds_encode(quote_python(self.lastname))) if self.priority is not None: showIndent(outfile, level) outfile.write('priority=%f,\n' % self.priority) @@ -2683,10 +2693,10 @@ class special_agent(GeneratedsSuper): eol_ = '' if self.firstname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_format_string(quote_xml(self.firstname).encode(ExternalEncoding), input_name='firstname'), namespace_, eol_)) + outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.firstname), input_name='firstname')), namespace_, eol_)) if self.lastname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_format_string(quote_xml(self.lastname).encode(ExternalEncoding), input_name='lastname'), namespace_, eol_)) + outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.lastname), input_name='lastname')), namespace_, eol_)) if self.priority is not None: showIndent(outfile, level, pretty_print) outfile.write('<%spriority>%s</%spriority>%s' % (namespace_, self.gds_format_float(self.priority, input_name='priority'), namespace_, eol_)) @@ -2703,10 +2713,10 @@ class special_agent(GeneratedsSuper): def exportLiteralChildren(self, outfile, level, name_): if self.firstname is not None: showIndent(outfile, level) - outfile.write('firstname=%s,\n' % quote_python(self.firstname).encode(ExternalEncoding)) + outfile.write('firstname=%s,\n' % self.gds_encode(quote_python(self.firstname))) if self.lastname is not None: showIndent(outfile, level) - outfile.write('lastname=%s,\n' % quote_python(self.lastname).encode(ExternalEncoding)) + outfile.write('lastname=%s,\n' % self.gds_encode(quote_python(self.lastname))) if self.priority is not None: showIndent(outfile, level) outfile.write('priority=%f,\n' % self.priority) @@ -2900,10 +2910,10 @@ class booster(GeneratedsSuper): eol_ = '' if self.firstname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_format_string(quote_xml(self.firstname).encode(ExternalEncoding), input_name='firstname'), namespace_, eol_)) + outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.firstname), input_name='firstname')), namespace_, eol_)) if self.lastname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_format_string(quote_xml(self.lastname).encode(ExternalEncoding), input_name='lastname'), namespace_, eol_)) + outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.lastname), input_name='lastname')), namespace_, eol_)) if self.other_name is not None: showIndent(outfile, level, pretty_print) outfile.write('<%sother-name>%s</%sother-name>%s' % (namespace_, self.gds_format_float(self.other_name, input_name='other-name'), namespace_, eol_)) @@ -2929,10 +2939,10 @@ class booster(GeneratedsSuper): def exportLiteralChildren(self, outfile, level, name_): if self.firstname is not None: showIndent(outfile, level) - outfile.write('firstname=%s,\n' % quote_python(self.firstname).encode(ExternalEncoding)) + outfile.write('firstname=%s,\n' % self.gds_encode(quote_python(self.firstname))) if self.lastname is not None: showIndent(outfile, level) - outfile.write('lastname=%s,\n' % quote_python(self.lastname).encode(ExternalEncoding)) + outfile.write('lastname=%s,\n' % self.gds_encode(quote_python(self.lastname))) if self.other_name is not None: showIndent(outfile, level) outfile.write('other_name=%f,\n' % self.other_name) @@ -3130,7 +3140,7 @@ class info(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='info'): if self.name is not None and 'name' not in already_processed: already_processed.add('name') - outfile.write(' name=%s' % (self.gds_format_string(quote_attrib(self.name).encode(ExternalEncoding), input_name='name'), )) + outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), )) if self.type_ is not None and 'type_' not in already_processed: already_processed.add('type_') outfile.write(' type="%s"' % self.gds_format_integer(self.type_, input_name='type')) @@ -3298,7 +3308,7 @@ class client_handlerType(GeneratedsSuper): eol_ = '' if self.fullname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfullname>%s</%sfullname>%s' % (namespace_, self.gds_format_string(quote_xml(self.fullname).encode(ExternalEncoding), input_name='fullname'), namespace_, eol_)) + outfile.write('<%sfullname>%s</%sfullname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.fullname), input_name='fullname')), namespace_, eol_)) if self.refid is not None: showIndent(outfile, level, pretty_print) outfile.write('<%srefid>%s</%srefid>%s' % (namespace_, self.gds_format_integer(self.refid, input_name='refid'), namespace_, eol_)) @@ -3313,7 +3323,7 @@ class client_handlerType(GeneratedsSuper): def exportLiteralChildren(self, outfile, level, name_): if self.fullname is not None: showIndent(outfile, level) - outfile.write('fullname=%s,\n' % quote_python(self.fullname).encode(ExternalEncoding)) + outfile.write('fullname=%s,\n' % self.gds_encode(quote_python(self.fullname))) if self.refid is not None: showIndent(outfile, level) outfile.write('refid=%d,\n' % self.refid) diff --git a/tests/out2_sup.py b/tests/out2_sup.py index 6f52bae..c3ecddf 100644 --- a/tests/out2_sup.py +++ b/tests/out2_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -1187,7 +1197,7 @@ class person(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='person'): if self.value is not None and 'value' not in already_processed: already_processed.add('value') - outfile.write(' value=%s' % (self.gds_format_string(quote_attrib(self.value).encode(ExternalEncoding), input_name='value'), )) + outfile.write(' value=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.value), input_name='value')), )) if self.id is not None and 'id' not in already_processed: already_processed.add('id') outfile.write(' id="%s"' % self.gds_format_integer(self.id, input_name='id')) @@ -1196,10 +1206,10 @@ class person(GeneratedsSuper): outfile.write(' ratio="%s"' % self.gds_format_float(self.ratio, input_name='ratio')) if self.fruit is not None and 'fruit' not in already_processed: already_processed.add('fruit') - outfile.write(' fruit=%s' % (self.gds_format_string(quote_attrib(self.fruit).encode(ExternalEncoding), input_name='fruit'), )) + outfile.write(' fruit=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.fruit), input_name='fruit')), )) if self.vegetable is not None and 'vegetable' not in already_processed: already_processed.add('vegetable') - outfile.write(' vegetable=%s' % (self.gds_format_string(quote_attrib(self.vegetable).encode(ExternalEncoding), input_name='vegetable'), )) + outfile.write(' vegetable=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.vegetable), input_name='vegetable')), )) if self.extensiontype_ is not None and 'xsi:type' not in already_processed: already_processed.add('xsi:type') outfile.write(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"') @@ -1211,10 +1221,10 @@ class person(GeneratedsSuper): eol_ = '' if self.name is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_format_string(quote_xml(self.name).encode(ExternalEncoding), input_name='name'), namespace_, eol_)) + outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.name), input_name='name')), namespace_, eol_)) for interest_ in self.interest: showIndent(outfile, level, pretty_print) - outfile.write('<%sinterest>%s</%sinterest>%s' % (namespace_, self.gds_format_string(quote_xml(interest_).encode(ExternalEncoding), input_name='interest'), namespace_, eol_)) + outfile.write('<%sinterest>%s</%sinterest>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(interest_), input_name='interest')), namespace_, eol_)) if self.category is not None: showIndent(outfile, level, pretty_print) outfile.write('<%scategory>%s</%scategory>%s' % (namespace_, self.gds_format_integer(self.category, input_name='category'), namespace_, eol_)) @@ -1224,7 +1234,7 @@ class person(GeneratedsSuper): promoter_.export(outfile, level, namespace_, name_='promoter', pretty_print=pretty_print) if self.description is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sdescription>%s</%sdescription>%s' % (namespace_, self.gds_format_string(quote_xml(self.description).encode(ExternalEncoding), input_name='description'), namespace_, eol_)) + outfile.write('<%sdescription>%s</%sdescription>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.description), input_name='description')), namespace_, eol_)) def exportLiteral(self, outfile, level, name_='person'): level += 1 already_processed = set() @@ -1255,13 +1265,13 @@ class person(GeneratedsSuper): def exportLiteralChildren(self, outfile, level, name_): if self.name is not None: showIndent(outfile, level) - outfile.write('name=%s,\n' % quote_python(self.name).encode(ExternalEncoding)) + outfile.write('name=%s,\n' % self.gds_encode(quote_python(self.name))) showIndent(outfile, level) outfile.write('interest=[\n') level += 1 for interest_ in self.interest: showIndent(outfile, level) - outfile.write('%s,\n' % quote_python(interest_).encode(ExternalEncoding)) + outfile.write('%s,\n' % self.gds_encode(quote_python(interest_))) level -= 1 showIndent(outfile, level) outfile.write('],\n') @@ -1294,7 +1304,7 @@ class person(GeneratedsSuper): outfile.write('],\n') if self.description is not None: showIndent(outfile, level) - outfile.write('description=%s,\n' % quote_python(self.description).encode(ExternalEncoding)) + outfile.write('description=%s,\n' % self.gds_encode(quote_python(self.description))) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -1450,12 +1460,12 @@ class programmer(person): self.elnonposint = elnonposint self.elnegint = elnegint self.elnonnegint = elnonnegint - if isinstance(eldate, basestring): + if isinstance(eldate, BaseStrType_): initvalue_ = datetime_.datetime.strptime(eldate, '%Y-%m-%d').date() else: initvalue_ = eldate self.eldate = initvalue_ - if isinstance(eldatetime, basestring): + if isinstance(eldatetime, BaseStrType_): initvalue_ = datetime_.datetime.strptime(eldatetime, '%Y-%m-%dT%H:%M:%S') else: initvalue_ = eldatetime @@ -1569,10 +1579,10 @@ class programmer(person): super(programmer, self).exportAttributes(outfile, level, already_processed, namespace_, name_='programmer') if self.language is not None and 'language' not in already_processed: already_processed.add('language') - outfile.write(' language=%s' % (self.gds_format_string(quote_attrib(self.language).encode(ExternalEncoding), input_name='language'), )) + outfile.write(' language=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.language), input_name='language')), )) if self.area is not None and 'area' not in already_processed: already_processed.add('area') - outfile.write(' area=%s' % (self.gds_format_string(quote_attrib(self.area).encode(ExternalEncoding), input_name='area'), )) + outfile.write(' area=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.area), input_name='area')), )) if self.attrposint is not None and 'attrposint' not in already_processed: already_processed.add('attrposint') outfile.write(' attrposint="%s"' % self.gds_format_integer(self.attrposint, input_name='attrposint')) @@ -1597,7 +1607,7 @@ class programmer(person): eol_ = '' if self.email is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%semail>%s</%semail>%s' % (namespace_, self.gds_format_string(quote_xml(self.email).encode(ExternalEncoding), input_name='email'), namespace_, eol_)) + outfile.write('<%semail>%s</%semail>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.email), input_name='email')), namespace_, eol_)) if self.elposint is not None: showIndent(outfile, level, pretty_print) outfile.write('<%selposint>%s</%selposint>%s' % (namespace_, self.gds_format_integer(self.elposint, input_name='elposint'), namespace_, eol_)) @@ -1618,7 +1628,7 @@ class programmer(person): outfile.write('<%seldatetime>%s</%seldatetime>%s' % (namespace_, self.gds_format_datetime(self.eldatetime, input_name='eldatetime'), namespace_, eol_)) if self.eltoken is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%seltoken>%s</%seltoken>%s' % (namespace_, self.gds_format_string(quote_xml(self.eltoken).encode(ExternalEncoding), input_name='eltoken'), namespace_, eol_)) + outfile.write('<%seltoken>%s</%seltoken>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.eltoken), input_name='eltoken')), namespace_, eol_)) if self.elshort is not None: showIndent(outfile, level, pretty_print) outfile.write('<%selshort>%s</%selshort>%s' % (namespace_, self.gds_format_integer(self.elshort, input_name='elshort'), namespace_, eol_)) @@ -1629,7 +1639,7 @@ class programmer(person): self.elparam.export(outfile, level, namespace_, name_='elparam', pretty_print=pretty_print) if self.elarraytypes is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%selarraytypes>%s</%selarraytypes>%s' % (namespace_, self.gds_format_string(quote_xml(self.elarraytypes).encode(ExternalEncoding), input_name='elarraytypes'), namespace_, eol_)) + outfile.write('<%selarraytypes>%s</%selarraytypes>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.elarraytypes), input_name='elarraytypes')), namespace_, eol_)) def exportLiteral(self, outfile, level, name_='programmer'): level += 1 already_processed = set() @@ -1666,7 +1676,7 @@ class programmer(person): super(programmer, self).exportLiteralChildren(outfile, level, name_) if self.email is not None: showIndent(outfile, level) - outfile.write('email=%s,\n' % quote_python(self.email).encode(ExternalEncoding)) + outfile.write('email=%s,\n' % self.gds_encode(quote_python(self.email))) if self.elposint is not None: showIndent(outfile, level) outfile.write('elposint=%d,\n' % self.elposint) @@ -1687,7 +1697,7 @@ class programmer(person): outfile.write('eldatetime=model_.GeneratedsSuper.gds_parse_datetime("%s"),\n' % self.gds_format_datetime(self.eldatetime, input_name='eldatetime')) if self.eltoken is not None: showIndent(outfile, level) - outfile.write('eltoken=%s,\n' % quote_python(self.eltoken).encode(ExternalEncoding)) + outfile.write('eltoken=%s,\n' % self.gds_encode(quote_python(self.eltoken))) if self.elshort is not None: showIndent(outfile, level) outfile.write('elshort=%d,\n' % self.elshort) @@ -1702,7 +1712,7 @@ class programmer(person): outfile.write('),\n') if self.elarraytypes is not None: showIndent(outfile, level) - outfile.write('elarraytypes=%s,\n' % quote_python(self.elarraytypes).encode(ExternalEncoding)) + outfile.write('elarraytypes=%s,\n' % self.gds_encode(quote_python(self.elarraytypes))) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -1963,7 +1973,7 @@ class param(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='param') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='param', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -1971,7 +1981,7 @@ class param(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='param'): if self.id is not None and 'id' not in already_processed: already_processed.add('id') - outfile.write(' id=%s' % (self.gds_format_string(quote_attrib(self.id).encode(ExternalEncoding), input_name='id'), )) + outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), )) if self.name is not None and 'name' not in already_processed: already_processed.add('name') outfile.write(' name=%s' % (quote_attrib(self.name), )) @@ -1983,10 +1993,10 @@ class param(GeneratedsSuper): outfile.write(' flow=%s' % (quote_attrib(self.flow), )) if self.semantic is not None and 'semantic' not in already_processed: already_processed.add('semantic') - outfile.write(' semantic=%s' % (self.gds_format_string(quote_attrib(self.semantic).encode(ExternalEncoding), input_name='semantic'), )) + outfile.write(' semantic=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.semantic), input_name='semantic')), )) if self.type_ is not None and 'type_' not in already_processed: already_processed.add('type_') - outfile.write(' type=%s' % (self.gds_format_string(quote_attrib(self.type_).encode(ExternalEncoding), input_name='type'), )) + outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), )) def exportChildren(self, outfile, level, namespace_='', name_='param', fromsubclass_=False, pretty_print=True): pass def exportLiteral(self, outfile, level, name_='param'): @@ -2166,7 +2176,7 @@ class python_programmer(programmer): super(python_programmer, self).exportAttributes(outfile, level, already_processed, namespace_, name_='python-programmer') if self.nick_name is not None and 'nick_name' not in already_processed: already_processed.add('nick_name') - outfile.write(' nick-name=%s' % (self.gds_format_string(quote_attrib(self.nick_name).encode(ExternalEncoding), input_name='nick-name'), )) + outfile.write(' nick-name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.nick_name), input_name='nick-name')), )) def exportChildren(self, outfile, level, namespace_='', name_='python-programmer', fromsubclass_=False, pretty_print=True): super(python_programmer, self).exportChildren(outfile, level, namespace_, name_, True, pretty_print=pretty_print) if pretty_print: @@ -2175,7 +2185,7 @@ class python_programmer(programmer): eol_ = '' if self.favorite_editor is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfavorite-editor>%s</%sfavorite-editor>%s' % (namespace_, self.gds_format_string(quote_xml(self.favorite_editor).encode(ExternalEncoding), input_name='favorite-editor'), namespace_, eol_)) + outfile.write('<%sfavorite-editor>%s</%sfavorite-editor>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.favorite_editor), input_name='favorite-editor')), namespace_, eol_)) def exportLiteral(self, outfile, level, name_='python-programmer'): level += 1 already_processed = set() @@ -2192,7 +2202,7 @@ class python_programmer(programmer): super(python_programmer, self).exportLiteralChildren(outfile, level, name_) if self.favorite_editor is not None: showIndent(outfile, level) - outfile.write('favorite_editor=%s,\n' % quote_python(self.favorite_editor).encode(ExternalEncoding)) + outfile.write('favorite_editor=%s,\n' % self.gds_encode(quote_python(self.favorite_editor))) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -2322,10 +2332,10 @@ class java_programmer(programmer): super(java_programmer, self).exportAttributes(outfile, level, already_processed, namespace_, name_='java-programmer') if self.nick_name is not None and 'nick_name' not in already_processed: already_processed.add('nick_name') - outfile.write(' nick-name=%s' % (self.gds_format_string(quote_attrib(self.nick_name).encode(ExternalEncoding), input_name='nick-name'), )) + outfile.write(' nick-name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.nick_name), input_name='nick-name')), )) if self.status is not None and 'status' not in already_processed: already_processed.add('status') - outfile.write(' status=%s' % (self.gds_format_string(quote_attrib(self.status).encode(ExternalEncoding), input_name='status'), )) + outfile.write(' status=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.status), input_name='status')), )) def exportChildren(self, outfile, level, namespace_='', name_='java-programmer', fromsubclass_=False, pretty_print=True): super(java_programmer, self).exportChildren(outfile, level, namespace_, name_, True, pretty_print=pretty_print) if pretty_print: @@ -2334,7 +2344,7 @@ class java_programmer(programmer): eol_ = '' if self.favorite_editor is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfavorite-editor>%s</%sfavorite-editor>%s' % (namespace_, self.gds_format_string(quote_xml(self.favorite_editor).encode(ExternalEncoding), input_name='favorite-editor'), namespace_, eol_)) + outfile.write('<%sfavorite-editor>%s</%sfavorite-editor>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.favorite_editor), input_name='favorite-editor')), namespace_, eol_)) def exportLiteral(self, outfile, level, name_='java-programmer'): level += 1 already_processed = set() @@ -2355,7 +2365,7 @@ class java_programmer(programmer): super(java_programmer, self).exportLiteralChildren(outfile, level, name_) if self.favorite_editor is not None: showIndent(outfile, level) - outfile.write('favorite_editor=%s,\n' % quote_python(self.favorite_editor).encode(ExternalEncoding)) + outfile.write('favorite_editor=%s,\n' % self.gds_encode(quote_python(self.favorite_editor))) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -2499,10 +2509,10 @@ class agent(GeneratedsSuper): eol_ = '' if self.firstname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_format_string(quote_xml(self.firstname).encode(ExternalEncoding), input_name='firstname'), namespace_, eol_)) + outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.firstname), input_name='firstname')), namespace_, eol_)) if self.lastname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_format_string(quote_xml(self.lastname).encode(ExternalEncoding), input_name='lastname'), namespace_, eol_)) + outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.lastname), input_name='lastname')), namespace_, eol_)) if self.priority is not None: showIndent(outfile, level, pretty_print) outfile.write('<%spriority>%s</%spriority>%s' % (namespace_, self.gds_format_float(self.priority, input_name='priority'), namespace_, eol_)) @@ -2519,10 +2529,10 @@ class agent(GeneratedsSuper): def exportLiteralChildren(self, outfile, level, name_): if self.firstname is not None: showIndent(outfile, level) - outfile.write('firstname=%s,\n' % quote_python(self.firstname).encode(ExternalEncoding)) + outfile.write('firstname=%s,\n' % self.gds_encode(quote_python(self.firstname))) if self.lastname is not None: showIndent(outfile, level) - outfile.write('lastname=%s,\n' % quote_python(self.lastname).encode(ExternalEncoding)) + outfile.write('lastname=%s,\n' % self.gds_encode(quote_python(self.lastname))) if self.priority is not None: showIndent(outfile, level) outfile.write('priority=%f,\n' % self.priority) @@ -2683,10 +2693,10 @@ class special_agent(GeneratedsSuper): eol_ = '' if self.firstname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_format_string(quote_xml(self.firstname).encode(ExternalEncoding), input_name='firstname'), namespace_, eol_)) + outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.firstname), input_name='firstname')), namespace_, eol_)) if self.lastname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_format_string(quote_xml(self.lastname).encode(ExternalEncoding), input_name='lastname'), namespace_, eol_)) + outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.lastname), input_name='lastname')), namespace_, eol_)) if self.priority is not None: showIndent(outfile, level, pretty_print) outfile.write('<%spriority>%s</%spriority>%s' % (namespace_, self.gds_format_float(self.priority, input_name='priority'), namespace_, eol_)) @@ -2703,10 +2713,10 @@ class special_agent(GeneratedsSuper): def exportLiteralChildren(self, outfile, level, name_): if self.firstname is not None: showIndent(outfile, level) - outfile.write('firstname=%s,\n' % quote_python(self.firstname).encode(ExternalEncoding)) + outfile.write('firstname=%s,\n' % self.gds_encode(quote_python(self.firstname))) if self.lastname is not None: showIndent(outfile, level) - outfile.write('lastname=%s,\n' % quote_python(self.lastname).encode(ExternalEncoding)) + outfile.write('lastname=%s,\n' % self.gds_encode(quote_python(self.lastname))) if self.priority is not None: showIndent(outfile, level) outfile.write('priority=%f,\n' % self.priority) @@ -2900,10 +2910,10 @@ class booster(GeneratedsSuper): eol_ = '' if self.firstname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_format_string(quote_xml(self.firstname).encode(ExternalEncoding), input_name='firstname'), namespace_, eol_)) + outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.firstname), input_name='firstname')), namespace_, eol_)) if self.lastname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_format_string(quote_xml(self.lastname).encode(ExternalEncoding), input_name='lastname'), namespace_, eol_)) + outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.lastname), input_name='lastname')), namespace_, eol_)) if self.other_name is not None: showIndent(outfile, level, pretty_print) outfile.write('<%sother-name>%s</%sother-name>%s' % (namespace_, self.gds_format_float(self.other_name, input_name='other-name'), namespace_, eol_)) @@ -2929,10 +2939,10 @@ class booster(GeneratedsSuper): def exportLiteralChildren(self, outfile, level, name_): if self.firstname is not None: showIndent(outfile, level) - outfile.write('firstname=%s,\n' % quote_python(self.firstname).encode(ExternalEncoding)) + outfile.write('firstname=%s,\n' % self.gds_encode(quote_python(self.firstname))) if self.lastname is not None: showIndent(outfile, level) - outfile.write('lastname=%s,\n' % quote_python(self.lastname).encode(ExternalEncoding)) + outfile.write('lastname=%s,\n' % self.gds_encode(quote_python(self.lastname))) if self.other_name is not None: showIndent(outfile, level) outfile.write('other_name=%f,\n' % self.other_name) @@ -3130,7 +3140,7 @@ class info(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='info'): if self.name is not None and 'name' not in already_processed: already_processed.add('name') - outfile.write(' name=%s' % (self.gds_format_string(quote_attrib(self.name).encode(ExternalEncoding), input_name='name'), )) + outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), )) if self.type_ is not None and 'type_' not in already_processed: already_processed.add('type_') outfile.write(' type="%s"' % self.gds_format_integer(self.type_, input_name='type')) @@ -3298,7 +3308,7 @@ class client_handlerType(GeneratedsSuper): eol_ = '' if self.fullname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfullname>%s</%sfullname>%s' % (namespace_, self.gds_format_string(quote_xml(self.fullname).encode(ExternalEncoding), input_name='fullname'), namespace_, eol_)) + outfile.write('<%sfullname>%s</%sfullname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.fullname), input_name='fullname')), namespace_, eol_)) if self.refid is not None: showIndent(outfile, level, pretty_print) outfile.write('<%srefid>%s</%srefid>%s' % (namespace_, self.gds_format_integer(self.refid, input_name='refid'), namespace_, eol_)) @@ -3313,7 +3323,7 @@ class client_handlerType(GeneratedsSuper): def exportLiteralChildren(self, outfile, level, name_): if self.fullname is not None: showIndent(outfile, level) - outfile.write('fullname=%s,\n' % quote_python(self.fullname).encode(ExternalEncoding)) + outfile.write('fullname=%s,\n' % self.gds_encode(quote_python(self.fullname))) if self.refid is not None: showIndent(outfile, level) outfile.write('refid=%d,\n' % self.refid) diff --git a/tests/people_procincl1_sup.py b/tests/people_procincl1_sup.py index c07c2f4..979c550 100644 --- a/tests/people_procincl1_sup.py +++ b/tests/people_procincl1_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -1041,7 +1051,7 @@ class person(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='person'): if self.value is not None and 'value' not in already_processed: already_processed.add('value') - outfile.write(' value=%s' % (self.gds_format_string(quote_attrib(self.value).encode(ExternalEncoding), input_name='value'), )) + outfile.write(' value=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.value), input_name='value')), )) if self.id is not None and 'id' not in already_processed: already_processed.add('id') outfile.write(' id="%s"' % self.gds_format_integer(self.id, input_name='id')) @@ -1050,10 +1060,10 @@ class person(GeneratedsSuper): outfile.write(' ratio="%s"' % self.gds_format_float(self.ratio, input_name='ratio')) if self.fruit is not None and 'fruit' not in already_processed: already_processed.add('fruit') - outfile.write(' fruit=%s' % (self.gds_format_string(quote_attrib(self.fruit).encode(ExternalEncoding), input_name='fruit'), )) + outfile.write(' fruit=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.fruit), input_name='fruit')), )) if self.vegetable is not None and 'vegetable' not in already_processed: already_processed.add('vegetable') - outfile.write(' vegetable=%s' % (self.gds_format_string(quote_attrib(self.vegetable).encode(ExternalEncoding), input_name='vegetable'), )) + outfile.write(' vegetable=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.vegetable), input_name='vegetable')), )) if self.extensiontype_ is not None and 'xsi:type' not in already_processed: already_processed.add('xsi:type') outfile.write(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"') @@ -1065,10 +1075,10 @@ class person(GeneratedsSuper): eol_ = '' if self.name is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_format_string(quote_xml(self.name).encode(ExternalEncoding), input_name='name'), namespace_, eol_)) + outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.name), input_name='name')), namespace_, eol_)) for interest_ in self.interest: showIndent(outfile, level, pretty_print) - outfile.write('<%sinterest>%s</%sinterest>%s' % (namespace_, self.gds_format_string(quote_xml(interest_).encode(ExternalEncoding), input_name='interest'), namespace_, eol_)) + outfile.write('<%sinterest>%s</%sinterest>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(interest_), input_name='interest')), namespace_, eol_)) if self.category is not None: showIndent(outfile, level, pretty_print) outfile.write('<%scategory>%s</%scategory>%s' % (namespace_, self.gds_format_integer(self.category, input_name='category'), namespace_, eol_)) @@ -1078,7 +1088,7 @@ class person(GeneratedsSuper): promoter_.export(outfile, level, namespace_, name_='promoter', pretty_print=pretty_print) if self.description is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sdescription>%s</%sdescription>%s' % (namespace_, self.gds_format_string(quote_xml(self.description).encode(ExternalEncoding), input_name='description'), namespace_, eol_)) + outfile.write('<%sdescription>%s</%sdescription>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.description), input_name='description')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -1282,7 +1292,7 @@ class param(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='param') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='param', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -1290,7 +1300,7 @@ class param(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='param'): if self.id is not None and 'id' not in already_processed: already_processed.add('id') - outfile.write(' id=%s' % (self.gds_format_string(quote_attrib(self.id).encode(ExternalEncoding), input_name='id'), )) + outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), )) if self.name is not None and 'name' not in already_processed: already_processed.add('name') outfile.write(' name=%s' % (quote_attrib(self.name), )) @@ -1302,10 +1312,10 @@ class param(GeneratedsSuper): outfile.write(' flow=%s' % (quote_attrib(self.flow), )) if self.semantic is not None and 'semantic' not in already_processed: already_processed.add('semantic') - outfile.write(' semantic=%s' % (self.gds_format_string(quote_attrib(self.semantic).encode(ExternalEncoding), input_name='semantic'), )) + outfile.write(' semantic=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.semantic), input_name='semantic')), )) if self.type_ is not None and 'type_' not in already_processed: already_processed.add('type_') - outfile.write(' type=%s' % (self.gds_format_string(quote_attrib(self.type_).encode(ExternalEncoding), input_name='type'), )) + outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), )) def exportChildren(self, outfile, level, namespace_='', name_='param', fromsubclass_=False, pretty_print=True): pass def build(self, node): @@ -1429,10 +1439,10 @@ class agent(GeneratedsSuper): eol_ = '' if self.firstname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_format_string(quote_xml(self.firstname).encode(ExternalEncoding), input_name='firstname'), namespace_, eol_)) + outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.firstname), input_name='firstname')), namespace_, eol_)) if self.lastname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_format_string(quote_xml(self.lastname).encode(ExternalEncoding), input_name='lastname'), namespace_, eol_)) + outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.lastname), input_name='lastname')), namespace_, eol_)) if self.priority is not None: showIndent(outfile, level, pretty_print) outfile.write('<%spriority>%s</%spriority>%s' % (namespace_, self.gds_format_float(self.priority, input_name='priority'), namespace_, eol_)) @@ -1566,10 +1576,10 @@ class special_agent(GeneratedsSuper): eol_ = '' if self.firstname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_format_string(quote_xml(self.firstname).encode(ExternalEncoding), input_name='firstname'), namespace_, eol_)) + outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.firstname), input_name='firstname')), namespace_, eol_)) if self.lastname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_format_string(quote_xml(self.lastname).encode(ExternalEncoding), input_name='lastname'), namespace_, eol_)) + outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.lastname), input_name='lastname')), namespace_, eol_)) if self.priority is not None: showIndent(outfile, level, pretty_print) outfile.write('<%spriority>%s</%spriority>%s' % (namespace_, self.gds_format_float(self.priority, input_name='priority'), namespace_, eol_)) @@ -1711,7 +1721,7 @@ class booster(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='booster'): if self.member_id is not None and 'member_id' not in already_processed: already_processed.add('member_id') - outfile.write(' member-id=%s' % (self.gds_format_string(quote_attrib(self.member_id).encode(ExternalEncoding), input_name='member-id'), )) + outfile.write(' member-id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.member_id), input_name='member-id')), )) def exportChildren(self, outfile, level, namespace_='', name_='booster', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' @@ -1719,10 +1729,10 @@ class booster(GeneratedsSuper): eol_ = '' if self.firstname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_format_string(quote_xml(self.firstname).encode(ExternalEncoding), input_name='firstname'), namespace_, eol_)) + outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.firstname), input_name='firstname')), namespace_, eol_)) if self.lastname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_format_string(quote_xml(self.lastname).encode(ExternalEncoding), input_name='lastname'), namespace_, eol_)) + outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.lastname), input_name='lastname')), namespace_, eol_)) if self.other_name is not None: showIndent(outfile, level, pretty_print) outfile.write('<%sother-name>%s</%sother-name>%s' % (namespace_, self.gds_format_float(self.other_name, input_name='other-name'), namespace_, eol_)) @@ -1855,7 +1865,7 @@ class info(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='info'): if self.name is not None and 'name' not in already_processed: already_processed.add('name') - outfile.write(' name=%s' % (self.gds_format_string(quote_attrib(self.name).encode(ExternalEncoding), input_name='name'), )) + outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), )) if self.type_ is not None and 'type_' not in already_processed: already_processed.add('type_') outfile.write(' type="%s"' % self.gds_format_integer(self.type_, input_name='type')) @@ -2042,7 +2052,7 @@ class automobile(vehicle): eol_ = '' if self.drivername is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sdrivername>%s</%sdrivername>%s' % (namespace_, self.gds_format_string(quote_xml(self.drivername).encode(ExternalEncoding), input_name='drivername'), namespace_, eol_)) + outfile.write('<%sdrivername>%s</%sdrivername>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.drivername), input_name='drivername')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -2120,7 +2130,7 @@ class airplane(vehicle): eol_ = '' if self.pilotname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%spilotname>%s</%spilotname>%s' % (namespace_, self.gds_format_string(quote_xml(self.pilotname).encode(ExternalEncoding), input_name='pilotname'), namespace_, eol_)) + outfile.write('<%spilotname>%s</%spilotname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.pilotname), input_name='pilotname')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -2177,7 +2187,7 @@ class programmer(person): self.elnonposint = elnonposint self.elnegint = elnegint self.elnonnegint = elnonnegint - if isinstance(eldate, basestring): + if isinstance(eldate, BaseStrType_): initvalue_ = datetime_.datetime.strptime(eldate, '%Y-%m-%d').date() else: initvalue_ = eldate @@ -2288,10 +2298,10 @@ class programmer(person): super(programmer, self).exportAttributes(outfile, level, already_processed, namespace_, name_='programmer') if self.language is not None and 'language' not in already_processed: already_processed.add('language') - outfile.write(' language=%s' % (self.gds_format_string(quote_attrib(self.language).encode(ExternalEncoding), input_name='language'), )) + outfile.write(' language=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.language), input_name='language')), )) if self.area is not None and 'area' not in already_processed: already_processed.add('area') - outfile.write(' area=%s' % (self.gds_format_string(quote_attrib(self.area).encode(ExternalEncoding), input_name='area'), )) + outfile.write(' area=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.area), input_name='area')), )) if self.attrposint is not None and 'attrposint' not in already_processed: already_processed.add('attrposint') outfile.write(' attrposint="%s"' % self.gds_format_integer(self.attrposint, input_name='attrposint')) @@ -2316,7 +2326,7 @@ class programmer(person): eol_ = '' if self.email is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%semail>%s</%semail>%s' % (namespace_, self.gds_format_string(quote_xml(self.email).encode(ExternalEncoding), input_name='email'), namespace_, eol_)) + outfile.write('<%semail>%s</%semail>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.email), input_name='email')), namespace_, eol_)) if self.elposint is not None: showIndent(outfile, level, pretty_print) outfile.write('<%selposint>%s</%selposint>%s' % (namespace_, self.gds_format_integer(self.elposint, input_name='elposint'), namespace_, eol_)) @@ -2334,7 +2344,7 @@ class programmer(person): outfile.write('<%seldate>%s</%seldate>%s' % (namespace_, self.gds_format_date(self.eldate, input_name='eldate'), namespace_, eol_)) if self.eltoken is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%seltoken>%s</%seltoken>%s' % (namespace_, self.gds_format_string(quote_xml(self.eltoken).encode(ExternalEncoding), input_name='eltoken'), namespace_, eol_)) + outfile.write('<%seltoken>%s</%seltoken>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.eltoken), input_name='eltoken')), namespace_, eol_)) if self.elshort is not None: showIndent(outfile, level, pretty_print) outfile.write('<%selshort>%s</%selshort>%s' % (namespace_, self.gds_format_integer(self.elshort, input_name='elshort'), namespace_, eol_)) @@ -2345,7 +2355,7 @@ class programmer(person): self.elparam.export(outfile, level, namespace_, name_='elparam', pretty_print=pretty_print) if self.elarraytypes is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%selarraytypes>%s</%selarraytypes>%s' % (namespace_, self.gds_format_string(quote_xml(self.elarraytypes).encode(ExternalEncoding), input_name='elarraytypes'), namespace_, eol_)) + outfile.write('<%selarraytypes>%s</%selarraytypes>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.elarraytypes), input_name='elarraytypes')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -2549,7 +2559,7 @@ class client_handlerType(GeneratedsSuper): eol_ = '' if self.fullname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfullname>%s</%sfullname>%s' % (namespace_, self.gds_format_string(quote_xml(self.fullname).encode(ExternalEncoding), input_name='fullname'), namespace_, eol_)) + outfile.write('<%sfullname>%s</%sfullname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.fullname), input_name='fullname')), namespace_, eol_)) if self.refid is not None: showIndent(outfile, level, pretty_print) outfile.write('<%srefid>%s</%srefid>%s' % (namespace_, self.gds_format_integer(self.refid, input_name='refid'), namespace_, eol_)) @@ -2642,10 +2652,10 @@ class java_programmer(programmer): super(java_programmer, self).exportAttributes(outfile, level, already_processed, namespace_, name_='java-programmer') if self.nick_name is not None and 'nick_name' not in already_processed: already_processed.add('nick_name') - outfile.write(' nick-name=%s' % (self.gds_format_string(quote_attrib(self.nick_name).encode(ExternalEncoding), input_name='nick-name'), )) + outfile.write(' nick-name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.nick_name), input_name='nick-name')), )) if self.status is not None and 'status' not in already_processed: already_processed.add('status') - outfile.write(' status=%s' % (self.gds_format_string(quote_attrib(self.status).encode(ExternalEncoding), input_name='status'), )) + outfile.write(' status=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.status), input_name='status')), )) def exportChildren(self, outfile, level, namespace_='', name_='java-programmer', fromsubclass_=False, pretty_print=True): super(java_programmer, self).exportChildren(outfile, level, namespace_, name_, True, pretty_print=pretty_print) if pretty_print: @@ -2654,7 +2664,7 @@ class java_programmer(programmer): eol_ = '' if self.favorite_editor is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfavorite-editor>%s</%sfavorite-editor>%s' % (namespace_, self.gds_format_string(quote_xml(self.favorite_editor).encode(ExternalEncoding), input_name='favorite-editor'), namespace_, eol_)) + outfile.write('<%sfavorite-editor>%s</%sfavorite-editor>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.favorite_editor), input_name='favorite-editor')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -2740,7 +2750,7 @@ class python_programmer(programmer): super(python_programmer, self).exportAttributes(outfile, level, already_processed, namespace_, name_='python-programmer') if self.nick_name is not None and 'nick_name' not in already_processed: already_processed.add('nick_name') - outfile.write(' nick-name=%s' % (self.gds_format_string(quote_attrib(self.nick_name).encode(ExternalEncoding), input_name='nick-name'), )) + outfile.write(' nick-name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.nick_name), input_name='nick-name')), )) def exportChildren(self, outfile, level, namespace_='', name_='python-programmer', fromsubclass_=False, pretty_print=True): super(python_programmer, self).exportChildren(outfile, level, namespace_, name_, True, pretty_print=pretty_print) if pretty_print: @@ -2749,7 +2759,7 @@ class python_programmer(programmer): eol_ = '' if self.favorite_editor is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfavorite-editor>%s</%sfavorite-editor>%s' % (namespace_, self.gds_format_string(quote_xml(self.favorite_editor).encode(ExternalEncoding), input_name='favorite-editor'), namespace_, eol_)) + outfile.write('<%sfavorite-editor>%s</%sfavorite-editor>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.favorite_editor), input_name='favorite-editor')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) diff --git a/tests/people_procincl2_sup.py b/tests/people_procincl2_sup.py index c07c2f4..979c550 100644 --- a/tests/people_procincl2_sup.py +++ b/tests/people_procincl2_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -1041,7 +1051,7 @@ class person(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='person'): if self.value is not None and 'value' not in already_processed: already_processed.add('value') - outfile.write(' value=%s' % (self.gds_format_string(quote_attrib(self.value).encode(ExternalEncoding), input_name='value'), )) + outfile.write(' value=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.value), input_name='value')), )) if self.id is not None and 'id' not in already_processed: already_processed.add('id') outfile.write(' id="%s"' % self.gds_format_integer(self.id, input_name='id')) @@ -1050,10 +1060,10 @@ class person(GeneratedsSuper): outfile.write(' ratio="%s"' % self.gds_format_float(self.ratio, input_name='ratio')) if self.fruit is not None and 'fruit' not in already_processed: already_processed.add('fruit') - outfile.write(' fruit=%s' % (self.gds_format_string(quote_attrib(self.fruit).encode(ExternalEncoding), input_name='fruit'), )) + outfile.write(' fruit=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.fruit), input_name='fruit')), )) if self.vegetable is not None and 'vegetable' not in already_processed: already_processed.add('vegetable') - outfile.write(' vegetable=%s' % (self.gds_format_string(quote_attrib(self.vegetable).encode(ExternalEncoding), input_name='vegetable'), )) + outfile.write(' vegetable=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.vegetable), input_name='vegetable')), )) if self.extensiontype_ is not None and 'xsi:type' not in already_processed: already_processed.add('xsi:type') outfile.write(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"') @@ -1065,10 +1075,10 @@ class person(GeneratedsSuper): eol_ = '' if self.name is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_format_string(quote_xml(self.name).encode(ExternalEncoding), input_name='name'), namespace_, eol_)) + outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.name), input_name='name')), namespace_, eol_)) for interest_ in self.interest: showIndent(outfile, level, pretty_print) - outfile.write('<%sinterest>%s</%sinterest>%s' % (namespace_, self.gds_format_string(quote_xml(interest_).encode(ExternalEncoding), input_name='interest'), namespace_, eol_)) + outfile.write('<%sinterest>%s</%sinterest>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(interest_), input_name='interest')), namespace_, eol_)) if self.category is not None: showIndent(outfile, level, pretty_print) outfile.write('<%scategory>%s</%scategory>%s' % (namespace_, self.gds_format_integer(self.category, input_name='category'), namespace_, eol_)) @@ -1078,7 +1088,7 @@ class person(GeneratedsSuper): promoter_.export(outfile, level, namespace_, name_='promoter', pretty_print=pretty_print) if self.description is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sdescription>%s</%sdescription>%s' % (namespace_, self.gds_format_string(quote_xml(self.description).encode(ExternalEncoding), input_name='description'), namespace_, eol_)) + outfile.write('<%sdescription>%s</%sdescription>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.description), input_name='description')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -1282,7 +1292,7 @@ class param(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='param') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='param', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -1290,7 +1300,7 @@ class param(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='param'): if self.id is not None and 'id' not in already_processed: already_processed.add('id') - outfile.write(' id=%s' % (self.gds_format_string(quote_attrib(self.id).encode(ExternalEncoding), input_name='id'), )) + outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), )) if self.name is not None and 'name' not in already_processed: already_processed.add('name') outfile.write(' name=%s' % (quote_attrib(self.name), )) @@ -1302,10 +1312,10 @@ class param(GeneratedsSuper): outfile.write(' flow=%s' % (quote_attrib(self.flow), )) if self.semantic is not None and 'semantic' not in already_processed: already_processed.add('semantic') - outfile.write(' semantic=%s' % (self.gds_format_string(quote_attrib(self.semantic).encode(ExternalEncoding), input_name='semantic'), )) + outfile.write(' semantic=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.semantic), input_name='semantic')), )) if self.type_ is not None and 'type_' not in already_processed: already_processed.add('type_') - outfile.write(' type=%s' % (self.gds_format_string(quote_attrib(self.type_).encode(ExternalEncoding), input_name='type'), )) + outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), )) def exportChildren(self, outfile, level, namespace_='', name_='param', fromsubclass_=False, pretty_print=True): pass def build(self, node): @@ -1429,10 +1439,10 @@ class agent(GeneratedsSuper): eol_ = '' if self.firstname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_format_string(quote_xml(self.firstname).encode(ExternalEncoding), input_name='firstname'), namespace_, eol_)) + outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.firstname), input_name='firstname')), namespace_, eol_)) if self.lastname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_format_string(quote_xml(self.lastname).encode(ExternalEncoding), input_name='lastname'), namespace_, eol_)) + outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.lastname), input_name='lastname')), namespace_, eol_)) if self.priority is not None: showIndent(outfile, level, pretty_print) outfile.write('<%spriority>%s</%spriority>%s' % (namespace_, self.gds_format_float(self.priority, input_name='priority'), namespace_, eol_)) @@ -1566,10 +1576,10 @@ class special_agent(GeneratedsSuper): eol_ = '' if self.firstname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_format_string(quote_xml(self.firstname).encode(ExternalEncoding), input_name='firstname'), namespace_, eol_)) + outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.firstname), input_name='firstname')), namespace_, eol_)) if self.lastname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_format_string(quote_xml(self.lastname).encode(ExternalEncoding), input_name='lastname'), namespace_, eol_)) + outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.lastname), input_name='lastname')), namespace_, eol_)) if self.priority is not None: showIndent(outfile, level, pretty_print) outfile.write('<%spriority>%s</%spriority>%s' % (namespace_, self.gds_format_float(self.priority, input_name='priority'), namespace_, eol_)) @@ -1711,7 +1721,7 @@ class booster(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='booster'): if self.member_id is not None and 'member_id' not in already_processed: already_processed.add('member_id') - outfile.write(' member-id=%s' % (self.gds_format_string(quote_attrib(self.member_id).encode(ExternalEncoding), input_name='member-id'), )) + outfile.write(' member-id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.member_id), input_name='member-id')), )) def exportChildren(self, outfile, level, namespace_='', name_='booster', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' @@ -1719,10 +1729,10 @@ class booster(GeneratedsSuper): eol_ = '' if self.firstname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_format_string(quote_xml(self.firstname).encode(ExternalEncoding), input_name='firstname'), namespace_, eol_)) + outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.firstname), input_name='firstname')), namespace_, eol_)) if self.lastname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_format_string(quote_xml(self.lastname).encode(ExternalEncoding), input_name='lastname'), namespace_, eol_)) + outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.lastname), input_name='lastname')), namespace_, eol_)) if self.other_name is not None: showIndent(outfile, level, pretty_print) outfile.write('<%sother-name>%s</%sother-name>%s' % (namespace_, self.gds_format_float(self.other_name, input_name='other-name'), namespace_, eol_)) @@ -1855,7 +1865,7 @@ class info(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='info'): if self.name is not None and 'name' not in already_processed: already_processed.add('name') - outfile.write(' name=%s' % (self.gds_format_string(quote_attrib(self.name).encode(ExternalEncoding), input_name='name'), )) + outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), )) if self.type_ is not None and 'type_' not in already_processed: already_processed.add('type_') outfile.write(' type="%s"' % self.gds_format_integer(self.type_, input_name='type')) @@ -2042,7 +2052,7 @@ class automobile(vehicle): eol_ = '' if self.drivername is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sdrivername>%s</%sdrivername>%s' % (namespace_, self.gds_format_string(quote_xml(self.drivername).encode(ExternalEncoding), input_name='drivername'), namespace_, eol_)) + outfile.write('<%sdrivername>%s</%sdrivername>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.drivername), input_name='drivername')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -2120,7 +2130,7 @@ class airplane(vehicle): eol_ = '' if self.pilotname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%spilotname>%s</%spilotname>%s' % (namespace_, self.gds_format_string(quote_xml(self.pilotname).encode(ExternalEncoding), input_name='pilotname'), namespace_, eol_)) + outfile.write('<%spilotname>%s</%spilotname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.pilotname), input_name='pilotname')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -2177,7 +2187,7 @@ class programmer(person): self.elnonposint = elnonposint self.elnegint = elnegint self.elnonnegint = elnonnegint - if isinstance(eldate, basestring): + if isinstance(eldate, BaseStrType_): initvalue_ = datetime_.datetime.strptime(eldate, '%Y-%m-%d').date() else: initvalue_ = eldate @@ -2288,10 +2298,10 @@ class programmer(person): super(programmer, self).exportAttributes(outfile, level, already_processed, namespace_, name_='programmer') if self.language is not None and 'language' not in already_processed: already_processed.add('language') - outfile.write(' language=%s' % (self.gds_format_string(quote_attrib(self.language).encode(ExternalEncoding), input_name='language'), )) + outfile.write(' language=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.language), input_name='language')), )) if self.area is not None and 'area' not in already_processed: already_processed.add('area') - outfile.write(' area=%s' % (self.gds_format_string(quote_attrib(self.area).encode(ExternalEncoding), input_name='area'), )) + outfile.write(' area=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.area), input_name='area')), )) if self.attrposint is not None and 'attrposint' not in already_processed: already_processed.add('attrposint') outfile.write(' attrposint="%s"' % self.gds_format_integer(self.attrposint, input_name='attrposint')) @@ -2316,7 +2326,7 @@ class programmer(person): eol_ = '' if self.email is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%semail>%s</%semail>%s' % (namespace_, self.gds_format_string(quote_xml(self.email).encode(ExternalEncoding), input_name='email'), namespace_, eol_)) + outfile.write('<%semail>%s</%semail>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.email), input_name='email')), namespace_, eol_)) if self.elposint is not None: showIndent(outfile, level, pretty_print) outfile.write('<%selposint>%s</%selposint>%s' % (namespace_, self.gds_format_integer(self.elposint, input_name='elposint'), namespace_, eol_)) @@ -2334,7 +2344,7 @@ class programmer(person): outfile.write('<%seldate>%s</%seldate>%s' % (namespace_, self.gds_format_date(self.eldate, input_name='eldate'), namespace_, eol_)) if self.eltoken is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%seltoken>%s</%seltoken>%s' % (namespace_, self.gds_format_string(quote_xml(self.eltoken).encode(ExternalEncoding), input_name='eltoken'), namespace_, eol_)) + outfile.write('<%seltoken>%s</%seltoken>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.eltoken), input_name='eltoken')), namespace_, eol_)) if self.elshort is not None: showIndent(outfile, level, pretty_print) outfile.write('<%selshort>%s</%selshort>%s' % (namespace_, self.gds_format_integer(self.elshort, input_name='elshort'), namespace_, eol_)) @@ -2345,7 +2355,7 @@ class programmer(person): self.elparam.export(outfile, level, namespace_, name_='elparam', pretty_print=pretty_print) if self.elarraytypes is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%selarraytypes>%s</%selarraytypes>%s' % (namespace_, self.gds_format_string(quote_xml(self.elarraytypes).encode(ExternalEncoding), input_name='elarraytypes'), namespace_, eol_)) + outfile.write('<%selarraytypes>%s</%selarraytypes>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.elarraytypes), input_name='elarraytypes')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -2549,7 +2559,7 @@ class client_handlerType(GeneratedsSuper): eol_ = '' if self.fullname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfullname>%s</%sfullname>%s' % (namespace_, self.gds_format_string(quote_xml(self.fullname).encode(ExternalEncoding), input_name='fullname'), namespace_, eol_)) + outfile.write('<%sfullname>%s</%sfullname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.fullname), input_name='fullname')), namespace_, eol_)) if self.refid is not None: showIndent(outfile, level, pretty_print) outfile.write('<%srefid>%s</%srefid>%s' % (namespace_, self.gds_format_integer(self.refid, input_name='refid'), namespace_, eol_)) @@ -2642,10 +2652,10 @@ class java_programmer(programmer): super(java_programmer, self).exportAttributes(outfile, level, already_processed, namespace_, name_='java-programmer') if self.nick_name is not None and 'nick_name' not in already_processed: already_processed.add('nick_name') - outfile.write(' nick-name=%s' % (self.gds_format_string(quote_attrib(self.nick_name).encode(ExternalEncoding), input_name='nick-name'), )) + outfile.write(' nick-name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.nick_name), input_name='nick-name')), )) if self.status is not None and 'status' not in already_processed: already_processed.add('status') - outfile.write(' status=%s' % (self.gds_format_string(quote_attrib(self.status).encode(ExternalEncoding), input_name='status'), )) + outfile.write(' status=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.status), input_name='status')), )) def exportChildren(self, outfile, level, namespace_='', name_='java-programmer', fromsubclass_=False, pretty_print=True): super(java_programmer, self).exportChildren(outfile, level, namespace_, name_, True, pretty_print=pretty_print) if pretty_print: @@ -2654,7 +2664,7 @@ class java_programmer(programmer): eol_ = '' if self.favorite_editor is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfavorite-editor>%s</%sfavorite-editor>%s' % (namespace_, self.gds_format_string(quote_xml(self.favorite_editor).encode(ExternalEncoding), input_name='favorite-editor'), namespace_, eol_)) + outfile.write('<%sfavorite-editor>%s</%sfavorite-editor>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.favorite_editor), input_name='favorite-editor')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -2740,7 +2750,7 @@ class python_programmer(programmer): super(python_programmer, self).exportAttributes(outfile, level, already_processed, namespace_, name_='python-programmer') if self.nick_name is not None and 'nick_name' not in already_processed: already_processed.add('nick_name') - outfile.write(' nick-name=%s' % (self.gds_format_string(quote_attrib(self.nick_name).encode(ExternalEncoding), input_name='nick-name'), )) + outfile.write(' nick-name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.nick_name), input_name='nick-name')), )) def exportChildren(self, outfile, level, namespace_='', name_='python-programmer', fromsubclass_=False, pretty_print=True): super(python_programmer, self).exportChildren(outfile, level, namespace_, name_, True, pretty_print=pretty_print) if pretty_print: @@ -2749,7 +2759,7 @@ class python_programmer(programmer): eol_ = '' if self.favorite_editor is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfavorite-editor>%s</%sfavorite-editor>%s' % (namespace_, self.gds_format_string(quote_xml(self.favorite_editor).encode(ExternalEncoding), input_name='favorite-editor'), namespace_, eol_)) + outfile.write('<%sfavorite-editor>%s</%sfavorite-editor>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.favorite_editor), input_name='favorite-editor')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) diff --git a/tests/prefix_classname1_sup.py b/tests/prefix_classname1_sup.py index d607f86..8c09004 100644 --- a/tests/prefix_classname1_sup.py +++ b/tests/prefix_classname1_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -1003,7 +1013,7 @@ class tomato_person(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='person'): if self.value is not None and 'value' not in already_processed: already_processed.add('value') - outfile.write(' value=%s' % (self.gds_format_string(quote_attrib(self.value).encode(ExternalEncoding), input_name='value'), )) + outfile.write(' value=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.value), input_name='value')), )) if self.id is not None and 'id' not in already_processed: already_processed.add('id') outfile.write(' id="%s"' % self.gds_format_integer(self.id, input_name='id')) @@ -1012,10 +1022,10 @@ class tomato_person(GeneratedsSuper): outfile.write(' ratio="%s"' % self.gds_format_float(self.ratio, input_name='ratio')) if self.fruit is not None and 'fruit' not in already_processed: already_processed.add('fruit') - outfile.write(' fruit=%s' % (self.gds_format_string(quote_attrib(self.fruit).encode(ExternalEncoding), input_name='fruit'), )) + outfile.write(' fruit=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.fruit), input_name='fruit')), )) if self.vegetable is not None and 'vegetable' not in already_processed: already_processed.add('vegetable') - outfile.write(' vegetable=%s' % (self.gds_format_string(quote_attrib(self.vegetable).encode(ExternalEncoding), input_name='vegetable'), )) + outfile.write(' vegetable=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.vegetable), input_name='vegetable')), )) if self.extensiontype_ is not None and 'xsi:type' not in already_processed: already_processed.add('xsi:type') outfile.write(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"') @@ -1027,10 +1037,10 @@ class tomato_person(GeneratedsSuper): eol_ = '' if self.name is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_format_string(quote_xml(self.name).encode(ExternalEncoding), input_name='name'), namespace_, eol_)) + outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.name), input_name='name')), namespace_, eol_)) for interest_ in self.interest: showIndent(outfile, level, pretty_print) - outfile.write('<%sinterest>%s</%sinterest>%s' % (namespace_, self.gds_format_string(quote_xml(interest_).encode(ExternalEncoding), input_name='interest'), namespace_, eol_)) + outfile.write('<%sinterest>%s</%sinterest>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(interest_), input_name='interest')), namespace_, eol_)) if self.category is not None: showIndent(outfile, level, pretty_print) outfile.write('<%scategory>%s</%scategory>%s' % (namespace_, self.gds_format_integer(self.category, input_name='category'), namespace_, eol_)) @@ -1040,7 +1050,7 @@ class tomato_person(GeneratedsSuper): promoter_.export(outfile, level, namespace_, name_='promoter', pretty_print=pretty_print) if self.description is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sdescription>%s</%sdescription>%s' % (namespace_, self.gds_format_string(quote_xml(self.description).encode(ExternalEncoding), input_name='description'), namespace_, eol_)) + outfile.write('<%sdescription>%s</%sdescription>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.description), input_name='description')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -1150,12 +1160,12 @@ class tomato_programmer(tomato_person): self.elnonposint = elnonposint self.elnegint = elnegint self.elnonnegint = elnonnegint - if isinstance(eldate, basestring): + if isinstance(eldate, BaseStrType_): initvalue_ = datetime_.datetime.strptime(eldate, '%Y-%m-%d').date() else: initvalue_ = eldate self.eldate = initvalue_ - if isinstance(eldatetime, basestring): + if isinstance(eldatetime, BaseStrType_): initvalue_ = datetime_.datetime.strptime(eldatetime, '%Y-%m-%dT%H:%M:%S') else: initvalue_ = eldatetime @@ -1269,10 +1279,10 @@ class tomato_programmer(tomato_person): super(tomato_programmer, self).exportAttributes(outfile, level, already_processed, namespace_, name_='programmer') if self.language is not None and 'language' not in already_processed: already_processed.add('language') - outfile.write(' language=%s' % (self.gds_format_string(quote_attrib(self.language).encode(ExternalEncoding), input_name='language'), )) + outfile.write(' language=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.language), input_name='language')), )) if self.area is not None and 'area' not in already_processed: already_processed.add('area') - outfile.write(' area=%s' % (self.gds_format_string(quote_attrib(self.area).encode(ExternalEncoding), input_name='area'), )) + outfile.write(' area=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.area), input_name='area')), )) if self.attrposint is not None and 'attrposint' not in already_processed: already_processed.add('attrposint') outfile.write(' attrposint="%s"' % self.gds_format_integer(self.attrposint, input_name='attrposint')) @@ -1297,7 +1307,7 @@ class tomato_programmer(tomato_person): eol_ = '' if self.email is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%semail>%s</%semail>%s' % (namespace_, self.gds_format_string(quote_xml(self.email).encode(ExternalEncoding), input_name='email'), namespace_, eol_)) + outfile.write('<%semail>%s</%semail>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.email), input_name='email')), namespace_, eol_)) if self.elposint is not None: showIndent(outfile, level, pretty_print) outfile.write('<%selposint>%s</%selposint>%s' % (namespace_, self.gds_format_integer(self.elposint, input_name='elposint'), namespace_, eol_)) @@ -1318,7 +1328,7 @@ class tomato_programmer(tomato_person): outfile.write('<%seldatetime>%s</%seldatetime>%s' % (namespace_, self.gds_format_datetime(self.eldatetime, input_name='eldatetime'), namespace_, eol_)) if self.eltoken is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%seltoken>%s</%seltoken>%s' % (namespace_, self.gds_format_string(quote_xml(self.eltoken).encode(ExternalEncoding), input_name='eltoken'), namespace_, eol_)) + outfile.write('<%seltoken>%s</%seltoken>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.eltoken), input_name='eltoken')), namespace_, eol_)) if self.elshort is not None: showIndent(outfile, level, pretty_print) outfile.write('<%selshort>%s</%selshort>%s' % (namespace_, self.gds_format_integer(self.elshort, input_name='elshort'), namespace_, eol_)) @@ -1329,7 +1339,7 @@ class tomato_programmer(tomato_person): self.elparam.export(outfile, level, namespace_, name_='elparam', pretty_print=pretty_print) if self.elarraytypes is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%selarraytypes>%s</%selarraytypes>%s' % (namespace_, self.gds_format_string(quote_xml(self.elarraytypes).encode(ExternalEncoding), input_name='elarraytypes'), namespace_, eol_)) + outfile.write('<%selarraytypes>%s</%selarraytypes>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.elarraytypes), input_name='elarraytypes')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -1544,7 +1554,7 @@ class tomato_param(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='param') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='param', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -1552,7 +1562,7 @@ class tomato_param(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='param'): if self.id is not None and 'id' not in already_processed: already_processed.add('id') - outfile.write(' id=%s' % (self.gds_format_string(quote_attrib(self.id).encode(ExternalEncoding), input_name='id'), )) + outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), )) if self.name is not None and 'name' not in already_processed: already_processed.add('name') outfile.write(' name=%s' % (quote_attrib(self.name), )) @@ -1564,10 +1574,10 @@ class tomato_param(GeneratedsSuper): outfile.write(' flow=%s' % (quote_attrib(self.flow), )) if self.semantic is not None and 'semantic' not in already_processed: already_processed.add('semantic') - outfile.write(' semantic=%s' % (self.gds_format_string(quote_attrib(self.semantic).encode(ExternalEncoding), input_name='semantic'), )) + outfile.write(' semantic=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.semantic), input_name='semantic')), )) if self.type_ is not None and 'type_' not in already_processed: already_processed.add('type_') - outfile.write(' type=%s' % (self.gds_format_string(quote_attrib(self.type_).encode(ExternalEncoding), input_name='type'), )) + outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), )) def exportChildren(self, outfile, level, namespace_='', name_='param', fromsubclass_=False, pretty_print=True): pass def build(self, node): @@ -1666,7 +1676,7 @@ class tomato_python_programmer(tomato_programmer): super(tomato_python_programmer, self).exportAttributes(outfile, level, already_processed, namespace_, name_='python-programmer') if self.nick_name is not None and 'nick_name' not in already_processed: already_processed.add('nick_name') - outfile.write(' nick-name=%s' % (self.gds_format_string(quote_attrib(self.nick_name).encode(ExternalEncoding), input_name='nick-name'), )) + outfile.write(' nick-name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.nick_name), input_name='nick-name')), )) def exportChildren(self, outfile, level, namespace_='', name_='python-programmer', fromsubclass_=False, pretty_print=True): super(tomato_python_programmer, self).exportChildren(outfile, level, namespace_, name_, True, pretty_print=pretty_print) if pretty_print: @@ -1675,7 +1685,7 @@ class tomato_python_programmer(tomato_programmer): eol_ = '' if self.favorite_editor is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfavorite-editor>%s</%sfavorite-editor>%s' % (namespace_, self.gds_format_string(quote_xml(self.favorite_editor).encode(ExternalEncoding), input_name='favorite-editor'), namespace_, eol_)) + outfile.write('<%sfavorite-editor>%s</%sfavorite-editor>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.favorite_editor), input_name='favorite-editor')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -1759,10 +1769,10 @@ class tomato_java_programmer(tomato_programmer): super(tomato_java_programmer, self).exportAttributes(outfile, level, already_processed, namespace_, name_='java-programmer') if self.nick_name is not None and 'nick_name' not in already_processed: already_processed.add('nick_name') - outfile.write(' nick-name=%s' % (self.gds_format_string(quote_attrib(self.nick_name).encode(ExternalEncoding), input_name='nick-name'), )) + outfile.write(' nick-name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.nick_name), input_name='nick-name')), )) if self.status is not None and 'status' not in already_processed: already_processed.add('status') - outfile.write(' status=%s' % (self.gds_format_string(quote_attrib(self.status).encode(ExternalEncoding), input_name='status'), )) + outfile.write(' status=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.status), input_name='status')), )) def exportChildren(self, outfile, level, namespace_='', name_='java-programmer', fromsubclass_=False, pretty_print=True): super(tomato_java_programmer, self).exportChildren(outfile, level, namespace_, name_, True, pretty_print=pretty_print) if pretty_print: @@ -1771,7 +1781,7 @@ class tomato_java_programmer(tomato_programmer): eol_ = '' if self.favorite_editor is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfavorite-editor>%s</%sfavorite-editor>%s' % (namespace_, self.gds_format_string(quote_xml(self.favorite_editor).encode(ExternalEncoding), input_name='favorite-editor'), namespace_, eol_)) + outfile.write('<%sfavorite-editor>%s</%sfavorite-editor>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.favorite_editor), input_name='favorite-editor')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -1869,10 +1879,10 @@ class tomato_agent(GeneratedsSuper): eol_ = '' if self.firstname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_format_string(quote_xml(self.firstname).encode(ExternalEncoding), input_name='firstname'), namespace_, eol_)) + outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.firstname), input_name='firstname')), namespace_, eol_)) if self.lastname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_format_string(quote_xml(self.lastname).encode(ExternalEncoding), input_name='lastname'), namespace_, eol_)) + outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.lastname), input_name='lastname')), namespace_, eol_)) if self.priority is not None: showIndent(outfile, level, pretty_print) outfile.write('<%spriority>%s</%spriority>%s' % (namespace_, self.gds_format_float(self.priority, input_name='priority'), namespace_, eol_)) @@ -1983,10 +1993,10 @@ class tomato_special_agent(GeneratedsSuper): eol_ = '' if self.firstname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_format_string(quote_xml(self.firstname).encode(ExternalEncoding), input_name='firstname'), namespace_, eol_)) + outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.firstname), input_name='firstname')), namespace_, eol_)) if self.lastname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_format_string(quote_xml(self.lastname).encode(ExternalEncoding), input_name='lastname'), namespace_, eol_)) + outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.lastname), input_name='lastname')), namespace_, eol_)) if self.priority is not None: showIndent(outfile, level, pretty_print) outfile.write('<%spriority>%s</%spriority>%s' % (namespace_, self.gds_format_float(self.priority, input_name='priority'), namespace_, eol_)) @@ -2130,10 +2140,10 @@ class tomato_booster(GeneratedsSuper): eol_ = '' if self.firstname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_format_string(quote_xml(self.firstname).encode(ExternalEncoding), input_name='firstname'), namespace_, eol_)) + outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.firstname), input_name='firstname')), namespace_, eol_)) if self.lastname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_format_string(quote_xml(self.lastname).encode(ExternalEncoding), input_name='lastname'), namespace_, eol_)) + outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.lastname), input_name='lastname')), namespace_, eol_)) if self.other_name is not None: showIndent(outfile, level, pretty_print) outfile.write('<%sother-name>%s</%sother-name>%s' % (namespace_, self.gds_format_float(self.other_name, input_name='other-name'), namespace_, eol_)) @@ -2263,7 +2273,7 @@ class tomato_info(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='info'): if self.name is not None and 'name' not in already_processed: already_processed.add('name') - outfile.write(' name=%s' % (self.gds_format_string(quote_attrib(self.name).encode(ExternalEncoding), input_name='name'), )) + outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), )) if self.type_ is not None and 'type_' not in already_processed: already_processed.add('type_') outfile.write(' type="%s"' % self.gds_format_integer(self.type_, input_name='type')) @@ -2364,7 +2374,7 @@ class tomato_client_handlerType(GeneratedsSuper): eol_ = '' if self.fullname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfullname>%s</%sfullname>%s' % (namespace_, self.gds_format_string(quote_xml(self.fullname).encode(ExternalEncoding), input_name='fullname'), namespace_, eol_)) + outfile.write('<%sfullname>%s</%sfullname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.fullname), input_name='fullname')), namespace_, eol_)) if self.refid is not None: showIndent(outfile, level, pretty_print) outfile.write('<%srefid>%s</%srefid>%s' % (namespace_, self.gds_format_integer(self.refid, input_name='refid'), namespace_, eol_)) diff --git a/tests/prefix_classname2_sup.py b/tests/prefix_classname2_sup.py index d607f86..8c09004 100644 --- a/tests/prefix_classname2_sup.py +++ b/tests/prefix_classname2_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -1003,7 +1013,7 @@ class tomato_person(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='person'): if self.value is not None and 'value' not in already_processed: already_processed.add('value') - outfile.write(' value=%s' % (self.gds_format_string(quote_attrib(self.value).encode(ExternalEncoding), input_name='value'), )) + outfile.write(' value=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.value), input_name='value')), )) if self.id is not None and 'id' not in already_processed: already_processed.add('id') outfile.write(' id="%s"' % self.gds_format_integer(self.id, input_name='id')) @@ -1012,10 +1022,10 @@ class tomato_person(GeneratedsSuper): outfile.write(' ratio="%s"' % self.gds_format_float(self.ratio, input_name='ratio')) if self.fruit is not None and 'fruit' not in already_processed: already_processed.add('fruit') - outfile.write(' fruit=%s' % (self.gds_format_string(quote_attrib(self.fruit).encode(ExternalEncoding), input_name='fruit'), )) + outfile.write(' fruit=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.fruit), input_name='fruit')), )) if self.vegetable is not None and 'vegetable' not in already_processed: already_processed.add('vegetable') - outfile.write(' vegetable=%s' % (self.gds_format_string(quote_attrib(self.vegetable).encode(ExternalEncoding), input_name='vegetable'), )) + outfile.write(' vegetable=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.vegetable), input_name='vegetable')), )) if self.extensiontype_ is not None and 'xsi:type' not in already_processed: already_processed.add('xsi:type') outfile.write(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"') @@ -1027,10 +1037,10 @@ class tomato_person(GeneratedsSuper): eol_ = '' if self.name is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_format_string(quote_xml(self.name).encode(ExternalEncoding), input_name='name'), namespace_, eol_)) + outfile.write('<%sname>%s</%sname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.name), input_name='name')), namespace_, eol_)) for interest_ in self.interest: showIndent(outfile, level, pretty_print) - outfile.write('<%sinterest>%s</%sinterest>%s' % (namespace_, self.gds_format_string(quote_xml(interest_).encode(ExternalEncoding), input_name='interest'), namespace_, eol_)) + outfile.write('<%sinterest>%s</%sinterest>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(interest_), input_name='interest')), namespace_, eol_)) if self.category is not None: showIndent(outfile, level, pretty_print) outfile.write('<%scategory>%s</%scategory>%s' % (namespace_, self.gds_format_integer(self.category, input_name='category'), namespace_, eol_)) @@ -1040,7 +1050,7 @@ class tomato_person(GeneratedsSuper): promoter_.export(outfile, level, namespace_, name_='promoter', pretty_print=pretty_print) if self.description is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sdescription>%s</%sdescription>%s' % (namespace_, self.gds_format_string(quote_xml(self.description).encode(ExternalEncoding), input_name='description'), namespace_, eol_)) + outfile.write('<%sdescription>%s</%sdescription>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.description), input_name='description')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -1150,12 +1160,12 @@ class tomato_programmer(tomato_person): self.elnonposint = elnonposint self.elnegint = elnegint self.elnonnegint = elnonnegint - if isinstance(eldate, basestring): + if isinstance(eldate, BaseStrType_): initvalue_ = datetime_.datetime.strptime(eldate, '%Y-%m-%d').date() else: initvalue_ = eldate self.eldate = initvalue_ - if isinstance(eldatetime, basestring): + if isinstance(eldatetime, BaseStrType_): initvalue_ = datetime_.datetime.strptime(eldatetime, '%Y-%m-%dT%H:%M:%S') else: initvalue_ = eldatetime @@ -1269,10 +1279,10 @@ class tomato_programmer(tomato_person): super(tomato_programmer, self).exportAttributes(outfile, level, already_processed, namespace_, name_='programmer') if self.language is not None and 'language' not in already_processed: already_processed.add('language') - outfile.write(' language=%s' % (self.gds_format_string(quote_attrib(self.language).encode(ExternalEncoding), input_name='language'), )) + outfile.write(' language=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.language), input_name='language')), )) if self.area is not None and 'area' not in already_processed: already_processed.add('area') - outfile.write(' area=%s' % (self.gds_format_string(quote_attrib(self.area).encode(ExternalEncoding), input_name='area'), )) + outfile.write(' area=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.area), input_name='area')), )) if self.attrposint is not None and 'attrposint' not in already_processed: already_processed.add('attrposint') outfile.write(' attrposint="%s"' % self.gds_format_integer(self.attrposint, input_name='attrposint')) @@ -1297,7 +1307,7 @@ class tomato_programmer(tomato_person): eol_ = '' if self.email is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%semail>%s</%semail>%s' % (namespace_, self.gds_format_string(quote_xml(self.email).encode(ExternalEncoding), input_name='email'), namespace_, eol_)) + outfile.write('<%semail>%s</%semail>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.email), input_name='email')), namespace_, eol_)) if self.elposint is not None: showIndent(outfile, level, pretty_print) outfile.write('<%selposint>%s</%selposint>%s' % (namespace_, self.gds_format_integer(self.elposint, input_name='elposint'), namespace_, eol_)) @@ -1318,7 +1328,7 @@ class tomato_programmer(tomato_person): outfile.write('<%seldatetime>%s</%seldatetime>%s' % (namespace_, self.gds_format_datetime(self.eldatetime, input_name='eldatetime'), namespace_, eol_)) if self.eltoken is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%seltoken>%s</%seltoken>%s' % (namespace_, self.gds_format_string(quote_xml(self.eltoken).encode(ExternalEncoding), input_name='eltoken'), namespace_, eol_)) + outfile.write('<%seltoken>%s</%seltoken>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.eltoken), input_name='eltoken')), namespace_, eol_)) if self.elshort is not None: showIndent(outfile, level, pretty_print) outfile.write('<%selshort>%s</%selshort>%s' % (namespace_, self.gds_format_integer(self.elshort, input_name='elshort'), namespace_, eol_)) @@ -1329,7 +1339,7 @@ class tomato_programmer(tomato_person): self.elparam.export(outfile, level, namespace_, name_='elparam', pretty_print=pretty_print) if self.elarraytypes is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%selarraytypes>%s</%selarraytypes>%s' % (namespace_, self.gds_format_string(quote_xml(self.elarraytypes).encode(ExternalEncoding), input_name='elarraytypes'), namespace_, eol_)) + outfile.write('<%selarraytypes>%s</%selarraytypes>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.elarraytypes), input_name='elarraytypes')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -1544,7 +1554,7 @@ class tomato_param(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='param') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='param', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -1552,7 +1562,7 @@ class tomato_param(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='param'): if self.id is not None and 'id' not in already_processed: already_processed.add('id') - outfile.write(' id=%s' % (self.gds_format_string(quote_attrib(self.id).encode(ExternalEncoding), input_name='id'), )) + outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), )) if self.name is not None and 'name' not in already_processed: already_processed.add('name') outfile.write(' name=%s' % (quote_attrib(self.name), )) @@ -1564,10 +1574,10 @@ class tomato_param(GeneratedsSuper): outfile.write(' flow=%s' % (quote_attrib(self.flow), )) if self.semantic is not None and 'semantic' not in already_processed: already_processed.add('semantic') - outfile.write(' semantic=%s' % (self.gds_format_string(quote_attrib(self.semantic).encode(ExternalEncoding), input_name='semantic'), )) + outfile.write(' semantic=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.semantic), input_name='semantic')), )) if self.type_ is not None and 'type_' not in already_processed: already_processed.add('type_') - outfile.write(' type=%s' % (self.gds_format_string(quote_attrib(self.type_).encode(ExternalEncoding), input_name='type'), )) + outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), )) def exportChildren(self, outfile, level, namespace_='', name_='param', fromsubclass_=False, pretty_print=True): pass def build(self, node): @@ -1666,7 +1676,7 @@ class tomato_python_programmer(tomato_programmer): super(tomato_python_programmer, self).exportAttributes(outfile, level, already_processed, namespace_, name_='python-programmer') if self.nick_name is not None and 'nick_name' not in already_processed: already_processed.add('nick_name') - outfile.write(' nick-name=%s' % (self.gds_format_string(quote_attrib(self.nick_name).encode(ExternalEncoding), input_name='nick-name'), )) + outfile.write(' nick-name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.nick_name), input_name='nick-name')), )) def exportChildren(self, outfile, level, namespace_='', name_='python-programmer', fromsubclass_=False, pretty_print=True): super(tomato_python_programmer, self).exportChildren(outfile, level, namespace_, name_, True, pretty_print=pretty_print) if pretty_print: @@ -1675,7 +1685,7 @@ class tomato_python_programmer(tomato_programmer): eol_ = '' if self.favorite_editor is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfavorite-editor>%s</%sfavorite-editor>%s' % (namespace_, self.gds_format_string(quote_xml(self.favorite_editor).encode(ExternalEncoding), input_name='favorite-editor'), namespace_, eol_)) + outfile.write('<%sfavorite-editor>%s</%sfavorite-editor>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.favorite_editor), input_name='favorite-editor')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -1759,10 +1769,10 @@ class tomato_java_programmer(tomato_programmer): super(tomato_java_programmer, self).exportAttributes(outfile, level, already_processed, namespace_, name_='java-programmer') if self.nick_name is not None and 'nick_name' not in already_processed: already_processed.add('nick_name') - outfile.write(' nick-name=%s' % (self.gds_format_string(quote_attrib(self.nick_name).encode(ExternalEncoding), input_name='nick-name'), )) + outfile.write(' nick-name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.nick_name), input_name='nick-name')), )) if self.status is not None and 'status' not in already_processed: already_processed.add('status') - outfile.write(' status=%s' % (self.gds_format_string(quote_attrib(self.status).encode(ExternalEncoding), input_name='status'), )) + outfile.write(' status=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.status), input_name='status')), )) def exportChildren(self, outfile, level, namespace_='', name_='java-programmer', fromsubclass_=False, pretty_print=True): super(tomato_java_programmer, self).exportChildren(outfile, level, namespace_, name_, True, pretty_print=pretty_print) if pretty_print: @@ -1771,7 +1781,7 @@ class tomato_java_programmer(tomato_programmer): eol_ = '' if self.favorite_editor is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfavorite-editor>%s</%sfavorite-editor>%s' % (namespace_, self.gds_format_string(quote_xml(self.favorite_editor).encode(ExternalEncoding), input_name='favorite-editor'), namespace_, eol_)) + outfile.write('<%sfavorite-editor>%s</%sfavorite-editor>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.favorite_editor), input_name='favorite-editor')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -1869,10 +1879,10 @@ class tomato_agent(GeneratedsSuper): eol_ = '' if self.firstname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_format_string(quote_xml(self.firstname).encode(ExternalEncoding), input_name='firstname'), namespace_, eol_)) + outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.firstname), input_name='firstname')), namespace_, eol_)) if self.lastname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_format_string(quote_xml(self.lastname).encode(ExternalEncoding), input_name='lastname'), namespace_, eol_)) + outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.lastname), input_name='lastname')), namespace_, eol_)) if self.priority is not None: showIndent(outfile, level, pretty_print) outfile.write('<%spriority>%s</%spriority>%s' % (namespace_, self.gds_format_float(self.priority, input_name='priority'), namespace_, eol_)) @@ -1983,10 +1993,10 @@ class tomato_special_agent(GeneratedsSuper): eol_ = '' if self.firstname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_format_string(quote_xml(self.firstname).encode(ExternalEncoding), input_name='firstname'), namespace_, eol_)) + outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.firstname), input_name='firstname')), namespace_, eol_)) if self.lastname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_format_string(quote_xml(self.lastname).encode(ExternalEncoding), input_name='lastname'), namespace_, eol_)) + outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.lastname), input_name='lastname')), namespace_, eol_)) if self.priority is not None: showIndent(outfile, level, pretty_print) outfile.write('<%spriority>%s</%spriority>%s' % (namespace_, self.gds_format_float(self.priority, input_name='priority'), namespace_, eol_)) @@ -2130,10 +2140,10 @@ class tomato_booster(GeneratedsSuper): eol_ = '' if self.firstname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_format_string(quote_xml(self.firstname).encode(ExternalEncoding), input_name='firstname'), namespace_, eol_)) + outfile.write('<%sfirstname>%s</%sfirstname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.firstname), input_name='firstname')), namespace_, eol_)) if self.lastname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_format_string(quote_xml(self.lastname).encode(ExternalEncoding), input_name='lastname'), namespace_, eol_)) + outfile.write('<%slastname>%s</%slastname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.lastname), input_name='lastname')), namespace_, eol_)) if self.other_name is not None: showIndent(outfile, level, pretty_print) outfile.write('<%sother-name>%s</%sother-name>%s' % (namespace_, self.gds_format_float(self.other_name, input_name='other-name'), namespace_, eol_)) @@ -2263,7 +2273,7 @@ class tomato_info(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='info'): if self.name is not None and 'name' not in already_processed: already_processed.add('name') - outfile.write(' name=%s' % (self.gds_format_string(quote_attrib(self.name).encode(ExternalEncoding), input_name='name'), )) + outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), )) if self.type_ is not None and 'type_' not in already_processed: already_processed.add('type_') outfile.write(' type="%s"' % self.gds_format_integer(self.type_, input_name='type')) @@ -2364,7 +2374,7 @@ class tomato_client_handlerType(GeneratedsSuper): eol_ = '' if self.fullname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfullname>%s</%sfullname>%s' % (namespace_, self.gds_format_string(quote_xml(self.fullname).encode(ExternalEncoding), input_name='fullname'), namespace_, eol_)) + outfile.write('<%sfullname>%s</%sfullname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.fullname), input_name='fullname')), namespace_, eol_)) if self.refid is not None: showIndent(outfile, level, pretty_print) outfile.write('<%srefid>%s</%srefid>%s' % (namespace_, self.gds_format_integer(self.refid, input_name='refid'), namespace_, eol_)) diff --git a/tests/recursive_simpletype1_sup.py b/tests/recursive_simpletype1_sup.py index f1a56ef..4929b8e 100644 --- a/tests/recursive_simpletype1_sup.py +++ b/tests/recursive_simpletype1_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -702,10 +712,10 @@ class PersonType(GeneratedsSuper): outfile.write('<%spersonId>%s</%spersonId>%s' % (namespace_, self.gds_format_integer(self.personId, input_name='personId'), namespace_, eol_)) if self.fname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfname>%s</%sfname>%s' % (namespace_, self.gds_format_string(quote_xml(self.fname).encode(ExternalEncoding), input_name='fname'), namespace_, eol_)) + outfile.write('<%sfname>%s</%sfname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.fname), input_name='fname')), namespace_, eol_)) if self.lname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%slname>%s</%slname>%s' % (namespace_, self.gds_format_string(quote_xml(self.lname).encode(ExternalEncoding), input_name='lname'), namespace_, eol_)) + outfile.write('<%slname>%s</%slname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.lname), input_name='lname')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) diff --git a/tests/recursive_simpletype2_sup.py b/tests/recursive_simpletype2_sup.py index f1a56ef..4929b8e 100644 --- a/tests/recursive_simpletype2_sup.py +++ b/tests/recursive_simpletype2_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -702,10 +712,10 @@ class PersonType(GeneratedsSuper): outfile.write('<%spersonId>%s</%spersonId>%s' % (namespace_, self.gds_format_integer(self.personId, input_name='personId'), namespace_, eol_)) if self.fname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sfname>%s</%sfname>%s' % (namespace_, self.gds_format_string(quote_xml(self.fname).encode(ExternalEncoding), input_name='fname'), namespace_, eol_)) + outfile.write('<%sfname>%s</%sfname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.fname), input_name='fname')), namespace_, eol_)) if self.lname is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%slname>%s</%slname>%s' % (namespace_, self.gds_format_string(quote_xml(self.lname).encode(ExternalEncoding), input_name='lname'), namespace_, eol_)) + outfile.write('<%slname>%s</%slname>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.lname), input_name='lname')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) diff --git a/tests/reference_simpletype1_sup.py b/tests/reference_simpletype1_sup.py index bf3d907..ab1f084 100644 --- a/tests/reference_simpletype1_sup.py +++ b/tests/reference_simpletype1_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') diff --git a/tests/reference_simpletype2_sup.py b/tests/reference_simpletype2_sup.py index bf3d907..ab1f084 100644 --- a/tests/reference_simpletype2_sup.py +++ b/tests/reference_simpletype2_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') diff --git a/tests/simplecontent_restriction1_sup.py b/tests/simplecontent_restriction1_sup.py index f069bc6..5cd34d3 100644 --- a/tests/simplecontent_restriction1_sup.py +++ b/tests/simplecontent_restriction1_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -706,7 +716,7 @@ class IdentifierType(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='IdentifierType') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='IdentifierType', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -714,25 +724,25 @@ class IdentifierType(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='IdentifierType'): if self.schemeID is not None and 'schemeID' not in already_processed: already_processed.add('schemeID') - outfile.write(' schemeID=%s' % (self.gds_format_string(quote_attrib(self.schemeID).encode(ExternalEncoding), input_name='schemeID'), )) + outfile.write(' schemeID=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.schemeID), input_name='schemeID')), )) if self.schemeName is not None and 'schemeName' not in already_processed: already_processed.add('schemeName') - outfile.write(' schemeName=%s' % (self.gds_format_string(quote_attrib(self.schemeName).encode(ExternalEncoding), input_name='schemeName'), )) + outfile.write(' schemeName=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.schemeName), input_name='schemeName')), )) if self.schemeAgencyID is not None and 'schemeAgencyID' not in already_processed: already_processed.add('schemeAgencyID') - outfile.write(' schemeAgencyID=%s' % (self.gds_format_string(quote_attrib(self.schemeAgencyID).encode(ExternalEncoding), input_name='schemeAgencyID'), )) + outfile.write(' schemeAgencyID=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.schemeAgencyID), input_name='schemeAgencyID')), )) if self.schemeAgencyName is not None and 'schemeAgencyName' not in already_processed: already_processed.add('schemeAgencyName') - outfile.write(' schemeAgencyName=%s' % (self.gds_format_string(quote_attrib(self.schemeAgencyName).encode(ExternalEncoding), input_name='schemeAgencyName'), )) + outfile.write(' schemeAgencyName=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.schemeAgencyName), input_name='schemeAgencyName')), )) if self.schemeVersionID is not None and 'schemeVersionID' not in already_processed: already_processed.add('schemeVersionID') - outfile.write(' schemeVersionID=%s' % (self.gds_format_string(quote_attrib(self.schemeVersionID).encode(ExternalEncoding), input_name='schemeVersionID'), )) + outfile.write(' schemeVersionID=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.schemeVersionID), input_name='schemeVersionID')), )) if self.schemeDataURI is not None and 'schemeDataURI' not in already_processed: already_processed.add('schemeDataURI') - outfile.write(' schemeDataURI=%s' % (self.gds_format_string(quote_attrib(self.schemeDataURI).encode(ExternalEncoding), input_name='schemeDataURI'), )) + outfile.write(' schemeDataURI=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.schemeDataURI), input_name='schemeDataURI')), )) if self.schemeURI is not None and 'schemeURI' not in already_processed: already_processed.add('schemeURI') - outfile.write(' schemeURI=%s' % (self.gds_format_string(quote_attrib(self.schemeURI).encode(ExternalEncoding), input_name='schemeURI'), )) + outfile.write(' schemeURI=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.schemeURI), input_name='schemeURI')), )) if self.extensiontype_ is not None and 'xsi:type' not in already_processed: already_processed.add('xsi:type') outfile.write(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"') @@ -829,7 +839,7 @@ class BillOfResourcesIDType(IdentifierType): self.exportAttributes(outfile, level, already_processed, namespace_, name_='BillOfResourcesIDType') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='BillOfResourcesIDType', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -898,7 +908,7 @@ class BillOfMaterialIDType(IdentifierType): self.exportAttributes(outfile, level, already_processed, namespace_, name_='BillOfMaterialIDType') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='BillOfMaterialIDType', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: diff --git a/tests/simplecontent_restriction2_sup.py b/tests/simplecontent_restriction2_sup.py index f069bc6..5cd34d3 100644 --- a/tests/simplecontent_restriction2_sup.py +++ b/tests/simplecontent_restriction2_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -706,7 +716,7 @@ class IdentifierType(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='IdentifierType') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='IdentifierType', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -714,25 +724,25 @@ class IdentifierType(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='IdentifierType'): if self.schemeID is not None and 'schemeID' not in already_processed: already_processed.add('schemeID') - outfile.write(' schemeID=%s' % (self.gds_format_string(quote_attrib(self.schemeID).encode(ExternalEncoding), input_name='schemeID'), )) + outfile.write(' schemeID=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.schemeID), input_name='schemeID')), )) if self.schemeName is not None and 'schemeName' not in already_processed: already_processed.add('schemeName') - outfile.write(' schemeName=%s' % (self.gds_format_string(quote_attrib(self.schemeName).encode(ExternalEncoding), input_name='schemeName'), )) + outfile.write(' schemeName=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.schemeName), input_name='schemeName')), )) if self.schemeAgencyID is not None and 'schemeAgencyID' not in already_processed: already_processed.add('schemeAgencyID') - outfile.write(' schemeAgencyID=%s' % (self.gds_format_string(quote_attrib(self.schemeAgencyID).encode(ExternalEncoding), input_name='schemeAgencyID'), )) + outfile.write(' schemeAgencyID=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.schemeAgencyID), input_name='schemeAgencyID')), )) if self.schemeAgencyName is not None and 'schemeAgencyName' not in already_processed: already_processed.add('schemeAgencyName') - outfile.write(' schemeAgencyName=%s' % (self.gds_format_string(quote_attrib(self.schemeAgencyName).encode(ExternalEncoding), input_name='schemeAgencyName'), )) + outfile.write(' schemeAgencyName=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.schemeAgencyName), input_name='schemeAgencyName')), )) if self.schemeVersionID is not None and 'schemeVersionID' not in already_processed: already_processed.add('schemeVersionID') - outfile.write(' schemeVersionID=%s' % (self.gds_format_string(quote_attrib(self.schemeVersionID).encode(ExternalEncoding), input_name='schemeVersionID'), )) + outfile.write(' schemeVersionID=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.schemeVersionID), input_name='schemeVersionID')), )) if self.schemeDataURI is not None and 'schemeDataURI' not in already_processed: already_processed.add('schemeDataURI') - outfile.write(' schemeDataURI=%s' % (self.gds_format_string(quote_attrib(self.schemeDataURI).encode(ExternalEncoding), input_name='schemeDataURI'), )) + outfile.write(' schemeDataURI=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.schemeDataURI), input_name='schemeDataURI')), )) if self.schemeURI is not None and 'schemeURI' not in already_processed: already_processed.add('schemeURI') - outfile.write(' schemeURI=%s' % (self.gds_format_string(quote_attrib(self.schemeURI).encode(ExternalEncoding), input_name='schemeURI'), )) + outfile.write(' schemeURI=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.schemeURI), input_name='schemeURI')), )) if self.extensiontype_ is not None and 'xsi:type' not in already_processed: already_processed.add('xsi:type') outfile.write(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"') @@ -829,7 +839,7 @@ class BillOfResourcesIDType(IdentifierType): self.exportAttributes(outfile, level, already_processed, namespace_, name_='BillOfResourcesIDType') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='BillOfResourcesIDType', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -898,7 +908,7 @@ class BillOfMaterialIDType(IdentifierType): self.exportAttributes(outfile, level, already_processed, namespace_, name_='BillOfMaterialIDType') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='', name_='BillOfMaterialIDType', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: diff --git a/tests/simpletype_memberspecs1_sup.py b/tests/simpletype_memberspecs1_sup.py index 85d473d..5fc9d99 100644 --- a/tests/simpletype_memberspecs1_sup.py +++ b/tests/simpletype_memberspecs1_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -679,7 +689,7 @@ class SpecialDate(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='SpecialDate') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='pl:', name_='SpecialDate', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -687,7 +697,7 @@ class SpecialDate(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='pl:', name_='SpecialDate'): if self.SpecialProperty is not None and 'SpecialProperty' not in already_processed: already_processed.add('SpecialProperty') - outfile.write(' SpecialProperty=%s' % (self.gds_format_string(quote_attrib(self.SpecialProperty).encode(ExternalEncoding), input_name='SpecialProperty'), )) + outfile.write(' SpecialProperty=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.SpecialProperty), input_name='SpecialProperty')), )) def exportChildren(self, outfile, level, namespace_='pl:', name_='SpecialDate', fromsubclass_=False, pretty_print=True): pass def build(self, node): @@ -754,7 +764,7 @@ class ExtremeDate(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='ExtremeDate') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='pl:', name_='ExtremeDate', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -762,7 +772,7 @@ class ExtremeDate(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='pl:', name_='ExtremeDate'): if self.ExtremeProperty is not None and 'ExtremeProperty' not in already_processed: already_processed.add('ExtremeProperty') - outfile.write(' ExtremeProperty=%s' % (self.gds_format_string(quote_attrib(self.ExtremeProperty).encode(ExternalEncoding), input_name='ExtremeProperty'), )) + outfile.write(' ExtremeProperty=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.ExtremeProperty), input_name='ExtremeProperty')), )) def exportChildren(self, outfile, level, namespace_='pl:', name_='ExtremeDate', fromsubclass_=False, pretty_print=True): pass def build(self, node): diff --git a/tests/simpletype_memberspecs2_sup.py b/tests/simpletype_memberspecs2_sup.py index 85d473d..5fc9d99 100644 --- a/tests/simpletype_memberspecs2_sup.py +++ b/tests/simpletype_memberspecs2_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -679,7 +689,7 @@ class SpecialDate(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='SpecialDate') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='pl:', name_='SpecialDate', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -687,7 +697,7 @@ class SpecialDate(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='pl:', name_='SpecialDate'): if self.SpecialProperty is not None and 'SpecialProperty' not in already_processed: already_processed.add('SpecialProperty') - outfile.write(' SpecialProperty=%s' % (self.gds_format_string(quote_attrib(self.SpecialProperty).encode(ExternalEncoding), input_name='SpecialProperty'), )) + outfile.write(' SpecialProperty=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.SpecialProperty), input_name='SpecialProperty')), )) def exportChildren(self, outfile, level, namespace_='pl:', name_='SpecialDate', fromsubclass_=False, pretty_print=True): pass def build(self, node): @@ -754,7 +764,7 @@ class ExtremeDate(GeneratedsSuper): self.exportAttributes(outfile, level, already_processed, namespace_, name_='ExtremeDate') if self.hasContent_(): outfile.write('>') - outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else str(self.valueOf_)).encode(ExternalEncoding)) + outfile.write((quote_xml(self.valueOf_) if type(self.valueOf_) is str else self.gds_encode(str(self.valueOf_)))) self.exportChildren(outfile, level + 1, namespace_='pl:', name_='ExtremeDate', pretty_print=pretty_print) outfile.write('</%s%s>%s' % (namespace_, name_, eol_)) else: @@ -762,7 +772,7 @@ class ExtremeDate(GeneratedsSuper): def exportAttributes(self, outfile, level, already_processed, namespace_='pl:', name_='ExtremeDate'): if self.ExtremeProperty is not None and 'ExtremeProperty' not in already_processed: already_processed.add('ExtremeProperty') - outfile.write(' ExtremeProperty=%s' % (self.gds_format_string(quote_attrib(self.ExtremeProperty).encode(ExternalEncoding), input_name='ExtremeProperty'), )) + outfile.write(' ExtremeProperty=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.ExtremeProperty), input_name='ExtremeProperty')), )) def exportChildren(self, outfile, level, namespace_='pl:', name_='ExtremeDate', fromsubclass_=False, pretty_print=True): pass def build(self, node): diff --git a/tests/simpletypes_other1_sup.py b/tests/simpletypes_other1_sup.py index b12e1b9..0d25aff 100644 --- a/tests/simpletypes_other1_sup.py +++ b/tests/simpletypes_other1_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -695,7 +705,7 @@ class simpleTypeTestsType(GeneratedsSuper): eol_ = '' for simpleTypeTest_ in self.simpleTypeTest: showIndent(outfile, level, pretty_print) - outfile.write('<%ssimpleTypeTest>%s</%ssimpleTypeTest>%s' % (namespace_, self.gds_format_string(quote_xml(simpleTypeTest_).encode(ExternalEncoding), input_name='simpleTypeTest'), namespace_, eol_)) + outfile.write('<%ssimpleTypeTest>%s</%ssimpleTypeTest>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(simpleTypeTest_), input_name='simpleTypeTest')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -776,7 +786,7 @@ class simpleTypeTest(GeneratedsSuper): self.floatVal2 = [] else: self.floatVal2 = floatVal2 - if isinstance(dateVal1, basestring): + if isinstance(dateVal1, BaseStrType_): initvalue_ = datetime_.datetime.strptime(dateVal1, '%Y-%m-%d').date() else: initvalue_ = dateVal1 @@ -785,7 +795,7 @@ class simpleTypeTest(GeneratedsSuper): self.dateVal2 = [] else: self.dateVal2 = dateVal2 - if isinstance(dateTimeVal1, basestring): + if isinstance(dateTimeVal1, BaseStrType_): initvalue_ = datetime_.datetime.strptime(dateTimeVal1, '%Y-%m-%dT%H:%M:%S') else: initvalue_ = dateTimeVal1 @@ -925,19 +935,19 @@ class simpleTypeTest(GeneratedsSuper): eol_ = '' if self.datetime1 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sdatetime1>%s</%sdatetime1>%s' % (namespace_, self.gds_format_string(quote_xml(self.datetime1).encode(ExternalEncoding), input_name='datetime1'), namespace_, eol_)) + outfile.write('<%sdatetime1>%s</%sdatetime1>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.datetime1), input_name='datetime1')), namespace_, eol_)) if self.datetime2 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sdatetime2>%s</%sdatetime2>%s' % (namespace_, self.gds_format_string(quote_xml(self.datetime2).encode(ExternalEncoding), input_name='datetime2'), namespace_, eol_)) + outfile.write('<%sdatetime2>%s</%sdatetime2>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.datetime2), input_name='datetime2')), namespace_, eol_)) if self.datetime3 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sdatetime3>%s</%sdatetime3>%s' % (namespace_, self.gds_format_string(quote_xml(self.datetime3).encode(ExternalEncoding), input_name='datetime3'), namespace_, eol_)) + outfile.write('<%sdatetime3>%s</%sdatetime3>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.datetime3), input_name='datetime3')), namespace_, eol_)) if self.datetime4 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sdatetime4>%s</%sdatetime4>%s' % (namespace_, self.gds_format_string(quote_xml(self.datetime4).encode(ExternalEncoding), input_name='datetime4'), namespace_, eol_)) + outfile.write('<%sdatetime4>%s</%sdatetime4>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.datetime4), input_name='datetime4')), namespace_, eol_)) if self.datetime5 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sdatetime5>%s</%sdatetime5>%s' % (namespace_, self.gds_format_string(quote_xml(self.datetime5).encode(ExternalEncoding), input_name='datetime5'), namespace_, eol_)) + outfile.write('<%sdatetime5>%s</%sdatetime5>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.datetime5), input_name='datetime5')), namespace_, eol_)) if self.integerVal1 is not None: showIndent(outfile, level, pretty_print) outfile.write('<%sintegerVal1>%s</%sintegerVal1>%s' % (namespace_, self.gds_format_integer(self.integerVal1, input_name='integerVal1'), namespace_, eol_)) @@ -946,10 +956,10 @@ class simpleTypeTest(GeneratedsSuper): outfile.write('<%sintegerVal2>%s</%sintegerVal2>%s' % (namespace_, self.gds_format_integer(integerVal2_, input_name='integerVal2'), namespace_, eol_)) if self.stringVal1 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sstringVal1>%s</%sstringVal1>%s' % (namespace_, self.gds_format_string(quote_xml(self.stringVal1).encode(ExternalEncoding), input_name='stringVal1'), namespace_, eol_)) + outfile.write('<%sstringVal1>%s</%sstringVal1>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.stringVal1), input_name='stringVal1')), namespace_, eol_)) for stringVal2_ in self.stringVal2: showIndent(outfile, level, pretty_print) - outfile.write('<%sstringVal2>%s</%sstringVal2>%s' % (namespace_, self.gds_format_string(quote_xml(stringVal2_).encode(ExternalEncoding), input_name='stringVal2'), namespace_, eol_)) + outfile.write('<%sstringVal2>%s</%sstringVal2>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(stringVal2_), input_name='stringVal2')), namespace_, eol_)) if self.booleanVal1 is not None: showIndent(outfile, level, pretty_print) outfile.write('<%sbooleanVal1>%s</%sbooleanVal1>%s' % (namespace_, self.gds_format_boolean(self.booleanVal1, input_name='booleanVal1'), namespace_, eol_)) diff --git a/tests/simpletypes_other2_sup.py b/tests/simpletypes_other2_sup.py index b12e1b9..0d25aff 100644 --- a/tests/simpletypes_other2_sup.py +++ b/tests/simpletypes_other2_sup.py @@ -33,6 +33,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -352,6 +356,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -406,7 +416,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -428,7 +438,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -695,7 +705,7 @@ class simpleTypeTestsType(GeneratedsSuper): eol_ = '' for simpleTypeTest_ in self.simpleTypeTest: showIndent(outfile, level, pretty_print) - outfile.write('<%ssimpleTypeTest>%s</%ssimpleTypeTest>%s' % (namespace_, self.gds_format_string(quote_xml(simpleTypeTest_).encode(ExternalEncoding), input_name='simpleTypeTest'), namespace_, eol_)) + outfile.write('<%ssimpleTypeTest>%s</%ssimpleTypeTest>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(simpleTypeTest_), input_name='simpleTypeTest')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -776,7 +786,7 @@ class simpleTypeTest(GeneratedsSuper): self.floatVal2 = [] else: self.floatVal2 = floatVal2 - if isinstance(dateVal1, basestring): + if isinstance(dateVal1, BaseStrType_): initvalue_ = datetime_.datetime.strptime(dateVal1, '%Y-%m-%d').date() else: initvalue_ = dateVal1 @@ -785,7 +795,7 @@ class simpleTypeTest(GeneratedsSuper): self.dateVal2 = [] else: self.dateVal2 = dateVal2 - if isinstance(dateTimeVal1, basestring): + if isinstance(dateTimeVal1, BaseStrType_): initvalue_ = datetime_.datetime.strptime(dateTimeVal1, '%Y-%m-%dT%H:%M:%S') else: initvalue_ = dateTimeVal1 @@ -925,19 +935,19 @@ class simpleTypeTest(GeneratedsSuper): eol_ = '' if self.datetime1 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sdatetime1>%s</%sdatetime1>%s' % (namespace_, self.gds_format_string(quote_xml(self.datetime1).encode(ExternalEncoding), input_name='datetime1'), namespace_, eol_)) + outfile.write('<%sdatetime1>%s</%sdatetime1>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.datetime1), input_name='datetime1')), namespace_, eol_)) if self.datetime2 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sdatetime2>%s</%sdatetime2>%s' % (namespace_, self.gds_format_string(quote_xml(self.datetime2).encode(ExternalEncoding), input_name='datetime2'), namespace_, eol_)) + outfile.write('<%sdatetime2>%s</%sdatetime2>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.datetime2), input_name='datetime2')), namespace_, eol_)) if self.datetime3 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sdatetime3>%s</%sdatetime3>%s' % (namespace_, self.gds_format_string(quote_xml(self.datetime3).encode(ExternalEncoding), input_name='datetime3'), namespace_, eol_)) + outfile.write('<%sdatetime3>%s</%sdatetime3>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.datetime3), input_name='datetime3')), namespace_, eol_)) if self.datetime4 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sdatetime4>%s</%sdatetime4>%s' % (namespace_, self.gds_format_string(quote_xml(self.datetime4).encode(ExternalEncoding), input_name='datetime4'), namespace_, eol_)) + outfile.write('<%sdatetime4>%s</%sdatetime4>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.datetime4), input_name='datetime4')), namespace_, eol_)) if self.datetime5 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sdatetime5>%s</%sdatetime5>%s' % (namespace_, self.gds_format_string(quote_xml(self.datetime5).encode(ExternalEncoding), input_name='datetime5'), namespace_, eol_)) + outfile.write('<%sdatetime5>%s</%sdatetime5>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.datetime5), input_name='datetime5')), namespace_, eol_)) if self.integerVal1 is not None: showIndent(outfile, level, pretty_print) outfile.write('<%sintegerVal1>%s</%sintegerVal1>%s' % (namespace_, self.gds_format_integer(self.integerVal1, input_name='integerVal1'), namespace_, eol_)) @@ -946,10 +956,10 @@ class simpleTypeTest(GeneratedsSuper): outfile.write('<%sintegerVal2>%s</%sintegerVal2>%s' % (namespace_, self.gds_format_integer(integerVal2_, input_name='integerVal2'), namespace_, eol_)) if self.stringVal1 is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%sstringVal1>%s</%sstringVal1>%s' % (namespace_, self.gds_format_string(quote_xml(self.stringVal1).encode(ExternalEncoding), input_name='stringVal1'), namespace_, eol_)) + outfile.write('<%sstringVal1>%s</%sstringVal1>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.stringVal1), input_name='stringVal1')), namespace_, eol_)) for stringVal2_ in self.stringVal2: showIndent(outfile, level, pretty_print) - outfile.write('<%sstringVal2>%s</%sstringVal2>%s' % (namespace_, self.gds_format_string(quote_xml(stringVal2_).encode(ExternalEncoding), input_name='stringVal2'), namespace_, eol_)) + outfile.write('<%sstringVal2>%s</%sstringVal2>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(stringVal2_), input_name='stringVal2')), namespace_, eol_)) if self.booleanVal1 is not None: showIndent(outfile, level, pretty_print) outfile.write('<%sbooleanVal1>%s</%sbooleanVal1>%s' % (namespace_, self.gds_format_boolean(self.booleanVal1, input_name='booleanVal1'), namespace_, eol_)) diff --git a/tests/test.py b/tests/test.py index 2a91d75..64df9a0 100755 --- a/tests/test.py +++ b/tests/test.py @@ -657,7 +657,7 @@ class GenTest(unittest.TestCase): def test_029_defaults_cases(self): cmdTempl = ( 'python generateDS.py --no-dates --no-versions ' - '--silence --member-specs=list -f ' + '--member-specs=list -f ' '-o tests/%s2_sup.py -s tests/%s2_sub.py ' '--super=%s2_sup ' 'tests/%s.xsd' diff --git a/tests/to_etree1_sup.py b/tests/to_etree1_sup.py index b513bbb..c697e58 100644 --- a/tests/to_etree1_sup.py +++ b/tests/to_etree1_sup.py @@ -35,6 +35,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -354,6 +358,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -408,7 +418,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -430,7 +440,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -1215,17 +1225,17 @@ class programmerType(personType): self.elnonposint = elnonposint self.elnegint = elnegint self.elnonnegint = elnonnegint - if isinstance(eldate, basestring): + if isinstance(eldate, BaseStrType_): initvalue_ = datetime_.datetime.strptime(eldate, '%Y-%m-%d').date() else: initvalue_ = eldate self.eldate = initvalue_ - if isinstance(eldatetime, basestring): + if isinstance(eldatetime, BaseStrType_): initvalue_ = datetime_.datetime.strptime(eldatetime, '%Y-%m-%dT%H:%M:%S') else: initvalue_ = eldatetime self.eldatetime = initvalue_ - if isinstance(eldatetime1, basestring): + if isinstance(eldatetime1, BaseStrType_): initvalue_ = datetime_.datetime.strptime(eldatetime1, '%Y-%m-%dT%H:%M:%S') else: initvalue_ = eldatetime1 @@ -2688,7 +2698,7 @@ class hot_agent(GeneratedsSuper): self.firstname = firstname self.lastname = lastname self.priority = priority - if isinstance(startDate, basestring): + if isinstance(startDate, BaseStrType_): initvalue_ = datetime_.datetime.strptime(startDate, '%Y-%m-%d').date() else: initvalue_ = startDate diff --git a/tests/to_etree2_sup.py b/tests/to_etree2_sup.py index b513bbb..c697e58 100644 --- a/tests/to_etree2_sup.py +++ b/tests/to_etree2_sup.py @@ -35,6 +35,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -354,6 +358,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -408,7 +418,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -430,7 +440,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -1215,17 +1225,17 @@ class programmerType(personType): self.elnonposint = elnonposint self.elnegint = elnegint self.elnonnegint = elnonnegint - if isinstance(eldate, basestring): + if isinstance(eldate, BaseStrType_): initvalue_ = datetime_.datetime.strptime(eldate, '%Y-%m-%d').date() else: initvalue_ = eldate self.eldate = initvalue_ - if isinstance(eldatetime, basestring): + if isinstance(eldatetime, BaseStrType_): initvalue_ = datetime_.datetime.strptime(eldatetime, '%Y-%m-%dT%H:%M:%S') else: initvalue_ = eldatetime self.eldatetime = initvalue_ - if isinstance(eldatetime1, basestring): + if isinstance(eldatetime1, BaseStrType_): initvalue_ = datetime_.datetime.strptime(eldatetime1, '%Y-%m-%dT%H:%M:%S') else: initvalue_ = eldatetime1 @@ -2688,7 +2698,7 @@ class hot_agent(GeneratedsSuper): self.firstname = firstname self.lastname = lastname self.priority = priority - if isinstance(startDate, basestring): + if isinstance(startDate, BaseStrType_): initvalue_ = datetime_.datetime.strptime(startDate, '%Y-%m-%d').date() else: initvalue_ = startDate diff --git a/tests/validate_simpletypes1_sup.py b/tests/validate_simpletypes1_sup.py index 03eb674..30547aa 100644 --- a/tests/validate_simpletypes1_sup.py +++ b/tests/validate_simpletypes1_sup.py @@ -32,6 +32,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -351,6 +355,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -405,7 +415,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -427,7 +437,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -974,13 +984,13 @@ class simpleOneType(GeneratedsSuper): outfile.write('<%sinteger_range_1_value>%s</%sinteger_range_1_value>%s' % (namespace_, self.gds_format_integer(self.integer_range_1_value, input_name='integer_range_1_value'), namespace_, eol_)) if self.pattern_value is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%spattern_value>%s</%spattern_value>%s' % (namespace_, self.gds_format_string(quote_xml(self.pattern_value).encode(ExternalEncoding), input_name='pattern_value'), namespace_, eol_)) + outfile.write('<%spattern_value>%s</%spattern_value>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.pattern_value), input_name='pattern_value')), namespace_, eol_)) if self.token_enum_value is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%stoken_enum_value>%s</%stoken_enum_value>%s' % (namespace_, self.gds_format_string(quote_xml(self.token_enum_value).encode(ExternalEncoding), input_name='token_enum_value'), namespace_, eol_)) + outfile.write('<%stoken_enum_value>%s</%stoken_enum_value>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.token_enum_value), input_name='token_enum_value')), namespace_, eol_)) if self.token_enum_value is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%stoken_enum_value>%s</%stoken_enum_value>%s' % (namespace_, self.gds_format_string(quote_xml(self.token_enum_value).encode(ExternalEncoding), input_name='token_enum_value'), namespace_, eol_)) + outfile.write('<%stoken_enum_value>%s</%stoken_enum_value>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.token_enum_value), input_name='token_enum_value')), namespace_, eol_)) if self.integer_range_incl_value is not None: showIndent(outfile, level, pretty_print) outfile.write('<%sinteger_range_incl_value>%s</%sinteger_range_incl_value>%s' % (namespace_, self.gds_format_integer(self.integer_range_incl_value, input_name='integer_range_incl_value'), namespace_, eol_)) @@ -989,10 +999,10 @@ class simpleOneType(GeneratedsSuper): outfile.write('<%sinteger_range_excl_value>%s</%sinteger_range_excl_value>%s' % (namespace_, self.gds_format_integer(self.integer_range_excl_value, input_name='integer_range_excl_value'), namespace_, eol_)) if self.min_max_length_value is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%smin_max_length_value>%s</%smin_max_length_value>%s' % (namespace_, self.gds_format_string(quote_xml(self.min_max_length_value).encode(ExternalEncoding), input_name='min_max_length_value'), namespace_, eol_)) + outfile.write('<%smin_max_length_value>%s</%smin_max_length_value>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.min_max_length_value), input_name='min_max_length_value')), namespace_, eol_)) if self.length_value is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%slength_value>%s</%slength_value>%s' % (namespace_, self.gds_format_string(quote_xml(self.length_value).encode(ExternalEncoding), input_name='length_value'), namespace_, eol_)) + outfile.write('<%slength_value>%s</%slength_value>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.length_value), input_name='length_value')), namespace_, eol_)) if self.totalDigits_value is not None: showIndent(outfile, level, pretty_print) outfile.write('<%stotalDigits_value>%s</%stotalDigits_value>%s' % (namespace_, self.gds_format_float(self.totalDigits_value, input_name='totalDigits_value'), namespace_, eol_)) @@ -1252,7 +1262,7 @@ class simpleTwoElementOneType(GeneratedsSuper): eol_ = '' if self.simpleTwoElementTwo is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%ssimpleTwoElementTwo>%s</%ssimpleTwoElementTwo>%s' % (namespace_, self.gds_format_string(quote_xml(self.simpleTwoElementTwo).encode(ExternalEncoding), input_name='simpleTwoElementTwo'), namespace_, eol_)) + outfile.write('<%ssimpleTwoElementTwo>%s</%ssimpleTwoElementTwo>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.simpleTwoElementTwo), input_name='simpleTwoElementTwo')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) diff --git a/tests/validate_simpletypes1_warnings.txt b/tests/validate_simpletypes1_warnings.txt index 243afed..a6a01c2 100644 --- a/tests/validate_simpletypes1_warnings.txt +++ b/tests/validate_simpletypes1_warnings.txt @@ -1,34 +1,34 @@ -tests/validate_simpletypes2_sup.py:867: UserWarning: Value "2" does not match xsd minExclusive restriction on integer_range_1_st +tests/validate_simpletypes2_sup.py:877: UserWarning: Value "2" does not match xsd minExclusive restriction on integer_range_1_st warnings_.warn('Value "%(value)s" does not match xsd minExclusive restriction on integer_range_1_st' % {"value" : value} ) -tests/validate_simpletypes2_sup.py:877: UserWarning: Value "mmaaa1234mnopzzz" does not match xsd pattern restrictions: [['^aaa.*zzz$', '^bbb.*xxx$'], ['^.*123.*$', '^.*456.*$']] +tests/validate_simpletypes2_sup.py:887: UserWarning: Value "mmaaa1234mnopzzz" does not match xsd pattern restrictions: [['^aaa.*zzz$', '^bbb.*xxx$'], ['^.*123.*$', '^.*456.*$']] warnings_.warn('Value "%s" does not match xsd pattern restrictions: %s' % (value.encode('utf-8'), self.validate_pattern_st_patterns_, )) -tests/validate_simpletypes2_sup.py:890: UserWarning: Value "floatxx" does not match xsd enumeration restriction on token_enum_st +tests/validate_simpletypes2_sup.py:900: UserWarning: Value "floatxx" does not match xsd enumeration restriction on token_enum_st warnings_.warn('Value "%(value)s" does not match xsd enumeration restriction on token_enum_st' % {"value" : value.encode("utf-8")} ) -tests/validate_simpletypes2_sup.py:897: UserWarning: Value "22" does not match xsd maxInclusive restriction on integer_range_incl_st +tests/validate_simpletypes2_sup.py:907: UserWarning: Value "22" does not match xsd maxInclusive restriction on integer_range_incl_st warnings_.warn('Value "%(value)s" does not match xsd maxInclusive restriction on integer_range_incl_st' % {"value" : value} ) -tests/validate_simpletypes2_sup.py:902: UserWarning: Value "-40" does not match xsd minExclusive restriction on integer_range_excl_st +tests/validate_simpletypes2_sup.py:912: UserWarning: Value "-40" does not match xsd minExclusive restriction on integer_range_excl_st warnings_.warn('Value "%(value)s" does not match xsd minExclusive restriction on integer_range_excl_st' % {"value" : value} ) -tests/validate_simpletypes2_sup.py:911: UserWarning: Value "mno pqr" does not match xsd minLength restriction on min_max_length_st +tests/validate_simpletypes2_sup.py:921: UserWarning: Value "mno pqr" does not match xsd minLength restriction on min_max_length_st warnings_.warn('Value "%(value)s" does not match xsd minLength restriction on min_max_length_st' % {"value" : value.encode("utf-8")} ) -tests/validate_simpletypes2_sup.py:916: UserWarning: Value "012345" does not match xsd length restriction on length_st +tests/validate_simpletypes2_sup.py:926: UserWarning: Value "012345" does not match xsd length restriction on length_st warnings_.warn('Value "%(value)s" does not match xsd length restriction on length_st' % {"value" : value.encode("utf-8")} ) -tests/validate_simpletypes2_sup.py:926: UserWarning: Value "0.2" does not match xsd minInclusive restriction on anonymous_float_valueType +tests/validate_simpletypes2_sup.py:936: UserWarning: Value "0.2" does not match xsd minInclusive restriction on anonymous_float_valueType warnings_.warn('Value "%(value)s" does not match xsd minInclusive restriction on anonymous_float_valueType' % {"value" : value} ) -tests/validate_simpletypes2_sup.py:869: UserWarning: Value "9" does not match xsd maxExclusive restriction on integer_range_1_st +tests/validate_simpletypes2_sup.py:879: UserWarning: Value "9" does not match xsd maxExclusive restriction on integer_range_1_st warnings_.warn('Value "%(value)s" does not match xsd maxExclusive restriction on integer_range_1_st' % {"value" : value} ) -tests/validate_simpletypes2_sup.py:877: UserWarning: Value "aaa1234mnopzzzbcd" does not match xsd pattern restrictions: [['^aaa.*zzz$', '^bbb.*xxx$'], ['^.*123.*$', '^.*456.*$']] +tests/validate_simpletypes2_sup.py:887: UserWarning: Value "aaa1234mnopzzzbcd" does not match xsd pattern restrictions: [['^aaa.*zzz$', '^bbb.*xxx$'], ['^.*123.*$', '^.*456.*$']] warnings_.warn('Value "%s" does not match xsd pattern restrictions: %s' % (value.encode('utf-8'), self.validate_pattern_st_patterns_, )) -tests/validate_simpletypes2_sup.py:895: UserWarning: Value "-50" does not match xsd minInclusive restriction on integer_range_incl_st +tests/validate_simpletypes2_sup.py:905: UserWarning: Value "-50" does not match xsd minInclusive restriction on integer_range_incl_st warnings_.warn('Value "%(value)s" does not match xsd minInclusive restriction on integer_range_incl_st' % {"value" : value} ) -tests/validate_simpletypes2_sup.py:909: UserWarning: Value "asdf asdf asdf asdf asdf asdf" does not match xsd maxLength restriction on min_max_length_st +tests/validate_simpletypes2_sup.py:919: UserWarning: Value "asdf asdf asdf asdf asdf asdf" does not match xsd maxLength restriction on min_max_length_st warnings_.warn('Value "%(value)s" does not match xsd maxLength restriction on min_max_length_st' % {"value" : value.encode("utf-8")} ) -tests/validate_simpletypes2_sup.py:916: UserWarning: Value "01234567890" does not match xsd length restriction on length_st +tests/validate_simpletypes2_sup.py:926: UserWarning: Value "01234567890" does not match xsd length restriction on length_st warnings_.warn('Value "%(value)s" does not match xsd length restriction on length_st' % {"value" : value.encode("utf-8")} ) -tests/validate_simpletypes2_sup.py:928: UserWarning: Value "6.6" does not match xsd maxInclusive restriction on anonymous_float_valueType +tests/validate_simpletypes2_sup.py:938: UserWarning: Value "6.6" does not match xsd maxInclusive restriction on anonymous_float_valueType warnings_.warn('Value "%(value)s" does not match xsd maxInclusive restriction on anonymous_float_valueType' % {"value" : value} ) -tests/validate_simpletypes2_sup.py:874: UserWarning: Value "aaa12zzz" does not match xsd minLength restriction on pattern_st +tests/validate_simpletypes2_sup.py:884: UserWarning: Value "aaa12zzz" does not match xsd minLength restriction on pattern_st warnings_.warn('Value "%(value)s" does not match xsd minLength restriction on pattern_st' % {"value" : value} ) -tests/validate_simpletypes2_sup.py:877: UserWarning: Value "aaa12zzz" does not match xsd pattern restrictions: [['^aaa.*zzz$', '^bbb.*xxx$'], ['^.*123.*$', '^.*456.*$']] +tests/validate_simpletypes2_sup.py:887: UserWarning: Value "aaa12zzz" does not match xsd pattern restrictions: [['^aaa.*zzz$', '^bbb.*xxx$'], ['^.*123.*$', '^.*456.*$']] warnings_.warn('Value "%s" does not match xsd pattern restrictions: %s' % (value.encode('utf-8'), self.validate_pattern_st_patterns_, )) -tests/validate_simpletypes2_sup.py:1220: UserWarning: Value "pqrst" does not match xsd minLength restriction on simpleTwoElementTwoType +tests/validate_simpletypes2_sup.py:1230: UserWarning: Value "pqrst" does not match xsd minLength restriction on simpleTwoElementTwoType warnings_.warn('Value "%(value)s" does not match xsd minLength restriction on simpleTwoElementTwoType' % {"value" : value.encode("utf-8")} ) diff --git a/tests/validate_simpletypes2_sup.py b/tests/validate_simpletypes2_sup.py index 03eb674..30547aa 100644 --- a/tests/validate_simpletypes2_sup.py +++ b/tests/validate_simpletypes2_sup.py @@ -32,6 +32,10 @@ from lxml import etree as etree_ Validate_simpletypes_ = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str def parsexml_(infile, parser=None, **kwargs): @@ -351,6 +355,12 @@ except ImportError as exp: @classmethod def gds_reverse_node_mapping(cls, mapping): return dict(((v, k) for k, v in mapping.iteritems())) + @staticmethod + def gds_encode(instring): + if sys.version_info.major == 2: + return instring.encode(ExternalEncoding) + else: + return instring def getSubclassFromModule_(module, class_): '''Get the subclass of a class from a specific module.''' @@ -405,7 +415,7 @@ def quote_xml(inStr): "Escape markup chars, but do not modify CDATA sections." if not inStr: return '' - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s2 = '' pos = 0 matchobjects = CDATA_pattern_.finditer(s1) @@ -427,7 +437,7 @@ def quote_xml_aux(inStr): def quote_attrib(inStr): - s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) + s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') @@ -974,13 +984,13 @@ class simpleOneType(GeneratedsSuper): outfile.write('<%sinteger_range_1_value>%s</%sinteger_range_1_value>%s' % (namespace_, self.gds_format_integer(self.integer_range_1_value, input_name='integer_range_1_value'), namespace_, eol_)) if self.pattern_value is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%spattern_value>%s</%spattern_value>%s' % (namespace_, self.gds_format_string(quote_xml(self.pattern_value).encode(ExternalEncoding), input_name='pattern_value'), namespace_, eol_)) + outfile.write('<%spattern_value>%s</%spattern_value>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.pattern_value), input_name='pattern_value')), namespace_, eol_)) if self.token_enum_value is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%stoken_enum_value>%s</%stoken_enum_value>%s' % (namespace_, self.gds_format_string(quote_xml(self.token_enum_value).encode(ExternalEncoding), input_name='token_enum_value'), namespace_, eol_)) + outfile.write('<%stoken_enum_value>%s</%stoken_enum_value>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.token_enum_value), input_name='token_enum_value')), namespace_, eol_)) if self.token_enum_value is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%stoken_enum_value>%s</%stoken_enum_value>%s' % (namespace_, self.gds_format_string(quote_xml(self.token_enum_value).encode(ExternalEncoding), input_name='token_enum_value'), namespace_, eol_)) + outfile.write('<%stoken_enum_value>%s</%stoken_enum_value>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.token_enum_value), input_name='token_enum_value')), namespace_, eol_)) if self.integer_range_incl_value is not None: showIndent(outfile, level, pretty_print) outfile.write('<%sinteger_range_incl_value>%s</%sinteger_range_incl_value>%s' % (namespace_, self.gds_format_integer(self.integer_range_incl_value, input_name='integer_range_incl_value'), namespace_, eol_)) @@ -989,10 +999,10 @@ class simpleOneType(GeneratedsSuper): outfile.write('<%sinteger_range_excl_value>%s</%sinteger_range_excl_value>%s' % (namespace_, self.gds_format_integer(self.integer_range_excl_value, input_name='integer_range_excl_value'), namespace_, eol_)) if self.min_max_length_value is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%smin_max_length_value>%s</%smin_max_length_value>%s' % (namespace_, self.gds_format_string(quote_xml(self.min_max_length_value).encode(ExternalEncoding), input_name='min_max_length_value'), namespace_, eol_)) + outfile.write('<%smin_max_length_value>%s</%smin_max_length_value>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.min_max_length_value), input_name='min_max_length_value')), namespace_, eol_)) if self.length_value is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%slength_value>%s</%slength_value>%s' % (namespace_, self.gds_format_string(quote_xml(self.length_value).encode(ExternalEncoding), input_name='length_value'), namespace_, eol_)) + outfile.write('<%slength_value>%s</%slength_value>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.length_value), input_name='length_value')), namespace_, eol_)) if self.totalDigits_value is not None: showIndent(outfile, level, pretty_print) outfile.write('<%stotalDigits_value>%s</%stotalDigits_value>%s' % (namespace_, self.gds_format_float(self.totalDigits_value, input_name='totalDigits_value'), namespace_, eol_)) @@ -1252,7 +1262,7 @@ class simpleTwoElementOneType(GeneratedsSuper): eol_ = '' if self.simpleTwoElementTwo is not None: showIndent(outfile, level, pretty_print) - outfile.write('<%ssimpleTwoElementTwo>%s</%ssimpleTwoElementTwo>%s' % (namespace_, self.gds_format_string(quote_xml(self.simpleTwoElementTwo).encode(ExternalEncoding), input_name='simpleTwoElementTwo'), namespace_, eol_)) + outfile.write('<%ssimpleTwoElementTwo>%s</%ssimpleTwoElementTwo>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.simpleTwoElementTwo), input_name='simpleTwoElementTwo')), namespace_, eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) diff --git a/tests/validate_simpletypes2_warnings.txt b/tests/validate_simpletypes2_warnings.txt index 243afed..a6a01c2 100644 --- a/tests/validate_simpletypes2_warnings.txt +++ b/tests/validate_simpletypes2_warnings.txt @@ -1,34 +1,34 @@ -tests/validate_simpletypes2_sup.py:867: UserWarning: Value "2" does not match xsd minExclusive restriction on integer_range_1_st +tests/validate_simpletypes2_sup.py:877: UserWarning: Value "2" does not match xsd minExclusive restriction on integer_range_1_st warnings_.warn('Value "%(value)s" does not match xsd minExclusive restriction on integer_range_1_st' % {"value" : value} ) -tests/validate_simpletypes2_sup.py:877: UserWarning: Value "mmaaa1234mnopzzz" does not match xsd pattern restrictions: [['^aaa.*zzz$', '^bbb.*xxx$'], ['^.*123.*$', '^.*456.*$']] +tests/validate_simpletypes2_sup.py:887: UserWarning: Value "mmaaa1234mnopzzz" does not match xsd pattern restrictions: [['^aaa.*zzz$', '^bbb.*xxx$'], ['^.*123.*$', '^.*456.*$']] warnings_.warn('Value "%s" does not match xsd pattern restrictions: %s' % (value.encode('utf-8'), self.validate_pattern_st_patterns_, )) -tests/validate_simpletypes2_sup.py:890: UserWarning: Value "floatxx" does not match xsd enumeration restriction on token_enum_st +tests/validate_simpletypes2_sup.py:900: UserWarning: Value "floatxx" does not match xsd enumeration restriction on token_enum_st warnings_.warn('Value "%(value)s" does not match xsd enumeration restriction on token_enum_st' % {"value" : value.encode("utf-8")} ) -tests/validate_simpletypes2_sup.py:897: UserWarning: Value "22" does not match xsd maxInclusive restriction on integer_range_incl_st +tests/validate_simpletypes2_sup.py:907: UserWarning: Value "22" does not match xsd maxInclusive restriction on integer_range_incl_st warnings_.warn('Value "%(value)s" does not match xsd maxInclusive restriction on integer_range_incl_st' % {"value" : value} ) -tests/validate_simpletypes2_sup.py:902: UserWarning: Value "-40" does not match xsd minExclusive restriction on integer_range_excl_st +tests/validate_simpletypes2_sup.py:912: UserWarning: Value "-40" does not match xsd minExclusive restriction on integer_range_excl_st warnings_.warn('Value "%(value)s" does not match xsd minExclusive restriction on integer_range_excl_st' % {"value" : value} ) -tests/validate_simpletypes2_sup.py:911: UserWarning: Value "mno pqr" does not match xsd minLength restriction on min_max_length_st +tests/validate_simpletypes2_sup.py:921: UserWarning: Value "mno pqr" does not match xsd minLength restriction on min_max_length_st warnings_.warn('Value "%(value)s" does not match xsd minLength restriction on min_max_length_st' % {"value" : value.encode("utf-8")} ) -tests/validate_simpletypes2_sup.py:916: UserWarning: Value "012345" does not match xsd length restriction on length_st +tests/validate_simpletypes2_sup.py:926: UserWarning: Value "012345" does not match xsd length restriction on length_st warnings_.warn('Value "%(value)s" does not match xsd length restriction on length_st' % {"value" : value.encode("utf-8")} ) -tests/validate_simpletypes2_sup.py:926: UserWarning: Value "0.2" does not match xsd minInclusive restriction on anonymous_float_valueType +tests/validate_simpletypes2_sup.py:936: UserWarning: Value "0.2" does not match xsd minInclusive restriction on anonymous_float_valueType warnings_.warn('Value "%(value)s" does not match xsd minInclusive restriction on anonymous_float_valueType' % {"value" : value} ) -tests/validate_simpletypes2_sup.py:869: UserWarning: Value "9" does not match xsd maxExclusive restriction on integer_range_1_st +tests/validate_simpletypes2_sup.py:879: UserWarning: Value "9" does not match xsd maxExclusive restriction on integer_range_1_st warnings_.warn('Value "%(value)s" does not match xsd maxExclusive restriction on integer_range_1_st' % {"value" : value} ) -tests/validate_simpletypes2_sup.py:877: UserWarning: Value "aaa1234mnopzzzbcd" does not match xsd pattern restrictions: [['^aaa.*zzz$', '^bbb.*xxx$'], ['^.*123.*$', '^.*456.*$']] +tests/validate_simpletypes2_sup.py:887: UserWarning: Value "aaa1234mnopzzzbcd" does not match xsd pattern restrictions: [['^aaa.*zzz$', '^bbb.*xxx$'], ['^.*123.*$', '^.*456.*$']] warnings_.warn('Value "%s" does not match xsd pattern restrictions: %s' % (value.encode('utf-8'), self.validate_pattern_st_patterns_, )) -tests/validate_simpletypes2_sup.py:895: UserWarning: Value "-50" does not match xsd minInclusive restriction on integer_range_incl_st +tests/validate_simpletypes2_sup.py:905: UserWarning: Value "-50" does not match xsd minInclusive restriction on integer_range_incl_st warnings_.warn('Value "%(value)s" does not match xsd minInclusive restriction on integer_range_incl_st' % {"value" : value} ) -tests/validate_simpletypes2_sup.py:909: UserWarning: Value "asdf asdf asdf asdf asdf asdf" does not match xsd maxLength restriction on min_max_length_st +tests/validate_simpletypes2_sup.py:919: UserWarning: Value "asdf asdf asdf asdf asdf asdf" does not match xsd maxLength restriction on min_max_length_st warnings_.warn('Value "%(value)s" does not match xsd maxLength restriction on min_max_length_st' % {"value" : value.encode("utf-8")} ) -tests/validate_simpletypes2_sup.py:916: UserWarning: Value "01234567890" does not match xsd length restriction on length_st +tests/validate_simpletypes2_sup.py:926: UserWarning: Value "01234567890" does not match xsd length restriction on length_st warnings_.warn('Value "%(value)s" does not match xsd length restriction on length_st' % {"value" : value.encode("utf-8")} ) -tests/validate_simpletypes2_sup.py:928: UserWarning: Value "6.6" does not match xsd maxInclusive restriction on anonymous_float_valueType +tests/validate_simpletypes2_sup.py:938: UserWarning: Value "6.6" does not match xsd maxInclusive restriction on anonymous_float_valueType warnings_.warn('Value "%(value)s" does not match xsd maxInclusive restriction on anonymous_float_valueType' % {"value" : value} ) -tests/validate_simpletypes2_sup.py:874: UserWarning: Value "aaa12zzz" does not match xsd minLength restriction on pattern_st +tests/validate_simpletypes2_sup.py:884: UserWarning: Value "aaa12zzz" does not match xsd minLength restriction on pattern_st warnings_.warn('Value "%(value)s" does not match xsd minLength restriction on pattern_st' % {"value" : value} ) -tests/validate_simpletypes2_sup.py:877: UserWarning: Value "aaa12zzz" does not match xsd pattern restrictions: [['^aaa.*zzz$', '^bbb.*xxx$'], ['^.*123.*$', '^.*456.*$']] +tests/validate_simpletypes2_sup.py:887: UserWarning: Value "aaa12zzz" does not match xsd pattern restrictions: [['^aaa.*zzz$', '^bbb.*xxx$'], ['^.*123.*$', '^.*456.*$']] warnings_.warn('Value "%s" does not match xsd pattern restrictions: %s' % (value.encode('utf-8'), self.validate_pattern_st_patterns_, )) -tests/validate_simpletypes2_sup.py:1220: UserWarning: Value "pqrst" does not match xsd minLength restriction on simpleTwoElementTwoType +tests/validate_simpletypes2_sup.py:1230: UserWarning: Value "pqrst" does not match xsd minLength restriction on simpleTwoElementTwoType warnings_.warn('Value "%(value)s" does not match xsd minLength restriction on simpleTwoElementTwoType' % {"value" : value.encode("utf-8")} ) diff --git a/tutorial/generateds_tutorial.html b/tutorial/generateds_tutorial.html index fc9f849..22ee4cc 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.18a</td> +<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.19a</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">December 16, 2015</td> +<tr class="field"><th class="field-name">date:</th><td class="field-body">February 08, 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: 2015-12-16 20:55 UTC. +Generated on: 2016-02-08 18:02 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.zip b/tutorial/generateds_tutorial.zip index 7c6fdd6a07d61e2adbceea14687cf1481b23ffa9..4d95f7ed52838130fc7596ee8b3d3f2c351bf979 100644 GIT binary patch delta 11980 zcmV;-E;G^m`~rdf0uoS50|XQR000O8Y)3Fi4L7EokrF5e>voz}8`!v!K_Y*tfh=v7 zLldAtGqh7rC(&o2vS>(hE(Y@BOUmbbc*qbfmMQY-@$u>A<}<50V8Ey|-u{C18nz)v zvV+Nv0_b4jVaODn_SL7*Z>p-+LvAV7aH}5?ehjVebl|A95mTzc{+mK@uJZ~kC%ptL zafITb0$y#-eZAQnk4N<;Ny&e4r4-x}1j^8nb<GI5MQF%-I=XOxM~q4OG1PS!a#8~L z(BcR>A`A&F>_-@S%QBpDRX?hNd-~@-B0f6V)^Mf1eASCnsjcBzKF{T7+CqufaP|$( z>;;_tsW{hAKSp<Ga}D3;Eu5PbTwPvXztc%EO_#uu8HBl(u@p6AG}3=$q9z}u3zxxS zGSTfZ0hbtJZc}62Dco-#;LaHg3G1bt)N`1IXi(JL_$e)II+xd{A0>0#ryR9m((gFQ zWjrjmG)_Jl2Qn3=EOWV-8rbb#O~*p-c5rN+X<?2g_&Ks?f{3SqZ)Mnl-2&$g#R7s) zy6Zh&fblvp7i?T`a&>=NK@+JHM!)axAek0B{lZn1v7d-6!6Wwkk&c8edMsYy#%8b? zWvV`jT@;pr*XtB)GiaaaO+&qoiM_&^daC!N?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