| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
… is flattened into two python packages
… its possible to debug it.
…s fixed before.
…essage # Conflicts: # betterproto/plugin.py
There was a problem hiding this comment.
Looks good. Multiple passes is definitely a step in the right direction.
I'd say it's good to go with a couple tweaks.
Sorry, something went wrong.
| Then run plugin.py from your IDE in debugging mode, and redirect stdin to the file. | ||
| """ | ||
| with open(str(dump_file), "wb") as fh: | ||
| sys.stderr.write(f"\033[31mWriting: {dump_file}\033[0m\n") |
There was a problem hiding this comment.
| sys.stderr.write(f"\033[31mWriting: {dump_file}\033[0m\n") | |
| sys.stderr.write(f"\033[31mWriting input from protoc to: {dump_file}\033[0m\n") |
Sorry, something went wrong.
| request = plugin.CodeGeneratorRequest() | ||
| request.ParseFromString(data) | ||
|
|
||
| dump_file = os.getenv("DUMP_FILE") |
There was a problem hiding this comment.
| dump_file = os.getenv("DUMP_FILE") | |
| dump_file = os.getenv("BETTERPROTO_DUMP") |
Sorry, something went wrong.
|
|
||
| for filename in sorted(output_paths.union(init_files)): | ||
| print(f"Writing {filename}", file=sys.stderr) | ||
| for output_package_name in sorted(output_paths.union(init_files)): |
There was a problem hiding this comment.
this diff sucks
Sorry, something went wrong.
There was a problem hiding this comment.
yeah, it went pretty bad after splitting up code into methods and renaming a bunch of vars :-/
should happen less and less as we get the code more organized
Sorry, something went wrong.
| print(f"Writing {output_package_name}", file=sys.stderr) | ||
|
|
||
|
|
||
| def lookup_method_input_type(method, types): |
There was a problem hiding this comment.
could move this method closer to where it's used (swap with read_protobuf_type)
Sorry, something went wrong.
|
Just a quick note about debugging: I had good success using VSCode with ptsvd. In plugin.py: def main():
import ptvsd
ptvsd.enable_attach()
ptvsd.wait_for_attach() # blocks execution until debugger is attachedAnd set breakpoints in VSCode wherever you want to drop into. Then in launch.json: {
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": false,
},
{
"name": "Attach (Remote Debug)",
"type": "python",
"request": "attach",
"localRoot": "${workspaceRoot}",
"remoteRoot": "${workspaceRoot}",
"port": 5678,
"secret": "",
"host":"0.0.0.0",
"justMyCode": false,
},
]
}Now running anything that calls plugin.py will just wait until you attach the VSCode debugger before continuing (and stopping at your breakpoints). |
Sorry, something went wrong.
Awesome tip! I took a note when you mentioned it on slack, and also found that PyCharm has something similar for those who use it. Haven't tried it yet tho! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fixes #23
Due to too much juggling with different branches, and an incorrect test-case, I mistakenly thought this bug was already fixed earlier.
The bug:
The solution
Additionally: