From ad46a190ab5fb61ac5244f4715f70d60212432c8 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 2 Oct 2022 20:44:24 +0200 Subject: [PATCH] minor code cleaning --- app/scodoc/TrivialFormulator.py | 7 ++----- app/scodoc/sco_preferences.py | 32 +++++++++++++------------------- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/app/scodoc/TrivialFormulator.py b/app/scodoc/TrivialFormulator.py index 522709151..0920ab0e5 100644 --- a/app/scodoc/TrivialFormulator.py +++ b/app/scodoc/TrivialFormulator.py @@ -543,11 +543,8 @@ class TF(object): disabled_items = descr.get("disabled_items", {}) if vertical: lem.append("") - for i in range(len(labels)): + for i in range(len(labels)): # pylint: disable=consider-using-enumerate if input_type == "checkbox": - # from app.scodoc.sco_utils import log # debug only - # log('checkbox: values[%s] = "%s"' % (field,repr(values[field]) )) - # log("descr['allowed_values'][%s] = '%s'" % (i, repr(descr['allowed_values'][i]))) if ( values[field] and descr["allowed_values"][i] in values[field] @@ -563,7 +560,7 @@ class TF(object): else: try: v = int(values[field]) - except: + except (ValueError, KeyError): v = False if v: checked = 'checked="checked"' diff --git a/app/scodoc/sco_preferences.py b/app/scodoc/sco_preferences.py index 4e5a8a2f0..f63155836 100644 --- a/app/scodoc/sco_preferences.py +++ b/app/scodoc/sco_preferences.py @@ -2113,28 +2113,22 @@ class BasePreferences(object): if "explanation" in descr: del descr["explanation"] if formsemestre_id: - descr["explanation"] = ( - """ou utiliser paramètre global""" - % pref_name - ) - # if descr.get('only_global',False): - # # pas modifiable, donne juste la valeur courante - # descr['readonly'] = True - # descr['explanation'] = '(valeur globale, non modifiable)' - # elif + descr[ + "explanation" + ] = """ou utiliser paramètre global""" if formsemestre_id and self.is_global(formsemestre_id, pref_name): # valeur actuelle globale (ou vient d'etre supprimee localement): # montre la valeur et menus pour la rendre locale descr["readonly"] = True - menu_global = ( - """ - + """ - % pref_name - ) - # descr["explanation"] = menu_global cat_elems.append((pref_name, descr)) @@ -2144,18 +2138,18 @@ class BasePreferences(object): if title: form.append( ( - "sep_%s" % cat, - {"input_type": "separator", "title": "

%s

" % title}, + f"sep_{cat}", + {"input_type": "separator", "title": f"

{title}

"}, ) ) subtitle = cat_descr.get("subtitle", None) if subtitle: form.append( ( - "sepsub_%s" % cat, + f"sepsub_{cat}", { "input_type": "separator", - "title": '

%s

' % subtitle, + "title": f'

{subtitle}

', }, ) )