Hi @aranega
I try to create static code from complex ecore models like capella. I always run into the problem of circular includes.
But I think this could be avoided if other modules are loaded by using import x instead of from x import y.
So if you have a module like this
module examlple
__init__.py
from .one import Foo
from .one import helper
one.py
from example import two
class Foo(two.Bar):
def __init__(self):
super().__init__()
print('Init Foo')
def helper():
print('Help')
def main():
foo = Foo()
if __name__ == '__main__':
main()
two.py
from example import helper
class Bar:
def __init__(self):
print('Init Bar')
helper()
As far as I understood, by using from x import y y is loaded into the local namespace. Therefore example above will not work.
but changing two.py to
two.py
import example
class Bar:
def __init__(self):
print('Init Bar')
example.helper()
And it can be resolved. So instead loading single classifiers from different ecore files importing the whole package can maybe solve this issue.
Maybe I find some time to dive deeper and can prepare a patch and some example. Hope you have a rough idea of the problem.
Maybe you can give me a hint how I easily get the containing package from the classifier in the code gen template.
Best regards,
Andreas
Hi @aranega
I try to create static code from complex ecore models like capella. I always run into the problem of circular includes.
But I think this could be avoided if other modules are loaded by using
import xinstead offrom x import y.So if you have a module like this
As far as I understood, by using
from x import yyis loaded into the local namespace. Therefore example above will not work.but changing two.py to
And it can be resolved. So instead loading single classifiers from different ecore files importing the whole package can maybe solve this issue.
Maybe I find some time to dive deeper and can prepare a patch and some example. Hope you have a rough idea of the problem.
Maybe you can give me a hint how I easily get the containing package from the classifier in the code gen template.
Best regards,
Andreas