[x3d-public] Next, in Python news...

John Carlson yottzumm at gmail.com
Sat Aug 21 03:10:00 PDT 2021


I've been converting JSON schema to pure python validators (no separate 
JSON schema file required) with a python package (not mine).  If I could 
convert X3DUOM to Python and get a free XML, VRML, and JSON schema 
validation in Python, that would WOW me. BTW, I see that you don't use 
an XML parser in Python yet?  May I recommend the popular ElementTree 
built-in package.  Here's a simple pattern (in python):

import xml.etree.ElementTree
soup = 
xml.etree.ElementTree.parse(open("../../specifications/X3dUnifiedObjectModel-4.0.xml")).getroot()

So, Don should look at pylint output in the logs, perhaps? Me too!  I 
just found out about pylint!  I can find bugs in Python while Don works 
on Python-creating XSLT?   That would seem a better division of labor.   
I just ran ```ant pylint```.  I can do that and search for bugs in 
x3d.py.  I see that my changes are 1.53/10 worse, so I'm backing the 
changes that I made to X3duomToX3dPythonPackage.xslt. Please revisit 
this email, or look at code I pasted below.  The problem is around 
isinstance.  I could be misunderstanding duck typing.  To me, 2 
ProtoBody's inside the isinstance parameters spells trouble, but I'm 
unsure of a fix at this point.  I have a backup of my changes should we 
need to recover.  Perhaps a step forward is better than a step backwards?

     @ProtoBody.setter
     def ProtoBody(self, ProtoBody):
         if  ProtoBody is None:
             ProtoBody = None # default
         assertValidSFNode(ProtoBody)
         if not ProtoBody is None and not 
isinstance(ProtoBody,(ProtoBody,ProtoInstance)):
             # print(flush=True)
             raise X3DTypeError(str(ProtoBody) + ' does not match 
required node type (ProtoBody,ProtoInstance) and is invalid')
         self.__ProtoBody = ProtoBody




More information about the x3d-public mailing list