Commit 34354b6f authored by Dave Kuhlman's avatar Dave Kuhlman

v. 2.29.20 Fixes for regular expr validation and date/time formatting

parent bc48e9eb
......@@ -141,6 +141,17 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Change history
--------------
Version 2.29.20 (07/30/2018)
- Fix to generation of regular expression used to validate a
simpleType. Before this fix, we were replacing "|" with "$|^" to
implement alternatives in a test. By removing that replacement,
we leave it up to the author of the schema to encode that test of
alternatives into the regular expression. Thanks to Bernd
Zimmermann for reporting this issue.
- Fixes to formatting of xs:dateTime. Thanks to Tim Hulst for this
fix.
Version 2.29.19 (07/20/2018)
- Merged pull request that makes generated enums for each simpleType
......
......@@ -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.19</td>
<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.29.20</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">July 20, 2018</td>
<tr class="field"><th class="field-name">date:</th><td class="field-body">July 30, 2018</td>
</tr>
</tbody>
</table>
......@@ -3392,7 +3392,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-07-20 18:42 UTC.
Generated on: 2018-07-30 20:37 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>
......
......@@ -227,7 +227,7 @@ _log = logging.getLogger(__name__)
# Do not modify the following VERSION comments.
# Used by updateversion.py.
##VERSION##
VERSION = '2.29.19'
VERSION = '2.29.20'
##VERSION##
BaseStrTypes = six.string_types
......@@ -265,7 +265,7 @@ NameSeparationRegexList = [
re.compile("(.)([0-9]+)"),
re.compile("([0-9])([a-zA-Z])"),
re.compile("([a-z])([A-Z])")
]
]
NonAlphaNumRegex = re.compile(r"\W+")
NamespacesDict = {}
......@@ -617,7 +617,7 @@ class SimpleTypeElement(XschemaElementBase):
def getAttributeGroup(self):
return self.attributeGroup
def getEnumValues(self):
return self.values
......@@ -4400,7 +4400,8 @@ def processValidatorBodyRestrictions(
pats1 = restriction.xpath(
"./xs:pattern/@value", namespaces=ns)
if pats1:
pats2 = [u'^{}$'.format(replaceVbars(p1)) for p1 in pats1]
#pats2 = [u'^{}$'.format(replaceVbars(p1)) for p1 in pats1]
pats2 = [u'^{}$'.format(p1) for p1 in pats1]
patterns1.append(pats2)
#
# Check for and generate code for each possible type of restriction.
......@@ -5581,7 +5582,8 @@ class GeneratedsSuper(object):
time_parts = input_data.split('.')
if len(time_parts) > 1:
micro_seconds = int(float('0.' + time_parts[1]) * 1000000)
input_data = '%s.%s' % (time_parts[0], micro_seconds, )
input_data = '%s.%s' % (
time_parts[0], "{{}}".format(micro_seconds).rjust(6, "0"), )
dt = datetime_.datetime.strptime(
input_data, '%Y-%m-%dT%H:%M:%S.%f')
else:
......@@ -5669,14 +5671,15 @@ class GeneratedsSuper(object):
_svalue += '{{0:02d}}:{{1:02d}}'.format(hours, minutes)
return _svalue
def gds_validate_simple_patterns(self, patterns, target):
# pat is a list of lists of strings/patterns. We should:
# - AND the outer elements
# - OR the inner elements
# pat is a list of lists of strings/patterns.
# The target value must match at least one of the patterns
# in order for the test to succeed.
found1 = True
for patterns1 in patterns:
found2 = False
for patterns2 in patterns1:
if re_.search(patterns2, target) is not None:
mo = re_.fullmatch(patterns2, target)
if mo is not None:
found2 = True
break
if not found2:
......@@ -6686,6 +6689,7 @@ def generateFromTree(wrt, prefix, elements, processed):
def generateSimpleTypes(wrt, prefix, simpleTypeDict):
global UppercaseEnums
def value2Uppercase(value):
if UppercaseEnums:
# This will turn a string 'fooBar123' to 'foo_Bar_123'
......@@ -6694,9 +6698,9 @@ def generateSimpleTypes(wrt, prefix, simpleTypeDict):
value = value.upper()
value = NonAlphaNumRegex.sub("", value)
return value
def validateIdentifier(name):
name = value2Uppercase(name)
validPythonIdentifier = True
if not PythonIdentifierRegex.match(name):
# it may start with a digit
escapedName = '_%s' % name
......@@ -6705,13 +6709,13 @@ def generateSimpleTypes(wrt, prefix, simpleTypeDict):
else:
raise ValueError
return NameTable.get(name, name)
def writeEnumClass(simpleType):
enumValues = simpleType.getEnumValues()
if enumValues:
output = ""
try:
className = validateIdentifier(simpleType.getName())
validateIdentifier(simpleType.getName())
except ValueError:
err_msg(
'*** The Simple Type name "%s" is not a valid '
......@@ -6729,7 +6733,7 @@ def generateSimpleTypes(wrt, prefix, simpleTypeDict):
output += ' %s=\'%s\'\n' % (validatedEnumValue, enumValue)
wrt(output)
wrt('\n\n')
for simpletypeName in sorted(simpleTypeDict.keys()):
if ':' not in simpletypeName:
continue
......
......@@ -12,7 +12,7 @@ generateDS -- Generate Data Structures from XML Schema
.. version
:revision: 2.29.19
:revision: 2.29.20
.. 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.19</td>
<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.29.20</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">July 20, 2018</td>
<tr class="field"><th class="field-name">date:</th><td class="field-body">July 30, 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-07-20 18:42 UTC.
Generated on: 2018-07-30 20:37 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.19
:revision: 2.29.20
.. 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.19'
VERSION = '2.29.20'
##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.19</td>
<tr class="field"><th class="field-name">revision:</th><td class="field-body">2.29.20</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">July 20, 2018</td>
<tr class="field"><th class="field-name">date:</th><td class="field-body">July 30, 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-07-20 18:42 UTC.
Generated on: 2018-07-30 20:37 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.19
:revision: 2.29.20
.. version
......
......@@ -40,7 +40,7 @@ except ImportError:
# Do not modify the following VERSION comments.
# Used by updateversion.py.
##VERSION##
VERSION = '2.29.19'
VERSION = '2.29.20'
##VERSION##
CatalogDict = {}
......
......@@ -8,7 +8,7 @@ setup(
# Do not modify the following VERSION comments.
# Used by updateversion.py.
##VERSION##
version="2.29.19",
version="2.29.20",
##VERSION##
author="Dave Kuhlman",
author_email="dkuhlman@davekuhlman.org",
......
......@@ -3,7 +3,7 @@
#
# Generated by generateDS.py.
# Python 2.7.14 (default, Sep 23 2017, 22:06:14) [GCC 7.2.0]
# Python 2.7.15 |Anaconda custom (64-bit)| (default, May 1 2018, 23:32:55) [GCC 7.2.0]
#
# Command line options:
# ('--no-dates', '')
......@@ -246,7 +246,8 @@ except ImportError as exp:
time_parts = input_data.split('.')
if len(time_parts) > 1:
micro_seconds = int(float('0.' + time_parts[1]) * 1000000)
input_data = '%s.%s' % (time_parts[0], micro_seconds, )
input_data = '%s.%s' % (
time_parts[0], "{}".format(micro_seconds).rjust(6, "0"), )
dt = datetime_.datetime.strptime(
input_data, '%Y-%m-%dT%H:%M:%S.%f')
else:
......@@ -334,14 +335,15 @@ except ImportError as exp:
_svalue += '{0:02d}:{1:02d}'.format(hours, minutes)
return _svalue
def gds_validate_simple_patterns(self, patterns, target):
# pat is a list of lists of strings/patterns. We should:
# - AND the outer elements
# - OR the inner elements
# pat is a list of lists of strings/patterns.
# The target value must match at least one of the patterns
# in order for the test to succeed.
found1 = True
for patterns1 in patterns:
found2 = False
for patterns2 in patterns1:
if re_.search(patterns2, target) is not None:
mo = re_.fullmatch(patterns2, target)
if mo is not None:
found2 = True
break
if not found2:
......
......@@ -3,7 +3,7 @@
#
# Generated by generateDS.py.
# Python 2.7.14 (default, Sep 23 2017, 22:06:14) [GCC 7.2.0]
# Python 2.7.15 |Anaconda custom (64-bit)| (default, May 1 2018, 23:32:55) [GCC 7.2.0]
#
# Command line options:
# ('--no-dates', '')
......@@ -246,7 +246,8 @@ except ImportError as exp:
time_parts = input_data.split('.')
if len(time_parts) > 1:
micro_seconds = int(float('0.' + time_parts[1]) * 1000000)
input_data = '%s.%s' % (time_parts[0], micro_seconds, )
input_data = '%s.%s' % (
time_parts[0], "{}".format(micro_seconds).rjust(6, "0"), )
dt = datetime_.datetime.strptime(
input_data, '%Y-%m-%dT%H:%M:%S.%f')
else:
......@@ -334,14 +335,15 @@ except ImportError as exp:
_svalue += '{0:02d}:{1:02d}'.format(hours, minutes)
return _svalue
def gds_validate_simple_patterns(self, patterns, target):
# pat is a list of lists of strings/patterns. We should:
# - AND the outer elements
# - OR the inner elements
# pat is a list of lists of strings/patterns.
# The target value must match at least one of the patterns
# in order for the test to succeed.
found1 = True
for patterns1 in patterns:
found2 = False
for patterns2 in patterns1:
if re_.search(patterns2, target) is not None:
mo = re_.fullmatch(patterns2, target)
if mo is not None:
found2 = True
break
if not found2:
......
......@@ -3,7 +3,7 @@
#
# Generated by generateDS.py.
# Python 2.7.14 (default, Sep 23 2017, 22:06:14) [GCC 7.2.0]
# Python 2.7.15 |Anaconda custom (64-bit)| (default, May 1 2018, 23:32:55) [GCC 7.2.0]
#
# Command line options:
# ('--no-dates', '')
......@@ -246,7 +246,8 @@ except ImportError as exp:
time_parts = input_data.split('.')
if len(time_parts) > 1:
micro_seconds = int(float('0.' + time_parts[1]) * 1000000)
input_data = '%s.%s' % (time_parts[0], micro_seconds, )
input_data = '%s.%s' % (
time_parts[0], "{}".format(micro_seconds).rjust(6, "0"), )
dt = datetime_.datetime.strptime(
input_data, '%Y-%m-%dT%H:%M:%S.%f')
else:
......@@ -334,14 +335,15 @@ except ImportError as exp:
_svalue += '{0:02d}:{1:02d}'.format(hours, minutes)
return _svalue
def gds_validate_simple_patterns(self, patterns, target):
# pat is a list of lists of strings/patterns. We should:
# - AND the outer elements
# - OR the inner elements
# pat is a list of lists of strings/patterns.
# The target value must match at least one of the patterns
# in order for the test to succeed.
found1 = True
for patterns1 in patterns:
found2 = False
for patterns2 in patterns1:
if re_.search(patterns2, target) is not None:
mo = re_.fullmatch(patterns2, target)
if mo is not None:
found2 = True
break
if not found2:
......
......@@ -3,7 +3,7 @@
#
# Generated by generateDS.py.
# Python 2.7.14 (default, Sep 23 2017, 22:06:14) [GCC 7.2.0]
# Python 2.7.15 |Anaconda custom (64-bit)| (default, May 1 2018, 23:32:55) [GCC 7.2.0]
#
# Command line options:
# ('--no-dates', '')
......@@ -246,7 +246,8 @@ except ImportError as exp:
time_parts = input_data.split('.')
if len(time_parts) > 1:
micro_seconds = int(float('0.' + time_parts[1]) * 1000000)
input_data = '%s.%s' % (time_parts[0], micro_seconds, )
input_data = '%s.%s' % (
time_parts[0], "{}".format(micro_seconds).rjust(6, "0"), )
dt = datetime_.datetime.strptime(
input_data, '%Y-%m-%dT%H:%M:%S.%f')
else:
......@@ -334,14 +335,15 @@ except ImportError as exp:
_svalue += '{0:02d}:{1:02d}'.format(hours, minutes)
return _svalue
def gds_validate_simple_patterns(self, patterns, target):
# pat is a list of lists of strings/patterns. We should:
# - AND the outer elements
# - OR the inner elements
# pat is a list of lists of strings/patterns.
# The target value must match at least one of the patterns
# in order for the test to succeed.
found1 = True
for patterns1 in patterns:
found2 = False
for patterns2 in patterns1:
if re_.search(patterns2, target) is not None:
mo = re_.fullmatch(patterns2, target)
if mo is not None:
found2 = True
break
if not found2:
......
......@@ -2,7 +2,7 @@
#
# Generated by generateDS.py.
# Python 2.7.14 (default, Sep 23 2017, 22:06:14) [GCC 7.2.0]
# Python 2.7.15 |Anaconda custom (64-bit)| (default, May 1 2018, 23:32:55) [GCC 7.2.0]
#
# Command line options:
# ('--no-dates', '')
......
......@@ -3,7 +3,7 @@
#
# Generated by generateDS.py.
# Python 2.7.14 (default, Sep 23 2017, 22:06:14) [GCC 7.2.0]
# Python 2.7.15 |Anaconda custom (64-bit)| (default, May 1 2018, 23:32:55) [GCC 7.2.0]
#
# Command line options:
# ('--no-dates', '')
......@@ -245,7 +245,8 @@ except ImportError as exp:
time_parts = input_data.split('.')
if len(time_parts) > 1:
micro_seconds = int(float('0.' + time_parts[1]) * 1000000)
input_data = '%s.%s' % (time_parts[0], micro_seconds, )
input_data = '%s.%s' % (
time_parts[0], "{}".format(micro_seconds).rjust(6, "0"), )
dt = datetime_.datetime.strptime(
input_data, '%Y-%m-%dT%H:%M:%S.%f')
else:
......@@ -333,14 +334,15 @@ except ImportError as exp:
_svalue += '{0:02d}:{1:02d}'.format(hours, minutes)
return _svalue
def gds_validate_simple_patterns(self, patterns, target):
# pat is a list of lists of strings/patterns. We should:
# - AND the outer elements
# - OR the inner elements
# pat is a list of lists of strings/patterns.
# The target value must match at least one of the patterns
# in order for the test to succeed.
found1 = True
for patterns1 in patterns:
found2 = False
for patterns2 in patterns1:
if re_.search(patterns2, target) is not None:
mo = re_.fullmatch(patterns2, target)
if mo is not None:
found2 = True
break
if not found2:
......
......@@ -2,7 +2,7 @@
#
# Generated by generateDS.py.
# Python 2.7.14 (default, Sep 23 2017, 22:06:14) [GCC 7.2.0]
# Python 2.7.15 |Anaconda custom (64-bit)| (default, May 1 2018, 23:32:55) [GCC 7.2.0]
#
# Command line options:
# ('--no-dates', '')
......
......@@ -3,7 +3,7 @@
#
# Generated by generateDS.py.
# Python 2.7.14 (default, Sep 23 2017, 22:06:14) [GCC 7.2.0]
# Python 2.7.15 |Anaconda custom (64-bit)| (default, May 1 2018, 23:32:55) [GCC 7.2.0]
#
# Command line options:
# ('--no-dates', '')
......@@ -245,7 +245,8 @@ except ImportError as exp:
time_parts = input_data.split('.')
if len(time_parts) > 1:
micro_seconds = int(float('0.' + time_parts[1]) * 1000000)
input_data = '%s.%s' % (time_parts[0], micro_seconds, )
input_data = '%s.%s' % (
time_parts[0], "{}".format(micro_seconds).rjust(6, "0"), )
dt = datetime_.datetime.strptime(
input_data, '%Y-%m-%dT%H:%M:%S.%f')
else:
......@@ -333,14 +334,15 @@ except ImportError as exp:
_svalue += '{0:02d}:{1:02d}'.format(hours, minutes)
return _svalue
def gds_validate_simple_patterns(self, patterns, target):
# pat is a list of lists of strings/patterns. We should:
# - AND the outer elements
# - OR the inner elements
# pat is a list of lists of strings/patterns.
# The target value must match at least one of the patterns
# in order for the test to succeed.
found1 = True
for patterns1 in patterns:
found2 = False
for patterns2 in patterns1:
if re_.search(patterns2, target) is not None:
mo = re_.fullmatch(patterns2, target)
if mo is not None:
found2 = True
break
if not found2:
......
......@@ -2,7 +2,7 @@
#
# Generated by generateDS.py.
# Python 2.7.14 (default, Sep 23 2017, 22:06:14) [GCC 7.2.0]
# Python 2.7.15 |Anaconda custom (64-bit)| (default, May 1 2018, 23:32:55) [GCC 7.2.0]
#
# Command line options:
# ('--no-dates', '')
......
......@@ -3,7 +3,7 @@
#
# Generated by generateDS.py.
# Python 2.7.14 (default, Sep 23 2017, 22:06:14) [GCC 7.2.0]
# Python 2.7.15 |Anaconda custom (64-bit)| (default, May 1 2018, 23:32:55) [GCC 7.2.0]
#
# Command line options:
# ('--no-dates', '')
......@@ -245,7 +245,8 @@ except ImportError as exp:
time_parts = input_data.split('.')
if len(time_parts) > 1:
micro_seconds = int(float('0.' + time_parts[1]) * 1000000)
input_data = '%s.%s' % (time_parts[0], micro_seconds, )
input_data = '%s.%s' % (
time_parts[0], "{}".format(micro_seconds).rjust(6, "0"), )
dt = datetime_.datetime.strptime(
input_data, '%Y-%m-%dT%H:%M:%S.%f')
else:
......@@ -333,14 +334,15 @@ except ImportError as exp:
_svalue += '{0:02d}:{1:02d}'.format(hours, minutes)
return _svalue
def gds_validate_simple_patterns(self, patterns, target):
# pat is a list of lists of strings/patterns. We should:
# - AND the outer elements
# - OR the inner elements
# pat is a list of lists of strings/patterns.
# The target value must match at least one of the patterns
# in order for the test to succeed.
found1 = True
for patterns1 in patterns:
found2 = False
for patterns2 in patterns1:
if re_.search(patterns2, target) is not None:
mo = re_.fullmatch(patterns2, target)
if mo is not None:
found2 = True
break
if not found2:
......
......@@ -2,7 +2,7 @@
#
# Generated by generateDS.py.
# Python 2.7.14 (default, Sep 23 2017, 22:06:14) [GCC 7.2.0]
# Python 2.7.15 |Anaconda custom (64-bit)| (default, May 1 2018, 23:32:55) [GCC 7.2.0]
#
# Command line options:
# ('--no-dates', '')
......
......@@ -3,7 +3,7 @@
#
# Generated by generateDS.py.
# Python 2.7.14 (default, Sep 23 2017, 22:06:14) [GCC 7.2.0]
# Python 2.7.15 |Anaconda custom (64-bit)| (default, May 1 2018, 23:32:55) [GCC 7.2.0]
#
# Command line options:
# ('--no-dates', '')
......@@ -245,7 +245,8 @@ except ImportError as exp:
time_parts = input_data.split('.')
if len(time_parts) > 1:
micro_seconds = int(float('0.' + time_parts[1]) * 1000000)
input_data = '%s.%s' % (time_parts[0], micro_seconds, )
input_data = '%s.%s' % (
time_parts[0], "{}".format(micro_seconds).rjust(6, "0"), )
dt = datetime_.datetime.strptime(
input_data, '%Y-%m-%dT%H:%M:%S.%f')
else:
......@@ -333,14 +334,15 @@ except ImportError as exp:
_svalue += '{0:02d}:{1:02d}'.format(hours, minutes)
return _svalue
def gds_validate_simple_patterns(self, patterns, target):
# pat is a list of lists of strings/patterns. We should:
# - AND the outer elements
# - OR the inner elements
# pat is a list of lists of strings/patterns.
# The target value must match at least one of the patterns
# in order for the test to succeed.
found1 = True
for patterns1 in patterns:
found2 = False
for patterns2 in patterns1:
if re_.search(patterns2, target) is not None:
mo = re_.fullmatch(patterns2, target)
if mo is not None:
found2 = True
break
if not found2:
......
......@@ -2,7 +2,7 @@
#
# Generated by generateDS.py.
# Python 2.7.14 (default, Sep 23 2017, 22:06:14) [GCC 7.2.0]
# Python 2.7.15 |Anaconda custom (64-bit)| (default, May 1 2018, 23:32:55) [GCC 7.2.0]
#
# Command line options:
# ('--no-dates', '')
......
......@@ -3,7 +3,7 @@
#
# Generated by generateDS.py.