[Python] Fix various codegen problems (#8292)

* [Python] Fix various codegen problems.

This includes:

-  escaping keywords happens **after** converting the case:
   - currently, `table ClassT` generate `class = Class()` which is invalid Python;
-  imports in `one_file` mode use the filename rather than the type name when resolving module names;
-  use `filename_suffix` instead of the hardcoded `_generated` one;
-  generate empty files if no structs or enums are available. This makes the set of output files more predictable for Bazel.

* [Python] Fix various codegen problems.

This includes:

-  escaping keywords happens **after** converting the case:
   - currently, `table ClassT` generate `class = Class()` which is invalid Python;
-  imports in `one_file` mode use the filename rather than the type name when resolving module names;
-  use `filename_suffix` instead of the hardcoded `_generated` one;
-  generate empty files if no structs or enums are available. This makes the set of output files more predictable for Bazel.
This commit is contained in:
Anton Bobukh
2024-05-01 14:39:47 -07:00
committed by GitHub
parent 7106d86685
commit c696275eaf
9 changed files with 53 additions and 16 deletions

4
tests/FromInclude.py Normal file
View File

@@ -0,0 +1,4 @@
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: OtherNameSpace