pylinting

This commit is contained in:
IDK 2021-02-02 14:49:49 +01:00
parent 1576a64ccd
commit b86c815b02
8 changed files with 71 additions and 33 deletions

View File

@ -45,7 +45,27 @@ HEAD = """# -*- coding: utf-8 -*-
#
# 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'
@ -55,15 +75,15 @@ rules_source_file='%s'
sourcefile,
)
from sco_codes_parcours import *
import sco_utils as scu
def _fmt(s):
if not s:
return None
if strlower(s) in ("ok", "oui", "o", "y", "yes"):
if scu.strlower(s) in ("ok", "oui", "o", "y", "yes"):
return True
if strlower(s) in ("no", "non"):
if scu.strlower(s) in ("no", "non"):
return False
if s == "*":
return ALL

View File

@ -1,12 +1,22 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
import pdb, os, sys, time, re, inspect
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.Header import Header
import pdb
import sys
import os
import re
import inspect
import time
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
# (logging to SQL is done in scolog)

View File

@ -5,6 +5,7 @@ import pdb, os, sys, string
import traceback
import psycopg2
import psycopg2.pool
import psycopg2.extras
import thread
from notes_log import log
from sco_exceptions import *
@ -67,16 +68,17 @@ def GetUsersDBConnexion(context, autocommit=True):
return cnx
# Nota: on pourrait maintenant utiliser psycopg2.extras.DictCursor
class ScoDocCursor(psycopg2.extensions.cursor):
"""A database cursor emulating some methods of psycopg v1 cursors"""
def dictfetchall(cursor):
col_names = [d[0] for d in cursor.description]
return [dict(zip(col_names, row)) for row in cursor.fetchall()]
def dictfetchall(self):
col_names = [d[0] for d in self.description]
return [dict(zip(col_names, row)) for row in self.fetchall()]
def dictfetchone(cursor):
col_names = [d[0] for d in cursor.description]
row = cursor.fetchone()
def dictfetchone(self):
col_names = [d[0] for d in self.description]
row = self.fetchone()
if row:
return dict(zip(col_names, row))
else:

View File

@ -210,7 +210,7 @@ class TableTag:
]
nb_notes_valides = len(notes_valides)
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))
# ************************************************************************

View File

@ -31,11 +31,13 @@
Il suffit d'appeler abs_notify() après chaque ajout d'absence.
"""
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.Header import Header
from email import Encoders
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 sco_utils import *

View File

@ -50,11 +50,15 @@ pg_dump SCORT | psql ANORT
import fcntl
import subprocess
import requests
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.MIMEBase import MIMEBase
from email.Header import Header
from email import Encoders
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 sco_utils import *
@ -74,7 +78,7 @@ def sco_dump_and_send_db(context, REQUEST=None):
try:
x = open(SCO_DUMP_LOCK, "w+")
fcntl.flock(x, fcntl.LOCK_EX | fcntl.LOCK_NB)
except fcntl.BlockingIOError:
except (IOError, OSError): # exception changed from Python 2 to 3
raise ScoValueError(
"Un envoi de la base "
+ db_name

View File

@ -27,6 +27,13 @@
"""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 sco_utils import *
@ -163,13 +170,6 @@ def generate_password():
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):
"Send password by email"
if not u["email"]: