Closed Numenter closed 2 years ago
Just running subprocesses also seems hacky. Still questioning the usefulness, but at least it is cross platform.
I would do it something like the following: https://github.com/Joshix-1/Suffragium/commit/3d34685d0178afb7b4596dc958cb1eb6d6bab8d3 (That is linted with pylint, formatted with black)
Found few issues https://github.com/Joshix-1/Suffragium/commit/cb8d46cf01118345f8b8e0a0b4ad834f6cd719ac The game_path didn't work on linux
And I marked it as executable with chmod +x
game_path was in windows style. I use normpath to fix it, dont know if this works. (I don't use linux)
That doesn't work, my solution worked, and should also work on windows With your solution I don't get any output from the lint that tells me it didn't worked
Also please mark the file executable
the mode of the file didn't change Also printing the error code doesn't make any sense if it is a number returned from subprocess.run And it will get printed twice if it is a string. One time with sys.exit and the other time with the print
I change the chmod with "git update-index --chmod=+x run_gdtoolkit.py" and "git ls-files -s run_gdtoolkit.py" shows that it has 755, but when i commit its back to 644.
I would format it with black (which makes pylint happy too): https://github.com/Joshix-1/Suffragium/commit/865366cf3db5ed68a2fd016b2b4d69c4de87f83b
We could also use this script in the lint workflow
So, we're gonna comply with PEP 8 (Tabs vs Spaces).
Just running subprocesses also seems hacky.
How not to use subprocess, enlighten me. @BjoernAkAManf Best I can to is get paths to the scripts and now?
import gdtoolkit
gdtoolkit_path = os.path.dirname(gdtoolkit.__file__)
gdformat_path = os.path.join(gdtoolkit_path, "formatter")
gdlint_path = os.path.join(gdtoolkit_path, "linter")
Import gdformat and import gdlint are not working for me.
Cant look myself right now, but using import for path resolution is better than relying on shell / manual path parsing.
Id have a look at their respective main files though. Not that good with python though.
gdlint uses from gdtoolkit.linter.__main__ import main
and gdformat uses from gdtoolkit.formatter.__main__ import main
These both don't look like they are stable API. Both rely on sys.argv and the first even calls sys.exit. It would be really hacky to use those functions
I think just calling the commands (like we do now) is the best solution.
With the current solution there are a few problems:
This commit fixes all of that: https://github.com/Joshix-1/Suffragium/commit/bf755487c797ec6a237ab5393e08de03e1f3ec7f
Description
Added a python script for simpler use of the GDScript Toolkit. #52
Type of change
Output