Author: bugman Date: Mon Oct 5 10:49:26 2015 New Revision: 27979 URL: http://svn.gna.org/viewcvs/relax?rev=27979&view=rev Log: Added an exception system to the find_unused_imports.py developer script. Sometimes pylint will give an "Unused import" warning for imports that are needed by the module. Therefore an exception list of the file name and module has been created to skip these warnings. The list covers the dep_check module and all of the profiling_*.py scripts in the directory test_suite/shared_data/dispersion/profiling/. Modified: trunk/devel_scripts/find_unused_imports.py Modified: trunk/devel_scripts/find_unused_imports.py URL: http://svn.gna.org/viewcvs/relax/trunk/devel_scripts/find_unused_imports.py?rev=27979&r1=27978&r2=27979&view=diff ============================================================================== --- trunk/devel_scripts/find_unused_imports.py (original) +++ trunk/devel_scripts/find_unused_imports.py Mon Oct 5 10:49:26 2015 @@ -7,6 +7,38 @@ from re import search from subprocess import PIPE, Popen import sys + + +# An exception list. +EXCEPTIONS = { + 'dep_check.py': ['bmrblib', 'bz2', 'cProfile', 'ctypes', 'epydoc', 'gzip', 'io', 'matplotlib', 'mpi4py', 'optparse', 'profile', 'pymol', 'readline', 'relax_fit', 'runpy', 'scipy', 'Structure', 'wx'], + 'test_suite/shared_data/dispersion/profiling/profiling_b14.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_b14_full.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_cr72.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_cr72_full.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_dpl94.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_it99.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_lm63.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_lm63_3site.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_mmq_cr72.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_mp05.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_norex.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_ns_cpmg_2site_3D.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_ns_cpmg_2site_3D_full.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_ns_cpmg_2site_expanded.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_ns_cpmg_2site_star.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_ns_cpmg_2site_star_full.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_ns_mmq_2site.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_ns_mmq_3site_linear.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_ns_r1rho_2site.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_ns_r1rho_3site.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_ns_r1rho_3site_linear.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_ns_mmq_3site.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_tap03.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_tsmfk01.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_tp02.py': ['cluster', 'single'], + 'test_suite/shared_data/dispersion/profiling/profiling_m61.py': ['cluster', 'single'] +} # Walk through the current dir. @@ -24,6 +56,13 @@ # Full path to the file. path = root + sep + file + # Does the file have exceptions? + exceptions = [] + for key in EXCEPTIONS: + if search(key, path): + for exc in EXCEPTIONS[key]: + exceptions.append("Unused import %s" % exc) + # The command. cmd = 'pylint %s' % path @@ -37,6 +76,14 @@ title_flag = True for line in pipe.stdout.readlines(): if search("Unused import", line): + # Exceptions. + skip = False + for exc in exceptions: + if search(exc, line): + skip = True + if skip: + continue + # First write out the file name, once. if title_flag: sys.stdout.write("File %s :\n" % path)