v. 2.44.3 Fixed generation of validate_ methods for superclasses
reverse node mapping
v. 2.44.1 black formatting; fix regexprs for Py 3.12
Hi, we just implemented this in a fork on our gitlab.com group: https://gitlab.com/cdehealth/generateds/-/tree/2.44.1+20240201?ref_type=tags Because of possible references before definition of classes, like unordered in the XSDs, we had to use forward references, not: id: NmlID = None but: id: 'NmlID' = None but we can still use it with getattr(self.id, type_name) It seems Intellisense is not catching it, but we can still use it as intended. Maybe we could merge this into the main repo here. Feedback...
Wanings in respect to generated code
v. 2.43.3 Added warning union inside simpleType and type_substitution unit test
v. 2.43.2 Several fixes for GraphQL support
AttributeError: 'str' object has no attribute 'year'
externalEncoding for UTF-8 outfile
v.. 2.43.1 Added split/join modules capability
v. 2.42.2 Added graphql unit test. Added graphql demo.
I have added support for the generation of modules that implement a GraphQL server that can be run with the Strawberry GraphQL Python package (https://strawberry.rocks/docs). You can learn about it here -- http://www.davekuhlman.org/generateDS.html#graphql-support There are likely bugs in this, but I did generate and run it with two reasonably complex examples: (1) the Demos/People schema and XML instance doc in the generateDS repository and (2) the neuroml schema (https://github.com/NeuroML/NeuroML2.git...
I have added support for the generation of modules that implement a GraphQL server that can be run with the Strawberry GraphQL Python package (https://strawberry.rocks/docs). You can learn about it here -- http://www.davekuhlman.org/generateDS.html#graphql-support There are likely bugs in this, but I did generate and run it with two reasonably complex examples: (1) the Demos/People schema and XML instance doc in the generateDS repository and (2) the neuroml schema (https://github.com/NeuroML/NeuroML2.git...
v. 2.42.1 Added support for Strawberry and GraphQL
Forgot to mention: I have added an __init__.py file in the same directory as the models.
Hello, I have issues when I try to run the generated code from external modules. I have generated Python classes using subclass, so I have a model.py and a model_subs.py files. From my external code I can reach models_subs but from it I cannot reach model.py, so something is happening with the interpreter path. I am able to workaround it by applying in models_subs the following statement: sys.path.append(os.path.abspath(__file__ + "/..")) I place it before the import models as supermod, and everything...
v. 2.41.5 Changed name of generated method "_hasContent" --> "has__content"
v. 2.41.4 Fix to formatting of floats.
Dear all, I am using generateDS since 2014 and it is a fantastic tool, thanks Dave! I have recently switched to 2.43.1 and I have the problem reported above: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/mbomben/work/python_scripts/make_plots.py", line 17, in mp plot.build(root) File "/Users/mbomben/work/python_scripts/root_multi_graph.py", line 2132, in build self.ns_prefix_ = node.prefix AttributeError: 'xml.etree.ElementTree.Element' object has no attribute...
Dear all, I am using generateDS since 2014 and it is a fantastic tool, thanks Dave! I have recently switched to 2.43.1 and I have the problem reported above: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/mbomben/work/python_scripts/make_plots.py", line 17, in mp plot.build(root) File "/Users/mbomben/work/python_scripts/root_multi_graph.py", line 2132, in build self.ns_prefix_ = node.prefix AttributeError: 'xml.etree.ElementTree.Element' object has no attribute...
Thank you for your report. However, I do not know what to do about this. You may be right in suggesting that the behavior should be different. Do you want to submit a patch? If so I'll consider it. But, I do not want to make a change that I do not understand. Maybe you could explain in detail how you think it should function. Or maybe tell me how the current behavior is a problem for you. Is there some behavior that you need and cannot get in main.py? I'll welcome suggestions.
xs:list element type mismatch
"ref" attribute support error
I hit into this issue recently while trying to convert an xsd specification to python classes using this tool. I am using the following repository to convert IP-XACT xsd specification: https://github.com/olofk/ipxact_gen I used the following command to generate a single file output: PYTHONPATH=. generateDS -f -o pyout/ipx.py --user-methods=gends_user_methods.py 2014/index.xsd Which results in successful conversion with some warnings: *** warning. Removing child with duplicate name: "activeInterface"...
Citing generateDS
Hi there, Have a look at Section 6.2 of the introduction and tutorial. From how I understand your problem, you would need to have a look at the classes generated by generateDS and how they create instances. Then you can create those instances yourself using your DataFrames. In the tutorial, the section shows this for an example and then also exports the resulting XML. Hope that helps, good luck!
Hi there, Have a look at section 6.2 of the introduction and tutorial. From how I understand your problem, you would need to have a look at the classes generated by generateDS and how they create instances. Then you can create those instances yourself using your DataFrames. In the tutorial, the section shows this for an example and then also exports the resulting XML. Hope that helps, good luck!
Hi, first of all i want to say thanks for creating generateDS. I'm managing a vacation house and I need to give the city tourist office an xml report that has some information about the tourist tax payment. Those info are spread across two different management platforms, so I created some python code that takes the data I need from different reports and groups them in a Pandas DataFrame. Then, from an xml report example i created an XSD Schema (the attached file). What I thought I could do is to...
v. 2.41.3 Recognize mixed=true on complexContent
v. 2.41.2 Fix to export of mixed and simpleContent
We are aware that this is not true for further child elements. So there should be a check if there is only a text/content/valueOf alone in this element, and written without eol_.
export adds eol and indent inside of content/valueOf
I followed the examples and suggestions of handling namespaces to read in an xml file. However, I am unable to resolve the issue. Below is the code I am using to generate the Classes and subclasses python generateDS.py -a "gml:" -o gmx_codelists.py -s gmx_codelists_app.py gmxCodelists.xml The error is as follows: AttributeError: 'NoneType' object has no attribute 'annotate' I am attaching the xml file here. I performed a similar conversion from an xsd Catalog file and that worked properly. Can someone...
I followed the examples and suggestions of handling namespaces to read in an xml file. However, I am unable to resolve the issue. Below is the code I am using to generate the Classes and subclasses python generateDS.py -a "gml:" -o gmx_codelists.py -b gmx_codelists_app.py gmxCodelists.xml The error is as follows: AttributeError: 'NoneType' object has no attribute 'annotate' I am attaching the xml file here. I performed a similar conversion from an xsd Catalog file and that worked properly. Can someone...
v. 2.41.1 Added command line option --use-regex-module
+1 for this feature (although I don't know how much work this is to implement). At the moment, our classes all look like this: Izhikevich2007Cell(neuro_lex_id=None, id=None, metaid=None, notes=None, properties=None, annotation=None, C=None, v0=None, k=None, vr=None, vt=None, vpeak=None, a=None, b=None, c=None, d=None, gds_collector_=None, **kwargs_) which means users don't really get any information about what each argument to the constructor should be---they need to go look at our schema documentation...
Fix imports in episodic compilation
Dave, Fair enough. Thank you. I am not sure I'll be having enough enthusiasm to support that too. Keep it in backlog if for some reason anyone would want to implement that.
Mikhail, Thanks for your detailed report. Yes, this seems like a reasonable request to me. But ... In response to your ticket and your questions, I have searched a bit at the code in generateDS.py looking for support for namespaces on attributes. I cannot find any. And, adding/implementing that support for namespace prefixes on attribute names would require significant changes at a number of locations in the code. That is not a task that I'm willing to take on. In addition, I'm a bit confused about...
Namespace of attributes
simpleType validation does not report a warning
One more question: What command line flags did you use when you ran generateDS.py (or generateds)? What were the commands that you ran for your test? Perhaps you could copy and paste them in a reply. In general, I'm groping for any information that would enable me to reproduce the error. Dave
Pablo, I'm trying to reproduce the exception that you've reported. Here's what I've done: I copied people.xsd and people.xml from generateds/tests in the source code distribution. I generated a module with this: $ ./generateDS.py -o people.py people.xsd I ran that module against people.xml: $ python people.py people.xml The above ran successfully and produced output. There are also people.xsd and people.xml in the generateds/Demos/People subdirectory. In order to run a test with those, you need to...
Broken inheritance when generating code
Hello! I have been testing the people library, but when running python people.py people.xml I receive the following error: Traceback (most recent call last): File "people.py", line 4390, in <module> main() File "people.py", line 4383, in main parse(args[0]) File "people.py", line 4253, in parse rootObj.build(rootNode, gds_collector_=gds_collector) File "people.py", line 1196, in build self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) File "people.py", line 1203, in _buildChildren...
v. 2.40.13 Fix for default value and/or nillable
Great, That patch, including your refinement, has now been uploaded as v. 2.40.12. Thanks again. Dave
Great, That patch has now been uploaded as v. 2.40.12. Thanks again. Dave
v. 2.40.12 Strip white space boolean values and backslash-n to
Hey, yes, that looks good. Thank you for your effort! Regard, Gabriel
That works but I did a small refinement to my fix. Your patch also includes the second iteration of fix for ticket #29. So here is what I am using for this ticket alone rather than a patch. def gds_parse_boolean(self, input_data, node=None, input_name=''): input_data = input_data.strip() if input_data in ('true', '1'): bval = True elif input_data in ('false', '0'): bval = False else: raise_parse_error(node, 'Requires boolean value') return bval
Pete, Thanks for reporting this. Attached is a patch -- actually, it's just the change that you suggest above. If it looks good to you, let me know, and it will be in the next release. Dave
boolean validation with whitespace
OK. So, attached is another patch. With this patch, generateDS.py produces the following line in the generated module: s1 = s1.replace('\n', ' ') I'm actually unsure about what it is supposed to do. So, I'll wait for you to tell me that it works and solves your problem before I upload another release. Thanks for your very helpful and explicit description of a solution. Hope I got it right this time. Dave
Unfortunately, no. However, I do have a question: In the source of generateDS.py I find s1 = s1.replace(r'\\n', ' '). In any other source file of your project, however, I find s1 = s1.replace(r'\n', ' '). Why this difference? When I run generateDS on my schema the resulting Super.py contains s1 = s1.replace(r'\n', ' ') Here's what I found out: - s1 = s1.replace(r'\n', ' ') would work for a string like the following s1 = 'test\\ntest' - s1 = s1.replace(r'\n', ' ') would NOT work...
Unfortunately, no. However, I do have a question: In the source of generateDS.py I find s1 = s1.replace(r'\\n', ' '). In any other source file of your project, however, I find s1 = s1.replace(r'\n', ' '). Why this difference? When I run generateDS on my schema the resulting Super.py contains s1 = s1.replace(r'\n', ' ') Here's what I found out: - s1 = s1.replace(r'\n', ' ') would work for a string like the following s1 = 'test\\ntest' -s1 = s1.replace(r'\n', ' ')would NOT work for...
Concerning your question about what is the difference between the following two lines? s1 = s1.replace(r'\\n', ' ') s1 = s1.replace('\n', ' ') Try running the following: a = r'\\n' b = '\n' print(len(a)) print(len(b)) print(a[0]) print(a[1]) print(a[2]) print(ord(b)) Thanks for the link to the StackOverflow page. Yes, that is informative and is a good explanation. So, did that latest version (v. 2.40.11) fix things for you? Dave
Dave, I just got aware of the fact that you added the following line: s1 = s1.replace(r'\\n', ' ') What would be the difference to the following line: s1 = s1.replace('\n', ' ') Taking the test here - only s2 contains the correct output (with ): string = '''asdf\nasdf''' s1 = string.replace(r'\\n', ' ') print(s1) s2 = string.replace('\n', ' ') print(s2) Regards, Gabriel
Dave, thank you for the quick response and implementation. I still owe you some explanation about this - the best I found is here https://stackoverflow.com/questions/514635/represent-space-and-tab-in-xml-tag I hope that helps. Thank you! Gabriel
Gabriel, I've created a new release: v. 2.40.11. It has been uploaded to sourceforge.net and to pypi.org. Thanks for your help with this. Dave
v. 2.40.11 Added transform of backslash-n to
David, Thanks for the report and the link to the schemas. I've looked into this a bit. I don't think I'm going to be able to fix it. It looks like fixes would be needed at multiple places in the code. There are several other places in the code where similar recursion-limit-exceeded occurs. And, I don't even know the correct way to fix any of those places. I can patch those to skip the recursion error, but then the module that we generate is incomplete. If you have a suggestion or a patch, please...
Gabriel, Thanks for the note. Your suggestion to transformed "\n" to " " sounds good to me. Although, I actually have no idea what the correct policy should be on this. If you have a rational, I'd be interested. I added a line to generateDS.py that replaces "\n" with " ". Hope I got it right. Attached is a patch. Please let me know whether this is what you intended and whether it works for you. If it works, I'll create a new release. Thanks for help. Dave
Namespace Recursion
Convert \n to
v. 2.40.10 Force conversion to string for anytypeobjs
v. 2.40.9 Fix to method gds_validate_simple_patterns
v. 2.40.9 Fix to method gds_validate_simple_patterns and update README
v. 2.40.8 Fix to generated __str__ method
v. 2.40.7 Fixes for -p (class name prefix) command line option
Ankur, Your fix looks good to me. I've applied that patch, did some testing, created a new version, and uploaded it to PyPI and SourceForge.net. Thanks for your help with this. Please let me know if/when there is another issue. Dave
v. 2.40.6 Fix for Python 2.7 and StringIO
Hi Dave, I think I figured out what was going on. In the generated nml.py file, in the __str__ method of GeneratedsSuper, we're initialising a new output variable as an object of the StringIO class. At the moment, we simply from io import StringIO, which while works for Python 3, isn't the right StringIO to use for Python 2. In Python 2, for strings, we must use StringIO.StringIO because there, io.StringIO is for unicode strings. So, I think the generateds.py code should be tweaked as per this diff:...
Hi Dave, I haven't been able to pin point the cause of the error yet but I did find a workaround that fixes the issue for us: https://github.com/NeuralEnsemble/libNeuroML/pull/110/commits/aa025c608a678697d14acaca1cf8d7ed0a0a7fd6 The error is caused when we use nml.py with other bits, like reading from HDF5 files, so I'm thinking it's caused by some code in our HDF5 related methods where we haven't been careful enough to take both Python 2 and 3 into account. So we'll just carry this tweak for the...
Hi Dave, Thanks for that. I'll go through the failing test and see if I can narrow it down. If you're not seeing the error, it could be something else in the library that's using nml.py perhaps. I'll report back once I have something. Thanks again, Ankur
OK, I've found a number of examples (*.nml) here: https://github.com/NeuroML/NeuroML2/tree/master/examples. But, the ones I have tried so far do not cause an exception, either with Python 3.9.7 nor with Python 2.7.18. The ones I've tried are: NML2_AnalogSynapsesHH.nml NML2_FullNeuroML.nml NML2_PyNNCells.nml For example, it displays exported output when I run this: $ python nml.py NML2_FullNeuroML.nml By the way, I'm running nml.py with Python 2.7.18, but I generated nml.py with Python 3.9.7. Dav...
Ankur, Thanks for your help with this. What I've done so far: Downloaded NeuroML_v2.2.xsd, helper_methods.py, and regenerate-nml.sh. Modified regenerate-nml.sh for my environment: path to generateDS.py, name of XML schema file. Ran regenerate-nml.sh -- generated nml.py. Build a virtual environment with Python 2.7.18, then installed lxml, and six required by generateDS. Next -- I need to run the new nml.py against an XML instance document so that it generates the reported exception. I looked in the...
Python2.7: TypeError: unicode argument expected, got 'str'
f'' strings break pre-3.6 Python releases