diff --git a/app/scodoc/sco_apogee_csv.py b/app/scodoc/sco_apogee_csv.py index 1e9610c1ba..28a02a6934 100644 --- a/app/scodoc/sco_apogee_csv.py +++ b/app/scodoc/sco_apogee_csv.py @@ -177,7 +177,7 @@ def fix_data_encoding( return text, message -class StringIOFileLineWrapper(object): +class StringIOFileLineWrapper: def __init__(self, data: str): self.f = io.StringIO(data) self.lineno = 0 @@ -1098,14 +1098,14 @@ def _apo_read_cols(f): # sanity check col_id = fs[0] # apoL_c0001, ... if col_id in cols: - raise ScoFormatError("duplicate column definition: %s" % col_id) + raise ScoFormatError(f"duplicate column definition: {col_id}") m = re.match(r"^apoL_c([0-9]{4})$", col_id) if not m: raise ScoFormatError( - "invalid column id: %s (expecting apoL_c%04d)" % (line, col_id) + f"invalid column id: {line} (expecting apoL_c{col_id})" ) if int(m.group(1)) != i: - raise ScoFormatError("invalid column id: %s for index %s" % (col_id, i)) + raise ScoFormatError(f"invalid column id: {col_id} for index {i}") cols[col_id] = DictCol(list(zip(col_keys, fs))) cols[col_id].lineno = f.lineno # for debuging purpose @@ -1127,11 +1127,10 @@ def _apo_read_TITRES(f): if len(fields) == 2: k, v = fields else: - log("Error read CSV: \nline=%s\nfields=%s" % (line, fields)) + log(f"Error read CSV: \nline={line}\nfields={fields}") log(dir(f)) raise ScoFormatError( - "Fichier Apogee incorrect (section titres, %d champs au lieu de 2)" - % len(fields) + f"Fichier Apogee incorrect (section titres, {len(fields)} champs au lieu de 2)" ) d[k] = v #