diff --git a/app/scodoc/TrivialFormulator.py b/app/scodoc/TrivialFormulator.py
index b86b1ae41..1a0eeaf7e 100644
--- a/app/scodoc/TrivialFormulator.py
+++ b/app/scodoc/TrivialFormulator.py
@@ -9,7 +9,7 @@
v 1.2
"""
-from types import BooleanType, StringType, UnicodeType
+from types import BooleanType, UnicodeType
def TrivialFormulator(
@@ -745,7 +745,7 @@ def dict2js(d):
v = "true"
else:
v = "false"
- elif type(v) == StringType or type(v) == UnicodeType:
+ elif isinstance(v, str): # ne marchera pas en python2
v = '"' + v + '"'
r.append("%s: %s" % (k, v))
@@ -756,7 +756,7 @@ def tf_error_message(msg):
"""html for form error message"""
if not msg:
return ""
- if type(msg) == StringType:
+ if isinstance(msg, str):
msg = [msg]
return (
'
'
diff --git a/app/scodoc/notes_table.py b/app/scodoc/notes_table.py
index 088804840..6f91befd6 100644
--- a/app/scodoc/notes_table.py
+++ b/app/scodoc/notes_table.py
@@ -27,7 +27,7 @@
"""Calculs sur les notes et cache des resultats
"""
-from types import StringType, FloatType
+from types import FloatType
import time
import pdb
import inspect
diff --git a/app/scodoc/notesdb.py b/app/scodoc/notesdb.py
index da1e52750..767921262 100644
--- a/app/scodoc/notesdb.py
+++ b/app/scodoc/notesdb.py
@@ -13,7 +13,6 @@ from flask import g
import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log
from app.scodoc.sco_exceptions import ScoException, ScoValueError, NoteProcessError
-from types import StringType
from cgi import escape
import datetime
@@ -24,7 +23,7 @@ def quote_dict(d):
"html quote all values in dict"
for k in d.keys():
v = d[k]
- if type(v) == StringType:
+ if isinstance(v, str):
d[k] = quote_html(v, quote=True)
@@ -475,7 +474,7 @@ def DateDMYtoISO(dmy, null_is_empty=False):
return ""
else:
return None
- if type(dmy) != StringType:
+ if not isinstance(dmy, str):
return dmy.strftime("%Y-%m-%d")
t = dmy.split("/")
diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py
index cb85a60b8..97f777bf1 100644
--- a/app/scodoc/sco_bulletins.py
+++ b/app/scodoc/sco_bulletins.py
@@ -29,7 +29,6 @@
"""
import time
-from types import StringType
import pprint
import email
from email.mime.multipart import MIMEMultipart
@@ -249,7 +248,7 @@ def formsemestre_bulletinetud_dict(
I["sum_ects"] = 0
I["sum_ects_capitalises"] = 0
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"] = " " + htmlutils.horizontal_bargraph(
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"])
else:
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"
else:
u["cur_moy_ue_txt"] = "bonus de %.3g points" % x
diff --git a/app/scodoc/sco_debouche.py b/app/scodoc/sco_debouche.py
index 8895c9c12..cb445d439 100644
--- a/app/scodoc/sco_debouche.py
+++ b/app/scodoc/sco_debouche.py
@@ -28,7 +28,6 @@
"""
Rapport (table) avec dernier semestre fréquenté et débouché de chaque étudiant
"""
-from types import StringType
import safehtml
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 !")
if not taglist:
taglist = []
- elif type(taglist) == StringType:
+ elif isinstance(taglist, str):
taglist = taglist.split(",")
taglist = [t.strip() for t in taglist]
# log('itemsuivi_tag_set: itemsuivi_id=%s taglist=%s' % (itemsuivi_id, taglist))
diff --git a/app/scodoc/sco_excel.py b/app/scodoc/sco_excel.py
index 186054959..ea771088d 100644
--- a/app/scodoc/sco_excel.py
+++ b/app/scodoc/sco_excel.py
@@ -29,7 +29,7 @@
""" Excel file handling
"""
import time, datetime
-from types import StringType, IntType, FloatType, LongType
+from types import IntType, FloatType, LongType
from pyExcelerator import *
diff --git a/app/scodoc/sco_formulas.py b/app/scodoc/sco_formulas.py
index e559074c6..fed0ebace 100644
--- a/app/scodoc/sco_formulas.py
+++ b/app/scodoc/sco_formulas.py
@@ -29,7 +29,7 @@
"""
import operator
-from types import FloatType, IntType, LongType, StringType
+from types import FloatType, IntType, LongType
from functools import reduce
@@ -74,7 +74,7 @@ class NoteVector(object):
try:
return self.v[i]
except:
- if type(i) == StringType:
+ if isinstance(i, str):
return self.v[self.name_idx[i]]
else:
raise IndexError("index %s out of range" % i)
diff --git a/app/scodoc/sco_liste_notes.py b/app/scodoc/sco_liste_notes.py
index 0d856e642..08e535fb4 100644
--- a/app/scodoc/sco_liste_notes.py
+++ b/app/scodoc/sco_liste_notes.py
@@ -28,7 +28,6 @@
"""Liste des notes d'une évaluation
"""
import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error
-from types import StringType
from operator import itemgetter
from flask import url_for, g
@@ -672,7 +671,7 @@ def _add_moymod_column(
) # note sur 20, ou 'NA','NI'
row[col_id] = scu.fmt_note(val, keep_numeric=keep_numeric)
row["_" + col_id + "_td_attrs"] = ' class="moyenne" '
- if type(val) != StringType:
+ if isinstance(val, str):
notes.append(val)
nb_notes = nb_notes + 1
sum_notes += val
diff --git a/app/scodoc/sco_pdf.py b/app/scodoc/sco_pdf.py
index c415a776e..a7d53b85c 100644
--- a/app/scodoc/sco_pdf.py
+++ b/app/scodoc/sco_pdf.py
@@ -35,7 +35,6 @@ import time
import cStringIO
import re
import os
-from types import StringType
import unicodedata
import traceback
import reportlab
@@ -249,7 +248,7 @@ class ScolarsPageTemplate(PageTemplate):
# ---- Filigranne (texte en diagonal en haut a gauche de chaque page)
if self.filigranne:
- if type(self.filigranne) == StringType:
+ if isinstance(self.filigranne, str):
filigranne = self.filigranne # same for all pages
else:
filigranne = self.filigranne.get(doc.page, None)
diff --git a/misc/extract_code_strings.py b/misc/extract_code_strings.py
index a8a41f45c..ad16304d6 100755
--- a/misc/extract_code_strings.py
+++ b/misc/extract_code_strings.py
@@ -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)
for x in ast.walk(p):
if x.__class__ == ast.Str:
- if type(x.s) == types.StringType:
+ if isinstance(x.s, str):
s = x.s
else:
s = x.s.encode("UTF-8")