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
Initial Python formatting support #3349
6d1fd7b
187d95d
8ba3eaf
a7e2e3d
82e9c5e
cbfcc86
7c2c214
a50a814
94232a3
2202873
fbe50d1
ba41b84
ea29e61
aaafebe
fac5edb
5474a79
3556f22
85aa173
165e547
556e158
a8f3202
c428caf
c0575f0
dd94da5
3b53d84
402b33a
fd6b16a
17681b1
1fab998
baa6d12
5800c91
b211ae7
a49e33a
aa3034e
df95c2c
e580c1e
da93748
ecc4ca9
7a610ae
24a6055
420ae3e
965a2d3
bee186b
1e77b84
abeb823
e8d411b
18e0b2b
7abd3ea
31e3b5e
fab0613
c5bc80a
98a1fec
4b750da
e9f5001
833b1e5
335a038
e3f2efd
2ca480a
2284911
362bc1c
01dd211
b8e5540
2402462
2abdd58
3f8296a
66c4be6
661aeaf
3db54a1
f56f434
d6e5dc7
320ab4f
93d1633
e1d6e78
01ee4b3
20a0ea1
bf155c5
029b7a9
f854f5a
3cea3e4
c461605
Diff settings
| @@ -14,7 +14,8 @@ const parsers = [ | ||
| "graphql", | ||
| "postcss", | ||
| "parse5", | ||
| "markdown" | ||
| "markdown", | ||
| "python" | ||
Show comment
Hide comment
Show comment
Hide comment
azz
Member
|
||
| ]; | ||
| function pipe(string) { | ||
| @@ -0,0 +1,36 @@ | ||
| "use strict"; | ||
| const spawnSync = require("child_process").spawnSync; | ||
| const path = require("path"); | ||
| function parseText(text, pythonExecutable) { | ||
| const executionResult = spawnSync( | ||
| pythonExecutable, | ||
| [path.join(__dirname, "../vendor/python/astexport.py")], | ||
| { | ||
| input: text | ||
| } | ||
| ); | ||
| const error = executionResult.stderr.toString(); | ||
| if (error) { | ||
| throw new Error(error); | ||
| } | ||
| return executionResult; | ||
| } | ||
| function parse(text, parsers, opts) { | ||
| const pythonExectuable = `python${opts.pythonVersion}`; | ||
Show comment
Hide comment
azz
Member
|
||
| const executionResult = parseText(text, pythonExectuable); | ||
| const ast = JSON.parse(executionResult.stdout.toString()); | ||
| // TODO: add comments | ||
| ast.comments = []; | ||
| return ast; | ||
| } | ||
| module.exports = parse; | ||
nit: newline here