removed StringType

This commit is contained in:
Emmanuel Viennet 2021-07-11 18:18:44 +02:00
parent 2bc3dc66a3
commit c71dcd3824
10 changed files with 15 additions and 20 deletions

View File

@ -9,7 +9,7 @@
v 1.2 v 1.2
""" """
from types import BooleanType, StringType, UnicodeType from types import BooleanType, UnicodeType
def TrivialFormulator( def TrivialFormulator(
@ -745,7 +745,7 @@ def dict2js(d):
v = "true" v = "true"
else: else:
v = "false" v = "false"
elif type(v) == StringType or type(v) == UnicodeType: elif isinstance(v, str): # ne marchera pas en python2
v = '"' + v + '"' v = '"' + v + '"'
r.append("%s: %s" % (k, v)) r.append("%s: %s" % (k, v))
@ -756,7 +756,7 @@ def tf_error_message(msg):
"""html for form error message""" """html for form error message"""
if not msg: if not msg:
return "" return ""
if type(msg) == StringType: if isinstance(msg, str):
msg = [msg] msg = [msg]
return ( return (
'<ul class="tf-msg"><li class="tf-msg">%s</li></ul>' '<ul class="tf-msg"><li class="tf-msg">%s</li></ul>'

View File

@ -27,7 +27,7 @@
"""Calculs sur les notes et cache des resultats """Calculs sur les notes et cache des resultats
""" """
from types import StringType, FloatType from types import FloatType
import time import time
import pdb import pdb
import inspect import inspect

View File

@ -13,7 +13,6 @@ from flask import g
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log from app.scodoc.notes_log import log
from app.scodoc.sco_exceptions import ScoException, ScoValueError, NoteProcessError from app.scodoc.sco_exceptions import ScoException, ScoValueError, NoteProcessError
from types import StringType
from cgi import escape from cgi import escape
import datetime import datetime
@ -24,7 +23,7 @@ def quote_dict(d):
"html quote all values in dict" "html quote all values in dict"
for k in d.keys(): for k in d.keys():
v = d[k] v = d[k]
if type(v) == StringType: if isinstance(v, str):
d[k] = quote_html(v, quote=True) d[k] = quote_html(v, quote=True)
@ -475,7 +474,7 @@ def DateDMYtoISO(dmy, null_is_empty=False):
return "" return ""
else: else:
return None return None
if type(dmy) != StringType: if not isinstance(dmy, str):
return dmy.strftime("%Y-%m-%d") return dmy.strftime("%Y-%m-%d")
t = dmy.split("/") t = dmy.split("/")

View File

@ -29,7 +29,6 @@
""" """
import time import time
from types import StringType
import pprint import pprint
import email import email
from email.mime.multipart import MIMEMultipart from email.mime.multipart import MIMEMultipart
@ -249,7 +248,7 @@ def formsemestre_bulletinetud_dict(
I["sum_ects"] = 0 I["sum_ects"] = 0
I["sum_ects_capitalises"] = 0 I["sum_ects_capitalises"] = 0
I["moy_moy"] = scu.fmt_note(nt.moy_moy) # moyenne des moyennes generales I["moy_moy"] = scu.fmt_note(nt.moy_moy) # moyenne des moyennes generales
if type(moy_gen) != StringType and type(nt.moy_moy) != StringType: if (not isinstance(moy_gen, str)) and (not isinstance(nt.moy_moy, str)):
I["moy_gen_bargraph_html"] = "&nbsp;" + htmlutils.horizontal_bargraph( I["moy_gen_bargraph_html"] = "&nbsp;" + htmlutils.horizontal_bargraph(
moy_gen * 5, nt.moy_moy * 5 moy_gen * 5, nt.moy_moy * 5
) )
@ -299,7 +298,7 @@ def formsemestre_bulletinetud_dict(
u["cur_moy_ue_txt"] = scu.fmt_note(ue_status["cur_moy_ue"]) u["cur_moy_ue_txt"] = scu.fmt_note(ue_status["cur_moy_ue"])
else: else:
x = scu.fmt_note(nt.bonus[etudid], keep_numeric=True) x = scu.fmt_note(nt.bonus[etudid], keep_numeric=True)
if type(x) == StringType: if isinstance(x, str):
u["cur_moy_ue_txt"] = "pas de bonus" u["cur_moy_ue_txt"] = "pas de bonus"
else: else:
u["cur_moy_ue_txt"] = "bonus de %.3g points" % x u["cur_moy_ue_txt"] = "bonus de %.3g points" % x

View File

@ -28,7 +28,6 @@
""" """
Rapport (table) avec dernier semestre fréquenté et débouché de chaque étudiant Rapport (table) avec dernier semestre fréquenté et débouché de chaque étudiant
""" """
from types import StringType
import safehtml import safehtml
from flask import url_for, g from flask import url_for, g
@ -377,7 +376,7 @@ def itemsuivi_tag_set(context, itemsuivi_id="", taglist=[], REQUEST=None):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !") raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
if not taglist: if not taglist:
taglist = [] taglist = []
elif type(taglist) == StringType: elif isinstance(taglist, str):
taglist = taglist.split(",") taglist = taglist.split(",")
taglist = [t.strip() for t in taglist] taglist = [t.strip() for t in taglist]
# log('itemsuivi_tag_set: itemsuivi_id=%s taglist=%s' % (itemsuivi_id, taglist)) # log('itemsuivi_tag_set: itemsuivi_id=%s taglist=%s' % (itemsuivi_id, taglist))

View File

@ -29,7 +29,7 @@
""" Excel file handling """ Excel file handling
""" """
import time, datetime import time, datetime
from types import StringType, IntType, FloatType, LongType from types import IntType, FloatType, LongType
from pyExcelerator import * from pyExcelerator import *

View File

@ -29,7 +29,7 @@
""" """
import operator import operator
from types import FloatType, IntType, LongType, StringType from types import FloatType, IntType, LongType
from functools import reduce from functools import reduce
@ -74,7 +74,7 @@ class NoteVector(object):
try: try:
return self.v[i] return self.v[i]
except: except:
if type(i) == StringType: if isinstance(i, str):
return self.v[self.name_idx[i]] return self.v[self.name_idx[i]]
else: else:
raise IndexError("index %s out of range" % i) raise IndexError("index %s out of range" % i)

View File

@ -28,7 +28,6 @@
"""Liste des notes d'une évaluation """Liste des notes d'une évaluation
""" """
import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error
from types import StringType
from operator import itemgetter from operator import itemgetter
from flask import url_for, g from flask import url_for, g
@ -672,7 +671,7 @@ def _add_moymod_column(
) # note sur 20, ou 'NA','NI' ) # note sur 20, ou 'NA','NI'
row[col_id] = scu.fmt_note(val, keep_numeric=keep_numeric) row[col_id] = scu.fmt_note(val, keep_numeric=keep_numeric)
row["_" + col_id + "_td_attrs"] = ' class="moyenne" ' row["_" + col_id + "_td_attrs"] = ' class="moyenne" '
if type(val) != StringType: if isinstance(val, str):
notes.append(val) notes.append(val)
nb_notes = nb_notes + 1 nb_notes = nb_notes + 1
sum_notes += val sum_notes += val

View File

@ -35,7 +35,6 @@ import time
import cStringIO import cStringIO
import re import re
import os import os
from types import StringType
import unicodedata import unicodedata
import traceback import traceback
import reportlab import reportlab
@ -249,7 +248,7 @@ class ScolarsPageTemplate(PageTemplate):
# ---- Filigranne (texte en diagonal en haut a gauche de chaque page) # ---- Filigranne (texte en diagonal en haut a gauche de chaque page)
if self.filigranne: if self.filigranne:
if type(self.filigranne) == StringType: if isinstance(self.filigranne, str):
filigranne = self.filigranne # same for all pages filigranne = self.filigranne # same for all pages
else: else:
filigranne = self.filigranne.get(doc.page, None) filigranne = self.filigranne.get(doc.page, None)

View File

@ -26,7 +26,7 @@ for srcfilename in sys.argv[1:]:
# L.extend(x.s.strip() for x in ast.walk(p) if x.__class__ == ast.Str) # L.extend(x.s.strip() for x in ast.walk(p) if x.__class__ == ast.Str)
for x in ast.walk(p): for x in ast.walk(p):
if x.__class__ == ast.Str: if x.__class__ == ast.Str:
if type(x.s) == types.StringType: if isinstance(x.s, str):
s = x.s s = x.s
else: else:
s = x.s.encode("UTF-8") s = x.s.encode("UTF-8")