Migration de Pylint v2 -> v3

This commit is contained in:
Philippe Roy 2023-12-28 06:05:45 +01:00
parent 75ec4194d4
commit 9fca493f2b
4 changed files with 64 additions and 21 deletions

Binary file not shown.

58
rp.py
View File

@ -10,7 +10,9 @@ import threading # Multithreading
import subprocess # Multiprocessus import subprocess # Multiprocessus
import xml.etree.ElementTree as ET # Creating/parsing XML file import xml.etree.ElementTree as ET # Creating/parsing XML file
import runpy # Exécution de script Python légère (sans import) import runpy # Exécution de script Python légère (sans import)
from pylint import epylint as lint # Mesure de la qualité d'un code Python # from pylint import epylint as lint # Mesure de la qualité d'un code Python
# from pylint import run_pylint # Mesure de la qualité d'un code Python
# from pylint.lint import Run as pylint_run
import rp_map1 as rp_map # Map definition import rp_map1 as rp_map # Map definition
import rp_doc # Documentation import rp_doc # Documentation
@ -211,22 +213,36 @@ def terrain_init (cont):
## ##
def python_validation(file): def python_validation(file):
(pylint_stdout, pylint_stderr) = lint.py_run(file+' --disable=C --disable=W --disable=R', return_std=True)
stdout = pylint_stdout.read() # Terminer le processus fils précédent
stderr = pylint_stderr.read() if ('pylint_proc' in scene.objects['Commands']):
if " error (" in stdout: # Présence d'erreur if scene.objects['Commands']['pylint_proc'].poll()==None:
scene.objects['Commands']['pylint_proc'].terminate()
# Lancer le processus fils
scene.objects['Commands']['pylint_proc'] = subprocess.Popen([sys.executable, os.path.join(os.getcwd(), "rp_pylint.py"), file], stdout=subprocess.PIPE, encoding = 'utf8')
stout = scene.objects['Commands']['pylint_proc'].communicate()
# Présence d'erreur
if stout[0][:-1] != 'None' and len(stout[0][:-1])>0 :
# UI : information # UI : information
scene.objects['Cmd-text']['modal']= True scene.objects['Cmd-text']['modal']= True
scene.objects['Cmd-text']['Text']= "Erreur dans le script ... " scene.objects['Cmd-text']['Text']= "Erreur dans le script ... "
scene.objects['Cmd-text'].setVisible(True,False) scene.objects['Cmd-text'].setVisible(True,False)
print(stdout) # Affichage console
# Affichage console
stout_lines = stout[0].split("\n")
for stout_line in stout_lines:
print ("Pylint :", stout_line) # Affichage console
return False return False
else:
scene.objects['Cmd-text']['modal']= False # Absence d'erreur
scene.objects['Cmd-text']['Text']= "" scene.objects['Cmd-text']['modal']= False
scene.objects['Cmd-text'].setVisible(False,False) scene.objects['Cmd-text']['Text']= ""
return True scene.objects['Cmd-text'].setVisible(False,False)
return True
## ##
# Exécuter le script # Exécuter le script
@ -531,7 +547,7 @@ def cmd_hl(cont):
scene.objects['Doc-cmd'].setVisible(False,False) scene.objects['Doc-cmd'].setVisible(False,False)
scene.objects['Doc-cmd-Hl'].setVisible(True,False) scene.objects['Doc-cmd-Hl'].setVisible(True,False)
# Text # Texte
text_hl ={"Run":"Exécuter (F5)", text_hl ={"Run":"Exécuter (F5)",
"Stop":"Stop et initialisation (F6)", "Stop":"Stop et initialisation (F6)",
"Pause":"Pause (F5)", "Pause":"Pause (F5)",
@ -564,8 +580,16 @@ def cmd_hl(cont):
# Désactivation # Désactivation
if cont.sensors['MO'].status == JUST_RELEASED and (scene.objects['Terrain']['manip_mode']==0 or scene.objects['Terrain']['manip_mode']==9): if cont.sensors['MO'].status == JUST_RELEASED and (scene.objects['Terrain']['manip_mode']==0 or scene.objects['Terrain']['manip_mode']==9):
scene.objects['Cmd-text']['Text']= ""
scene.objects['Cmd-text'].setVisible(False,False) # Texte
if scene.objects['Cmd-text']['modal']:
scene.objects['Cmd-text']['Text']= "Erreur dans le script ... "
scene.objects['Cmd-text'].setVisible(True,False)
else:
scene.objects['Cmd-text']['Text']= ""
scene.objects['Cmd-text'].setVisible(False,False)
# Icone
if obj.name!="Run" and obj.name!="Pause" and obj.name!="Stop" and obj.name!="Sound-cmd" and obj.name!="NoSound-cmd" and obj.name!="Task-cmd" and obj.name!="Task_close-cmd" and obj.name!="Doc-cmd-colbox": if obj.name!="Run" and obj.name!="Pause" and obj.name!="Stop" and obj.name!="Sound-cmd" and obj.name!="NoSound-cmd" and obj.name!="Task-cmd" and obj.name!="Task_close-cmd" and obj.name!="Doc-cmd-colbox":
scene.objects[obj.name+'-Hl'].setVisible(False,True) scene.objects[obj.name+'-Hl'].setVisible(False,True)
obj.setVisible(True,True) obj.setVisible(True,True)
@ -1363,18 +1387,18 @@ def store_close_click(cont):
def file_open(): def file_open():
# Terminer le processus file précédent # Terminer le processus fils précédent
if ('file_proc' in scene.objects['Commands']): if ('file_proc' in scene.objects['Commands']):
if scene.objects['Commands']['file_proc'].poll()==None: if scene.objects['Commands']['file_proc'].poll()==None:
scene.objects['Commands']['file_proc'].terminate() scene.objects['Commands']['file_proc'].terminate()
# Démarrer le processus file # Démarrer le processus fils
if sys.platform=="linux": # wxPython ne s'installe pas bien sur GNU/linux -> Qt5 if sys.platform=="linux": # wxPython ne s'installe pas bien sur GNU/linux -> Qt5
scene.objects['Commands']['file_proc'] = subprocess.Popen([sys.executable, os.path.join(os.getcwd(), "rp_file_qt.py")], stdout=subprocess.PIPE, encoding = 'utf8') scene.objects['Commands']['file_proc'] = subprocess.Popen([sys.executable, os.path.join(os.getcwd(), "rp_file_qt.py")], stdout=subprocess.PIPE, encoding = 'utf8')
else: # Qt5 ne s'installe pas bien sur Windows -> wxPython else: # Qt5 ne s'installe pas bien sur Windows -> wxPython
scene.objects['Commands']['file_proc'] = subprocess.Popen([sys.executable, os.path.join(os.getcwd(), "rp_file_wx.py")], stdout=subprocess.PIPE, encoding = 'utf8') scene.objects['Commands']['file_proc'] = subprocess.Popen([sys.executable, os.path.join(os.getcwd(), "rp_file_wx.py")], stdout=subprocess.PIPE, encoding = 'utf8')
# Récupérer le nom du fchier # Récupérer le nom du fichier
stout = scene.objects['Commands']['file_proc'].communicate() stout = scene.objects['Commands']['file_proc'].communicate()
if stout[0][:-1] != 'None' and len(stout[0][:-1])>0 : if stout[0][:-1] != 'None' and len(stout[0][:-1])>0 :
scene.objects['Commands']['script'] = stout[0][:-1] scene.objects['Commands']['script'] = stout[0][:-1]

View File

@ -1,11 +1,11 @@
<data> <data>
<config> <config>
<speed>1.0</speed> <speed>2.0</speed>
<sound>False</sound> <sound>False</sound>
<cam> <cam>
<worldPosition.x>0.0057830810546875</worldPosition.x> <worldPosition.x>4.116782188415527</worldPosition.x>
<worldPosition.y>-26.440298080444336</worldPosition.y> <worldPosition.y>-39.253841400146484</worldPosition.y>
<worldPosition.z>20.22315788269043</worldPosition.z> <worldPosition.z>29.45159339904785</worldPosition.z>
</cam> </cam>
<screen> <screen>
<width>1599</width> <width>1599</width>

19
rp_pylint.py Normal file
View File

@ -0,0 +1,19 @@
import sys
from pylint import run_pylint
###############################################################################
# rp_pylint.py
# @title: Mesure de la qualité d'un code Python
# @project: Ropy (Blender-EduTech)
# @lang: fr
# @authors: Philippe Roy <philippe.roy@ac-grenoble.fr>
# @copyright: Copyright (C) 2024 Philippe Roy
# @license: GNU GPL
###############################################################################
# print (sys.argv[0])
# print (sys.argv[1])
# run_pylint(argv=["--version"])
run_pylint(argv=["--errors-only", sys.argv[1]])
# run_pylint(argv=["--disable=line-too-long", sys.argv[1]])
sys.exit(0)