Hi Dave,
I'm working on a feature to solve an issue we are facing during our builds.
We have to invoke the generateDS compiler multiple times for different projects that have some dependencies from one to another.
We are using the multi file output.
However when we do that, the xsds that are located in one project but also imported in the second project gets generated twice.
This can cause problems with isinstance
checks in python.
What I'm trying to do is, I will add an option to provide a mapping from namespace to module.
During code generation, if the namespace is in this mapping, I will import the names from the provided module instead of a local import.
Also prevent generating the python file for the imported xsd.
An example mapping can be like this:
{
"some/namespace/foo": "some.namespace.foo",
"some/other/namespace/bar": "some.other.namespace.bar"
}
The generated imports would be like the follows:
# instead of 'from .foo import Class1'
from some.namespace.foo import Class1
# instead of 'from .bar import Class2'
from some.other.namepace.bar import Class2
foo.py
and bar.py
would not be generated.
What are your thoughts?
I already have an implementation but I need to add a test case.
I agree. This is likely an area and feature that need work.
When you have something that you believe is working and that I can look at, please send me a pull request or a
diff
, whichever is easiest.Thinking about this a bit more.
You may not have found this, because it's buried quite deep in the
code. It may interest you to take a look at function
create_mapping
in filegenerateds/gds_collect_namespace_mappings.py
.It's called from function
parseAndGenerate
in filegenerateds/generateDS.py
.It does not do what you are trying to do, as far as I understand it.
But, it might be of interest. It might provide ideas about how to
solve your namespace-to-module mapping problem.
Dave
Hi Dave, I opened a PR: https://sourceforge.net/p/generateds/code/merge-requests/3/
Mustafa,
I've merged your changes, created a new release, and pushed/uploaded it as v. 2.40.1.
Thank you much for your work on this. I appreciate it, and, hopefully, other users will, too.