Re: [Generateds-discuss] gds_validate_simple_patterns and MusicXml
Brought to you by:
dkuhlman
From: Dave K. <dku...@da...> - 2021-08-14 00:05:17
|
Rick, Thanks again for the report. I believe I've fixed this now. We'll now generate an additional line of code to convert the Python `datetime`, `date`, or `time` object to string before doing the regular expression match for validation. I've uploaded this patched version to PyPI and SourceForge. If you get a chance to try it, please let me know whether ti fixes the issue for you. Dave On Mon 09 Aug 2021 08:03:39 AM PDT, Taube, Heinrich K wrote: > Hi, I am prepping to teach a cs+music class in the fall and Ive used > generateDS to convert the MusicXml schema > (https://www.musicxml.com/for-developers/musicxml-xsd/) into a > generateDS python file. Thank you for such an awesome program!! Ive > been trying it out on some musicxml scores, and I've found one > problem so far. If a musicxml file contains an element like this: > <encoding-date>2021-08-09</encoding-date> > > then parsing fails in gds_validate_simple_patterns() with the message > > TypeError: expected string or bytes-like object > > Here’s a partial stack trace: > […] > File "/Users/taube/Software/musx/musx/mxml/musicxml.py", line > 31792, in _buildChildren > self.validate_yyyy_mm_dd(self.encoding_date[-1]) > File "/Users/taube/Software/musx/musx/mxml/musicxml.py", line > 31707, in validate_yyyy_mm_dd > if not self.gds_validate_simple_patterns( > File "/Users/taube/Software/musx/musx/mxml/musicxml.py", line 507, > in gds_validate_simple_patterns > mo = re_.search(patterns2, target) > File > "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/re.py", > line 201, in search > return _compile(pattern, flags).search(string) > TypeError: expected string or bytes-like object > > If I delete that one line from the musicxml file, then the file is > parsed successfully. I’m wondering if you have any suggestions on > what I can do to stop the exception? > Ive tried putting a few print statements in the musicxml.py file to > try to look more closely at what is happening but for some reason I > cant get the print statements to show up in my terminal. Im not sure > why that is yet (the musicxml.py file is 3.1 megabytes and maybe > that has something to do with it…) The only other issue I could > point at is that when i create the musicxml.py file like this > > $ generateDS -o musicxml.py --root-element "score_partwise" > schema/musicxml.xsd > > I get many many of messages like this: > > *** No suitable ns prefix for element "<XschemaElement name: > "key-accidental" type: "key-accidental">”. > > and a handful with these warnings: > > *** warning. Removing child with duplicate name: “tie" > *** warning. child chord already removed > > However, despite the warnings it seems like the code is actually > parsing xml Elements correctly so I’ve not looked into this any more. > > > If you have pointers on what I might be able to do with > gds_validate_simple_patterns it would be greatly appreciated! > > > Rick Taube > ________________________________ > Chair, Composition/Theory > School of Music > University of Illinois Urbana-Champaign > Email: ta...@il...<mailto:ta...@il...> > President, Illiac Software Inc. > https://harmonia.illiacsoftware.com/ > Email: ta...@il... -- Dave Kuhlman http://www.davekuhlman.org |