[x3d-public] Next, in Python news...
John Carlson
yottzumm at gmail.com
Sun Aug 22 05:44:06 PDT 2021
Here is the file with DOS/Windows line endings.
My apologies.
John
On 8/22/21 7:33 AM, John Carlson wrote:
> Don, attached is the python, with slight changes that does not produce
> XML. Indeed, it errors out in ProtoBody setter in ??? class.
>
> I tried to patch x3d.py, but ran into other issues.
>
> There might be an issue with Linux linefeeds?
>
> I can convert if you can't. I recommend WordPad instead of NotePad.
>
> John
>
>
> On 8/21/21 11:57 PM, Brutzman, Donald (Don) (CIV) wrote:
>> Hi John, am trying to follow your message.
>>
>> We have pylint but recent upgrade to python caused a gap, not
>> resolved yet.
>>
>> Meanwhile python evaluates everything building the scene graph quite
>> strictly, primarily through setters when creating values. I'm not
>> sure it is possible to create invalid XML, VRML or JSON from x3d.py
>> package. If such a case is found, let's fix the bug it indicates.
>>
>> If you have an example python program/snippet that does _not_ produce
>> valid XML, VRML or JSON, please advise.
>>
>> v/r Don
>>
>>
>> -----Original Message-----
>> From: x3d-public <x3d-public-bounces at web3d.org> On Behalf Of John
>> Carlson
>> Sent: Saturday, August 21, 2021 3:10 AM
>> To: X3D Graphics public mailing list <x3d-public at web3d.org>
>> Subject: [x3d-public] Next, in Python news...
>>
>> 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
>>
>>
>> _______________________________________________
>> x3d-public mailing list
>> x3d-public at web3d.org
>> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
More information about the x3d-public
mailing list