diff --git a/app/scodoc/sco_excel.py b/app/scodoc/sco_excel.py index 9a9faf6e..e8c02fe9 100644 --- a/app/scodoc/sco_excel.py +++ b/app/scodoc/sco_excel.py @@ -567,23 +567,27 @@ def excel_bytes_to_list(bytes_content): filelike = io.BytesIO(bytes_content) return _excel_to_list(filelike) except: - raise ScoValueError(""" + raise ScoValueError( + """ scolars_import_excel_file: un contenu xlsx semble corrompu! peut-être avez vous fourni un fichier au mauvais format (txt, xls, ..) - """) + """ + ) def excel_file_to_list(filename): try: return _excel_to_list(filename) except: - raise ScoValueError(""" - scolars_import_excel_file: un contenu xlsx semble corrompu! - peut-être avez vous fourni un fichier au mauvais format (txt, xls, ..) - """) + raise ScoValueError( + """scolars_import_excel_file: un contenu xlsx + semble corrompu ! + Peut-être avez-vous fourni un fichier au mauvais format (txt, xls, ...) + """ + ) -def _excel_to_list(filelike): # we may need 'encoding' argument ? +def _excel_to_list(filelike): """returns list of list convert_to_string is a conversion function applied to all non-string values (ie numbers) """ @@ -591,7 +595,8 @@ def _excel_to_list(filelike): # we may need 'encoding' argument ? wb = load_workbook(filename=filelike, read_only=True, data_only=True) except: log("Excel_to_list: failure to import document") - open("/tmp/last_scodoc_import_failure" + scu.XLSX_SUFFIX, "wb").write(filelike) + with open("/tmp/last_scodoc_import_failure" + scu.XLSX_SUFFIX, "wb") as f: + f.write(filelike) raise ScoValueError( "Fichier illisible: assurez-vous qu'il s'agit bien d'un document Excel !" )