From d33c82e34881de4106f28e08d29db53fabc69f3a Mon Sep 17 00:00:00 2001 From: Maxime Alves LIRMM Date: Thu, 10 Feb 2022 10:30:19 +0100 Subject: [PATCH] [0.6.7] fix ODSResponse --- halfapi/__init__.py | 2 +- halfapi/lib/responses.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/halfapi/__init__.py b/halfapi/__init__.py index 8bdd8e4..f6cd348 100644 --- a/halfapi/__init__.py +++ b/halfapi/__init__.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -__version__ = '0.6.6' +__version__ = '0.6.7' def version(): return f'HalfAPI version:{__version__}' diff --git a/halfapi/lib/responses.py b/halfapi/lib/responses.py index 8984ad4..6001acb 100644 --- a/halfapi/lib/responses.py +++ b/halfapi/lib/responses.py @@ -26,6 +26,7 @@ import orjson from starlette.responses import PlainTextResponse, Response, JSONResponse from .user import JWTUser, Nobody +from ..logging import logger __all__ = [ @@ -129,8 +130,15 @@ class ODSResponse(Response): return with BytesIO() as ods_file: - # rows.insert(0, rownames) - self.sheet = pe.Sheet(d_rows) + rows = [] + if len(d_rows): + rows_names = list(d_rows[0].keys()) + for elt in d_rows: + rows.append(list(elt.values())) + + rows.insert(rows_names) + + self.sheet = pe.Sheet(rows) self.sheet.save_to_memory( file_type='ods', stream=ods_file)