Commit 6ed6e78b authored by Dave Kuhlman's avatar Dave Kuhlman

v. 2.29.16 -- Fixes for character encoding

parent 6d4930f8
......@@ -141,6 +141,18 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Change history
--------------
Version 2.29.16 (06/21/2018)
- Added dependencies to ``setup.py``. Thanks to Laszlo for this
suggestion.
- Fixes to specifying character encodings. We now read XML schema
files in binary mode. (2) We now use the value of
--external-encoding only when a generated module is run under
Python 2 (not Python 3); we use it to encode the XML instance
document; if --external-encoding was not used, then we use
"utf-8" to encode exported XML. Thanks to Laszlo for his
guidance on this.
Version 2.29.15 (05/16/2018)
- Fixed issue related to use of command line flag
......
......@@ -220,7 +220,7 @@ They are used by updateversion.py. -->
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.29.15</td>
<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.29.16</td>
</tr>
</tbody>
</table>
......@@ -229,7 +229,7 @@ They are used by updateversion.py. -->
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">date:</th><td class="field-body">May 16, 2018</td>
<tr class="field"><th class="field-name">date:</th><td class="field-body">June 22, 2018</td>
</tr>
</tbody>
</table>
......@@ -3386,7 +3386,7 @@ following among others:</p>
<div class="footer">
<hr class="footer" />
<a class="reference external" href="generateDS.txt">View document source</a>.
Generated on: 2018-05-16 18:03 UTC.
Generated on: 2018-06-22 18:15 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>
......
......@@ -225,7 +225,7 @@ _log = logging.getLogger(__name__)
# Do not modify the following VERSION comments.
# Used by updateversion.py.
##VERSION##
VERSION = '2.29.15'
VERSION = '2.29.16'
##VERSION##
BaseStrTypes = six.string_types
......@@ -252,7 +252,7 @@ NoDates = False
NoVersion = False
AlwaysExportDefault = False
Dirpath = []
ExternalEncoding = sys.getdefaultencoding()
ExternalEncoding = ''
Namespacedef = ''
NoNameSpaceDefs = False
CleanupNameList = [(re.compile('[-:.]'), '_')]
......@@ -5727,7 +5727,11 @@ class GeneratedsSuper(object):
@staticmethod
def gds_encode(instring):
if sys.version_info.major == 2:
return instring.encode(ExternalEncoding)
if ExternalEncoding:
encoding = ExternalEncoding
else:
encoding = 'utf-8'
return instring.encode(encoding)
else:
return instring
@staticmethod
......@@ -6908,7 +6912,7 @@ def parseAndGenerate(
if xschemaFileName == '-':
infile = sys.stdin
else:
infile = open(xschemaFileName, 'r')
infile = open(xschemaFileName, 'rb')
if SingleFileOutput:
parser = make_parser()
dh = XschemaHandler()
......@@ -7226,7 +7230,7 @@ def main():
processIncludes = 1
namespacedef = ''
NoNameSpaceDefs = False
ExternalEncoding = sys.getdefaultencoding()
ExternalEncoding = ''
NoDates = False
NoVersion = False
NoQuestions = False
......
......@@ -12,7 +12,7 @@ generateDS -- Generate Data Structures from XML Schema
.. version
:revision: 2.29.15
:revision: 2.29.16
.. version
......
......@@ -220,7 +220,7 @@ They are used by updateversion.py. -->
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.29.15</td>
<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.29.16</td>
</tr>
</tbody>
</table>
......@@ -229,7 +229,7 @@ They are used by updateversion.py. -->
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">date:</th><td class="field-body">May 16, 2018</td>
<tr class="field"><th class="field-name">date:</th><td class="field-body">June 22, 2018</td>
</tr>
</tbody>
</table>
......@@ -401,7 +401,7 @@ $ mv generateds_gui.mo locale/ru/LC_MESSAGES/
<div class="footer">
<hr class="footer" />
<a class="reference external" href="generateds_gui_notes.txt">View document source</a>.
Generated on: 2018-05-16 18:03 UTC.
Generated on: 2018-06-22 18:15 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>
......
......@@ -12,7 +12,7 @@ GenerateDS GUI Notes
.. version
:revision: 2.29.15
:revision: 2.29.16
.. version
......
......@@ -41,7 +41,7 @@ from libgenerateDS.gui import generateds_gui_session
# Do not modify the following VERSION comments.
# Used by updateversion.py.
##VERSION##
VERSION = '2.29.15'
VERSION = '2.29.16'
##VERSION##
......
......@@ -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.29.15</td>
<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.29.16</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">May 16, 2018</td>
<tr class="field"><th class="field-name">date:</th><td class="field-body">June 22, 2018</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: 2018-05-16 18:03 UTC.
Generated on: 2018-06-22 18:15 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>
......
......@@ -8,7 +8,7 @@ How to package a generateDS.py generated library
.. version
:revision: 2.29.15
:revision: 2.29.16
.. version
......
......@@ -40,7 +40,7 @@ except ImportError:
# Do not modify the following VERSION comments.
# Used by updateversion.py.
##VERSION##
VERSION = '2.29.15'
VERSION = '2.29.16'
##VERSION##
CatalogDict = {}
......@@ -63,7 +63,7 @@ def load_catalog(catalogpath):
global CatalogBaseUrl
if catalogpath:
CatalogBaseUrl = os.path.split(catalogpath)[0]
catalog = etree.parse(open(catalogpath))
catalog = etree.parse(open(catalogpath, "rb"))
for elements in catalog.getroot().findall(
"{urn:oasis:names:tc:entity:xmlns:xml:catalog}public"):
CatalogDict[elements.get("publicId")] = elements.get("uri")
......@@ -95,6 +95,7 @@ def get_all_root_file_paths(
catalogpath=None,
shallow=False):
load_catalog(catalogpath)
# Note: infile has been opened in binary mode.
doc1 = etree.parse(infile)
root1 = doc1.getroot()
rootPaths = []
......@@ -319,6 +320,7 @@ def make_file(outFileName, options):
def prep_schema_doc(infile, outfile, inpath, options):
# Note: infile has been opened in binary mode.
doc1 = etree.parse(infile)
root1 = doc1.getroot()
params = Params()
......@@ -348,7 +350,7 @@ def prep_schema_doc(infile, outfile, inpath, options):
def prep_schema(inpath, outpath, options):
if inpath:
infile = open(inpath, 'r')
infile = open(inpath, 'rb')
else:
infile = sys.stdin
if outpath:
......
......@@ -2,12 +2,13 @@
#from distutils.core import setup
from setuptools import setup
setup(name="generateDS",
setup(
name="generateDS",
#
# Do not modify the following VERSION comments.
# Used by updateversion.py.
##VERSION##
version="2.29.15",
version="2.29.16",
##VERSION##
author="Dave Kuhlman",
author_email="dkuhlman@davekuhlman.org",
......@@ -26,20 +27,14 @@ methods to the subclasses in order to process the contents of an
XML document.""",
platforms="platform-independent",
license="http://www.opensource.org/licenses/mit-license.php",
## py_modules=[
## "generateDS",
## "process_includes",
## "gui.generateds_gui",
## "gui.generateds_gui_session",
## ],
py_modules=[
"process_includes",
],
],
# include_package_data=True,
packages = [
packages=[
"libgenerateDS",
"libgenerateDS.gui",
],
],
scripts=[
"generateDS.py",
"process_includes.py",
......@@ -47,8 +42,8 @@ XML document.""",
"django/gends_run_gen_django.py",
"django/gends_extract_simple_types.py",
"django/gends_generate_django.py",
],
entry_points = {
],
entry_points={
"console_scripts": [
"generateDS = generateDS:main",
"process_includes = process_includes:main",
......@@ -57,6 +52,9 @@ XML document.""",
"gends_extract_simple_types = gends_extract_simple_types:main",
"gends_generate_django = gends_generate_django:main",
],
}
)
},
install_requires=[
"six",
"lxml",
],
)
......@@ -406,7 +406,11 @@ except ImportError as exp:
@staticmethod
def gds_encode(instring):
if sys.version_info.major == 2:
return instring.encode(ExternalEncoding)
if ExternalEncoding:
encoding = ExternalEncoding
else:
encoding = 'utf-8'
return instring.encode(encoding)
else:
return instring
@staticmethod
......@@ -453,7 +457,7 @@ except ImportError as exp:
# Globals
#
ExternalEncoding = 'ascii'
ExternalEncoding = ''
Tag_pattern_ = re_.compile(r'({.*})?(.*)')
String_cleanup_pat_ = re_.compile(r"[\n\r\s]+")
Namespace_extract_pat_ = re_.compile(r'{(.*)}(.*)')
......
......@@ -406,7 +406,11 @@ except ImportError as exp:
@staticmethod
def gds_encode(instring):
if sys.version_info.major == 2:
return instring.encode(ExternalEncoding)
if ExternalEncoding:
encoding = ExternalEncoding
else:
encoding = 'utf-8'
return instring.encode(encoding)
else:
return instring
@staticmethod
......@@ -453,7 +457,7 @@ except ImportError as exp:
# Globals
#
ExternalEncoding = 'ascii'
ExternalEncoding = ''
Tag_pattern_ = re_.compile(r'({.*})?(.*)')
String_cleanup_pat_ = re_.compile(r"[\n\r\s]+")
Namespace_extract_pat_ = re_.compile(r'{(.*)}(.*)')
......
......@@ -406,7 +406,11 @@ except ImportError as exp:
@staticmethod
def gds_encode(instring):
if sys.version_info.major == 2:
return instring.encode(ExternalEncoding)
if ExternalEncoding:
encoding = ExternalEncoding
else:
encoding = 'utf-8'
return instring.encode(encoding)
else:
return instring
@staticmethod
......@@ -453,7 +457,7 @@ except ImportError as exp:
# Globals
#
ExternalEncoding = 'ascii'
ExternalEncoding = ''
Tag_pattern_ = re_.compile(r'({.*})?(.*)')
String_cleanup_pat_ = re_.compile(r"[\n\r\s]+")
Namespace_extract_pat_ = re_.compile(r'{(.*)}(.*)')
......
......@@ -406,7 +406,11 @@ except ImportError as exp:
@staticmethod
def gds_encode(instring):
if sys.version_info.major == 2:
return instring.encode(ExternalEncoding)
if ExternalEncoding:
encoding = ExternalEncoding
else:
encoding = 'utf-8'
return instring.encode(encoding)
else:
return instring
@staticmethod
......@@ -453,7 +457,7 @@ except ImportError as exp:
# Globals
#
ExternalEncoding = 'ascii'
ExternalEncoding = ''
Tag_pattern_ = re_.compile(r'({.*})?(.*)')
String_cleanup_pat_ = re_.compile(r"[\n\r\s]+")
Namespace_extract_pat_ = re_.compile(r'{(.*)}(.*)')
......
......@@ -41,7 +41,7 @@ def parsexml_(infile, parser=None, **kwargs):
# Globals
#
ExternalEncoding = 'ascii'
ExternalEncoding = ''
#
# Data representation classes
......
......@@ -405,7 +405,11 @@ except ImportError as exp:
@staticmethod
def gds_encode(instring):
if sys.version_info.major == 2:
return instring.encode(ExternalEncoding)
if ExternalEncoding:
encoding = ExternalEncoding
else:
encoding = 'utf-8'
return instring.encode(encoding)
else:
return instring
@staticmethod
......@@ -452,7 +456,7 @@ except ImportError as exp:
# Globals
#
ExternalEncoding = 'ascii'
ExternalEncoding = ''
Tag_pattern_ = re_.compile(r'({.*})?(.*)')
String_cleanup_pat_ = re_.compile(r"[\n\r\s]+")
Namespace_extract_pat_ = re_.compile(r'{(.*)}(.*)')
......
......@@ -41,7 +41,7 @@ def parsexml_(infile, parser=None, **kwargs):
# Globals
#
ExternalEncoding = 'ascii'
ExternalEncoding = ''
#
# Data representation classes
......
......@@ -405,7 +405,11 @@ except ImportError as exp:
@staticmethod
def gds_encode(instring):
if sys.version_info.major == 2:
return instring.encode(ExternalEncoding)
if ExternalEncoding:
encoding = ExternalEncoding
else:
encoding = 'utf-8'
return instring.encode(encoding)
else:
return instring
@staticmethod
......@@ -452,7 +456,7 @@ except ImportError as exp:
# Globals
#
ExternalEncoding = 'ascii'
ExternalEncoding = ''
Tag_pattern_ = re_.compile(r'({.*})?(.*)')
String_cleanup_pat_ = re_.compile(r"[\n\r\s]+")
Namespace_extract_pat_ = re_.compile(r'{(.*)}(.*)')
......
......@@ -41,7 +41,7 @@ def parsexml_(infile, parser=None, **kwargs):
# Globals
#
ExternalEncoding = 'ascii'
ExternalEncoding = ''
#
# Data representation classes
......
......@@ -405,7 +405,11 @@ except ImportError as exp:
@staticmethod
def gds_encode(instring):
if sys.version_info.major == 2:
return instring.encode(ExternalEncoding)
if ExternalEncoding:
encoding = ExternalEncoding
else:
encoding = 'utf-8'
return instring.encode(encoding)
else:
return instring
@staticmethod
......@@ -452,7 +456,7 @@ except ImportError as exp:
# Globals
#
ExternalEncoding = 'ascii'
ExternalEncoding = ''
Tag_pattern_ = re_.compile(r'({.*})?(.*)')
String_cleanup_pat_ = re_.compile(r"[\n\r\s]+")
Namespace_extract_pat_ = re_.compile(r'{(.*)}(.*)')
......
......@@ -41,7 +41,7 @@ def parsexml_(infile, parser=None, **kwargs):
# Globals
#
ExternalEncoding = 'ascii'
ExternalEncoding = ''
#
# Data representation classes
......
......@@ -405,7 +405,11 @@ except ImportError as exp:
@staticmethod
def gds_encode(instring):
if sys.version_info.major == 2:
return instring.encode(ExternalEncoding)
if ExternalEncoding:
encoding = ExternalEncoding
else:
encoding = 'utf-8'
return instring.encode(encoding)
else:
return instring
@staticmethod
......@@ -452,7 +456,7 @@ except ImportError as exp:
# Globals
#
ExternalEncoding = 'ascii'
ExternalEncoding = ''
Tag_pattern_ = re_.compile(r'({.*})?(.*)')
String_cleanup_pat_ = re_.compile(r"[\n\r\s]+")
Namespace_extract_pat_ = re_.compile(r'{(.*)}(.*)')
......
......@@ -41,7 +41,7 @@ def parsexml_(infile, parser=None, **kwargs):
# Globals
#
ExternalEncoding = 'ascii'
ExternalEncoding = ''
#
# Data representation classes
......
......@@ -405,7 +405,11 @@ except ImportError as exp:
@staticmethod
def gds_encode(instring):
if sys.version_info.major == 2:
return instring.encode(ExternalEncoding)
if ExternalEncoding:
encoding = ExternalEncoding
else:
encoding = 'utf-8'
return instring.encode(encoding)
else:
return instring
@staticmethod
......@@ -452,7 +456,7 @@ except ImportError as exp:
# Globals
#
ExternalEncoding = 'ascii'
ExternalEncoding = ''
Tag_pattern_ = re_.compile(r'({.*})?(.*)')
String_cleanup_pat_ = re_.compile(r"[\n\r\s]+")
Namespace_extract_pat_ = re_.compile(r'{(.*)}(.*)')
......
......@@ -41,7 +41,7 @@ def parsexml_(infile, parser=None, **kwargs):
# Globals
#
ExternalEncoding = 'ascii'
ExternalEncoding = ''
#
# Data representation classes
......
......@@ -405,7 +405,11 @@ except ImportError as exp:
@staticmethod
def gds_encode(instring):
if sys.version_info.major == 2:
return instring.encode(ExternalEncoding)
if ExternalEncoding:
encoding = ExternalEncoding
else:
encoding = 'utf-8'
return instring.encode(encoding)
else:
return instring
@staticmethod
......@@ -452,7 +456,7 @@ except ImportError as exp:
# Globals
#
ExternalEncoding = 'ascii'
ExternalEncoding = ''
Tag_pattern_ = re_.compile(r'({.*})?(.*)')
String_cleanup_pat_ = re_.compile(r"[\n\r\s]+")
Namespace_extract_pat_ = re_.compile(r'{(.*)}(.*)')
......
......@@ -42,7 +42,7 @@ def parsexml_(infile, parser=None, **kwargs):
# Globals
#
ExternalEncoding = 'ascii'
ExternalEncoding = ''
#
# Data representation classes
......
......@@ -406,7 +406,11 @@ except ImportError as exp:
@staticmethod
def gds_encode(instring):
if sys.version_info.major == 2:
return instring.encode(ExternalEncoding)
if ExternalEncoding:
encoding = ExternalEncoding
else:
encoding = 'utf-8'
return instring.encode(encoding)
else:
return instring
@staticmethod
......@@ -453,7 +457,7 @@ except ImportError as exp:
# Globals
#
ExternalEncoding = 'ascii'
ExternalEncoding = ''
Tag_pattern_ = re_.compile(r'({.*})?(.*)')
String_cleanup_pat_ = re_.compile(r"[\n\r\s]+")
Namespace_extract_pat_ = re_.compile(r'{(.*)}(.*)')
......
......@@ -42,7 +42,7 @@ def parsexml_(infile, parser=None, **kwargs):
# Globals
#
ExternalEncoding = 'ascii'
ExternalEncoding = ''
#
# Data representation classes
......
......@@ -406,7 +406,11 @@ except ImportError as exp:
@staticmethod
def gds_encode(instring):
if sys.version_info.major == 2:
return instring.encode(ExternalEncoding)
if ExternalEncoding:
encoding = ExternalEncoding
else:
encoding = 'utf-8'
return instring.encode(encoding)
else:
return instring
@staticmethod
......@@ -453,7 +457,7 @@ except ImportError as exp:
# Globals
#
ExternalEncoding = 'ascii'