better indent

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2022-02-27 21:23:35 -08:00
parent b09684bd9e
commit 0b9c32e6bf
8 changed files with 183 additions and 98 deletions

View File

@ -136,8 +136,10 @@ def generatePath(path: str, name: str, method: str, endpoint: dict):
": " +
parameter_type +
",\n")
f.write("*, client: Client) -> Dict[str, Any]:\n")
f.write("\turl = \"{}" + name + "\".format(client.base_url,\n")
f.write("\t*,\n")
f.write("\tclient: Client,\n")
f.write(") -> Dict[str, Any]:\n")
f.write("\turl = \"{}" + name + "\".format(client.base_url")
# Iterate over the parameters.
if 'parameters' in endpoint:
parameters = endpoint['parameters']
@ -153,12 +155,11 @@ def generatePath(path: str, name: str, method: str, endpoint: dict):
print(" parameter: ", parameter)
raise Exception("Unknown parameter type")
f.write(
"\t" +
", " +
parameter_name +
"=" +
camel_to_snake(parameter_name) +
",\n")
f.write("\t)\n")
camel_to_snake(parameter_name))
f.write(")\n")
f.write("\n")
f.write("\theaders: Dict[str, Any] = client.get_headers()\n")
f.write("\tcookies: Dict[str, Any] = client.get_cookies()\n")
@ -244,7 +245,9 @@ def generatePath(path: str, name: str, method: str, endpoint: dict):
": " +
parameter_type +
",\n")
f.write("*, client: Client) -> Response[Union[Any, " +
f.write("\t*,\n")
f.write("\tclient: Client,\n")
f.write(") -> Response[Union[Any, " +
", ".join(endoint_refs) +
"]]:\n")
f.write("\tkwargs = _get_kwargs(\n")
@ -303,7 +306,9 @@ def generatePath(path: str, name: str, method: str, endpoint: dict):
": " +
parameter_type +
",\n")
f.write("*, client: Client) -> Optional[Union[Any, " +
f.write("\t*,\n")
f.write("\tclient: Client,\n")
f.write(") -> Optional[Union[Any, " +
", ".join(endoint_refs) +
"]]:\n")
if 'description' in endpoint:
@ -325,7 +330,7 @@ def generatePath(path: str, name: str, method: str, endpoint: dict):
print(" parameter: ", parameter)
raise Exception("Unknown parameter type")
f.write(
"\t" +
"\t\t" +
camel_to_snake(parameter_name) +
"=" +
camel_to_snake(parameter_name) +
@ -358,7 +363,9 @@ def generatePath(path: str, name: str, method: str, endpoint: dict):
": " +
parameter_type +
",\n")
f.write("*, client: Client) -> Response[Union[Any, " +
f.write("\t*,\n")
f.write("\tclient: Client,\n")
f.write(") -> Response[Union[Any, " +
", ".join(endoint_refs) +
"]]:\n")
f.write("\tkwargs = _get_kwargs(\n")
@ -415,13 +422,16 @@ def generatePath(path: str, name: str, method: str, endpoint: dict):
": " +
parameter_type +
",\n")
f.write("*, client: Client) -> Optional[Union[Any, " +
f.write("\t*,\n")
f.write("\tclient: Client,\n")
f.write(") -> Optional[Union[Any, " +
", ".join(endoint_refs) +
"]]:\n")
if 'description' in endpoint:
f.write("\t\"\"\" " + endpoint['description'] + " \"\"\"\n")
f.write("\n")
f.write("\treturn (await asyncio_detailed(\n")
f.write("\treturn (\n")
f.write("\t\tawait asyncio_detailed(\n")
# Iterate over the parameters.
if 'parameters' in endpoint:
parameters = endpoint['parameters']
@ -437,13 +447,14 @@ def generatePath(path: str, name: str, method: str, endpoint: dict):
print(" parameter: ", parameter)
raise Exception("Unknown parameter type")
f.write(
"\t\t" +
"\t\t\t" +
camel_to_snake(parameter_name) +
"=" +
camel_to_snake(parameter_name) +
",\n")
f.write("\t\tclient=client,\n")
f.write("\t)).parsed\n")
f.write("\t\t\tclient=client,\n")
f.write("\t\t)\n")
f.write("\t).parsed\n")
# Close the file.
f.close()
@ -864,6 +875,7 @@ def getEndpointRefs(endpoint: dict) -> [str]:
json = content[content_type]['schema']
if '$ref' in json:
ref = json['$ref'].replace('#/components/schemas/', '')
if ref not in refs:
refs.append(ref)
return refs

View File

@ -8,10 +8,10 @@ from ...types import Response
def _get_kwargs(
id: str,
*, client: Client) -> Dict[str, Any]:
url = "{}/file/conversion/{id}".format(client.base_url,
id=id,
)
*,
client: Client,
) -> Dict[str, Any]:
url = "{}/file/conversion/{id}".format(client.base_url, id=id)
headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()
@ -57,7 +57,9 @@ def _build_response(*, response: httpx.Response) -> Response[Union[Any, FileConv
def sync_detailed(
id: str,
*, client: Client) -> Response[Union[Any, FileConversion]]:
*,
client: Client,
) -> Response[Union[Any, FileConversion]]:
kwargs = _get_kwargs(
id=id,
client=client,
@ -73,7 +75,9 @@ def sync_detailed(
def sync(
id: str,
*, client: Client) -> Optional[Union[Any, FileConversion]]:
*,
client: Client,
) -> Optional[Union[Any, FileConversion]]:
""" Get the status and output of an async file conversion. """
return sync_detailed(
@ -84,7 +88,9 @@ def sync(
async def asyncio_detailed(
id: str,
*, client: Client) -> Response[Union[Any, FileConversion]]:
*,
client: Client,
) -> Response[Union[Any, FileConversion]]:
kwargs = _get_kwargs(
id=id,
client=client,
@ -98,10 +104,14 @@ async def asyncio_detailed(
async def asyncio(
id: str,
*, client: Client) -> Optional[Union[Any, FileConversion]]:
*,
client: Client,
) -> Optional[Union[Any, FileConversion]]:
""" Get the status and output of an async file conversion. """
return (await asyncio_detailed(
return (
await asyncio_detailed(
id=id,
client=client,
)).parsed
)
).parsed

View File

@ -4,7 +4,6 @@ import httpx
from ...client import Client
from ...models.file_conversion import FileConversion
from ...models.file_conversion import FileConversion
from ...models.valid_source_file_format import ValidSourceFileFormat
from ...models.valid_output_file_format import ValidOutputFileFormat
from ...types import Response
@ -12,11 +11,10 @@ from ...types import Response
def _get_kwargs(
source_format: ValidSourceFileFormat,
output_format: ValidOutputFileFormat,
*, client: Client) -> Dict[str, Any]:
url = "{}/file/conversion/{sourceFormat}/{outputFormat}".format(client.base_url,
sourceFormat=source_format,
outputFormat=output_format,
)
*,
client: Client,
) -> Dict[str, Any]:
url = "{}/file/conversion/{sourceFormat}/{outputFormat}".format(client.base_url, sourceFormat=source_format, outputFormat=output_format)
headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()
@ -29,7 +27,7 @@ def _get_kwargs(
}
def _parse_response(*, response: httpx.Response) -> Optional[Union[Any, FileConversion, FileConversion]]:
def _parse_response(*, response: httpx.Response) -> Optional[Union[Any, FileConversion]]:
if response.status_code == 200:
response_200 = FileConversion.from_dict(response.json())
return response_200
@ -54,7 +52,7 @@ def _parse_response(*, response: httpx.Response) -> Optional[Union[Any, FileConv
return None
def _build_response(*, response: httpx.Response) -> Response[Union[Any, FileConversion, FileConversion]]:
def _build_response(*, response: httpx.Response) -> Response[Union[Any, FileConversion]]:
return Response(
status_code=response.status_code,
content=response.content,
@ -66,7 +64,9 @@ def _build_response(*, response: httpx.Response) -> Response[Union[Any, FileConv
def sync_detailed(
source_format: ValidSourceFileFormat,
output_format: ValidOutputFileFormat,
*, client: Client) -> Response[Union[Any, FileConversion, FileConversion]]:
*,
client: Client,
) -> Response[Union[Any, FileConversion]]:
kwargs = _get_kwargs(
source_format=source_format,
output_format=output_format,
@ -84,7 +84,9 @@ def sync_detailed(
def sync(
source_format: ValidSourceFileFormat,
output_format: ValidOutputFileFormat,
*, client: Client) -> Optional[Union[Any, FileConversion, FileConversion]]:
*,
client: Client,
) -> Optional[Union[Any, FileConversion]]:
""" Convert a CAD file from one format to another. If the file being converted is larger than 30MB, it will be performed asynchronously. """
return sync_detailed(
@ -97,7 +99,9 @@ def sync(
async def asyncio_detailed(
source_format: ValidSourceFileFormat,
output_format: ValidOutputFileFormat,
*, client: Client) -> Response[Union[Any, FileConversion, FileConversion]]:
*,
client: Client,
) -> Response[Union[Any, FileConversion]]:
kwargs = _get_kwargs(
source_format=source_format,
output_format=output_format,
@ -113,11 +117,15 @@ async def asyncio_detailed(
async def asyncio(
source_format: ValidSourceFileFormat,
output_format: ValidOutputFileFormat,
*, client: Client) -> Optional[Union[Any, FileConversion, FileConversion]]:
*,
client: Client,
) -> Optional[Union[Any, FileConversion]]:
""" Convert a CAD file from one format to another. If the file being converted is larger than 30MB, it will be performed asynchronously. """
return (await asyncio_detailed(
return (
await asyncio_detailed(
source_format=source_format,
output_format=output_format,
client=client,
)).parsed
)
).parsed

View File

@ -6,9 +6,10 @@ from ...client import Client
from ...types import Response
def _get_kwargs(
*, client: Client) -> Dict[str, Any]:
url = "{}/_internal/gpu/devices".format(client.base_url,
)
*,
client: Client,
) -> Dict[str, Any]:
url = "{}/_internal/gpu/devices".format(client.base_url)
headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()
@ -43,7 +44,9 @@ def _build_response(*, response: httpx.Response) -> Response[Union[Any, ]]:
def sync_detailed(
*, client: Client) -> Response[Union[Any, ]]:
*,
client: Client,
) -> Response[Union[Any, ]]:
kwargs = _get_kwargs(
client=client,
)
@ -57,7 +60,9 @@ def sync_detailed(
def sync(
*, client: Client) -> Optional[Union[Any, ]]:
*,
client: Client,
) -> Optional[Union[Any, ]]:
""" Get information about GPU devices on this server. This is primarily used for debugging. This endpoint can only be used by specific KittyCAD employees. """
return sync_detailed(
@ -66,7 +71,9 @@ def sync(
async def asyncio_detailed(
*, client: Client) -> Response[Union[Any, ]]:
*,
client: Client,
) -> Response[Union[Any, ]]:
kwargs = _get_kwargs(
client=client,
)
@ -78,9 +85,13 @@ async def asyncio_detailed(
async def asyncio(
*, client: Client) -> Optional[Union[Any, ]]:
*,
client: Client,
) -> Optional[Union[Any, ]]:
""" Get information about GPU devices on this server. This is primarily used for debugging. This endpoint can only be used by specific KittyCAD employees. """
return (await asyncio_detailed(
return (
await asyncio_detailed(
client=client,
)).parsed
)
).parsed

View File

@ -7,9 +7,10 @@ from ...models.file_conversion import FileConversion
from ...types import Response
def _get_kwargs(
*, client: Client) -> Dict[str, Any]:
url = "{}/_internal/async/conversions/stop".format(client.base_url,
)
*,
client: Client,
) -> Dict[str, Any]:
url = "{}/_internal/async/conversions/stop".format(client.base_url)
headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()
@ -48,7 +49,9 @@ def _build_response(*, response: httpx.Response) -> Response[Union[Any, FileConv
def sync_detailed(
*, client: Client) -> Response[Union[Any, FileConversion]]:
*,
client: Client,
) -> Response[Union[Any, FileConversion]]:
kwargs = _get_kwargs(
client=client,
)
@ -62,7 +65,9 @@ def sync_detailed(
def sync(
*, client: Client) -> Optional[Union[Any, FileConversion]]:
*,
client: Client,
) -> Optional[Union[Any, FileConversion]]:
""" Stop all async conversions that are currently running. This endpoint can only be used by specific KittyCAD employees. """
return sync_detailed(
@ -71,7 +76,9 @@ def sync(
async def asyncio_detailed(
*, client: Client) -> Response[Union[Any, FileConversion]]:
*,
client: Client,
) -> Response[Union[Any, FileConversion]]:
kwargs = _get_kwargs(
client=client,
)
@ -83,9 +90,13 @@ async def asyncio_detailed(
async def asyncio(
*, client: Client) -> Optional[Union[Any, FileConversion]]:
*,
client: Client,
) -> Optional[Union[Any, FileConversion]]:
""" Stop all async conversions that are currently running. This endpoint can only be used by specific KittyCAD employees. """
return (await asyncio_detailed(
return (
await asyncio_detailed(
client=client,
)).parsed
)
).parsed

View File

@ -7,9 +7,10 @@ from ...models.auth_session import AuthSession
from ...types import Response
def _get_kwargs(
*, client: Client) -> Dict[str, Any]:
url = "{}/_meta/debug/session".format(client.base_url,
)
*,
client: Client,
) -> Dict[str, Any]:
url = "{}/_meta/debug/session".format(client.base_url)
headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()
@ -45,7 +46,9 @@ def _build_response(*, response: httpx.Response) -> Response[Union[Any, AuthSess
def sync_detailed(
*, client: Client) -> Response[Union[Any, AuthSession]]:
*,
client: Client,
) -> Response[Union[Any, AuthSession]]:
kwargs = _get_kwargs(
client=client,
)
@ -59,7 +62,9 @@ def sync_detailed(
def sync(
*, client: Client) -> Optional[Union[Any, AuthSession]]:
*,
client: Client,
) -> Optional[Union[Any, AuthSession]]:
""" Get information about your API request session. This is primarily used for debugging. """
return sync_detailed(
@ -68,7 +73,9 @@ def sync(
async def asyncio_detailed(
*, client: Client) -> Response[Union[Any, AuthSession]]:
*,
client: Client,
) -> Response[Union[Any, AuthSession]]:
kwargs = _get_kwargs(
client=client,
)
@ -80,9 +87,13 @@ async def asyncio_detailed(
async def asyncio(
*, client: Client) -> Optional[Union[Any, AuthSession]]:
*,
client: Client,
) -> Optional[Union[Any, AuthSession]]:
""" Get information about your API request session. This is primarily used for debugging. """
return (await asyncio_detailed(
return (
await asyncio_detailed(
client=client,
)).parsed
)
).parsed

View File

@ -7,9 +7,10 @@ from ...models.instance import Instance
from ...types import Response
def _get_kwargs(
*, client: Client) -> Dict[str, Any]:
url = "{}/_meta/debug/instance".format(client.base_url,
)
*,
client: Client,
) -> Dict[str, Any]:
url = "{}/_meta/debug/instance".format(client.base_url)
headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()
@ -45,7 +46,9 @@ def _build_response(*, response: httpx.Response) -> Response[Union[Any, Instance
def sync_detailed(
*, client: Client) -> Response[Union[Any, Instance]]:
*,
client: Client,
) -> Response[Union[Any, Instance]]:
kwargs = _get_kwargs(
client=client,
)
@ -59,7 +62,9 @@ def sync_detailed(
def sync(
*, client: Client) -> Optional[Union[Any, Instance]]:
*,
client: Client,
) -> Optional[Union[Any, Instance]]:
""" Get information about this specific API server instance. This is primarily used for debugging. """
return sync_detailed(
@ -68,7 +73,9 @@ def sync(
async def asyncio_detailed(
*, client: Client) -> Response[Union[Any, Instance]]:
*,
client: Client,
) -> Response[Union[Any, Instance]]:
kwargs = _get_kwargs(
client=client,
)
@ -80,9 +87,13 @@ async def asyncio_detailed(
async def asyncio(
*, client: Client) -> Optional[Union[Any, Instance]]:
*,
client: Client,
) -> Optional[Union[Any, Instance]]:
""" Get information about this specific API server instance. This is primarily used for debugging. """
return (await asyncio_detailed(
return (
await asyncio_detailed(
client=client,
)).parsed
)
).parsed

View File

@ -7,9 +7,10 @@ from ...models.pong_message import PongMessage
from ...types import Response
def _get_kwargs(
*, client: Client) -> Dict[str, Any]:
url = "{}/ping".format(client.base_url,
)
*,
client: Client,
) -> Dict[str, Any]:
url = "{}/ping".format(client.base_url)
headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()
@ -39,7 +40,9 @@ def _build_response(*, response: httpx.Response) -> Response[Union[Any, PongMess
def sync_detailed(
*, client: Client) -> Response[Union[Any, PongMessage]]:
*,
client: Client,
) -> Response[Union[Any, PongMessage]]:
kwargs = _get_kwargs(
client=client,
)
@ -53,7 +56,9 @@ def sync_detailed(
def sync(
*, client: Client) -> Optional[Union[Any, PongMessage]]:
*,
client: Client,
) -> Optional[Union[Any, PongMessage]]:
""" Simple ping to the server. """
return sync_detailed(
@ -62,7 +67,9 @@ def sync(
async def asyncio_detailed(
*, client: Client) -> Response[Union[Any, PongMessage]]:
*,
client: Client,
) -> Response[Union[Any, PongMessage]]:
kwargs = _get_kwargs(
client=client,
)
@ -74,9 +81,13 @@ async def asyncio_detailed(
async def asyncio(
*, client: Client) -> Optional[Union[Any, PongMessage]]:
*,
client: Client,
) -> Optional[Union[Any, PongMessage]]:
""" Simple ping to the server. """
return (await asyncio_detailed(
return (
await asyncio_detailed(
client=client,
)).parsed
)
).parsed