1- from flask import Blueprint , request
1+ from flask import Blueprint , request
22from typing import List , Dict , Any , Union
33from utils_flask_sqla .response import json_resp
44
99 get_taxa_by_cd_nom ,
1010 get_all_medias_types ,
1111 get_all_attributes ,
12- refresh_taxonlist
12+ refresh_taxonlist ,
1313)
1414
1515taxo_api = Blueprint ("taxonomy" , __name__ )
1616
17+
1718@taxo_api .route ("/taxonomy/refresh" , methods = ["GET" ])
1819@json_resp
1920def refresh ():
@@ -57,7 +58,7 @@ def get_lists():
5758@taxo_api .route ("/taxonomy/lists/<int:id>/species" , methods = ["GET" ])
5859@json_resp
5960# @lru_cache()
60- def get_list (id )-> Union [List [Dict [str , Any ]], Dict [str , str ]]:
61+ def get_list (id ) -> Union [List [Dict [str , Any ]], Dict [str , str ]]:
6162 """Renvoie l'ensemble des espèces de la liste demandée.
6263
6364 GET /taxonomy/lists/<id>/species
@@ -252,20 +253,21 @@ def get_list(id)-> Union[List[Dict[str, Any]], Dict[str, str]]:
252253 message: "Invalid list ID"
253254 raises:
254255 Exception: En cas d'erreur inattendue pendant le traitement.
255- """
256+ """
256257
257258 try :
258259 params = request .args .to_dict ()
259260 res = taxhub_rest_get_taxon_list (id , params )
260261 if isinstance (res , dict ) and "items" in res :
261- reformatted_taxa = reformat_taxa (res )
262+ reformatted_taxa = reformat_taxa (res )
262263 else :
263264 reformatted_taxa = []
264265 print (reformatted_taxa )
265266 return reformatted_taxa
266267 except Exception as e :
267268 return {"message" : str (e )}, 400
268269
270+
269271@taxo_api .route ("/taxonomy/taxon/<int:cd_nom>" , methods = ["GET" ])
270272@json_resp
271273def get_taxon_from_cd_nom (cd_nom ):
@@ -292,12 +294,12 @@ def get_taxon_from_cd_nom(cd_nom):
292294 return get_taxa_by_cd_nom (cd_nom = cd_nom )
293295 except Exception as e :
294296 return {"message" : str (e )}, 400
295-
297+
296298
297299@taxo_api .route ("/taxonomy/tmedias/types" , methods = ["GET" ])
298300@json_resp
299- def get_media_types ()-> List [Dict [str , Union [int , str ]]]:
300- """Get all media types.
301+ def get_media_types () -> List [Dict [str , Union [int , str ]]]:
302+ """Get all media types.
301303 ---
302304 tags:
303305 - Taxon
@@ -330,15 +332,16 @@ def get_media_types()-> List[Dict[str, Union[int, str]]]:
330332 message:
331333 type: string
332334 description: Error message.
333- """
334- try :
335- return get_all_medias_types ()
336- except Exception as e :
337- return {"message" : str (e )}, 400
335+ """
336+ try :
337+ return get_all_medias_types ()
338+ except Exception as e :
339+ return {"message" : str (e )}, 400
340+
338341
339342@taxo_api .route ("/taxonomy/bibattributs" , methods = ["GET" ])
340343@json_resp
341- def get_attributes ()-> List [Dict [str , Union [int , str ]]]:
344+ def get_attributes () -> List [Dict [str , Union [int , str ]]]:
342345 """
343346 Get all attributes.
344347 ---
@@ -404,4 +407,4 @@ def get_attributes()-> List[Dict[str, Union[int, str]]]:
404407 try :
405408 return get_all_attributes ()
406409 except Exception as e :
407- return {"message" : str (e )}, 400
410+ return {"message" : str (e )}, 400
0 commit comments