forked from ScoDoc/ScoDoc
pylinting
This commit is contained in:
parent
1576a64ccd
commit
b86c815b02
28
csv2rules.py
28
csv2rules.py
@ -45,7 +45,27 @@ HEAD = """# -*- coding: utf-8 -*-
|
|||||||
#
|
#
|
||||||
# Command: %s %s
|
# Command: %s %s
|
||||||
#
|
#
|
||||||
from sco_codes_parcours import *
|
from sco_codes_parcours import (
|
||||||
|
DUTRule,
|
||||||
|
ADC,
|
||||||
|
ADJ,
|
||||||
|
ADM,
|
||||||
|
AJ,
|
||||||
|
ALL,
|
||||||
|
ATB,
|
||||||
|
ATJ,
|
||||||
|
ATT,
|
||||||
|
CMP,
|
||||||
|
NAR,
|
||||||
|
NEXT,
|
||||||
|
RA_OR_NEXT,
|
||||||
|
RA_OR_RS,
|
||||||
|
RAT,
|
||||||
|
REO,
|
||||||
|
REDOANNEE,
|
||||||
|
REDOSEM,
|
||||||
|
RS_OR_NEXT,
|
||||||
|
)
|
||||||
|
|
||||||
rules_source_file='%s'
|
rules_source_file='%s'
|
||||||
|
|
||||||
@ -55,15 +75,15 @@ rules_source_file='%s'
|
|||||||
sourcefile,
|
sourcefile,
|
||||||
)
|
)
|
||||||
|
|
||||||
from sco_codes_parcours import *
|
import sco_utils as scu
|
||||||
|
|
||||||
|
|
||||||
def _fmt(s):
|
def _fmt(s):
|
||||||
if not s:
|
if not s:
|
||||||
return None
|
return None
|
||||||
if strlower(s) in ("ok", "oui", "o", "y", "yes"):
|
if scu.strlower(s) in ("ok", "oui", "o", "y", "yes"):
|
||||||
return True
|
return True
|
||||||
if strlower(s) in ("no", "non"):
|
if scu.strlower(s) in ("no", "non"):
|
||||||
return False
|
return False
|
||||||
if s == "*":
|
if s == "*":
|
||||||
return ALL
|
return ALL
|
||||||
|
18
notes_log.py
18
notes_log.py
@ -1,12 +1,22 @@
|
|||||||
# -*- mode: python -*-
|
# -*- mode: python -*-
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import pdb, os, sys, time, re, inspect
|
import pdb
|
||||||
from email.MIMEMultipart import MIMEMultipart
|
import sys
|
||||||
from email.MIMEText import MIMEText
|
import os
|
||||||
from email.Header import Header
|
import re
|
||||||
|
import inspect
|
||||||
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
from email.MIMEMultipart import ( # pylint: disable=no-name-in-module,import-error
|
||||||
|
MIMEMultipart,
|
||||||
|
)
|
||||||
|
from email.MIMEText import MIMEText # pylint: disable=no-name-in-module,import-error
|
||||||
|
from email.MIMEBase import MIMEBase # pylint: disable=no-name-in-module,import-error
|
||||||
|
from email.Header import Header # pylint: disable=no-name-in-module,import-error
|
||||||
|
from email import Encoders # pylint: disable=no-name-in-module,import-error
|
||||||
|
|
||||||
# Simple & stupid file logguer, used only to debug
|
# Simple & stupid file logguer, used only to debug
|
||||||
# (logging to SQL is done in scolog)
|
# (logging to SQL is done in scolog)
|
||||||
|
|
||||||
|
14
notesdb.py
14
notesdb.py
@ -5,6 +5,7 @@ import pdb, os, sys, string
|
|||||||
import traceback
|
import traceback
|
||||||
import psycopg2
|
import psycopg2
|
||||||
import psycopg2.pool
|
import psycopg2.pool
|
||||||
|
import psycopg2.extras
|
||||||
import thread
|
import thread
|
||||||
from notes_log import log
|
from notes_log import log
|
||||||
from sco_exceptions import *
|
from sco_exceptions import *
|
||||||
@ -67,16 +68,17 @@ def GetUsersDBConnexion(context, autocommit=True):
|
|||||||
return cnx
|
return cnx
|
||||||
|
|
||||||
|
|
||||||
|
# Nota: on pourrait maintenant utiliser psycopg2.extras.DictCursor
|
||||||
class ScoDocCursor(psycopg2.extensions.cursor):
|
class ScoDocCursor(psycopg2.extensions.cursor):
|
||||||
"""A database cursor emulating some methods of psycopg v1 cursors"""
|
"""A database cursor emulating some methods of psycopg v1 cursors"""
|
||||||
|
|
||||||
def dictfetchall(cursor):
|
def dictfetchall(self):
|
||||||
col_names = [d[0] for d in cursor.description]
|
col_names = [d[0] for d in self.description]
|
||||||
return [dict(zip(col_names, row)) for row in cursor.fetchall()]
|
return [dict(zip(col_names, row)) for row in self.fetchall()]
|
||||||
|
|
||||||
def dictfetchone(cursor):
|
def dictfetchone(self):
|
||||||
col_names = [d[0] for d in cursor.description]
|
col_names = [d[0] for d in self.description]
|
||||||
row = cursor.fetchone()
|
row = self.fetchone()
|
||||||
if row:
|
if row:
|
||||||
return dict(zip(col_names, row))
|
return dict(zip(col_names, row))
|
||||||
else:
|
else:
|
||||||
|
@ -210,7 +210,7 @@ class TableTag:
|
|||||||
]
|
]
|
||||||
nb_notes_valides = len(notes_valides)
|
nb_notes_valides = len(notes_valides)
|
||||||
if nb_notes_valides > 0:
|
if nb_notes_valides > 0:
|
||||||
(moy, coeff) = moyenne_ponderee_terme_a_terme(notes_valides, force=True)
|
(moy, _) = moyenne_ponderee_terme_a_terme(notes_valides, force=True)
|
||||||
self.statistiques[tag] = (moy, max(notes_valides), min(notes_valides))
|
self.statistiques[tag] = (moy, max(notes_valides), min(notes_valides))
|
||||||
|
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
@ -31,11 +31,13 @@
|
|||||||
|
|
||||||
Il suffit d'appeler abs_notify() après chaque ajout d'absence.
|
Il suffit d'appeler abs_notify() après chaque ajout d'absence.
|
||||||
"""
|
"""
|
||||||
|
from email.MIMEMultipart import ( # pylint: disable=no-name-in-module,import-error
|
||||||
from email.MIMEMultipart import MIMEMultipart
|
MIMEMultipart,
|
||||||
from email.MIMEText import MIMEText
|
)
|
||||||
from email.Header import Header
|
from email.MIMEText import MIMEText # pylint: disable=no-name-in-module,import-error
|
||||||
from email import Encoders
|
from email.MIMEBase import MIMEBase # pylint: disable=no-name-in-module,import-error
|
||||||
|
from email.Header import Header # pylint: disable=no-name-in-module,import-error
|
||||||
|
from email import Encoders # pylint: disable=no-name-in-module,import-error
|
||||||
|
|
||||||
from notesdb import *
|
from notesdb import *
|
||||||
from sco_utils import *
|
from sco_utils import *
|
||||||
|
@ -50,11 +50,15 @@ pg_dump SCORT | psql ANORT
|
|||||||
import fcntl
|
import fcntl
|
||||||
import subprocess
|
import subprocess
|
||||||
import requests
|
import requests
|
||||||
from email.MIMEMultipart import MIMEMultipart
|
|
||||||
from email.MIMEText import MIMEText
|
from email.MIMEMultipart import ( # pylint: disable=no-name-in-module,import-error
|
||||||
from email.MIMEBase import MIMEBase
|
MIMEMultipart,
|
||||||
from email.Header import Header
|
)
|
||||||
from email import Encoders
|
from email.MIMEText import MIMEText # pylint: disable=no-name-in-module,import-error
|
||||||
|
from email.MIMEBase import MIMEBase # pylint: disable=no-name-in-module,import-error
|
||||||
|
from email.Header import Header # pylint: disable=no-name-in-module,import-error
|
||||||
|
from email import Encoders # pylint: disable=no-name-in-module,import-error
|
||||||
|
|
||||||
|
|
||||||
from notesdb import *
|
from notesdb import *
|
||||||
from sco_utils import *
|
from sco_utils import *
|
||||||
@ -74,7 +78,7 @@ def sco_dump_and_send_db(context, REQUEST=None):
|
|||||||
try:
|
try:
|
||||||
x = open(SCO_DUMP_LOCK, "w+")
|
x = open(SCO_DUMP_LOCK, "w+")
|
||||||
fcntl.flock(x, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
fcntl.flock(x, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||||
except fcntl.BlockingIOError:
|
except (IOError, OSError): # exception changed from Python 2 to 3
|
||||||
raise ScoValueError(
|
raise ScoValueError(
|
||||||
"Un envoi de la base "
|
"Un envoi de la base "
|
||||||
+ db_name
|
+ db_name
|
||||||
|
@ -27,6 +27,13 @@
|
|||||||
|
|
||||||
"""Import d'utilisateurs via fichier Excel
|
"""Import d'utilisateurs via fichier Excel
|
||||||
"""
|
"""
|
||||||
|
from email.MIMEMultipart import ( # pylint: disable=no-name-in-module,import-error
|
||||||
|
MIMEMultipart,
|
||||||
|
)
|
||||||
|
from email.MIMEText import MIMEText # pylint: disable=no-name-in-module,import-error
|
||||||
|
from email.MIMEBase import MIMEBase # pylint: disable=no-name-in-module,import-error
|
||||||
|
from email.Header import Header # pylint: disable=no-name-in-module,import-error
|
||||||
|
from email import Encoders # pylint: disable=no-name-in-module,import-error
|
||||||
|
|
||||||
from notesdb import *
|
from notesdb import *
|
||||||
from sco_utils import *
|
from sco_utils import *
|
||||||
@ -163,13 +170,6 @@ def generate_password():
|
|||||||
return "".join(RNG.sample(l, PASSLEN))
|
return "".join(RNG.sample(l, PASSLEN))
|
||||||
|
|
||||||
|
|
||||||
from email.MIMEMultipart import MIMEMultipart
|
|
||||||
from email.MIMEText import MIMEText
|
|
||||||
from email.MIMEBase import MIMEBase
|
|
||||||
from email.Header import Header
|
|
||||||
from email import Encoders
|
|
||||||
|
|
||||||
|
|
||||||
def mail_password(u, context=None, reset=False):
|
def mail_password(u, context=None, reset=False):
|
||||||
"Send password by email"
|
"Send password by email"
|
||||||
if not u["email"]:
|
if not u["email"]:
|
||||||
|
Loading…
Reference in New Issue
Block a user