diff --git a/ImportScolars.py b/ImportScolars.py index 8a417632..4502abd3 100644 --- a/ImportScolars.py +++ b/ImportScolars.py @@ -34,8 +34,9 @@ import time import pdb import collections import types +import re -from sco_utils import * +import sco_utils as scu import notesdb as ndb from notes_log import log import scolars @@ -107,7 +108,7 @@ ADMISSION_MODIFIABLE_FIELDS = ( def sco_import_format(with_codesemestre=True): "returns tuples (Attribut, Type, Table, AllowNulls, Description)" r = [] - for l in open(SCO_SRCDIR + "/" + FORMAT_FILE): + for l in open(scu.SCO_SRCDIR + "/" + FORMAT_FILE): l = l.strip() if l and l[0] != "#": fs = l.split(";") @@ -166,10 +167,10 @@ def sco_import_generate_excel_sample( titles = [] titlesStyles = [] for l in fmt: - name = strlower(l[0]) + name = scu.strlower(l[0]) if (not with_codesemestre) and name == "codesemestre": continue # pas de colonne codesemestre - if only_tables is not None and strlower(l[2]) not in only_tables: + if only_tables is not None and scu.strlower(l[2]) not in only_tables: continue # table non demandée if name in exclude_cols: continue # colonne exclue @@ -206,7 +207,7 @@ def sco_import_generate_excel_sample( ) l.append(etud["partitionsgroupes"]) else: - key = strlower(field).split()[0] + key = scu.strlower(field).split()[0] l.append(etud.get(key, "")) lines.append(l) else: @@ -279,7 +280,7 @@ def scolars_import_excel_file( titles = {} fmt = sco_import_format() for l in fmt: - tit = strlower(l[0]).split()[0] # titles in lowercase, and take 1st word + tit = scu.strlower(l[0]).split()[0] # titles in lowercase, and take 1st word if ( (not formsemestre_id) or (tit != "codesemestre") ) and tit not in exclude_cols: @@ -288,7 +289,7 @@ def scolars_import_excel_file( # log("titles=%s" % titles) # remove quotes, downcase and keep only 1st word try: - fs = [strlower(stripquotes(s)).split()[0] for s in data[0]] + fs = [scu.strlower(scu.stripquotes(s)).split()[0] for s in data[0]] except: raise ScoValueError("Titres de colonnes invalides (ou vides ?)") # log("excel: fs='%s'\ndata=%s" % (str(fs), str(data))) @@ -365,7 +366,7 @@ def scolars_import_excel_file( % (val, linenum, titleslist[i]) ) # xxx Ad-hoc checks (should be in format description) - if strlower(titleslist[i]) == "sexe": + if scu.strlower(titleslist[i]) == "sexe": try: val = scolars.normalize_sexe(val) except: @@ -374,13 +375,13 @@ def scolars_import_excel_file( % (val, linenum, titleslist[i]) ) # Excel date conversion: - if strlower(titleslist[i]) == "date_naissance": + if scu.strlower(titleslist[i]) == "date_naissance": if val: if re.match("^[0-9]*\.?[0-9]*$", str(val)): val = sco_excel.xldate_as_datetime(float(val)) # INE if ( - strlower(titleslist[i]) == "code_ine" + scu.strlower(titleslist[i]) == "code_ine" and always_require_ine and not val ): @@ -703,7 +704,7 @@ _ADM_PATTERN = re.compile(r"[\W]+", re.UNICODE) # supprime tout sauf alphanum def adm_normalize_string(s): # normalize unicode title - return suppression_diacritics(_ADM_PATTERN.sub("", s.strip().lower())).replace( + return scu.suppression_diacritics(_ADM_PATTERN.sub("", s.strip().lower())).replace( "_", "" ) diff --git a/html_sco_header.py b/html_sco_header.py index d66a875b..89003b66 100644 --- a/html_sco_header.py +++ b/html_sco_header.py @@ -27,7 +27,7 @@ import cgi -from sco_utils import * +import sco_utils as scu from sco_formsemestre_status import formsemestre_page_title """ @@ -97,7 +97,7 @@ def sco_header( "page_title": page_title or context.title_or_id(), "no_side_bar": no_side_bar, "ScoURL": context.ScoURL(), - "encoding": SCO_ENCODING, + "encoding": scu.SCO_ENCODING, "titrebandeau_mkup": "