mirror of
https://github.com/thegeneralist01/twitter-openapi
synced 2026-01-11 07:30:37 +01:00
update task
Signed-off-by: ふぁ <yuki@yuki0311.com>
This commit is contained in:
parent
a45f91318e
commit
f15b064123
2 changed files with 26 additions and 0 deletions
3
.vscode/tasks.json
vendored
3
.vscode/tasks.json
vendored
|
|
@ -6,8 +6,10 @@
|
|||
"type": "shell",
|
||||
"linux": {
|
||||
"command": [
|
||||
"source .venv/bin/activate;",
|
||||
"python3 tools/build.py;",
|
||||
"java -jar openapi-generator-cli.jar generate -c test/python/openapi-generator-config.yaml -g python;",
|
||||
"python3 test/python/replace.py;",
|
||||
"python3 -m pip install ./python_generated;"
|
||||
]
|
||||
},
|
||||
|
|
@ -16,6 +18,7 @@
|
|||
".venv/Scripts/activate;",
|
||||
"python tools/build.py;",
|
||||
"java -jar openapi-generator-cli.jar generate -c test/python/openapi-generator-config.yaml -g python;",
|
||||
"python test/python/replace.py;",
|
||||
"python -m pip install ./python_generated;"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
23
test/python/replace.py
Normal file
23
test/python/replace.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import glob
|
||||
|
||||
for file in glob.glob("python_generated/openapi_client/models/*.py"):
|
||||
with open(file, "r") as f:
|
||||
text = f.read()
|
||||
|
||||
indent = " "
|
||||
|
||||
text = text.replace(
|
||||
f"{indent}{indent}try:",
|
||||
f"{indent}{indent}if match == 0:",
|
||||
)
|
||||
text = text.replace(
|
||||
f"{indent}{indent}except (ValidationError, ValueError) as e:",
|
||||
f"{indent}{indent}else:",
|
||||
)
|
||||
text = text.replace(
|
||||
f"{indent}{indent}{indent}error_messages.append(str(e))",
|
||||
f"{indent}{indent}{indent}pass",
|
||||
)
|
||||
|
||||
with open(file, "w") as f:
|
||||
f.write(text)
|
||||
Loading…
Add table
Add a link
Reference in a new issue