Menu

#22 Adding basic episodic compilation

1.0
open
nobody
None
2021-09-28
2021-09-23
No

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?

Discussion

  • Mustafa Şenol Coşar

    I already have an implementation but I need to add a test case.

     
  • Dave Kuhlman

    Dave Kuhlman - 2021-09-23

    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.

     
  • Dave Kuhlman

    Dave Kuhlman - 2021-09-24

    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 file generateds/gds_collect_namespace_mappings.py.
    It's called from function parseAndGenerate in file
    generateds/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

     
  • Dave Kuhlman

    Dave Kuhlman - 2021-09-28

    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.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.