Hi Dave,
I'm trying to use gends to create django models from the xccdf xsd file provided by NIST (https://csrc.nist.gov/schema/xccdf/1.2/xccdf_1.2.xsd).
When I do, I'm receiving the error below. It appears to be that it's reading in a null list from the xsd somewhere but I'm not sure how to proceed.
Any thoughts are welcome!
Thanks,
Drew
./gends_run_gen_django.py -f -v ./xccdf.xsd
schema_name_stem: xccdf
bindings_file_name: xccdflib.py
removing: xccdflib.py
running ./generateDS.py -f -o xccdflib.py --member-specs=dict ./xccdf.xsd
running ./gends_extract_simple_types.py -f ./xccdf.xsd
running ./gends_generate_django.py -f xccdflib
error
Traceback (most recent call last):
File "./gends_generate_django.py", line 251, in <module>
main()
File "./gends_generate_django.py", line 245, in main
generate_model(options, module_name)
File "./gends_generate_django.py", line 126, in generate_model
class_back_refs = make_class_back_refs(supermod, class_name_set)
File "./gends_generate_django.py", line 196, in make_class_back_refs
data_type = member_spec.data_type[0]
IndexError: list index out of range
</module> error
message
ANY
message ***
Drew,
Thanks for the report.
I've been able to reproduce the exception.
I believe that the superclass used by the Django support can get out
of sync with the latest version generated by gDS. I don't normally
try to keep the file
django_etl/gends_generate_django.py
up-to-date. Anyway, that's the first thing I'll check.
By the way, comparing the lines and line numbers in the traceback,
it seems that you are using the files in
./django_etl/
and notthe ones under
./django/
. Please let me know if I'm wrong aboutthat.
More later when I know more.
Dave
Drew,
The exception had a different cause than I expected. Anyway, I fixed that error, I believe. And, I've also updated the boilerplate in
django_etl/generatedssuper.py
. Now I can generatemodels.py
,admin.py
, andforms.py
.If you get a chance to take a look, please let me know if it now does what you expect it to do.
The new version (v. 2.39.4) is at SourceForge and PyPI.
Thanks for help.
Dave
Dave,
First, let me take a moment to thank you ... a TON.
Thanks for this project, as well as thank you for helping me with this
particular issue.
I've downloaded the new code, created a work directory, copied the .xsd
file into that work directory. Then I copied the .py files from the root
dir into the working directory and then copied the .py files from the
django_etl directory into the working directory as well.
I ran "python ./generateDS.py --export=django -o xccdf.py ./xccdf.xsd"
and it generated the xccdf.py file, the xccdflib.py file and the
generateds_definedsimpletypes.py, as expected.
I then ran "./gends_run_gen_django.py -v ./xccdf.xsd" and it generated
the forms.py, admin.py and models.py files, just as expected. This
is an absolutely
excellent tool to help with this endeavour!
If I've not run the commands in the proper way or order, please let me
know. I'm going to review the files now but I believe that it works as
expected now.
to do something a bit unusual and create a file folder structure OFF the
root dir ('/') that followed the included xml path (for instance, I needed
to create /schema/cpe/2.3 and place both the cpe-language_2.3.xsd and the
cpe-naming_2.3.xsd files in that directory in order for generateDS.py to
recognize them.
contains the logic that if the include starts with '/', it will look in the
OS absolutely path (i.e. '/schema/cpe/2.3'). This is the case with the
xccdf xsd file. The cpe xsd files start with the '/'.
Anyway, THANK YOU for helping with fixing this issue and thank you for
maintaining this project.
I appreciate.
-Drew
On Tue, Aug 17, 2021 at 6:29 PM Dave Kuhlman dkuhlman@users.sourceforge.net
wrote:
Related
Tickets: #16
Opps. I forgot to copy my temporary changes to the repo.
That was dumb of me to do it this way.
Now the changes are there.: v. 2.39.5
And, they've been uploaded.
Dave
Dave,
First, let me take a moment to thank you ... a TON.
Thanks for this project, as well as thank you for helping me with this particular issue.
I've downloaded the new code, created a work directory, copied the .xsd file into that work directory. Then I copied the .py files from the root dir into the working directory and then copied the .py files from the django_etl directory into the working directory as well.
I ran "python ./generateDS.py --export=django -o xccdf.py ./xccdf.xsd" and it generated the xccdf.py file, the xccdflib.py file and the generateds_definedsimpletypes.py, as expected.
I then ran "./gends_run_gen_django.py -v ./xccdf.xsd" and it generated the forms.py, admin.py and models.py files, just as expected. This is an absolutely excellent tool to help with this endeavour!
If I've not run the commands in the proper way or order, please let me know. I'm going to review the files now but I believe that it works as expected now.
Anyway, THANK YOU for helping with fixing this issue and thank you for maintaining this project.
I appreciate.
-Drew