Commit e00ce53e authored by Félix Hartmann's avatar Félix Hartmann
Browse files

[bugfix] Fixes of encoding problems, maintaining Py2/3 compatibility.

parent b79c283b
......@@ -1196,8 +1196,10 @@ def show_tige_options():
# Ajout d'une boite tk pour l'export
toptige = Tk.Toplevel(master=root)
start_title = _("Settings for organ")
#start_title = _("Réglages pour l'organe")
toptige.title(start_title + " %i"%hdf5_tigeid)
if python2:
toptige.title(start_title.decode("utf8") + " %i"%hdf5_tigeid)
else:
toptige.title(start_title + " %i"%hdf5_tigeid)
#Case pour changer nom de la tige
idframe = Tk.Frame(toptige)
......@@ -1223,6 +1225,9 @@ def show_tige_options():
start_text = _("Export organ at")
end_text = _("to csv.")
if python2:
start_text = start_text.decode('utf8')
end_text = end_text.decode('utf8')
tigebutton_export = Tk.Button(master=toptige,
text=start_text+" t=%i "%(cur_image+1)+end_text,
command=export_one_tige)
......@@ -3334,15 +3339,18 @@ def _export_tige_id_mapper_to_csv(summary=True):
output_i["beta_tilde"] = beta_dict["beta_tilde"]
output_i["beta_fit_R2"] = beta_dict["R2"]
if gamma_dict is not None:
gamma_unit = gamma_dict["gamma_unit"]
if gamma_dict is not None and "gamma" in gamma_dict:
if python2:
gamma_unit = str(gamma_dict["gamma_unit"])
else:
gamma_unit = str(gamma_dict["gamma_unit"], "utf8")
output_i["gamma_(%s)"%gamma_unit] = gamma_dict["gamma"]
output_i["gamma_fit_R2"] = gamma_dict["R2"]
gamma_tilde = gamma_dict.get("gamma_tilde")
if gamma_tilde is not None:
output_i["gamma_tilde"] = gamma_tilde
if B_dict is not None:
if B_dict is not None and 'B' in B_dict:
B = B_dict["B"]
output_i["B"] = B
if gamma_dict is None or "gamma_tilde" not in gamma_dict:
......@@ -3355,18 +3363,28 @@ def _export_tige_id_mapper_to_csv(summary=True):
output_i["Lc"] = B_dict["Lc"]
if growth_dict is not None and "dLdt" in growth_dict:
dLdt_unit = growth_dict["dLdt_unit"]
if python2:
dLdt_unit = str(growth_dict["dLdt_unit"])
else:
dLdt_unit = str(growth_dict["dLdt_unit"], "utf8")
output_i["dLdt_(%s)"%dLdt_unit] = growth_dict["dLdt"]
if "Lgz" in growth_dict:
length_unit = growth_dict["length_unit"]
if python2:
length_unit = str(growth_dict["length_unit"])
RER_unit = str(growth_dict["RER_unit"])
else:
length_unit = str(growth_dict["length_unit"], "utf8")
RER_unit = str(growth_dict["RER_unit"], "utf8")
output_i["Lgz_(%s)"%length_unit] = growth_dict["Lgz"]
RER_unit = growth_dict["RER_unit"]
output_i["RER_(%s)"%RER_unit] = growth_dict["RER"]
if beta_dict is not None and "beta_tilde" in beta_dict:
output_i["radius_(%s)"%length_unit] = beta_dict["radius"]
output_i["Ainit_(rad)"] = beta_dict["Ainit"]
dAdt_unit = beta_dict["dAdt_unit"]
if python2:
dAdt_unit = str(beta_dict["dAdt_unit"])
else:
dAdt_unit = str(beta_dict["dAdt_unit"], "utf8")
output_i["dAdt_(%s)"%dAdt_unit] = beta_dict["dAdt"]
output_i['scale (cm/pix)'] = scale_cmpix
......@@ -4549,15 +4567,15 @@ class Interekt:
Nimgs = len(files_to_process)
for i, f in enumerate(files_to_process):
# On affiche l'état d'avancement
msg1_fr = ("""Création du fichier interekt_data.h5"""
"""\ndans le dossier""")
msg2_fr = ("""\nConversion des images...""")
msg1_en = _(
"""Creating the file interekt_data.h5\nin the folder""")
msg2_en = _("""\nConverting images...""")
self.display_message(msg1_en + " %s"%base_dir_path + msg2_en
+ " (%i/%i)"%(i, Nimgs))
msg1 = _("""Creating the file interekt_data.h5\nin the folder""")
msg2 = _("""\nConverting images...""")
if python2:
self.display_message(
msg1.decode('utf8') + " %s"%base_dir_path
+ msg2.decode('utf8') + " (%i/%i)"%(i, Nimgs))
else:
self.display_message(msg1 + " %s"%base_dir_path + msg2
+ " (%i/%i)"%(i, Nimgs))
# On augmente la barre de progression du GUI
dstep = 1/float(Nimgs) * 100.
......@@ -4612,7 +4630,11 @@ def set_string_variables():
strings["residuals"] = _("residuals")
strings["initial"] = _("initial")
strings["Missing data"] = _("Missing data")
strings["Unit mismatch"] = _("Unit mismatch") # "Unités incompatibles"
strings["Unit mismatch"] = _("Unit mismatch")
if python2:
for key, value in strings.items():
strings[key] = value.decode('utf8')
# Set the local directory
localedir = 'locales'
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment