bee_python 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +202 -0
- data/build/README +23 -0
- data/egg/egg/build.yml +70 -0
- data/egg/egg/ez_setup.py +280 -0
- data/egg/egg/script.py +12 -0
- data/egg/egg/setup.erb +11 -0
- data/egg/egg/suite.py +37 -0
- data/egg/egg/test.py +31 -0
- data/egg/egg.yml +69 -0
- data/egg/http/build.erb +53 -0
- data/egg/http/server.py +34 -0
- data/egg/http.yml +50 -0
- data/egg/mysql/mysql.py +43 -0
- data/egg/mysql.yml +44 -0
- data/egg/project/build.erb +77 -0
- data/egg/project/script.py +42 -0
- data/egg/project/test.py +31 -0
- data/egg/project.yml +59 -0
- data/egg/script/build.erb +35 -0
- data/egg/script/script.py +42 -0
- data/egg/script.yml +50 -0
- data/egg/soap/build.erb +52 -0
- data/egg/soap/client.py +18 -0
- data/egg/soap/server.py +30 -0
- data/egg/soap.yml +58 -0
- data/egg/source/source.py +42 -0
- data/egg/source.yml +47 -0
- data/egg/test/test.py +28 -0
- data/egg/test.yml +44 -0
- data/egg/xmlrpc/build.erb +52 -0
- data/egg/xmlrpc/client.py +22 -0
- data/egg/xmlrpc/server.py +24 -0
- data/egg/xmlrpc.yml +51 -0
- data/lib/bee_task_python.rb +390 -0
- data/test/build.yml +16 -0
- data/test/tc_bee_task_python.rb +27 -0
- data/test/test_build.rb +26 -0
- data/test/test_build_listener.rb +62 -0
- data/test/ts_bee_python.rb +26 -0
- data/tools/common/__init__.py +5 -0
- data/tools/common/common/__init__.py +140 -0
- data/tools/common/common/__pkginfo__.py +43 -0
- data/tools/common/common/adbh.py +35 -0
- data/tools/common/common/cache.py +114 -0
- data/tools/common/common/changelog.py +234 -0
- data/tools/common/common/clcommands.py +181 -0
- data/tools/common/common/cli.py +212 -0
- data/tools/common/common/compat.py +328 -0
- data/tools/common/common/configuration.py +1087 -0
- data/tools/common/common/contexts.py +58 -0
- data/tools/common/common/corbautils.py +117 -0
- data/tools/common/common/daemon.py +171 -0
- data/tools/common/common/date.py +279 -0
- data/tools/common/common/db.py +49 -0
- data/tools/common/common/dbf.py +229 -0
- data/tools/common/common/debugger.py +208 -0
- data/tools/common/common/decorators.py +190 -0
- data/tools/common/common/deprecation.py +118 -0
- data/tools/common/common/fileutils.py +409 -0
- data/tools/common/common/graph.py +259 -0
- data/tools/common/common/html.py +142 -0
- data/tools/common/common/interface.py +76 -0
- data/tools/common/common/logging_ext.py +166 -0
- data/tools/common/common/modutils.py +670 -0
- data/tools/common/common/optik_ext.py +383 -0
- data/tools/common/common/optparser.py +92 -0
- data/tools/common/common/pdf_ext.py +111 -0
- data/tools/common/common/proc.py +276 -0
- data/tools/common/common/pyro_ext.py +146 -0
- data/tools/common/common/pytest.py +754 -0
- data/tools/common/common/shellutils.py +383 -0
- data/tools/common/common/sphinx_ext.py +87 -0
- data/tools/common/common/sphinxutils.py +122 -0
- data/tools/common/common/sqlgen.py +31 -0
- data/tools/common/common/table.py +930 -0
- data/tools/common/common/tasksqueue.py +97 -0
- data/tools/common/common/test/__init__.py +1 -0
- data/tools/common/common/test/data/ChangeLog +184 -0
- data/tools/common/common/test/data/MyPyPa-0.1.0-py2.5.egg +0 -0
- data/tools/common/common/test/data/__init__.py +1 -0
- data/tools/common/common/test/data/content_differ_dir/NOTHING +0 -0
- data/tools/common/common/test/data/content_differ_dir/README +1 -0
- data/tools/common/common/test/data/content_differ_dir/subdir/coin +1 -0
- data/tools/common/common/test/data/content_differ_dir/subdir/toto.txt +53 -0
- data/tools/common/common/test/data/file_differ_dir/NOTHING +0 -0
- data/tools/common/common/test/data/file_differ_dir/README +1 -0
- data/tools/common/common/test/data/file_differ_dir/subdir/toto.txt +53 -0
- data/tools/common/common/test/data/file_differ_dir/subdirtwo/Hello +0 -0
- data/tools/common/common/test/data/find_test/__init__.py +0 -0
- data/tools/common/common/test/data/find_test/foo.txt +0 -0
- data/tools/common/common/test/data/find_test/module.py +0 -0
- data/tools/common/common/test/data/find_test/module2.py +0 -0
- data/tools/common/common/test/data/find_test/newlines.txt +0 -0
- data/tools/common/common/test/data/find_test/noendingnewline.py +0 -0
- data/tools/common/common/test/data/find_test/nonregr.py +0 -0
- data/tools/common/common/test/data/find_test/normal_file.txt +0 -0
- data/tools/common/common/test/data/find_test/spam.txt +0 -0
- data/tools/common/common/test/data/find_test/sub/doc.txt +0 -0
- data/tools/common/common/test/data/find_test/sub/momo.py +0 -0
- data/tools/common/common/test/data/find_test/test.ini +0 -0
- data/tools/common/common/test/data/find_test/test1.msg +0 -0
- data/tools/common/common/test/data/find_test/test2.msg +0 -0
- data/tools/common/common/test/data/find_test/write_protected_file.txt +0 -0
- data/tools/common/common/test/data/foo.txt +9 -0
- data/tools/common/common/test/data/module.py +88 -0
- data/tools/common/common/test/data/module2.py +77 -0
- data/tools/common/common/test/data/newlines.txt +3 -0
- data/tools/common/common/test/data/noendingnewline.py +36 -0
- data/tools/common/common/test/data/nonregr.py +14 -0
- data/tools/common/common/test/data/normal_file.txt +0 -0
- data/tools/common/common/test/data/reference_dir/NOTHING +0 -0
- data/tools/common/common/test/data/reference_dir/README +1 -0
- data/tools/common/common/test/data/reference_dir/subdir/coin +1 -0
- data/tools/common/common/test/data/reference_dir/subdir/toto.txt +53 -0
- data/tools/common/common/test/data/same_dir/NOTHING +0 -0
- data/tools/common/common/test/data/same_dir/README +1 -0
- data/tools/common/common/test/data/same_dir/subdir/coin +1 -0
- data/tools/common/common/test/data/same_dir/subdir/toto.txt +53 -0
- data/tools/common/common/test/data/spam.txt +9 -0
- data/tools/common/common/test/data/sub/doc.txt +1 -0
- data/tools/common/common/test/data/sub/momo.py +1 -0
- data/tools/common/common/test/data/subdir_differ_dir/NOTHING +0 -0
- data/tools/common/common/test/data/subdir_differ_dir/README +1 -0
- data/tools/common/common/test/data/subdir_differ_dir/subdir/coin +1 -0
- data/tools/common/common/test/data/subdir_differ_dir/subdir/toto.txt +53 -0
- data/tools/common/common/test/data/test.ini +20 -0
- data/tools/common/common/test/data/test1.msg +30 -0
- data/tools/common/common/test/data/test2.msg +42 -0
- data/tools/common/common/test/data/write_protected_file.txt +0 -0
- data/tools/common/common/test/foomod.py +17 -0
- data/tools/common/common/test/unittest_cache.py +129 -0
- data/tools/common/common/test/unittest_changelog.py +37 -0
- data/tools/common/common/test/unittest_compat.py +239 -0
- data/tools/common/common/test/unittest_configuration.py +348 -0
- data/tools/common/common/test/unittest_date.py +154 -0
- data/tools/common/common/test/unittest_decorators.py +62 -0
- data/tools/common/common/test/unittest_deprecation.py +76 -0
- data/tools/common/common/test/unittest_fileutils.py +133 -0
- data/tools/common/common/test/unittest_graph.py +50 -0
- data/tools/common/common/test/unittest_html.py +76 -0
- data/tools/common/common/test/unittest_interface.py +87 -0
- data/tools/common/common/test/unittest_modutils.py +244 -0
- data/tools/common/common/test/unittest_pytest.py +50 -0
- data/tools/common/common/test/unittest_shellutils.py +248 -0
- data/tools/common/common/test/unittest_table.py +448 -0
- data/tools/common/common/test/unittest_taskqueue.py +71 -0
- data/tools/common/common/test/unittest_testlib.py +956 -0
- data/tools/common/common/test/unittest_textutils.py +247 -0
- data/tools/common/common/test/unittest_tree.py +248 -0
- data/tools/common/common/test/unittest_umessage.py +55 -0
- data/tools/common/common/test/unittest_ureports_html.py +64 -0
- data/tools/common/common/test/unittest_ureports_text.py +105 -0
- data/tools/common/common/test/unittest_xmlutils.py +75 -0
- data/tools/common/common/test/utils.py +87 -0
- data/tools/common/common/testlib.py +1927 -0
- data/tools/common/common/textutils.py +476 -0
- data/tools/common/common/tree.py +372 -0
- data/tools/common/common/umessage.py +161 -0
- data/tools/common/common/ureports/__init__.py +174 -0
- data/tools/common/common/ureports/docbook_writer.py +139 -0
- data/tools/common/common/ureports/html_writer.py +131 -0
- data/tools/common/common/ureports/nodes.py +201 -0
- data/tools/common/common/ureports/text_writer.py +140 -0
- data/tools/common/common/vcgutils.py +216 -0
- data/tools/common/common/visitor.py +107 -0
- data/tools/common/common/xmlrpcutils.py +136 -0
- data/tools/common/common/xmlutils.py +61 -0
- data/tools/compile/compile.py +16 -0
- data/tools/coverage/coverage.py +602 -0
- data/tools/epydoc/__init__.py +227 -0
- data/tools/epydoc/__init__.pyc +0 -0
- data/tools/epydoc/apidoc.py +2203 -0
- data/tools/epydoc/apidoc.pyc +0 -0
- data/tools/epydoc/checker.py +349 -0
- data/tools/epydoc/checker.pyc +0 -0
- data/tools/epydoc/cli.py +1470 -0
- data/tools/epydoc/cli.pyc +0 -0
- data/tools/epydoc/compat.py +250 -0
- data/tools/epydoc/compat.pyc +0 -0
- data/tools/epydoc/docbuilder.py +1358 -0
- data/tools/epydoc/docbuilder.pyc +0 -0
- data/tools/epydoc/docintrospecter.py +1056 -0
- data/tools/epydoc/docintrospecter.pyc +0 -0
- data/tools/epydoc/docparser.py +2113 -0
- data/tools/epydoc/docparser.pyc +0 -0
- data/tools/epydoc/docstringparser.py +1111 -0
- data/tools/epydoc/docstringparser.pyc +0 -0
- data/tools/epydoc/docwriter/__init__.py +12 -0
- data/tools/epydoc/docwriter/__init__.pyc +0 -0
- data/tools/epydoc/docwriter/dotgraph.py +1351 -0
- data/tools/epydoc/docwriter/dotgraph.pyc +0 -0
- data/tools/epydoc/docwriter/html.py +3491 -0
- data/tools/epydoc/docwriter/html.pyc +0 -0
- data/tools/epydoc/docwriter/html_colorize.py +909 -0
- data/tools/epydoc/docwriter/html_colorize.pyc +0 -0
- data/tools/epydoc/docwriter/html_css.py +550 -0
- data/tools/epydoc/docwriter/html_css.pyc +0 -0
- data/tools/epydoc/docwriter/html_help.py +190 -0
- data/tools/epydoc/docwriter/html_help.pyc +0 -0
- data/tools/epydoc/docwriter/latex.py +1187 -0
- data/tools/epydoc/docwriter/latex.pyc +0 -0
- data/tools/epydoc/docwriter/plaintext.py +276 -0
- data/tools/epydoc/docwriter/plaintext.pyc +0 -0
- data/tools/epydoc/docwriter/xlink.py +505 -0
- data/tools/epydoc/docwriter/xlink.pyc +0 -0
- data/tools/epydoc/gui.py +1148 -0
- data/tools/epydoc/gui.pyc +0 -0
- data/tools/epydoc/log.py +204 -0
- data/tools/epydoc/log.pyc +0 -0
- data/tools/epydoc/markup/__init__.py +623 -0
- data/tools/epydoc/markup/__init__.pyc +0 -0
- data/tools/epydoc/markup/doctest.py +311 -0
- data/tools/epydoc/markup/doctest.pyc +0 -0
- data/tools/epydoc/markup/epytext.py +2116 -0
- data/tools/epydoc/markup/epytext.pyc +0 -0
- data/tools/epydoc/markup/javadoc.py +250 -0
- data/tools/epydoc/markup/javadoc.pyc +0 -0
- data/tools/epydoc/markup/plaintext.py +78 -0
- data/tools/epydoc/markup/plaintext.pyc +0 -0
- data/tools/epydoc/markup/pyval_repr.py +532 -0
- data/tools/epydoc/markup/pyval_repr.pyc +0 -0
- data/tools/epydoc/markup/restructuredtext.py +906 -0
- data/tools/epydoc/markup/restructuredtext.pyc +0 -0
- data/tools/epydoc/test/__init__.py +97 -0
- data/tools/epydoc/test/__init__.pyc +0 -0
- data/tools/epydoc/test/util.py +226 -0
- data/tools/epydoc/test/util.pyc +0 -0
- data/tools/epydoc/util.py +289 -0
- data/tools/epydoc/util.pyc +0 -0
- data/tools/logilab/logilab/__init__.py +5 -0
- data/tools/logilab/logilab/astng/__init__.py +82 -0
- data/tools/logilab/logilab/astng/__pkginfo__.py +76 -0
- data/tools/logilab/logilab/astng/_exceptions.py +64 -0
- data/tools/logilab/logilab/astng/_nodes_ast.py +667 -0
- data/tools/logilab/logilab/astng/_nodes_compiler.py +758 -0
- data/tools/logilab/logilab/astng/bases.py +608 -0
- data/tools/logilab/logilab/astng/builder.py +239 -0
- data/tools/logilab/logilab/astng/inference.py +426 -0
- data/tools/logilab/logilab/astng/inspector.py +289 -0
- data/tools/logilab/logilab/astng/manager.py +421 -0
- data/tools/logilab/logilab/astng/mixins.py +165 -0
- data/tools/logilab/logilab/astng/node_classes.py +848 -0
- data/tools/logilab/logilab/astng/nodes.py +85 -0
- data/tools/logilab/logilab/astng/nodes_as_string.py +389 -0
- data/tools/logilab/logilab/astng/patchcomptransformer.py +159 -0
- data/tools/logilab/logilab/astng/protocols.py +333 -0
- data/tools/logilab/logilab/astng/raw_building.py +212 -0
- data/tools/logilab/logilab/astng/rebuilder.py +307 -0
- data/tools/logilab/logilab/astng/scoped_nodes.py +951 -0
- data/tools/logilab/logilab/astng/test/__init__.py +19 -0
- data/tools/logilab/logilab/astng/test/data/MyPyPa-0.1.0-py2.5.egg +0 -0
- data/tools/logilab/logilab/astng/test/data/MyPyPa-0.1.0-py2.5.zip +0 -0
- data/tools/logilab/logilab/astng/test/data/SSL1/Connection1.py +33 -0
- data/tools/logilab/logilab/astng/test/data/SSL1/__init__.py +20 -0
- data/tools/logilab/logilab/astng/test/data/__init__.py +20 -0
- data/tools/logilab/logilab/astng/test/data/all.py +29 -0
- data/tools/logilab/logilab/astng/test/data/appl/__init__.py +23 -0
- data/tools/logilab/logilab/astng/test/data/appl/myConnection.py +30 -0
- data/tools/logilab/logilab/astng/test/data/format.py +34 -0
- data/tools/logilab/logilab/astng/test/data/module.py +90 -0
- data/tools/logilab/logilab/astng/test/data/module2.py +112 -0
- data/tools/logilab/logilab/astng/test/data/noendingnewline.py +57 -0
- data/tools/logilab/logilab/astng/test/data/nonregr.py +76 -0
- data/tools/logilab/logilab/astng/test/data/notall.py +28 -0
- data/tools/logilab/logilab/astng/test/data2/__init__.py +20 -0
- data/tools/logilab/logilab/astng/test/data2/clientmodule_test.py +51 -0
- data/tools/logilab/logilab/astng/test/data2/suppliermodule_test.py +32 -0
- data/tools/logilab/logilab/astng/test/regrtest.py +135 -0
- data/tools/logilab/logilab/astng/test/regrtest_data/absimport.py +22 -0
- data/tools/logilab/logilab/astng/test/regrtest_data/descriptor_crash.py +31 -0
- data/tools/logilab/logilab/astng/test/regrtest_data/import_package_subpackage_module.py +68 -0
- data/tools/logilab/logilab/astng/test/regrtest_data/package/__init__.py +24 -0
- data/tools/logilab/logilab/astng/test/regrtest_data/package/subpackage/__init__.py +20 -0
- data/tools/logilab/logilab/astng/test/regrtest_data/package/subpackage/module.py +20 -0
- data/tools/logilab/logilab/astng/test/unittest_builder.py +684 -0
- data/tools/logilab/logilab/astng/test/unittest_inference.py +1112 -0
- data/tools/logilab/logilab/astng/test/unittest_inspector.py +105 -0
- data/tools/logilab/logilab/astng/test/unittest_lookup.py +302 -0
- data/tools/logilab/logilab/astng/test/unittest_manager.py +98 -0
- data/tools/logilab/logilab/astng/test/unittest_nodes.py +302 -0
- data/tools/logilab/logilab/astng/test/unittest_scoped_nodes.py +501 -0
- data/tools/logilab/logilab/astng/test/unittest_utils.py +104 -0
- data/tools/logilab/logilab/astng/utils.py +342 -0
- data/tools/logilab/logilab/common/__init__.py +140 -0
- data/tools/logilab/logilab/common/__pkginfo__.py +43 -0
- data/tools/logilab/logilab/common/adbh.py +35 -0
- data/tools/logilab/logilab/common/cache.py +114 -0
- data/tools/logilab/logilab/common/changelog.py +234 -0
- data/tools/logilab/logilab/common/clcommands.py +181 -0
- data/tools/logilab/logilab/common/cli.py +212 -0
- data/tools/logilab/logilab/common/compat.py +328 -0
- data/tools/logilab/logilab/common/configuration.py +1087 -0
- data/tools/logilab/logilab/common/contexts.py +58 -0
- data/tools/logilab/logilab/common/corbautils.py +117 -0
- data/tools/logilab/logilab/common/daemon.py +171 -0
- data/tools/logilab/logilab/common/date.py +279 -0
- data/tools/logilab/logilab/common/db.py +49 -0
- data/tools/logilab/logilab/common/dbf.py +229 -0
- data/tools/logilab/logilab/common/debugger.py +208 -0
- data/tools/logilab/logilab/common/decorators.py +190 -0
- data/tools/logilab/logilab/common/deprecation.py +118 -0
- data/tools/logilab/logilab/common/fileutils.py +409 -0
- data/tools/logilab/logilab/common/graph.py +259 -0
- data/tools/logilab/logilab/common/html.py +142 -0
- data/tools/logilab/logilab/common/interface.py +76 -0
- data/tools/logilab/logilab/common/logging_ext.py +166 -0
- data/tools/logilab/logilab/common/modutils.py +670 -0
- data/tools/logilab/logilab/common/optik_ext.py +383 -0
- data/tools/logilab/logilab/common/optparser.py +92 -0
- data/tools/logilab/logilab/common/pdf_ext.py +111 -0
- data/tools/logilab/logilab/common/proc.py +276 -0
- data/tools/logilab/logilab/common/pyro_ext.py +146 -0
- data/tools/logilab/logilab/common/pytest.py +754 -0
- data/tools/logilab/logilab/common/shellutils.py +383 -0
- data/tools/logilab/logilab/common/sphinx_ext.py +87 -0
- data/tools/logilab/logilab/common/sphinxutils.py +122 -0
- data/tools/logilab/logilab/common/sqlgen.py +31 -0
- data/tools/logilab/logilab/common/table.py +930 -0
- data/tools/logilab/logilab/common/tasksqueue.py +97 -0
- data/tools/logilab/logilab/common/test/__init__.py +1 -0
- data/tools/logilab/logilab/common/test/data/ChangeLog +184 -0
- data/tools/logilab/logilab/common/test/data/MyPyPa-0.1.0-py2.5.egg +0 -0
- data/tools/logilab/logilab/common/test/data/__init__.py +1 -0
- data/tools/logilab/logilab/common/test/data/content_differ_dir/NOTHING +0 -0
- data/tools/logilab/logilab/common/test/data/content_differ_dir/README +1 -0
- data/tools/logilab/logilab/common/test/data/content_differ_dir/subdir/coin +1 -0
- data/tools/logilab/logilab/common/test/data/content_differ_dir/subdir/toto.txt +53 -0
- data/tools/logilab/logilab/common/test/data/file_differ_dir/NOTHING +0 -0
- data/tools/logilab/logilab/common/test/data/file_differ_dir/README +1 -0
- data/tools/logilab/logilab/common/test/data/file_differ_dir/subdir/toto.txt +53 -0
- data/tools/logilab/logilab/common/test/data/file_differ_dir/subdirtwo/Hello +0 -0
- data/tools/logilab/logilab/common/test/data/find_test/__init__.py +0 -0
- data/tools/logilab/logilab/common/test/data/find_test/foo.txt +0 -0
- data/tools/logilab/logilab/common/test/data/find_test/module.py +0 -0
- data/tools/logilab/logilab/common/test/data/find_test/module2.py +0 -0
- data/tools/logilab/logilab/common/test/data/find_test/newlines.txt +0 -0
- data/tools/logilab/logilab/common/test/data/find_test/noendingnewline.py +0 -0
- data/tools/logilab/logilab/common/test/data/find_test/nonregr.py +0 -0
- data/tools/logilab/logilab/common/test/data/find_test/normal_file.txt +0 -0
- data/tools/logilab/logilab/common/test/data/find_test/spam.txt +0 -0
- data/tools/logilab/logilab/common/test/data/find_test/sub/doc.txt +0 -0
- data/tools/logilab/logilab/common/test/data/find_test/sub/momo.py +0 -0
- data/tools/logilab/logilab/common/test/data/find_test/test.ini +0 -0
- data/tools/logilab/logilab/common/test/data/find_test/test1.msg +0 -0
- data/tools/logilab/logilab/common/test/data/find_test/test2.msg +0 -0
- data/tools/logilab/logilab/common/test/data/find_test/write_protected_file.txt +0 -0
- data/tools/logilab/logilab/common/test/data/foo.txt +9 -0
- data/tools/logilab/logilab/common/test/data/module.py +88 -0
- data/tools/logilab/logilab/common/test/data/module2.py +77 -0
- data/tools/logilab/logilab/common/test/data/newlines.txt +3 -0
- data/tools/logilab/logilab/common/test/data/noendingnewline.py +36 -0
- data/tools/logilab/logilab/common/test/data/nonregr.py +14 -0
- data/tools/logilab/logilab/common/test/data/normal_file.txt +0 -0
- data/tools/logilab/logilab/common/test/data/reference_dir/NOTHING +0 -0
- data/tools/logilab/logilab/common/test/data/reference_dir/README +1 -0
- data/tools/logilab/logilab/common/test/data/reference_dir/subdir/coin +1 -0
- data/tools/logilab/logilab/common/test/data/reference_dir/subdir/toto.txt +53 -0
- data/tools/logilab/logilab/common/test/data/same_dir/NOTHING +0 -0
- data/tools/logilab/logilab/common/test/data/same_dir/README +1 -0
- data/tools/logilab/logilab/common/test/data/same_dir/subdir/coin +1 -0
- data/tools/logilab/logilab/common/test/data/same_dir/subdir/toto.txt +53 -0
- data/tools/logilab/logilab/common/test/data/spam.txt +9 -0
- data/tools/logilab/logilab/common/test/data/sub/doc.txt +1 -0
- data/tools/logilab/logilab/common/test/data/sub/momo.py +1 -0
- data/tools/logilab/logilab/common/test/data/subdir_differ_dir/NOTHING +0 -0
- data/tools/logilab/logilab/common/test/data/subdir_differ_dir/README +1 -0
- data/tools/logilab/logilab/common/test/data/subdir_differ_dir/subdir/coin +1 -0
- data/tools/logilab/logilab/common/test/data/subdir_differ_dir/subdir/toto.txt +53 -0
- data/tools/logilab/logilab/common/test/data/test.ini +20 -0
- data/tools/logilab/logilab/common/test/data/test1.msg +30 -0
- data/tools/logilab/logilab/common/test/data/test2.msg +42 -0
- data/tools/logilab/logilab/common/test/data/write_protected_file.txt +0 -0
- data/tools/logilab/logilab/common/test/foomod.py +17 -0
- data/tools/logilab/logilab/common/test/unittest_cache.py +129 -0
- data/tools/logilab/logilab/common/test/unittest_changelog.py +37 -0
- data/tools/logilab/logilab/common/test/unittest_compat.py +239 -0
- data/tools/logilab/logilab/common/test/unittest_configuration.py +348 -0
- data/tools/logilab/logilab/common/test/unittest_date.py +154 -0
- data/tools/logilab/logilab/common/test/unittest_decorators.py +62 -0
- data/tools/logilab/logilab/common/test/unittest_deprecation.py +76 -0
- data/tools/logilab/logilab/common/test/unittest_fileutils.py +133 -0
- data/tools/logilab/logilab/common/test/unittest_graph.py +50 -0
- data/tools/logilab/logilab/common/test/unittest_html.py +76 -0
- data/tools/logilab/logilab/common/test/unittest_interface.py +87 -0
- data/tools/logilab/logilab/common/test/unittest_modutils.py +244 -0
- data/tools/logilab/logilab/common/test/unittest_pytest.py +50 -0
- data/tools/logilab/logilab/common/test/unittest_shellutils.py +248 -0
- data/tools/logilab/logilab/common/test/unittest_table.py +448 -0
- data/tools/logilab/logilab/common/test/unittest_taskqueue.py +71 -0
- data/tools/logilab/logilab/common/test/unittest_testlib.py +956 -0
- data/tools/logilab/logilab/common/test/unittest_textutils.py +247 -0
- data/tools/logilab/logilab/common/test/unittest_tree.py +248 -0
- data/tools/logilab/logilab/common/test/unittest_umessage.py +55 -0
- data/tools/logilab/logilab/common/test/unittest_ureports_html.py +64 -0
- data/tools/logilab/logilab/common/test/unittest_ureports_text.py +105 -0
- data/tools/logilab/logilab/common/test/unittest_xmlutils.py +75 -0
- data/tools/logilab/logilab/common/test/utils.py +87 -0
- data/tools/logilab/logilab/common/testlib.py +1927 -0
- data/tools/logilab/logilab/common/textutils.py +476 -0
- data/tools/logilab/logilab/common/tree.py +372 -0
- data/tools/logilab/logilab/common/umessage.py +161 -0
- data/tools/logilab/logilab/common/ureports/__init__.py +174 -0
- data/tools/logilab/logilab/common/ureports/docbook_writer.py +139 -0
- data/tools/logilab/logilab/common/ureports/html_writer.py +131 -0
- data/tools/logilab/logilab/common/ureports/nodes.py +201 -0
- data/tools/logilab/logilab/common/ureports/text_writer.py +140 -0
- data/tools/logilab/logilab/common/vcgutils.py +216 -0
- data/tools/logilab/logilab/common/visitor.py +107 -0
- data/tools/logilab/logilab/common/xmlrpcutils.py +136 -0
- data/tools/logilab/logilab/common/xmlutils.py +61 -0
- data/tools/pychecker/COPYRIGHT +31 -0
- data/tools/pychecker/ChangeLog +349 -0
- data/tools/pychecker/CodeChecks.py +1969 -0
- data/tools/pychecker/CodeChecks.pyc +0 -0
- data/tools/pychecker/CodeChecks.pyo +0 -0
- data/tools/pychecker/Config.py +475 -0
- data/tools/pychecker/Config.pyc +0 -0
- data/tools/pychecker/Config.pyo +0 -0
- data/tools/pychecker/KNOWN_BUGS +100 -0
- data/tools/pychecker/MAINTAINERS +81 -0
- data/tools/pychecker/NEWS +406 -0
- data/tools/pychecker/OP.py +131 -0
- data/tools/pychecker/OP.pyc +0 -0
- data/tools/pychecker/OP.pyo +0 -0
- data/tools/pychecker/OptionTypes.py +117 -0
- data/tools/pychecker/OptionTypes.pyc +0 -0
- data/tools/pychecker/OptionTypes.pyo +0 -0
- data/tools/pychecker/README +152 -0
- data/tools/pychecker/Stack.py +115 -0
- data/tools/pychecker/Stack.pyc +0 -0
- data/tools/pychecker/Stack.pyo +0 -0
- data/tools/pychecker/TODO +101 -0
- data/tools/pychecker/VERSION +1 -0
- data/tools/pychecker/Warning.py +50 -0
- data/tools/pychecker/Warning.pyc +0 -0
- data/tools/pychecker/Warning.pyo +0 -0
- data/tools/pychecker/__init__.py +17 -0
- data/tools/pychecker/__init__.pyc +0 -0
- data/tools/pychecker/__init__.pyo +0 -0
- data/tools/pychecker/checker.py +961 -0
- data/tools/pychecker/checker.pyc +0 -0
- data/tools/pychecker/checker.pyo +0 -0
- data/tools/pychecker/function.py +159 -0
- data/tools/pychecker/function.pyc +0 -0
- data/tools/pychecker/function.pyo +0 -0
- data/tools/pychecker/msgs.py +175 -0
- data/tools/pychecker/msgs.pyc +0 -0
- data/tools/pychecker/msgs.pyo +0 -0
- data/tools/pychecker/options.py +275 -0
- data/tools/pychecker/options.pyc +0 -0
- data/tools/pychecker/options.pyo +0 -0
- data/tools/pychecker/pcmodules.py +19 -0
- data/tools/pychecker/pcmodules.pyc +0 -0
- data/tools/pychecker/pcmodules.pyo +0 -0
- data/tools/pychecker/printer.py +47 -0
- data/tools/pychecker/printer.pyc +0 -0
- data/tools/pychecker/printer.pyo +0 -0
- data/tools/pychecker/python.py +427 -0
- data/tools/pychecker/python.pyc +0 -0
- data/tools/pychecker/python.pyo +0 -0
- data/tools/pychecker/utils.py +102 -0
- data/tools/pychecker/utils.pyc +0 -0
- data/tools/pychecker/utils.pyo +0 -0
- data/tools/pychecker/warn.py +778 -0
- data/tools/pychecker/warn.pyc +0 -0
- data/tools/pychecker/warn.pyo +0 -0
- data/tools/pylint2/pylint/__init__.py +16 -0
- data/tools/pylint2/pylint/__pkginfo__.py +67 -0
- data/tools/pylint2/pylint/checkers/__init__.py +155 -0
- data/tools/pylint2/pylint/checkers/base.py +749 -0
- data/tools/pylint2/pylint/checkers/classes.py +527 -0
- data/tools/pylint2/pylint/checkers/design_analysis.py +344 -0
- data/tools/pylint2/pylint/checkers/exceptions.py +183 -0
- data/tools/pylint2/pylint/checkers/format.py +367 -0
- data/tools/pylint2/pylint/checkers/imports.py +379 -0
- data/tools/pylint2/pylint/checkers/logging.py +98 -0
- data/tools/pylint2/pylint/checkers/misc.py +128 -0
- data/tools/pylint2/pylint/checkers/newstyle.py +107 -0
- data/tools/pylint2/pylint/checkers/raw_metrics.py +125 -0
- data/tools/pylint2/pylint/checkers/similar.py +333 -0
- data/tools/pylint2/pylint/checkers/string_format.py +239 -0
- data/tools/pylint2/pylint/checkers/typecheck.py +364 -0
- data/tools/pylint2/pylint/checkers/utils.py +208 -0
- data/tools/pylint2/pylint/checkers/variables.py +498 -0
- data/tools/pylint2/pylint/config.py +149 -0
- data/tools/pylint2/pylint/epylint.py +149 -0
- data/tools/pylint2/pylint/gui.py +433 -0
- data/tools/pylint2/pylint/interfaces.py +98 -0
- data/tools/pylint2/pylint/lint.py +914 -0
- data/tools/pylint2/pylint/pyreverse/__init__.py +5 -0
- data/tools/pylint2/pylint/pyreverse/diadefslib.py +229 -0
- data/tools/pylint2/pylint/pyreverse/diagrams.py +247 -0
- data/tools/pylint2/pylint/pyreverse/main.py +123 -0
- data/tools/pylint2/pylint/pyreverse/utils.py +131 -0
- data/tools/pylint2/pylint/pyreverse/writer.py +196 -0
- data/tools/pylint2/pylint/reporters/__init__.py +67 -0
- data/tools/pylint2/pylint/reporters/guireporter.py +36 -0
- data/tools/pylint2/pylint/reporters/html.py +69 -0
- data/tools/pylint2/pylint/reporters/text.py +156 -0
- data/tools/pylint2/pylint/utils.py +518 -0
- data/tools/pylint2/pylint.py +16 -0
- data/tools/test/suite.py +35 -0
- metadata +566 -0
@@ -0,0 +1,914 @@
|
|
1
|
+
# Copyright (c) 2003-2010 Sylvain Thenault (thenault@gmail.com).
|
2
|
+
# Copyright (c) 2003-2010 LOGILAB S.A. (Paris, FRANCE).
|
3
|
+
# http://www.logilab.fr/ -- mailto:contact@logilab.fr
|
4
|
+
#
|
5
|
+
# This program is free software; you can redistribute it and/or modify it under
|
6
|
+
# the terms of the GNU General Public License as published by the Free Software
|
7
|
+
# Foundation; either version 2 of the License, or (at your option) any later
|
8
|
+
# version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
11
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
12
|
+
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License along with
|
15
|
+
# this program; if not, write to the Free Software Foundation, Inc.,
|
16
|
+
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
17
|
+
""" %prog [options] module_or_package
|
18
|
+
|
19
|
+
Check that a module satisfy a coding standard (and more !).
|
20
|
+
|
21
|
+
%prog --help
|
22
|
+
|
23
|
+
Display this help message and exit.
|
24
|
+
|
25
|
+
%prog --help-msg <msg-id>[,<msg-id>]
|
26
|
+
|
27
|
+
Display help messages about given message identifiers and exit.
|
28
|
+
"""
|
29
|
+
|
30
|
+
# import this first to avoid builtin namespace pollution
|
31
|
+
from pylint.checkers import utils
|
32
|
+
|
33
|
+
import sys
|
34
|
+
import os
|
35
|
+
import re
|
36
|
+
import tokenize
|
37
|
+
from warnings import warn
|
38
|
+
|
39
|
+
from logilab.common.configuration import UnsupportedAction, OptionsManagerMixIn
|
40
|
+
from logilab.common.optik_ext import check_csv
|
41
|
+
from logilab.common.modutils import load_module_from_name
|
42
|
+
from logilab.common.interface import implements
|
43
|
+
from logilab.common.textutils import splitstrip
|
44
|
+
from logilab.common.fileutils import norm_open
|
45
|
+
from logilab.common.ureports import Table, Text, Section
|
46
|
+
from logilab.common.graph import ordered_nodes
|
47
|
+
from logilab.common.__pkginfo__ import version as common_version
|
48
|
+
|
49
|
+
from logilab.astng import MANAGER, nodes
|
50
|
+
from logilab.astng.__pkginfo__ import version as astng_version
|
51
|
+
|
52
|
+
from pylint.utils import PyLintASTWalker, UnknownMessage, MessagesHandlerMixIn,\
|
53
|
+
ReportsHandlerMixIn, MSG_TYPES, expand_modules
|
54
|
+
from pylint.interfaces import ILinter, IRawChecker, IASTNGChecker
|
55
|
+
from pylint.checkers import BaseRawChecker, EmptyReport, \
|
56
|
+
table_lines_from_stats
|
57
|
+
from pylint.reporters.text import TextReporter, ParseableTextReporter, \
|
58
|
+
VSTextReporter, ColorizedTextReporter
|
59
|
+
from pylint.reporters.html import HTMLReporter
|
60
|
+
from pylint import config
|
61
|
+
|
62
|
+
from pylint.__pkginfo__ import version
|
63
|
+
|
64
|
+
|
65
|
+
OPTION_RGX = re.compile('\s*#*\s*pylint:(.*)')
|
66
|
+
REPORTER_OPT_MAP = {'text': TextReporter,
|
67
|
+
'parseable': ParseableTextReporter,
|
68
|
+
'msvs': VSTextReporter,
|
69
|
+
'colorized': ColorizedTextReporter,
|
70
|
+
'html': HTMLReporter,}
|
71
|
+
|
72
|
+
|
73
|
+
# Python Linter class #########################################################
|
74
|
+
|
75
|
+
MSGS = {
|
76
|
+
'F0001': ('%s',
|
77
|
+
'Used when an error occurred preventing the analysis of a \
|
78
|
+
module (unable to find it for instance).'),
|
79
|
+
'F0002': ('%s: %s',
|
80
|
+
'Used when an unexpected error occurred while building the ASTNG \
|
81
|
+
representation. This is usually accompanied by a traceback. \
|
82
|
+
Please report such errors !'),
|
83
|
+
'F0003': ('ignored builtin module %s',
|
84
|
+
'Used to indicate that the user asked to analyze a builtin module\
|
85
|
+
which has been skipped.'),
|
86
|
+
'F0004': ('unexpected inferred value %s',
|
87
|
+
'Used to indicate that some value of an unexpected type has been \
|
88
|
+
inferred.'),
|
89
|
+
|
90
|
+
'I0001': ('Unable to run raw checkers on built-in module %s',
|
91
|
+
'Used to inform that a built-in module has not been checked \
|
92
|
+
using the raw checkers.'),
|
93
|
+
|
94
|
+
'I0010': ('Unable to consider inline option %r',
|
95
|
+
'Used when an inline option is either badly formatted or can\'t \
|
96
|
+
be used inside modules.'),
|
97
|
+
|
98
|
+
'I0011': ('Locally disabling %s',
|
99
|
+
'Used when an inline option disables a message or a messages \
|
100
|
+
category.'),
|
101
|
+
'I0012': ('Locally enabling %s',
|
102
|
+
'Used when an inline option enables a message or a messages \
|
103
|
+
category.'),
|
104
|
+
'I0013': ('Ignoring entire file',
|
105
|
+
'Used to inform that the file will not be checked'),
|
106
|
+
|
107
|
+
|
108
|
+
'E0001': ('%s',
|
109
|
+
'Used when a syntax error is raised for a module.'),
|
110
|
+
|
111
|
+
'E0011': ('Unrecognized file option %r',
|
112
|
+
'Used when an unknown inline option is encountered.'),
|
113
|
+
'E0012': ('Bad option value %r',
|
114
|
+
'Used when a bad value for an inline option is encountered.'),
|
115
|
+
}
|
116
|
+
|
117
|
+
|
118
|
+
class PyLinter(OptionsManagerMixIn, MessagesHandlerMixIn, ReportsHandlerMixIn,
|
119
|
+
BaseRawChecker):
|
120
|
+
"""lint Python modules using external checkers.
|
121
|
+
|
122
|
+
This is the main checker controlling the other ones and the reports
|
123
|
+
generation. It is itself both a raw checker and an astng checker in order
|
124
|
+
to:
|
125
|
+
* handle message activation / deactivation at the module level
|
126
|
+
* handle some basic but necessary stats'data (number of classes, methods...)
|
127
|
+
"""
|
128
|
+
|
129
|
+
__implements__ = (ILinter, IRawChecker)
|
130
|
+
|
131
|
+
name = 'master'
|
132
|
+
priority = 0
|
133
|
+
level = 0
|
134
|
+
msgs = MSGS
|
135
|
+
may_be_disabled = False
|
136
|
+
|
137
|
+
options = (('ignore',
|
138
|
+
{'type' : 'csv', 'metavar' : '<file>',
|
139
|
+
'dest' : 'black_list', 'default' : ('CVS',),
|
140
|
+
'help' : 'Add <file or directory> to the black list. It \
|
141
|
+
should be a base name, not a path. You may set this option multiple times.'}),
|
142
|
+
|
143
|
+
('persistent',
|
144
|
+
{'default': True, 'type' : 'yn', 'metavar' : '<y_or_n>',
|
145
|
+
'level': 1,
|
146
|
+
'help' : 'Pickle collected data for later comparisons.'}),
|
147
|
+
|
148
|
+
('load-plugins',
|
149
|
+
{'type' : 'csv', 'metavar' : '<modules>', 'default' : (),
|
150
|
+
'level': 1,
|
151
|
+
'help' : 'List of plugins (as comma separated values of \
|
152
|
+
python modules names) to load, usually to register additional checkers.'}),
|
153
|
+
|
154
|
+
('output-format',
|
155
|
+
{'default': 'text', 'type': 'choice', 'metavar' : '<format>',
|
156
|
+
'choices': ('text', 'parseable', 'msvs', 'colorized', 'html'),
|
157
|
+
'short': 'f',
|
158
|
+
'group': 'Reports',
|
159
|
+
'help' : 'Set the output format. Available formats are text,\
|
160
|
+
parseable, colorized, msvs (visual studio) and html'}),
|
161
|
+
|
162
|
+
('include-ids',
|
163
|
+
{'type' : 'yn', 'metavar' : '<y_or_n>', 'default' : 0,
|
164
|
+
'short': 'i',
|
165
|
+
'group': 'Reports',
|
166
|
+
'help' : 'Include message\'s id in output'}),
|
167
|
+
|
168
|
+
('files-output',
|
169
|
+
{'default': 0, 'type' : 'yn', 'metavar' : '<y_or_n>',
|
170
|
+
'group': 'Reports', 'level': 1,
|
171
|
+
'help' : 'Put messages in a separate file for each module / \
|
172
|
+
package specified on the command line instead of printing them on stdout. \
|
173
|
+
Reports (if any) will be written in a file name "pylint_global.[txt|html]".'}),
|
174
|
+
|
175
|
+
('reports',
|
176
|
+
{'default': 1, 'type' : 'yn', 'metavar' : '<y_or_n>',
|
177
|
+
'short': 'r',
|
178
|
+
'group': 'Reports',
|
179
|
+
'help' : 'Tells whether to display a full report or only the\
|
180
|
+
messages'}),
|
181
|
+
|
182
|
+
('evaluation',
|
183
|
+
{'type' : 'string', 'metavar' : '<python_expression>',
|
184
|
+
'group': 'Reports', 'level': 1,
|
185
|
+
'default': '10.0 - ((float(5 * error + warning + refactor + \
|
186
|
+
convention) / statement) * 10)',
|
187
|
+
'help' : 'Python expression which should return a note less \
|
188
|
+
than 10 (10 is the highest note). You have access to the variables errors \
|
189
|
+
warning, statement which respectively contain the number of errors / warnings\
|
190
|
+
messages and the total number of statements analyzed. This is used by the \
|
191
|
+
global evaluation report (R0004).'}),
|
192
|
+
|
193
|
+
('comment',
|
194
|
+
{'default': 0, 'type' : 'yn', 'metavar' : '<y_or_n>',
|
195
|
+
'group': 'Reports', 'level': 1,
|
196
|
+
'help' : 'Add a comment according to your evaluation note. \
|
197
|
+
This is used by the global evaluation report (R0004).'}),
|
198
|
+
|
199
|
+
('enable',
|
200
|
+
{'type' : 'csv', 'metavar': '<msg ids>',
|
201
|
+
'short': 'e',
|
202
|
+
'group': 'Messages control',
|
203
|
+
'help' : 'Enable the message, report, category or checker with the '
|
204
|
+
'given id(s). You can either give multiple identifier '
|
205
|
+
'separated by comma (,) or put this option multiple time.'}),
|
206
|
+
|
207
|
+
('disable',
|
208
|
+
{'type' : 'csv', 'metavar': '<msg ids>',
|
209
|
+
'short': 'd',
|
210
|
+
'group': 'Messages control',
|
211
|
+
'help' : 'Disable the message, report, category or checker with the '
|
212
|
+
'given id(s). You can either give multiple identifier '
|
213
|
+
'separated by comma (,) or put this option multiple time.'}),
|
214
|
+
)
|
215
|
+
|
216
|
+
option_groups = (
|
217
|
+
('Messages control', 'Options controling analysis messages'),
|
218
|
+
('Reports', 'Options related to output formating and reporting'),
|
219
|
+
)
|
220
|
+
|
221
|
+
def __init__(self, options=(), reporter=None, option_groups=(),
|
222
|
+
pylintrc=None):
|
223
|
+
# some stuff has to be done before ancestors initialization...
|
224
|
+
#
|
225
|
+
# checkers / reporter / astng manager
|
226
|
+
self.reporter = None
|
227
|
+
self._checkers = {}
|
228
|
+
self._ignore_file = False
|
229
|
+
# visit variables
|
230
|
+
self.base_name = None
|
231
|
+
self.base_file = None
|
232
|
+
self.current_name = None
|
233
|
+
self.current_file = None
|
234
|
+
self.stats = None
|
235
|
+
# init options
|
236
|
+
self.options = options + PyLinter.options
|
237
|
+
self.option_groups = option_groups + PyLinter.option_groups
|
238
|
+
self._options_methods = {
|
239
|
+
'enable': self.enable,
|
240
|
+
'disable': self.disable}
|
241
|
+
self._bw_options_methods = {'disable-msg': self.disable,
|
242
|
+
'enable-msg': self.enable}
|
243
|
+
full_version = '%%prog %s, \nastng %s, common %s\nPython %s' % (
|
244
|
+
version, astng_version, common_version, sys.version)
|
245
|
+
OptionsManagerMixIn.__init__(self, usage=__doc__,
|
246
|
+
version=full_version,
|
247
|
+
config_file=pylintrc or config.PYLINTRC)
|
248
|
+
MessagesHandlerMixIn.__init__(self)
|
249
|
+
ReportsHandlerMixIn.__init__(self)
|
250
|
+
BaseRawChecker.__init__(self)
|
251
|
+
# provided reports
|
252
|
+
self.reports = (('RP0001', 'Messages by category',
|
253
|
+
report_total_messages_stats),
|
254
|
+
('RP0002', '% errors / warnings by module',
|
255
|
+
report_messages_by_module_stats),
|
256
|
+
('RP0003', 'Messages',
|
257
|
+
report_messages_stats),
|
258
|
+
('RP0004', 'Global evaluation',
|
259
|
+
self.report_evaluation),
|
260
|
+
)
|
261
|
+
self.register_checker(self)
|
262
|
+
self._dynamic_plugins = []
|
263
|
+
self.load_provider_defaults()
|
264
|
+
self.set_reporter(reporter or TextReporter(sys.stdout))
|
265
|
+
|
266
|
+
def load_plugin_modules(self, modnames):
|
267
|
+
"""take a list of module names which are pylint plugins and load
|
268
|
+
and register them
|
269
|
+
"""
|
270
|
+
for modname in modnames:
|
271
|
+
if modname in self._dynamic_plugins:
|
272
|
+
continue
|
273
|
+
self._dynamic_plugins.append(modname)
|
274
|
+
module = load_module_from_name(modname)
|
275
|
+
module.register(self)
|
276
|
+
|
277
|
+
def set_reporter(self, reporter):
|
278
|
+
"""set the reporter used to display messages and reports"""
|
279
|
+
self.reporter = reporter
|
280
|
+
reporter.linter = self
|
281
|
+
|
282
|
+
def set_option(self, optname, value, action=None, optdict=None):
|
283
|
+
"""overridden from configuration.OptionsProviderMixin to handle some
|
284
|
+
special options
|
285
|
+
"""
|
286
|
+
if optname in self._options_methods or optname in self._bw_options_methods:
|
287
|
+
if value:
|
288
|
+
try:
|
289
|
+
meth = self._options_methods[optname]
|
290
|
+
except KeyError:
|
291
|
+
meth = self._bw_options_methods[optname]
|
292
|
+
warn('%s is deprecated, replace it by %s' % (
|
293
|
+
optname, optname.split('-')[0]), DeprecationWarning)
|
294
|
+
value = check_csv(None, optname, value)
|
295
|
+
if isinstance(value, (list, tuple)):
|
296
|
+
for _id in value :
|
297
|
+
meth(_id)
|
298
|
+
else :
|
299
|
+
meth(value)
|
300
|
+
elif optname == 'output-format':
|
301
|
+
self.set_reporter(REPORTER_OPT_MAP[value.lower()]())
|
302
|
+
try:
|
303
|
+
BaseRawChecker.set_option(self, optname, value, action, optdict)
|
304
|
+
except UnsupportedAction:
|
305
|
+
print >> sys.stderr, 'option %s can\'t be read from config file' % \
|
306
|
+
optname
|
307
|
+
|
308
|
+
# checkers manipulation methods ############################################
|
309
|
+
|
310
|
+
def register_checker(self, checker):
|
311
|
+
"""register a new checker
|
312
|
+
|
313
|
+
checker is an object implementing IRawChecker or / and IASTNGChecker
|
314
|
+
"""
|
315
|
+
assert checker.priority <= 0, 'checker priority can\'t be >= 0'
|
316
|
+
self._checkers.setdefault(checker.name, []).append(checker)
|
317
|
+
if hasattr(checker, 'reports'):
|
318
|
+
for r_id, r_title, r_cb in checker.reports:
|
319
|
+
self.register_report(r_id, r_title, r_cb, checker)
|
320
|
+
self.register_options_provider(checker)
|
321
|
+
if hasattr(checker, 'msgs'):
|
322
|
+
self.register_messages(checker)
|
323
|
+
checker.load_defaults()
|
324
|
+
|
325
|
+
def disable_noerror_messages(self):
|
326
|
+
for msgcat, msgids in self._msgs_by_category.iteritems():
|
327
|
+
if msgcat == 'E':
|
328
|
+
for msgid in msgids:
|
329
|
+
self.enable(msgid)
|
330
|
+
else:
|
331
|
+
for msgid in msgids:
|
332
|
+
self.disable(msgid)
|
333
|
+
|
334
|
+
# block level option handling #############################################
|
335
|
+
#
|
336
|
+
# see func_block_disable_msg.py test case for expected behaviour
|
337
|
+
|
338
|
+
def process_tokens(self, tokens):
|
339
|
+
"""process tokens from the current module to search for module/block
|
340
|
+
level options
|
341
|
+
"""
|
342
|
+
comment = tokenize.COMMENT
|
343
|
+
newline = tokenize.NEWLINE
|
344
|
+
for (tok_type, _, start, _, line) in tokens:
|
345
|
+
if tok_type not in (comment, newline):
|
346
|
+
continue
|
347
|
+
match = OPTION_RGX.search(line)
|
348
|
+
if match is None:
|
349
|
+
continue
|
350
|
+
if match.group(1).strip() == "disable-all":
|
351
|
+
self.add_message('I0013', line=start[0])
|
352
|
+
self._ignore_file = True
|
353
|
+
return
|
354
|
+
try:
|
355
|
+
opt, value = match.group(1).split('=', 1)
|
356
|
+
except ValueError:
|
357
|
+
self.add_message('I0010', args=match.group(1).strip(),
|
358
|
+
line=start[0])
|
359
|
+
continue
|
360
|
+
opt = opt.strip()
|
361
|
+
if opt in self._options_methods or opt in self._bw_options_methods:
|
362
|
+
try:
|
363
|
+
meth = self._options_methods[opt]
|
364
|
+
except KeyError:
|
365
|
+
meth = self._bw_options_methods[opt]
|
366
|
+
warn('%s is deprecated, replace it by %s (%s)' % (
|
367
|
+
opt, opt.split('-')[0], self.current_file),
|
368
|
+
DeprecationWarning)
|
369
|
+
for msgid in splitstrip(value):
|
370
|
+
try:
|
371
|
+
meth(msgid, 'module', start[0])
|
372
|
+
except UnknownMessage:
|
373
|
+
self.add_message('E0012', args=msgid, line=start[0])
|
374
|
+
else:
|
375
|
+
self.add_message('E0011', args=opt, line=start[0])
|
376
|
+
|
377
|
+
def collect_block_lines(self, node, msg_state):
|
378
|
+
"""walk ast to collect block level options line numbers"""
|
379
|
+
# recurse on children (depth first)
|
380
|
+
for child in node.get_children():
|
381
|
+
self.collect_block_lines(child, msg_state)
|
382
|
+
first = node.fromlineno
|
383
|
+
last = node.tolineno
|
384
|
+
# first child line number used to distinguish between disable
|
385
|
+
# which are the first child of scoped node with those defined later.
|
386
|
+
# For instance in the code below:
|
387
|
+
#
|
388
|
+
# 1. def meth8(self):
|
389
|
+
# 2. """test late disabling"""
|
390
|
+
# 3. # pylint: disable=E1102
|
391
|
+
# 4. print self.blip
|
392
|
+
# 5. # pylint: disable=E1101
|
393
|
+
# 6. print self.bla
|
394
|
+
#
|
395
|
+
# E1102 should be disabled from line 1 to 6 while E1101 from line 5 to 6
|
396
|
+
#
|
397
|
+
# this is necessary to disable locally messages applying to class /
|
398
|
+
# function using their fromlineno
|
399
|
+
if isinstance(node, (nodes.Module, nodes.Class, nodes.Function)) and node.body:
|
400
|
+
firstchildlineno = node.body[0].fromlineno
|
401
|
+
else:
|
402
|
+
firstchildlineno = last
|
403
|
+
for msgid, lines in msg_state.iteritems():
|
404
|
+
for lineno, state in lines.items():
|
405
|
+
if first <= lineno <= last:
|
406
|
+
if lineno > firstchildlineno:
|
407
|
+
state = True
|
408
|
+
# set state for all lines for this block
|
409
|
+
first, last = node.block_range(lineno)
|
410
|
+
for line in xrange(first, last+1):
|
411
|
+
# do not override existing entries
|
412
|
+
if not line in self._module_msgs_state.get(msgid, ()):
|
413
|
+
if line in lines: # state change in the same block
|
414
|
+
state = lines[line]
|
415
|
+
try:
|
416
|
+
self._module_msgs_state[msgid][line] = state
|
417
|
+
except KeyError:
|
418
|
+
self._module_msgs_state[msgid] = {line: state}
|
419
|
+
del lines[lineno]
|
420
|
+
|
421
|
+
|
422
|
+
# code checking methods ###################################################
|
423
|
+
|
424
|
+
def sort_checkers(self, checkers=None):
|
425
|
+
if checkers is None:
|
426
|
+
checkers = [checker for checkers in self._checkers.values()
|
427
|
+
for checker in checkers]
|
428
|
+
graph = {}
|
429
|
+
cls_instance = {}
|
430
|
+
for checker in checkers:
|
431
|
+
graph[checker.__class__] = set(checker.needs_checkers)
|
432
|
+
cls_instance[checker.__class__] = checker
|
433
|
+
checkers = [cls_instance.get(cls) for cls in ordered_nodes(graph)]
|
434
|
+
checkers.remove(self)
|
435
|
+
checkers.insert(0, self)
|
436
|
+
return checkers
|
437
|
+
|
438
|
+
def _get_checkers(self):
|
439
|
+
# compute checkers needed according to activated messages and reports
|
440
|
+
neededcheckers = set()
|
441
|
+
for checkers in self._checkers.values():
|
442
|
+
for checker in checkers:
|
443
|
+
for msgid in checker.msgs:
|
444
|
+
if self._msgs_state.get(msgid, True):
|
445
|
+
neededcheckers.add(checker)
|
446
|
+
break
|
447
|
+
else:
|
448
|
+
for reportid, _, _ in checker.reports:
|
449
|
+
if self.is_report_enabled(reportid):
|
450
|
+
neededcheckers.add(checker)
|
451
|
+
break
|
452
|
+
return self.sort_checkers(neededcheckers)
|
453
|
+
|
454
|
+
def check(self, files_or_modules):
|
455
|
+
"""main checking entry: check a list of files or modules from their
|
456
|
+
name.
|
457
|
+
"""
|
458
|
+
self.reporter.include_ids = self.config.include_ids
|
459
|
+
if not isinstance(files_or_modules, (list, tuple)):
|
460
|
+
files_or_modules = (files_or_modules,)
|
461
|
+
checkers = self._get_checkers()
|
462
|
+
rawcheckers = []
|
463
|
+
walker = PyLintASTWalker()
|
464
|
+
# notify global begin
|
465
|
+
for checker in checkers:
|
466
|
+
checker.open()
|
467
|
+
if implements(checker, IASTNGChecker):
|
468
|
+
walker.add_checker(checker)
|
469
|
+
if implements(checker, IRawChecker) and checker is not self: #XXX
|
470
|
+
rawcheckers.append(checker)
|
471
|
+
# build ast and check modules or packages
|
472
|
+
for descr in self.expand_files(files_or_modules):
|
473
|
+
modname, filepath = descr['name'], descr['path']
|
474
|
+
self.set_current_module(modname, filepath)
|
475
|
+
# get the module representation
|
476
|
+
astng = self.get_astng(filepath, modname)
|
477
|
+
if astng is None:
|
478
|
+
continue
|
479
|
+
self.base_name = descr['basename']
|
480
|
+
self.base_file = descr['basepath']
|
481
|
+
if self.config.files_output:
|
482
|
+
reportfile = 'pylint_%s.%s' % (modname, self.reporter.extension)
|
483
|
+
self.reporter.set_output(open(reportfile, 'w'))
|
484
|
+
self._ignore_file = False
|
485
|
+
# fix the current file (if the source file was not available or
|
486
|
+
# if it's actually a c extension)
|
487
|
+
self.current_file = astng.file
|
488
|
+
self.check_astng_module(astng, walker, rawcheckers)
|
489
|
+
# notify global end
|
490
|
+
self.set_current_module('')
|
491
|
+
self.stats['statement'] = walker.nbstatements
|
492
|
+
checkers.reverse()
|
493
|
+
for checker in checkers:
|
494
|
+
checker.close()
|
495
|
+
|
496
|
+
def expand_files(self, modules):
|
497
|
+
"""get modules and errors from a list of modules and handle errors
|
498
|
+
"""
|
499
|
+
result, errors = expand_modules(modules, self.config.black_list)
|
500
|
+
for error in errors:
|
501
|
+
message = modname = error["mod"]
|
502
|
+
key = error["key"]
|
503
|
+
self.set_current_module(modname)
|
504
|
+
if key == "F0001":
|
505
|
+
message = str(error["ex"]).replace(os.getcwd() + os.sep, '')
|
506
|
+
self.add_message(key, args=message)
|
507
|
+
return result
|
508
|
+
|
509
|
+
def set_current_module(self, modname, filepath=None):
|
510
|
+
"""set the name of the currently analyzed module and
|
511
|
+
init statistics for it
|
512
|
+
"""
|
513
|
+
if not modname and filepath is None:
|
514
|
+
return
|
515
|
+
self.current_name = modname
|
516
|
+
self.current_file = filepath or modname
|
517
|
+
self.stats['by_module'][modname] = {}
|
518
|
+
self.stats['by_module'][modname]['statement'] = 0
|
519
|
+
for msg_cat in MSG_TYPES.values():
|
520
|
+
self.stats['by_module'][modname][msg_cat] = 0
|
521
|
+
# XXX hack, to be correct we need to keep module_msgs_state
|
522
|
+
# for every analyzed module (the problem stands with localized
|
523
|
+
# messages which are only detected in the .close step)
|
524
|
+
if modname:
|
525
|
+
self._module_msgs_state = {}
|
526
|
+
self._module_msg_cats_state = {}
|
527
|
+
|
528
|
+
def get_astng(self, filepath, modname):
|
529
|
+
"""return a astng representation for a module"""
|
530
|
+
try:
|
531
|
+
return MANAGER.astng_from_file(filepath, modname)
|
532
|
+
except SyntaxError, ex:
|
533
|
+
self.add_message('E0001', line=ex.lineno, args=ex.msg)
|
534
|
+
except KeyboardInterrupt:
|
535
|
+
raise
|
536
|
+
except Exception, ex:
|
537
|
+
#if __debug__:
|
538
|
+
# import traceback
|
539
|
+
# traceback.print_exc()
|
540
|
+
self.add_message('F0002', args=(ex.__class__, ex))
|
541
|
+
|
542
|
+
def check_astng_module(self, astng, walker, rawcheckers):
|
543
|
+
"""check a module from its astng representation, real work"""
|
544
|
+
# call raw checkers if possible
|
545
|
+
if not astng.pure_python:
|
546
|
+
self.add_message('I0001', args=astng.name)
|
547
|
+
else:
|
548
|
+
#assert astng.file.endswith('.py')
|
549
|
+
stream = norm_open(astng.file)
|
550
|
+
# invoke IRawChecker interface on self to fetch module/block
|
551
|
+
# level options
|
552
|
+
self.process_module(stream)
|
553
|
+
if self._ignore_file:
|
554
|
+
return False
|
555
|
+
# walk ast to collect line numbers
|
556
|
+
orig_state = self._module_msgs_state.copy()
|
557
|
+
self._module_msgs_state = {}
|
558
|
+
self.collect_block_lines(astng, orig_state)
|
559
|
+
for checker in rawcheckers:
|
560
|
+
stream.seek(0)
|
561
|
+
checker.process_module(stream)
|
562
|
+
# generate events to astng checkers
|
563
|
+
walker.walk(astng)
|
564
|
+
return True
|
565
|
+
|
566
|
+
# IASTNGChecker interface #################################################
|
567
|
+
|
568
|
+
def open(self):
|
569
|
+
"""initialize counters"""
|
570
|
+
self.stats = { 'by_module' : {},
|
571
|
+
'by_msg' : {},
|
572
|
+
}
|
573
|
+
for msg_cat in MSG_TYPES.values():
|
574
|
+
self.stats[msg_cat] = 0
|
575
|
+
|
576
|
+
def close(self):
|
577
|
+
"""close the whole package /module, it's time to make reports !
|
578
|
+
|
579
|
+
if persistent run, pickle results for later comparison
|
580
|
+
"""
|
581
|
+
if self.base_name is not None:
|
582
|
+
# load old results if any
|
583
|
+
old_stats = config.load_results(self.base_name)
|
584
|
+
if self.config.reports:
|
585
|
+
self.make_reports(self.stats, old_stats)
|
586
|
+
elif self.config.output_format == 'html':
|
587
|
+
self.reporter.display_results(Section())
|
588
|
+
# save results if persistent run
|
589
|
+
if self.config.persistent:
|
590
|
+
config.save_results(self.stats, self.base_name)
|
591
|
+
|
592
|
+
# specific reports ########################################################
|
593
|
+
|
594
|
+
def report_evaluation(self, sect, stats, old_stats):
|
595
|
+
"""make the global evaluation report"""
|
596
|
+
# check with at least check 1 statements (usually 0 when there is a
|
597
|
+
# syntax error preventing pylint from further processing)
|
598
|
+
if stats['statement'] == 0:
|
599
|
+
raise EmptyReport()
|
600
|
+
# get a global note for the code
|
601
|
+
evaluation = self.config.evaluation
|
602
|
+
try:
|
603
|
+
note = eval(evaluation, {}, self.stats)
|
604
|
+
except Exception, ex:
|
605
|
+
msg = 'An exception occurred while rating: %s' % ex
|
606
|
+
else:
|
607
|
+
stats['global_note'] = note
|
608
|
+
msg = 'Your code has been rated at %.2f/10' % note
|
609
|
+
if old_stats.has_key('global_note'):
|
610
|
+
msg += ' (previous run: %.2f/10)' % old_stats['global_note']
|
611
|
+
if self.config.comment:
|
612
|
+
msg = '%s\n%s' % (msg, config.get_note_message(note))
|
613
|
+
sect.append(Text(msg))
|
614
|
+
|
615
|
+
# some reporting functions ####################################################
|
616
|
+
|
617
|
+
def report_total_messages_stats(sect, stats, old_stats):
|
618
|
+
"""make total errors / warnings report"""
|
619
|
+
lines = ['type', 'number', 'previous', 'difference']
|
620
|
+
lines += table_lines_from_stats(stats, old_stats,
|
621
|
+
('convention', 'refactor',
|
622
|
+
'warning', 'error'))
|
623
|
+
sect.append(Table(children=lines, cols=4, rheaders=1))
|
624
|
+
|
625
|
+
def report_messages_stats(sect, stats, _):
|
626
|
+
"""make messages type report"""
|
627
|
+
if not stats['by_msg']:
|
628
|
+
# don't print this report when we didn't detected any errors
|
629
|
+
raise EmptyReport()
|
630
|
+
in_order = [(value, msg_id)
|
631
|
+
for msg_id, value in stats['by_msg'].items()
|
632
|
+
if not msg_id.startswith('I')]
|
633
|
+
in_order.sort()
|
634
|
+
in_order.reverse()
|
635
|
+
lines = ('message id', 'occurrences')
|
636
|
+
for value, msg_id in in_order:
|
637
|
+
lines += (msg_id, str(value))
|
638
|
+
sect.append(Table(children=lines, cols=2, rheaders=1))
|
639
|
+
|
640
|
+
def report_messages_by_module_stats(sect, stats, _):
|
641
|
+
"""make errors / warnings by modules report"""
|
642
|
+
if len(stats['by_module']) == 1:
|
643
|
+
# don't print this report when we are analysing a single module
|
644
|
+
raise EmptyReport()
|
645
|
+
by_mod = {}
|
646
|
+
for m_type in ('fatal', 'error', 'warning', 'refactor', 'convention'):
|
647
|
+
total = stats[m_type]
|
648
|
+
for module in stats['by_module'].keys():
|
649
|
+
mod_total = stats['by_module'][module][m_type]
|
650
|
+
if total == 0:
|
651
|
+
percent = 0
|
652
|
+
else:
|
653
|
+
percent = float((mod_total)*100) / total
|
654
|
+
by_mod.setdefault(module, {})[m_type] = percent
|
655
|
+
sorted_result = []
|
656
|
+
for module, mod_info in by_mod.items():
|
657
|
+
sorted_result.append((mod_info['error'],
|
658
|
+
mod_info['warning'],
|
659
|
+
mod_info['refactor'],
|
660
|
+
mod_info['convention'],
|
661
|
+
module))
|
662
|
+
sorted_result.sort()
|
663
|
+
sorted_result.reverse()
|
664
|
+
lines = ['module', 'error', 'warning', 'refactor', 'convention']
|
665
|
+
for line in sorted_result:
|
666
|
+
if line[0] == 0 and line[1] == 0:
|
667
|
+
break
|
668
|
+
lines.append(line[-1])
|
669
|
+
for val in line[:-1]:
|
670
|
+
lines.append('%.2f' % val)
|
671
|
+
if len(lines) == 5:
|
672
|
+
raise EmptyReport()
|
673
|
+
sect.append(Table(children=lines, cols=5, rheaders=1))
|
674
|
+
|
675
|
+
|
676
|
+
# utilities ###################################################################
|
677
|
+
|
678
|
+
# this may help to import modules using gettext
|
679
|
+
|
680
|
+
try:
|
681
|
+
__builtins__._ = str
|
682
|
+
except AttributeError:
|
683
|
+
__builtins__['_'] = str
|
684
|
+
|
685
|
+
|
686
|
+
def preprocess_options(args, search_for):
|
687
|
+
"""look for some options (keys of <search_for>) which have to be processed
|
688
|
+
before others
|
689
|
+
|
690
|
+
values of <search_for> are callback functions to call when the option is
|
691
|
+
found
|
692
|
+
"""
|
693
|
+
i = 0
|
694
|
+
while i < len(args):
|
695
|
+
arg = args[i]
|
696
|
+
if arg.startswith('--'):
|
697
|
+
try:
|
698
|
+
option, val = arg[2:].split('=', 1)
|
699
|
+
except ValueError:
|
700
|
+
option, val = arg[2:], None
|
701
|
+
try:
|
702
|
+
cb, takearg = search_for[option]
|
703
|
+
del args[i]
|
704
|
+
if takearg and val is None:
|
705
|
+
val = args[i]
|
706
|
+
del args[i]
|
707
|
+
cb(option, val)
|
708
|
+
except KeyError:
|
709
|
+
i += 1
|
710
|
+
else:
|
711
|
+
i += 1
|
712
|
+
|
713
|
+
class Run:
|
714
|
+
"""helper class to use as main for pylint :
|
715
|
+
|
716
|
+
run(*sys.argv[1:])
|
717
|
+
"""
|
718
|
+
LinterClass = PyLinter
|
719
|
+
option_groups = (
|
720
|
+
('Commands', 'Options which are actually commands. Options in this \
|
721
|
+
group are mutually exclusive.'),
|
722
|
+
)
|
723
|
+
|
724
|
+
def __init__(self, args, reporter=None, exit=True):
|
725
|
+
self._rcfile = None
|
726
|
+
self._plugins = []
|
727
|
+
preprocess_options(args, {
|
728
|
+
# option: (callback, takearg)
|
729
|
+
'rcfile': (self.cb_set_rcfile, True),
|
730
|
+
'load-plugins': (self.cb_add_plugins, True),
|
731
|
+
})
|
732
|
+
self.linter = linter = self.LinterClass((
|
733
|
+
('rcfile',
|
734
|
+
{'action' : 'callback', 'callback' : lambda *args: 1,
|
735
|
+
'type': 'string', 'metavar': '<file>',
|
736
|
+
'help' : 'Specify a configuration file.'}),
|
737
|
+
|
738
|
+
('init-hook',
|
739
|
+
{'action' : 'callback', 'type' : 'string', 'metavar': '<code>',
|
740
|
+
'callback' : cb_init_hook, 'level': 1,
|
741
|
+
'help' : 'Python code to execute, usually for sys.path \
|
742
|
+
manipulation such as pygtk.require().'}),
|
743
|
+
|
744
|
+
('help-msg',
|
745
|
+
{'action' : 'callback', 'type' : 'string', 'metavar': '<msg-id>',
|
746
|
+
'callback' : self.cb_help_message,
|
747
|
+
'group': 'Commands',
|
748
|
+
'help' : '''Display a help message for the given message id and \
|
749
|
+
exit. The value may be a comma separated list of message ids.'''}),
|
750
|
+
|
751
|
+
('list-msgs',
|
752
|
+
{'action' : 'callback', 'metavar': '<msg-id>',
|
753
|
+
'callback' : self.cb_list_messages,
|
754
|
+
'group': 'Commands', 'level': 1,
|
755
|
+
'help' : "Generate pylint's messages."}),
|
756
|
+
|
757
|
+
('full-documentation',
|
758
|
+
{'action' : 'callback', 'metavar': '<msg-id>',
|
759
|
+
'callback' : self.cb_full_documentation,
|
760
|
+
'group': 'Commands', 'level': 1,
|
761
|
+
'help' : "Generate pylint's full documentation."}),
|
762
|
+
|
763
|
+
('generate-rcfile',
|
764
|
+
{'action' : 'callback', 'callback' : self.cb_generate_config,
|
765
|
+
'group': 'Commands',
|
766
|
+
'help' : '''Generate a sample configuration file according to \
|
767
|
+
the current configuration. You can put other options before this one to get \
|
768
|
+
them in the generated configuration.'''}),
|
769
|
+
|
770
|
+
('generate-man',
|
771
|
+
{'action' : 'callback', 'callback' : self.cb_generate_manpage,
|
772
|
+
'group': 'Commands',
|
773
|
+
'help' : "Generate pylint's man page.",'hide': True}),
|
774
|
+
|
775
|
+
('errors-only',
|
776
|
+
{'action' : 'callback', 'callback' : self.cb_error_mode,
|
777
|
+
'short': 'E',
|
778
|
+
'help' : '''In error mode, checkers without error messages are \
|
779
|
+
disabled and for others, only the ERROR messages are displayed, and no reports \
|
780
|
+
are done by default'''}),
|
781
|
+
|
782
|
+
('profile',
|
783
|
+
{'type' : 'yn', 'metavar' : '<y_or_n>',
|
784
|
+
'default': False, 'hide': True,
|
785
|
+
'help' : 'Profiled execution.'}),
|
786
|
+
|
787
|
+
), option_groups=self.option_groups,
|
788
|
+
reporter=reporter, pylintrc=self._rcfile)
|
789
|
+
# register standard checkers
|
790
|
+
from pylint import checkers
|
791
|
+
checkers.initialize(linter)
|
792
|
+
# load command line plugins
|
793
|
+
linter.load_plugin_modules(self._plugins)
|
794
|
+
# add some help section
|
795
|
+
linter.add_help_section('Environment variables', config.ENV_HELP, level=1)
|
796
|
+
linter.add_help_section('Output', '''
|
797
|
+
Using the default text output, the message format is :
|
798
|
+
|
799
|
+
MESSAGE_TYPE: LINE_NUM:[OBJECT:] MESSAGE
|
800
|
+
|
801
|
+
There are 5 kind of message types :
|
802
|
+
* (C) convention, for programming standard violation
|
803
|
+
* (R) refactor, for bad code smell
|
804
|
+
* (W) warning, for python specific problems
|
805
|
+
* (E) error, for probable bugs in the code
|
806
|
+
* (F) fatal, if an error occurred which prevented pylint from doing further
|
807
|
+
processing.
|
808
|
+
''', level=1)
|
809
|
+
linter.add_help_section('Output status code', '''
|
810
|
+
Pylint should leave with following status code:
|
811
|
+
* 0 if everything went fine
|
812
|
+
* 1 if a fatal message was issued
|
813
|
+
* 2 if an error message was issued
|
814
|
+
* 4 if a warning message was issued
|
815
|
+
* 8 if a refactor message was issued
|
816
|
+
* 16 if a convention message was issued
|
817
|
+
* 32 on usage error
|
818
|
+
|
819
|
+
status 1 to 16 will be bit-ORed so you can know which different categories has
|
820
|
+
been issued by analysing pylint output status code
|
821
|
+
''', level=1)
|
822
|
+
# read configuration
|
823
|
+
linter.disable('W0704')
|
824
|
+
linter.read_config_file()
|
825
|
+
# is there some additional plugins in the file configuration, in
|
826
|
+
config_parser = linter.cfgfile_parser
|
827
|
+
if config_parser.has_option('MASTER', 'load-plugins'):
|
828
|
+
plugins = splitstrip(config_parser.get('MASTER', 'load-plugins'))
|
829
|
+
linter.load_plugin_modules(plugins)
|
830
|
+
# now we can load file config and command line, plugins (which can
|
831
|
+
# provide options) have been registered
|
832
|
+
linter.load_config_file()
|
833
|
+
if reporter:
|
834
|
+
# if a custom reporter is provided as argument, it may be overridden
|
835
|
+
# by file parameters, so re-set it here, but before command line
|
836
|
+
# parsing so it's still overrideable by command line option
|
837
|
+
linter.set_reporter(reporter)
|
838
|
+
args = linter.load_command_line_configuration(args)
|
839
|
+
if not args:
|
840
|
+
print linter.help()
|
841
|
+
sys.exit(32)
|
842
|
+
# insert current working directory to the python path to have a correct
|
843
|
+
# behaviour
|
844
|
+
sys.path.insert(0, os.getcwd())
|
845
|
+
if self.linter.config.profile:
|
846
|
+
print >> sys.stderr, '** profiled run'
|
847
|
+
from hotshot import Profile, stats
|
848
|
+
prof = Profile('stones.prof')
|
849
|
+
prof.runcall(linter.check, args)
|
850
|
+
prof.close()
|
851
|
+
data = stats.load('stones.prof')
|
852
|
+
data.strip_dirs()
|
853
|
+
data.sort_stats('time', 'calls')
|
854
|
+
data.print_stats(30)
|
855
|
+
else:
|
856
|
+
linter.check(args)
|
857
|
+
sys.path.pop(0)
|
858
|
+
if exit:
|
859
|
+
sys.exit(self.linter.msg_status)
|
860
|
+
|
861
|
+
def cb_set_rcfile(self, name, value):
|
862
|
+
"""callback for option preprocessing (i.e. before optik parsing)"""
|
863
|
+
self._rcfile = value
|
864
|
+
|
865
|
+
def cb_add_plugins(self, name, value):
|
866
|
+
"""callback for option preprocessing (i.e. before optik parsing)"""
|
867
|
+
self._plugins.extend(splitstrip(value))
|
868
|
+
|
869
|
+
def cb_error_mode(self, *args, **kwargs):
|
870
|
+
"""error mode:
|
871
|
+
* disable all but error messages
|
872
|
+
* disable the 'miscellaneous' checker which can be safely deactivated in
|
873
|
+
debug
|
874
|
+
* disable reports
|
875
|
+
* do not save execution information
|
876
|
+
"""
|
877
|
+
self.linter.disable_noerror_messages()
|
878
|
+
self.linter.disable('miscellaneous')
|
879
|
+
self.linter.set_option('reports', False)
|
880
|
+
self.linter.set_option('persistent', False)
|
881
|
+
|
882
|
+
def cb_generate_config(self, *args, **kwargs):
|
883
|
+
"""optik callback for sample config file generation"""
|
884
|
+
self.linter.generate_config(skipsections=('COMMANDS',))
|
885
|
+
sys.exit(0)
|
886
|
+
|
887
|
+
def cb_generate_manpage(self, *args, **kwargs):
|
888
|
+
"""optik callback for sample config file generation"""
|
889
|
+
from pylint import __pkginfo__
|
890
|
+
self.linter.generate_manpage(__pkginfo__)
|
891
|
+
sys.exit(0)
|
892
|
+
|
893
|
+
def cb_help_message(self, option, optname, value, parser):
|
894
|
+
"""optik callback for printing some help about a particular message"""
|
895
|
+
self.linter.help_message(splitstrip(value))
|
896
|
+
sys.exit(0)
|
897
|
+
|
898
|
+
def cb_full_documentation(self, option, optname, value, parser):
|
899
|
+
"""optik callback for printing full documentation"""
|
900
|
+
self.linter.print_full_documentation()
|
901
|
+
sys.exit(0)
|
902
|
+
|
903
|
+
def cb_list_messages(self, option, optname, value, parser): # FIXME
|
904
|
+
"""optik callback for printing available messages"""
|
905
|
+
self.linter.list_messages()
|
906
|
+
sys.exit(0)
|
907
|
+
|
908
|
+
def cb_init_hook(option, optname, value, parser):
|
909
|
+
"""exec arbitrary code to set sys.path for instance"""
|
910
|
+
exec value
|
911
|
+
|
912
|
+
|
913
|
+
if __name__ == '__main__':
|
914
|
+
Run(sys.argv[1:])
|