[x3d-public] X3DJSONLD Python volunteers wanted to clean up python validator output!
John Carlson
yottzumm at gmail.com
Tue Apr 27 03:29:33 PDT 2021
Python volunteers wanted to clean up output from python exceptions when
validating JSON. Maybe just a try except is required?
Python code examples
In account:
https://github.com/coderextreme
repo/path (you'll have to click through):
X3DJSONLD/src/main/python$ cat generateSchemas.py
[snip]
# now try to validate some JSON validation examples
print(f"3.3, HelloWorld.json")
os.system(f'python3 validate33.py <
/c/x3d-code/www.web3d.org/x3d/content/examples/HelloWorld.json')
print(f"4.0, AllAudioGraphNodesTest.json")
os.system(f'python3 validate40.py <
/c/x3d-code/www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/AudioSpatialSound/AllAudioGraphNodesTest.json')
print(f"3.3, CADPartChildTransformationAlternativeB.json")
os.system(f'python3 validate33.py <
/c/x3d-code/www.web3d.org/x3d/content/examples/Basic/CAD/CADPartChildTransformationAlternativeB.json')
print(f"3.3, CADPartChildTransformationAlternativeC.json")
os.system(f'python3 validate33.py <
/c/x3d-code/www.web3d.org/x3d/content/examples/Basic/CAD/CADPartChildTransformationAlternativeC.json')
=======================================================================================
Shell example:
X3DJSONLD/src/main/python$ cat ~/x3dvalidate/BasicPointSprites1.json |
python3 validate40.py
Traceback (most recent call last):
File "validate40.py", line 5, in <module>
schemaparser40.validate(json.loads(sys.stdin.read()))
File
"/home/coderextreme/X3DJSONLD/src/main/python/schemaparser40.py", line
47, in validate
validate___definitions_x3d(data__X3D)
File
"/home/coderextreme/X3DJSONLD/src/main/python/schemaparser40.py", line
103, in validate___definitions_x3d
validate___definitions_scene(data__Scene)
File
"/home/coderextreme/X3DJSONLD/src/main/python/schemaparser40.py", line
128, in validate___definitions_scene
validate___definitions__x3dchildnode_x3dmetadataobject_layersetmfnode(data__children)
File
"/home/coderextreme/X3DJSONLD/src/main/python/schemaparser40.py", line
331, in
validate___definitions__x3dchildnode_x3dmetadataobject_layersetmfnode
validate___definitions_transform(data_item__Transform)
File
"/home/coderextreme/X3DJSONLD/src/main/python/schemaparser40.py", line
50267, in validate___definitions_transform
raise JsonSchemaValueException("data must be valid exactly by one
of oneOf definition", value=data, name="data", definition={'type':
'object', 'oneOf': [{'type': 'object', 'properties': {'@class': {'type':
'string'}, '@USE': {'type': 'string'}, '-children': {'type': 'array',
'minItems': 1, 'items': {'type': 'object', 'properties': {'#comment':
{'type': 'string'}}, 'additionalProperties': False}}}, 'required':
['@USE'], 'additionalProperties': False}, {'type': 'object',
'properties': {'IS': {'$ref': '#/definitions/IS'}, '@bboxCenter':
{'pattern':
'^\\s*(([+-]?((0|[1-9][0-9]*)(\\.[0-9]*)?|\\.[0-9]+)([Ee][+-]?[0-9]+)?)\\s+){2}([+-]?((0|[1-9][0-9]*)(\\.[0-9]*)?|\\.[0-9]+)([Ee][+-]?[0-9]+)?)\\s*$',
'$comment': 'SFVec3f initializeOnly', 'type': 'array', 'minItems': 3,
'maxItems': 3, 'items': {'default': 0, 'type': 'number'}},
'@bboxDisplay': {'pattern': '^\\s*(true|false)\\s*$', 'default': False,
'$comment': 'SFBool inputOutput', 'type': 'boolean'}, '@bboxSize':
{'pattern':
'^\\s*(([+-]?((0|[1-9][0-9]*)(\\.[0-9]*)?|\\.[0-9]+)([Ee][+-]?[0-9]+)?)\\s+){2}([+-]?((0|[1-9][0-9]*)(\\.[0-9]*)?|\\.[0-9]+)([Ee][+-]?[0-9]+)?)\\s*$',
'$comment': 'SFVec3f initializeOnly', 'type': 'array', 'minItems': 3,
'maxItems': 3, 'items': {'default': -1, 'type': 'number'}}, '@center':
{'pattern':
'^\\s*(([+-]?((0|[1-9][0-9]*)(\\.[0-9]*)?|\\.[0-9]+)([Ee][+-]?[0-9]+)?)\\s+){2}([+-]?((0|[1-9][0-9]*)(\\.[0-9]*)?|\\.[0-9]+)([Ee][+-]?[0-9]+)?)\\s*$',
'$comment': 'SFVec3f inputOutput', 'type': 'array', 'minItems': 3,
'maxItems': 3, 'items': {'default': 0, 'type': 'number'}}, '-children':
{'$ref': '#/definitions/-X3DChildNodeMFNode'}, '-metadata': {'$ref':
'#/definitions/-X3DMetadataObjectSFNode'}, '@rotation': {'pattern':
'^\\s*(([+-]?((0|[1-9][0-9]*)(\\.[0-9]*)?|\\.[0-9]+)([Ee][+-]?[0-9]+)?)\\s+){3}([+-]?((0|[1-9][0-9]*)(\\.[0-9]*)?|\\.[0-9]+)([Ee][+-]?[0-9]+)?)\\s*$',
'$comment': 'SFRotation inputOutput', 'type': 'array', 'minItems': 4,
'maxItems': 4, 'items': [{'default': 0, 'type': 'number'}, {'default':
0, 'type': 'number'}, {'default': 1, 'type': 'number'}, {'default': 0,
'type': 'number'}], 'additionalItems': False}, '@scale': {'pattern':
'^\\s*(([+-]?((0|[1-9][0-9]*)(\\.[0-9]*)?|\\.[0-9]+)([Ee][+-]?[0-9]+)?)\\s+){2}([+-]?((0|[1-9][0-9]*)(\\.[0-9]*)?|\\.[0-9]+)([Ee][+-]?[0-9]+)?)\\s*$',
'$comment': 'SFVec3f inputOutput', 'type': 'array', 'minItems': 3,
'maxItems': 3, 'items': {'default': 1, 'type': 'number'}},
'@scaleOrientation': {'pattern':
'^\\s*(([+-]?((0|[1-9][0-9]*)(\\.[0-9]*)?|\\.[0-9]+)([Ee][+-]?[0-9]+)?)\\s+){3}([+-]?((0|[1-9][0-9]*)(\\.[0-9]*)?|\\.[0-9]+)([Ee][+-]?[0-9]+)?)\\s*$',
'$comment': 'SFRotation inputOutput', 'type': 'array', 'minItems': 4,
'maxItems': 4, 'items': [{'default': 0, 'type': 'number'}, {'default':
0, 'type': 'number'}, {'default': 1, 'type': 'number'}, {'default': 0,
'type': 'number'}], 'additionalItems': False}, '@translation':
{'pattern':
'^\\s*(([+-]?((0|[1-9][0-9]*)(\\.[0-9]*)?|\\.[0-9]+)([Ee][+-]?[0-9]+)?)\\s+){2}([+-]?((0|[1-9][0-9]*)(\\.[0-9]*)?|\\.[0-9]+)([Ee][+-]?[0-9]+)?)\\s*$',
'$comment': 'SFVec3f inputOutput', 'type': 'array', 'minItems': 3,
'maxItems': 3, 'items': {'default': 0, 'type': 'number'}}, '@visible':
{'pattern': '^\\s*(true|false)\\s*$', 'default': True, '$comment':
'SFBool inputOutput', 'type': 'boolean'}, '@DEF': {'pattern':
'^(\\s|\\S)*$', '$comment': 'SFString inputOutput', 'type': 'string'},
'@class': {'pattern': '^(\\s|\\S)*$', '$comment': 'SFString
inputOutput', 'type': 'string'}, '@style': {'pattern': '^(\\s|\\S)*$',
'$comment': 'SFString inputOutput', 'type': 'string'}},
'additionalProperties': False}]}, rule='oneOf')
fastjsonschema.exceptions.JsonSchemaValueException: data must be valid
exactly by one of oneOf definition
More information about the x3d-public
mailing list