cleaning up

This commit is contained in:
Yeicor
2024-02-16 20:35:27 +01:00
parent 0545d8fbe2
commit c10e5f0896
14 changed files with 58 additions and 105 deletions

View File

@@ -23,7 +23,7 @@ show_object = show
def _get_app() -> web.Application:
"""Required by aiohttp-devtools"""
logging.basicConfig(level=logging.DEBUG)
from logo.logo import build_logo
from logo import build_logo
server.show_cad(build_logo(), 'logo')
return server.app

View File

@@ -1,15 +1,19 @@
from typing import AsyncGenerator
async def glb_sequence_to_glbs(glb_sequence: AsyncGenerator[bytes, None]) -> AsyncGenerator[bytes, None]:
async def glb_sequence_to_glbs(glb_sequence: AsyncGenerator[bytes, None], count: int = -1) -> AsyncGenerator[bytes, None]:
"""Converts a sequence of GLB files into a single GLBS file.
This is a streaming response in the custom GLBS format which consists of the "GLBS" magic text followed by
a sequence of GLB files, each with a 4-byte little-endian length prefix."""
a count of GLB files (0xffffffff if unknown) and a sequence of GLB files, each with a length prefix. All numbers are
4-byte little-endian unsigned integers."""
# Write the magic text
yield b'GLBS'
# Write the count
yield count.to_bytes(4, 'little')
# Write the GLB files
async for glb in glb_sequence:
# Write the length prefix
@@ -26,7 +30,7 @@ if __name__ == '__main__':
yield b'glb00001'
yield b'glb2'
async for chunk in glb_sequence_to_glbs(glb_sequence()):
async for chunk in glb_sequence_to_glbs(glb_sequence(), 2):
print(chunk)
asyncio.run(test_glb_sequence_to_glbs())

View File

@@ -202,7 +202,7 @@ class Server:
if logger.isEnabledFor(logging.INFO):
# noinspection PyTypeChecker
export_data = tqdm.asyncio.tqdm(export_data, total=total_parts)
async for chunk in glb_sequence_to_glbs(export_data):
async for chunk in glb_sequence_to_glbs(export_data, total_parts):
await response.write(chunk)
finally:
# Close the export data subscription
@@ -308,7 +308,7 @@ class Server:
if logger.isEnabledFor(logging.INFO):
# noinspection PyTypeChecker
glbs_parts = tqdm.asyncio.tqdm(glbs_parts, total=total_export_size, position=0)
glbs_parts = glb_sequence_to_glbs(glbs_parts)
glbs_parts = glb_sequence_to_glbs(glbs_parts, total_export_size)
async for glbs_part in glbs_parts:
yield glbs_part
finally: