[deps] added pyods3 for organigramme..., deleted CSVresponse from libs

This commit is contained in:
Maxime Alves LIRMM 2020-07-16 17:52:46 +02:00
parent 5bc97a2a58
commit ceb0b075de
2 changed files with 3 additions and 17 deletions

View File

@ -7,28 +7,13 @@ from io import TextIOBase, StringIO
# asgi framework # asgi framework
from starlette.responses import PlainTextResponse, Response from starlette.responses import PlainTextResponse, Response
__all__ = ['CSVResponse', __all__ = [
'InternalServerErrorResponse', 'InternalServerErrorResponse',
'NotFoundResponse', 'NotFoundResponse',
'NotImplementedResponse', 'NotImplementedResponse',
'PlainTextResponse', 'PlainTextResponse',
'UnauthorizedResponse'] 'UnauthorizedResponse']
class CSVResponse(Response):
def __init__(self, obj):
with StringIO() as csv_file:
csv_obj = csv.writer(csv_file, dialect="excel")
csv_obj.writerows([elt.values() for elt in obj])
filename = f'Personnels_LIRMM-{date.today()}.csv'
super().__init__(
content=csv_file.getvalue(),
headers={
'Content-Type': 'text/csv; charset=UTF-8',
'Content-Disposition': f'attachment; filename="{filename}"'},
status_code = 200)
class InternalServerErrorResponse(Response): class InternalServerErrorResponse(Response):
""" The 500 Internal Server Error default Response """ The 500 Internal Server Error default Response

View File

@ -17,6 +17,7 @@ fastapi = { version = "^0", optional = true }
organigramme = { git = "git@gite.lirmm.fr:newsi/api/organigramme.git", optional = true } organigramme = { git = "git@gite.lirmm.fr:newsi/api/organigramme.git", optional = true }
sidb = { git = "git@gite.lirmm.fr:newsi/sidb_halfORM.git", optional = true } sidb = { git = "git@gite.lirmm.fr:newsi/sidb_halfORM.git", optional = true }
python-dotenv = "^0.14.0" python-dotenv = "^0.14.0"
pyexcel-ods3 = { version = "^0.5.3", optional = true }
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]
pytest = "^5" pytest = "^5"
@ -24,7 +25,7 @@ requests = "^2"
pytest-env = "^0.6.2" pytest-env = "^0.6.2"
[tool.poetry.extras] [tool.poetry.extras]
organigramme = [ "fastapi", "organigramme", "sidb" ] organigramme = [ "fastapi", "organigramme", "sidb", "pyexcel-ods3" ]
[tool.poetry.scripts] [tool.poetry.scripts]
halfapi = 'halfapi.cli:cli' halfapi = 'halfapi.cli:cli'