-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
python: import statement not generated when using KSY imports in a certain way #876
Comments
Last time I investigated this a bit (more specifically, while looking into #295 and soon realized that there isn't a quick fix but rather an architectonic change), I found that there isn't anything in the compiler code like iterating the Note that this applies only in the part of KSC handling the actual code generation - other parts require the imported spec to be present, because the type derivations and checks depend on it. |
Just so I understand, are imports entirely unusable at the moment?
This seems to imply there is some combination of tricks that cause imports to be generated, but I have not found one that generates the expected import statement in any language. |
This issue looks as a duplicate of #703, so I'll close this one too. We're not doing a great job at identifying duplicate issues 😐
I don't think they're unusable, except that a module does not get imported just because you reference its inner type/enum. Importing other modules as a whole works fine, AFAIK. Referencing the top-level type of the imported module from some "dummy" type will add the import for sure, but I'm not sure whether this alone is enough to allow referencing nested types/enums in the imported spec - I wouldn't be surprised if it generates an invalid path to the imported type/enum for some languages. |
Duplicate of #703 |
When generating Python code with Kaitai 0.9 for the .wav some import statements that should be generated are not generated.
The wav.ksy file has an import:
The code that is generated does not import the riff module. When adding a dummy type like this and regenerating, then it is:
The difference in generated code:
Another issue is that the class
Riff
, which is used in the code, is not imported either.Normally I would have expected something like
from riff import Riff
for it to work.My guess is that referencing an enum in an imported file is where code generation fails:
I don't know where in the compiler to fix this.
The text was updated successfully, but these errors were encountered: