mirror of
https://forge.apps.education.fr/blender-edutech/ropy.git
synced 2024-01-27 08:23:20 +01:00
Migration de Pylint v2 -> v3
This commit is contained in:
parent
75ec4194d4
commit
9fca493f2b
BIN
ropy-34.blend
BIN
ropy-34.blend
Binary file not shown.
46
rp.py
46
rp.py
@ -10,7 +10,9 @@ import threading # Multithreading
|
||||
import subprocess # Multiprocessus
|
||||
import xml.etree.ElementTree as ET # Creating/parsing XML file
|
||||
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_doc # Documentation
|
||||
@ -211,18 +213,32 @@ def terrain_init (cont):
|
||||
##
|
||||
|
||||
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()
|
||||
stderr = pylint_stderr.read()
|
||||
if " error (" in stdout: # Présence d'erreur
|
||||
|
||||
# Terminer le processus fils précédent
|
||||
if ('pylint_proc' in scene.objects['Commands']):
|
||||
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
|
||||
scene.objects['Cmd-text']['modal']= True
|
||||
scene.objects['Cmd-text']['Text']= "Erreur dans le script ... "
|
||||
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
|
||||
else:
|
||||
|
||||
# Absence d'erreur
|
||||
scene.objects['Cmd-text']['modal']= False
|
||||
scene.objects['Cmd-text']['Text']= ""
|
||||
scene.objects['Cmd-text'].setVisible(False,False)
|
||||
@ -531,7 +547,7 @@ def cmd_hl(cont):
|
||||
scene.objects['Doc-cmd'].setVisible(False,False)
|
||||
scene.objects['Doc-cmd-Hl'].setVisible(True,False)
|
||||
|
||||
# Text
|
||||
# Texte
|
||||
text_hl ={"Run":"Exécuter (F5)",
|
||||
"Stop":"Stop et initialisation (F6)",
|
||||
"Pause":"Pause (F5)",
|
||||
@ -564,8 +580,16 @@ def cmd_hl(cont):
|
||||
|
||||
# Désactivation
|
||||
if cont.sensors['MO'].status == JUST_RELEASED and (scene.objects['Terrain']['manip_mode']==0 or scene.objects['Terrain']['manip_mode']==9):
|
||||
|
||||
# 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":
|
||||
scene.objects[obj.name+'-Hl'].setVisible(False,True)
|
||||
obj.setVisible(True,True)
|
||||
@ -1363,18 +1387,18 @@ def store_close_click(cont):
|
||||
|
||||
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 scene.objects['Commands']['file_proc'].poll()==None:
|
||||
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
|
||||
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
|
||||
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()
|
||||
if stout[0][:-1] != 'None' and len(stout[0][:-1])>0 :
|
||||
scene.objects['Commands']['script'] = stout[0][:-1]
|
||||
|
@ -1,11 +1,11 @@
|
||||
<data>
|
||||
<config>
|
||||
<speed>1.0</speed>
|
||||
<speed>2.0</speed>
|
||||
<sound>False</sound>
|
||||
<cam>
|
||||
<worldPosition.x>0.0057830810546875</worldPosition.x>
|
||||
<worldPosition.y>-26.440298080444336</worldPosition.y>
|
||||
<worldPosition.z>20.22315788269043</worldPosition.z>
|
||||
<worldPosition.x>4.116782188415527</worldPosition.x>
|
||||
<worldPosition.y>-39.253841400146484</worldPosition.y>
|
||||
<worldPosition.z>29.45159339904785</worldPosition.z>
|
||||
</cam>
|
||||
<screen>
|
||||
<width>1599</width>
|
||||
|
19
rp_pylint.py
Normal file
19
rp_pylint.py
Normal 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)
|
Loading…
Reference in New Issue
Block a user