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,749 @@
|
|
1
|
+
# Copyright (c) 2003-2010 LOGILAB S.A. (Paris, FRANCE).
|
2
|
+
# Copyright (c) 2009-2010 Arista Networks, Inc.
|
3
|
+
# http://www.logilab.fr/ -- mailto:contact@logilab.fr
|
4
|
+
# This program is free software; you can redistribute it and/or modify it under
|
5
|
+
# the terms of the GNU General Public License as published by the Free Software
|
6
|
+
# Foundation; either version 2 of the License, or (at your option) any later
|
7
|
+
# version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
10
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
11
|
+
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along with
|
14
|
+
# this program; if not, write to the Free Software Foundation, Inc.,
|
15
|
+
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
16
|
+
"""basic checker for Python code"""
|
17
|
+
|
18
|
+
|
19
|
+
from logilab import astng
|
20
|
+
from logilab.common.compat import any
|
21
|
+
from logilab.common.ureports import Table
|
22
|
+
from logilab.astng import are_exclusive
|
23
|
+
|
24
|
+
from pylint.interfaces import IASTNGChecker
|
25
|
+
from pylint.reporters import diff_string
|
26
|
+
from pylint.checkers import BaseChecker, EmptyReport
|
27
|
+
|
28
|
+
|
29
|
+
import re
|
30
|
+
|
31
|
+
# regex for class/function/variable/constant name
|
32
|
+
CLASS_NAME_RGX = re.compile('[A-Z_][a-zA-Z0-9]+$')
|
33
|
+
MOD_NAME_RGX = re.compile('(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$')
|
34
|
+
CONST_NAME_RGX = re.compile('(([A-Z_][A-Z0-9_]*)|(__.*__))$')
|
35
|
+
COMP_VAR_RGX = re.compile('[A-Za-z_][A-Za-z0-9_]*$')
|
36
|
+
DEFAULT_NAME_RGX = re.compile('[a-z_][a-z0-9_]{2,30}$')
|
37
|
+
# do not require a doc string on system methods
|
38
|
+
NO_REQUIRED_DOC_RGX = re.compile('__.*__')
|
39
|
+
|
40
|
+
del re
|
41
|
+
|
42
|
+
def in_loop(node):
|
43
|
+
"""return True if the node is inside a kind of for loop"""
|
44
|
+
parent = node.parent
|
45
|
+
while parent is not None:
|
46
|
+
if isinstance(parent, (astng.For, astng.ListComp, astng.GenExpr)):
|
47
|
+
return True
|
48
|
+
parent = parent.parent
|
49
|
+
return False
|
50
|
+
|
51
|
+
def in_nested_list(nested_list, obj):
|
52
|
+
"""return true if the object is an element of <nested_list> or of a nested
|
53
|
+
list
|
54
|
+
"""
|
55
|
+
for elmt in nested_list:
|
56
|
+
if isinstance(elmt, (list, tuple)):
|
57
|
+
if in_nested_list(elmt, obj):
|
58
|
+
return True
|
59
|
+
elif elmt == obj:
|
60
|
+
return True
|
61
|
+
return False
|
62
|
+
|
63
|
+
def report_by_type_stats(sect, stats, old_stats):
|
64
|
+
"""make a report of
|
65
|
+
|
66
|
+
* percentage of different types documented
|
67
|
+
* percentage of different types with a bad name
|
68
|
+
"""
|
69
|
+
# percentage of different types documented and/or with a bad name
|
70
|
+
nice_stats = {}
|
71
|
+
for node_type in ('module', 'class', 'method', 'function'):
|
72
|
+
try:
|
73
|
+
total = stats[node_type]
|
74
|
+
except KeyError:
|
75
|
+
raise EmptyReport()
|
76
|
+
nice_stats[node_type] = {}
|
77
|
+
if total != 0:
|
78
|
+
try:
|
79
|
+
documented = total - stats['undocumented_'+node_type]
|
80
|
+
percent = (documented * 100.) / total
|
81
|
+
nice_stats[node_type]['percent_documented'] = '%.2f' % percent
|
82
|
+
except KeyError:
|
83
|
+
nice_stats[node_type]['percent_documented'] = 'NC'
|
84
|
+
try:
|
85
|
+
percent = (stats['badname_'+node_type] * 100.) / total
|
86
|
+
nice_stats[node_type]['percent_badname'] = '%.2f' % percent
|
87
|
+
except KeyError:
|
88
|
+
nice_stats[node_type]['percent_badname'] = 'NC'
|
89
|
+
lines = ('type', 'number', 'old number', 'difference',
|
90
|
+
'%documented', '%badname')
|
91
|
+
for node_type in ('module', 'class', 'method', 'function'):
|
92
|
+
new = stats[node_type]
|
93
|
+
old = old_stats.get(node_type, None)
|
94
|
+
if old is not None:
|
95
|
+
diff_str = diff_string(old, new)
|
96
|
+
else:
|
97
|
+
old, diff_str = 'NC', 'NC'
|
98
|
+
lines += (node_type, str(new), str(old), diff_str,
|
99
|
+
nice_stats[node_type].get('percent_documented', '0'),
|
100
|
+
nice_stats[node_type].get('percent_badname', '0'))
|
101
|
+
sect.append(Table(children=lines, cols=6, rheaders=1))
|
102
|
+
|
103
|
+
class _BasicChecker(BaseChecker):
|
104
|
+
__implements__ = IASTNGChecker
|
105
|
+
name = 'basic'
|
106
|
+
|
107
|
+
class BasicErrorChecker(_BasicChecker):
|
108
|
+
msgs = {
|
109
|
+
'E0100': ('__init__ method is a generator',
|
110
|
+
'Used when the special class method __init__ is turned into a '
|
111
|
+
'generator by a yield in its body.'),
|
112
|
+
'E0101': ('Explicit return in __init__',
|
113
|
+
'Used when the special class method __init__ has an explicit \
|
114
|
+
return value.'),
|
115
|
+
'E0102': ('%s already defined line %s',
|
116
|
+
'Used when a function / class / method is redefined.'),
|
117
|
+
'E0103': ('%r not properly in loop',
|
118
|
+
'Used when break or continue keywords are used outside a loop.'),
|
119
|
+
|
120
|
+
'E0104': ('Return outside function',
|
121
|
+
'Used when a "return" statement is found outside a function or '
|
122
|
+
'method.'),
|
123
|
+
'E0105': ('Yield outside function',
|
124
|
+
'Used when a "yield" statement is found outside a function or '
|
125
|
+
'method.'),
|
126
|
+
'E0106': ('Return with argument inside generator',
|
127
|
+
'Used when a "return" statement with an argument is found '
|
128
|
+
'outside in a generator function or method (e.g. with some '
|
129
|
+
'"yield" statements).'),
|
130
|
+
'E0107': ("Use of the non-existent %s operator",
|
131
|
+
"Used when you attempt to use the C-style pre-increment or"
|
132
|
+
"pre-decrement operator -- and ++, which doesn't exist in Python."),
|
133
|
+
}
|
134
|
+
|
135
|
+
def __init__(self, linter):
|
136
|
+
_BasicChecker.__init__(self, linter)
|
137
|
+
self._returns = None
|
138
|
+
|
139
|
+
def open(self):
|
140
|
+
self._returns = []
|
141
|
+
|
142
|
+
def visit_class(self, node):
|
143
|
+
self._check_redefinition('class', node)
|
144
|
+
|
145
|
+
def visit_function(self, node):
|
146
|
+
self._returns.append([])
|
147
|
+
self._check_redefinition(node.is_method() and 'method' or 'function', node)
|
148
|
+
|
149
|
+
def leave_function(self, node):
|
150
|
+
"""most of the work is done here on close:
|
151
|
+
checks for max returns, branch, return in __init__
|
152
|
+
"""
|
153
|
+
returns = self._returns.pop()
|
154
|
+
if node.is_method() and node.name == '__init__':
|
155
|
+
if node.is_generator():
|
156
|
+
self.add_message('E0100', node=node)
|
157
|
+
else:
|
158
|
+
values = [r.value for r in returns]
|
159
|
+
if [v for v in values if not (v is None or
|
160
|
+
(isinstance(v, astng.Const) and v.value is None)
|
161
|
+
or (isinstance(v, astng.Name) and v.name == 'None'))]:
|
162
|
+
self.add_message('E0101', node=node)
|
163
|
+
elif node.is_generator():
|
164
|
+
# make sure we don't mix non-None returns and yields
|
165
|
+
for retnode in returns:
|
166
|
+
if isinstance(retnode, astng.Return) and \
|
167
|
+
isinstance(retnode.value, astng.Const) and \
|
168
|
+
retnode.value.value is not None:
|
169
|
+
self.add_message('E0106', node=node,
|
170
|
+
line=retnode.fromlineno)
|
171
|
+
|
172
|
+
def visit_return(self, node):
|
173
|
+
# if self._returns is empty, we're outside a function
|
174
|
+
if not self._returns:
|
175
|
+
self.add_message('E0104', node=node)
|
176
|
+
return
|
177
|
+
self._returns[-1].append(node)
|
178
|
+
|
179
|
+
def visit_yield(self, node):
|
180
|
+
# if self._returns is empty, we're outside a function
|
181
|
+
if not self._returns:
|
182
|
+
self.add_message('E0105', node=node)
|
183
|
+
return
|
184
|
+
self._returns[-1].append(node)
|
185
|
+
|
186
|
+
def visit_continue(self, node):
|
187
|
+
self._check_in_loop(node, 'continue')
|
188
|
+
|
189
|
+
def visit_break(self, node):
|
190
|
+
self._check_in_loop(node, 'break')
|
191
|
+
|
192
|
+
def visit_unaryop(self, node):
|
193
|
+
"""check use of the non-existent ++ adn -- operator operator"""
|
194
|
+
if ((node.op in '+-') and
|
195
|
+
isinstance(node.operand, astng.UnaryOp) and
|
196
|
+
(node.operand.op == node.op)):
|
197
|
+
self.add_message('E0107', node=node, args=node.op*2)
|
198
|
+
|
199
|
+
def _check_in_loop(self, node, node_name):
|
200
|
+
"""check that a node is inside a for or while loop"""
|
201
|
+
_node = node.parent
|
202
|
+
while _node:
|
203
|
+
if isinstance(_node, (astng.For, astng.While)):
|
204
|
+
break
|
205
|
+
_node = _node.parent
|
206
|
+
else:
|
207
|
+
self.add_message('E0103', node=node, args=node_name)
|
208
|
+
|
209
|
+
def _check_redefinition(self, redeftype, node):
|
210
|
+
"""check for redefinition of a function / method / class name"""
|
211
|
+
defined_self = node.parent.frame()[node.name]
|
212
|
+
if defined_self is not node and not are_exclusive(node, defined_self):
|
213
|
+
self.add_message('E0102', node=node,
|
214
|
+
args=(redeftype, defined_self.fromlineno))
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
class BasicChecker(_BasicChecker):
|
219
|
+
"""checks for :
|
220
|
+
* doc strings
|
221
|
+
* modules / classes / functions / methods / arguments / variables name
|
222
|
+
* number of arguments, local variables, branches, returns and statements in
|
223
|
+
functions, methods
|
224
|
+
* required module attributes
|
225
|
+
* dangerous default values as arguments
|
226
|
+
* redefinition of function / method / class
|
227
|
+
* uses of the global statement
|
228
|
+
"""
|
229
|
+
|
230
|
+
__implements__ = IASTNGChecker
|
231
|
+
|
232
|
+
name = 'basic'
|
233
|
+
msgs = {
|
234
|
+
'W0101': ('Unreachable code',
|
235
|
+
'Used when there is some code behind a "return" or "raise" \
|
236
|
+
statement, which will never be accessed.'),
|
237
|
+
'W0102': ('Dangerous default value %s as argument',
|
238
|
+
'Used when a mutable value as list or dictionary is detected in \
|
239
|
+
a default value for an argument.'),
|
240
|
+
'W0104': ('Statement seems to have no effect',
|
241
|
+
'Used when a statement doesn\'t have (or at least seems to) \
|
242
|
+
any effect.'),
|
243
|
+
'W0105': ('String statement has no effect',
|
244
|
+
'Used when a string is used as a statement (which of course \
|
245
|
+
has no effect). This is a particular case of W0104 with its \
|
246
|
+
own message so you can easily disable it if you\'re using \
|
247
|
+
those strings as documentation, instead of comments.'),
|
248
|
+
'W0108': ('Lambda may not be necessary',
|
249
|
+
'Used when the body of a lambda expression is a function call \
|
250
|
+
on the same argument list as the lambda itself; such lambda \
|
251
|
+
expressions are in all but a few cases replaceable with the \
|
252
|
+
function being called in the body of the lambda.'),
|
253
|
+
'W0109': ("Duplicate key %r in dictionary",
|
254
|
+
"Used when a dictionary expression binds the same key multiple \
|
255
|
+
times."),
|
256
|
+
'W0122': ('Use of the exec statement',
|
257
|
+
'Used when you use the "exec" statement, to discourage its \
|
258
|
+
usage. That doesn\'t mean you can not use it !'),
|
259
|
+
|
260
|
+
'W0141': ('Used builtin function %r',
|
261
|
+
'Used when a black listed builtin function is used (see the '
|
262
|
+
'bad-function option). Usual black listed functions are the ones '
|
263
|
+
'like map, or filter , where Python offers now some cleaner '
|
264
|
+
'alternative like list comprehension.'),
|
265
|
+
'W0142': ('Used * or ** magic',
|
266
|
+
'Used when a function or method is called using `*args` or '
|
267
|
+
'`**kwargs` to dispatch arguments. This doesn\'t improve '
|
268
|
+
'readability and should be used with care.'),
|
269
|
+
'W0150': ("%s statement in finally block may swallow exception",
|
270
|
+
"Used when a break or a return statement is found inside the \
|
271
|
+
finally clause of a try...finally block: the exceptions raised \
|
272
|
+
in the try clause will be silently swallowed instead of being \
|
273
|
+
re-raised."),
|
274
|
+
'W0199': ('Assert called on a 2-uple. Did you mean \'assert x,y\'?',
|
275
|
+
'A call of assert on a tuple will always evaluate to true if '
|
276
|
+
'the tuple is not empty, and will always evaluate to false if '
|
277
|
+
'it is.'),
|
278
|
+
|
279
|
+
'C0121': ('Missing required attribute "%s"', # W0103
|
280
|
+
'Used when an attribute required for modules is missing.'),
|
281
|
+
|
282
|
+
}
|
283
|
+
|
284
|
+
options = (('required-attributes',
|
285
|
+
{'default' : (), 'type' : 'csv',
|
286
|
+
'metavar' : '<attributes>',
|
287
|
+
'help' : 'Required attributes for module, separated by a '
|
288
|
+
'comma'}
|
289
|
+
),
|
290
|
+
('bad-functions',
|
291
|
+
{'default' : ('map', 'filter', 'apply', 'input'),
|
292
|
+
'type' :'csv', 'metavar' : '<builtin function names>',
|
293
|
+
'help' : 'List of builtins function names that should not be '
|
294
|
+
'used, separated by a comma'}
|
295
|
+
),
|
296
|
+
)
|
297
|
+
reports = ( ('RP0101', 'Statistics by type', report_by_type_stats), )
|
298
|
+
|
299
|
+
def __init__(self, linter):
|
300
|
+
_BasicChecker.__init__(self, linter)
|
301
|
+
self.stats = None
|
302
|
+
self._tryfinallys = None
|
303
|
+
|
304
|
+
def open(self):
|
305
|
+
"""initialize visit variables and statistics
|
306
|
+
"""
|
307
|
+
self._tryfinallys = []
|
308
|
+
self.stats = self.linter.add_stats(module=0, function=0,
|
309
|
+
method=0, class_=0)
|
310
|
+
|
311
|
+
def visit_module(self, node):
|
312
|
+
"""check module name, docstring and required arguments
|
313
|
+
"""
|
314
|
+
self.stats['module'] += 1
|
315
|
+
self._check_required_attributes(node, self.config.required_attributes)
|
316
|
+
|
317
|
+
def visit_class(self, node):
|
318
|
+
"""check module name, docstring and redefinition
|
319
|
+
increment branch counter
|
320
|
+
"""
|
321
|
+
self.stats['class'] += 1
|
322
|
+
|
323
|
+
def visit_discard(self, node):
|
324
|
+
"""check for various kind of statements without effect"""
|
325
|
+
expr = node.value
|
326
|
+
if isinstance(expr, astng.Const) and isinstance(expr.value, basestring):
|
327
|
+
# treat string statement in a separated message
|
328
|
+
self.add_message('W0105', node=node)
|
329
|
+
return
|
330
|
+
# ignore if this is :
|
331
|
+
# * a function call (can't predicate side effects)
|
332
|
+
# * the unique children of a try/except body
|
333
|
+
# * a yield (which are wrapped by a discard node in _ast XXX)
|
334
|
+
if not (any(expr.nodes_of_class((astng.CallFunc, astng.Yield)))
|
335
|
+
or isinstance(node.parent, astng.TryExcept) and node.parent.body == [node]):
|
336
|
+
self.add_message('W0104', node=node)
|
337
|
+
|
338
|
+
def visit_lambda(self, node):
|
339
|
+
"""check whether or not the lambda is suspicious
|
340
|
+
"""
|
341
|
+
# if the body of the lambda is a call expression with the same
|
342
|
+
# argument list as the lambda itself, then the lambda is
|
343
|
+
# possibly unnecessary and at least suspicious.
|
344
|
+
if node.args.defaults:
|
345
|
+
# If the arguments of the lambda include defaults, then a
|
346
|
+
# judgment cannot be made because there is no way to check
|
347
|
+
# that the defaults defined by the lambda are the same as
|
348
|
+
# the defaults defined by the function called in the body
|
349
|
+
# of the lambda.
|
350
|
+
return
|
351
|
+
call = node.body
|
352
|
+
if not isinstance(call, astng.CallFunc):
|
353
|
+
# The body of the lambda must be a function call expression
|
354
|
+
# for the lambda to be unnecessary.
|
355
|
+
return
|
356
|
+
# XXX are lambda still different with astng >= 0.18 ?
|
357
|
+
# *args and **kwargs need to be treated specially, since they
|
358
|
+
# are structured differently between the lambda and the function
|
359
|
+
# call (in the lambda they appear in the args.args list and are
|
360
|
+
# indicated as * and ** by two bits in the lambda's flags, but
|
361
|
+
# in the function call they are omitted from the args list and
|
362
|
+
# are indicated by separate attributes on the function call node).
|
363
|
+
ordinary_args = list(node.args.args)
|
364
|
+
if node.args.kwarg:
|
365
|
+
if (not call.kwargs
|
366
|
+
or not isinstance(call.kwargs, astng.Name)
|
367
|
+
or node.args.kwarg != call.kwargs.name):
|
368
|
+
return
|
369
|
+
elif call.kwargs:
|
370
|
+
return
|
371
|
+
if node.args.vararg:
|
372
|
+
if (not call.starargs
|
373
|
+
or not isinstance(call.starargs, astng.Name)
|
374
|
+
or node.args.vararg != call.starargs.name):
|
375
|
+
return
|
376
|
+
elif call.starargs:
|
377
|
+
return
|
378
|
+
# The "ordinary" arguments must be in a correspondence such that:
|
379
|
+
# ordinary_args[i].name == call.args[i].name.
|
380
|
+
if len(ordinary_args) != len(call.args):
|
381
|
+
return
|
382
|
+
for i in xrange(len(ordinary_args)):
|
383
|
+
if not isinstance(call.args[i], astng.Name):
|
384
|
+
return
|
385
|
+
if node.args.args[i].name != call.args[i].name:
|
386
|
+
return
|
387
|
+
self.add_message('W0108', line=node.fromlineno, node=node)
|
388
|
+
|
389
|
+
def visit_function(self, node):
|
390
|
+
"""check function name, docstring, arguments, redefinition,
|
391
|
+
variable names, max locals
|
392
|
+
"""
|
393
|
+
self.stats[node.is_method() and 'method' or 'function'] += 1
|
394
|
+
# check default arguments'value
|
395
|
+
self._check_defaults(node)
|
396
|
+
|
397
|
+
def visit_return(self, node):
|
398
|
+
"""1 - check is the node has a right sibling (if so, that's some
|
399
|
+
unreachable code)
|
400
|
+
2 - check is the node is inside the finally clause of a try...finally
|
401
|
+
block
|
402
|
+
"""
|
403
|
+
self._check_unreachable(node)
|
404
|
+
# Is it inside final body of a try...finally bloc ?
|
405
|
+
self._check_not_in_finally(node, 'return', (astng.Function,))
|
406
|
+
|
407
|
+
def visit_continue(self, node):
|
408
|
+
"""check is the node has a right sibling (if so, that's some unreachable
|
409
|
+
code)
|
410
|
+
"""
|
411
|
+
self._check_unreachable(node)
|
412
|
+
|
413
|
+
def visit_break(self, node):
|
414
|
+
"""1 - check is the node has a right sibling (if so, that's some
|
415
|
+
unreachable code)
|
416
|
+
2 - check is the node is inside the finally clause of a try...finally
|
417
|
+
block
|
418
|
+
"""
|
419
|
+
# 1 - Is it right sibling ?
|
420
|
+
self._check_unreachable(node)
|
421
|
+
# 2 - Is it inside final body of a try...finally bloc ?
|
422
|
+
self._check_not_in_finally(node, 'break', (astng.For, astng.While,))
|
423
|
+
|
424
|
+
def visit_raise(self, node):
|
425
|
+
"""check is the node has a right sibling (if so, that's some unreachable
|
426
|
+
code)
|
427
|
+
"""
|
428
|
+
self._check_unreachable(node)
|
429
|
+
|
430
|
+
def visit_exec(self, node):
|
431
|
+
"""just print a warning on exec statements"""
|
432
|
+
self.add_message('W0122', node=node)
|
433
|
+
|
434
|
+
def visit_callfunc(self, node):
|
435
|
+
"""visit a CallFunc node -> check if this is not a blacklisted builtin
|
436
|
+
call and check for * or ** use
|
437
|
+
"""
|
438
|
+
if isinstance(node.func, astng.Name):
|
439
|
+
name = node.func.name
|
440
|
+
# ignore the name if it's not a builtin (i.e. not defined in the
|
441
|
+
# locals nor globals scope)
|
442
|
+
if not (node.frame().has_key(name) or
|
443
|
+
node.root().has_key(name)):
|
444
|
+
if name in self.config.bad_functions:
|
445
|
+
self.add_message('W0141', node=node, args=name)
|
446
|
+
if node.starargs or node.kwargs:
|
447
|
+
scope = node.scope()
|
448
|
+
if isinstance(scope, astng.Function):
|
449
|
+
toprocess = [(n, vn) for (n, vn) in ((node.starargs, scope.args.vararg),
|
450
|
+
(node.kwargs, scope.args.kwarg)) if n]
|
451
|
+
if toprocess:
|
452
|
+
for cfnode, fargname in toprocess[:]:
|
453
|
+
if getattr(cfnode, 'name', None) == fargname:
|
454
|
+
toprocess.remove((cfnode, fargname))
|
455
|
+
if not toprocess:
|
456
|
+
return # W0142 can be skipped
|
457
|
+
self.add_message('W0142', node=node.func)
|
458
|
+
|
459
|
+
def visit_assert(self, node):
|
460
|
+
"""check the use of an assert statement on a tuple."""
|
461
|
+
if node.fail is None and isinstance(node.test, astng.Tuple) and \
|
462
|
+
len(node.test.elts) == 2:
|
463
|
+
self.add_message('W0199', line=node.fromlineno, node=node)
|
464
|
+
|
465
|
+
def visit_dict(self, node):
|
466
|
+
"""check duplicate key in dictionary"""
|
467
|
+
keys = set()
|
468
|
+
for k, v in node.items:
|
469
|
+
if isinstance(k, astng.Const):
|
470
|
+
key = k.value
|
471
|
+
if key in keys:
|
472
|
+
self.add_message('W0109', node=node, args=key)
|
473
|
+
keys.add(key)
|
474
|
+
|
475
|
+
def visit_tryfinally(self, node):
|
476
|
+
"""update try...finally flag"""
|
477
|
+
self._tryfinallys.append(node)
|
478
|
+
|
479
|
+
def leave_tryfinally(self, node):
|
480
|
+
"""update try...finally flag"""
|
481
|
+
self._tryfinallys.pop()
|
482
|
+
|
483
|
+
|
484
|
+
def _check_unreachable(self, node):
|
485
|
+
"""check unreachable code"""
|
486
|
+
unreach_stmt = node.next_sibling()
|
487
|
+
if unreach_stmt is not None:
|
488
|
+
self.add_message('W0101', node=unreach_stmt)
|
489
|
+
|
490
|
+
def _check_defaults(self, node):
|
491
|
+
"""check for dangerous default values as arguments"""
|
492
|
+
for default in node.args.defaults:
|
493
|
+
try:
|
494
|
+
value = default.infer().next()
|
495
|
+
except astng.InferenceError:
|
496
|
+
continue
|
497
|
+
if isinstance(value, (astng.Dict, astng.List)):
|
498
|
+
if value is default:
|
499
|
+
msg = default.as_string()
|
500
|
+
else:
|
501
|
+
msg = '%s (%s)' % (default.as_string(), value.as_string())
|
502
|
+
self.add_message('W0102', node=node, args=(msg,))
|
503
|
+
|
504
|
+
def _check_required_attributes(self, node, attributes):
|
505
|
+
"""check for required attributes"""
|
506
|
+
for attr in attributes:
|
507
|
+
if not node.has_key(attr):
|
508
|
+
self.add_message('C0121', node=node, args=attr)
|
509
|
+
|
510
|
+
def _check_not_in_finally(self, node, node_name, breaker_classes=()):
|
511
|
+
"""check that a node is not inside a finally clause of a
|
512
|
+
try...finally statement.
|
513
|
+
If we found before a try...finally bloc a parent which its type is
|
514
|
+
in breaker_classes, we skip the whole check."""
|
515
|
+
# if self._tryfinallys is empty, we're not a in try...finally bloc
|
516
|
+
if not self._tryfinallys:
|
517
|
+
return
|
518
|
+
# the node could be a grand-grand...-children of the try...finally
|
519
|
+
_parent = node.parent
|
520
|
+
_node = node
|
521
|
+
while _parent and not isinstance(_parent, breaker_classes):
|
522
|
+
if hasattr(_parent, 'finalbody') and _node in _parent.finalbody:
|
523
|
+
self.add_message('W0150', node=node, args=node_name)
|
524
|
+
return
|
525
|
+
_node = _parent
|
526
|
+
_parent = _node.parent
|
527
|
+
|
528
|
+
|
529
|
+
|
530
|
+
class NameChecker(_BasicChecker):
|
531
|
+
msgs = {
|
532
|
+
'C0102': ('Black listed name "%s"',
|
533
|
+
'Used when the name is listed in the black list (unauthorized \
|
534
|
+
names).'),
|
535
|
+
'C0103': ('Invalid name "%s" (should match %s)',
|
536
|
+
'Used when the name doesn\'t match the regular expression \
|
537
|
+
associated to its type (constant, variable, class...).'),
|
538
|
+
|
539
|
+
}
|
540
|
+
options = (('module-rgx',
|
541
|
+
{'default' : MOD_NAME_RGX,
|
542
|
+
'type' :'regexp', 'metavar' : '<regexp>',
|
543
|
+
'help' : 'Regular expression which should only match correct '
|
544
|
+
'module names'}
|
545
|
+
),
|
546
|
+
('const-rgx',
|
547
|
+
{'default' : CONST_NAME_RGX,
|
548
|
+
'type' :'regexp', 'metavar' : '<regexp>',
|
549
|
+
'help' : 'Regular expression which should only match correct '
|
550
|
+
'module level names'}
|
551
|
+
),
|
552
|
+
('class-rgx',
|
553
|
+
{'default' : CLASS_NAME_RGX,
|
554
|
+
'type' :'regexp', 'metavar' : '<regexp>',
|
555
|
+
'help' : 'Regular expression which should only match correct '
|
556
|
+
'class names'}
|
557
|
+
),
|
558
|
+
('function-rgx',
|
559
|
+
{'default' : DEFAULT_NAME_RGX,
|
560
|
+
'type' :'regexp', 'metavar' : '<regexp>',
|
561
|
+
'help' : 'Regular expression which should only match correct '
|
562
|
+
'function names'}
|
563
|
+
),
|
564
|
+
('method-rgx',
|
565
|
+
{'default' : DEFAULT_NAME_RGX,
|
566
|
+
'type' :'regexp', 'metavar' : '<regexp>',
|
567
|
+
'help' : 'Regular expression which should only match correct '
|
568
|
+
'method names'}
|
569
|
+
),
|
570
|
+
('attr-rgx',
|
571
|
+
{'default' : DEFAULT_NAME_RGX,
|
572
|
+
'type' :'regexp', 'metavar' : '<regexp>',
|
573
|
+
'help' : 'Regular expression which should only match correct '
|
574
|
+
'instance attribute names'}
|
575
|
+
),
|
576
|
+
('argument-rgx',
|
577
|
+
{'default' : DEFAULT_NAME_RGX,
|
578
|
+
'type' :'regexp', 'metavar' : '<regexp>',
|
579
|
+
'help' : 'Regular expression which should only match correct '
|
580
|
+
'argument names'}),
|
581
|
+
('variable-rgx',
|
582
|
+
{'default' : DEFAULT_NAME_RGX,
|
583
|
+
'type' :'regexp', 'metavar' : '<regexp>',
|
584
|
+
'help' : 'Regular expression which should only match correct '
|
585
|
+
'variable names'}
|
586
|
+
),
|
587
|
+
('inlinevar-rgx',
|
588
|
+
{'default' : COMP_VAR_RGX,
|
589
|
+
'type' :'regexp', 'metavar' : '<regexp>',
|
590
|
+
'help' : 'Regular expression which should only match correct '
|
591
|
+
'list comprehension / generator expression variable \
|
592
|
+
names'}
|
593
|
+
),
|
594
|
+
# XXX use set
|
595
|
+
('good-names',
|
596
|
+
{'default' : ('i', 'j', 'k', 'ex', 'Run', '_'),
|
597
|
+
'type' :'csv', 'metavar' : '<names>',
|
598
|
+
'help' : 'Good variable names which should always be accepted,'
|
599
|
+
' separated by a comma'}
|
600
|
+
),
|
601
|
+
('bad-names',
|
602
|
+
{'default' : ('foo', 'bar', 'baz', 'toto', 'tutu', 'tata'),
|
603
|
+
'type' :'csv', 'metavar' : '<names>',
|
604
|
+
'help' : 'Bad variable names which should always be refused, '
|
605
|
+
'separated by a comma'}
|
606
|
+
),
|
607
|
+
)
|
608
|
+
|
609
|
+
def open(self):
|
610
|
+
self.stats = self.linter.add_stats(badname_module=0,
|
611
|
+
badname_class=0, badname_function=0,
|
612
|
+
badname_method=0, badname_attr=0,
|
613
|
+
badname_const=0,
|
614
|
+
badname_variable=0,
|
615
|
+
badname_inlinevar=0,
|
616
|
+
badname_argument=0)
|
617
|
+
|
618
|
+
def visit_module(self, node):
|
619
|
+
self._check_name('module', node.name.split('.')[-1], node)
|
620
|
+
|
621
|
+
def visit_class(self, node):
|
622
|
+
self._check_name('class', node.name, node)
|
623
|
+
for attr, anodes in node.instance_attrs.items():
|
624
|
+
self._check_name('attr', attr, anodes[0])
|
625
|
+
|
626
|
+
def visit_function(self, node):
|
627
|
+
self._check_name(node.is_method() and 'method' or 'function',
|
628
|
+
node.name, node)
|
629
|
+
# check arguments name
|
630
|
+
args = node.args.args
|
631
|
+
if args is not None:
|
632
|
+
self._recursive_check_names(args, node)
|
633
|
+
|
634
|
+
def visit_assname(self, node):
|
635
|
+
"""check module level assigned names"""
|
636
|
+
frame = node.frame()
|
637
|
+
ass_type = node.ass_type()
|
638
|
+
if isinstance(ass_type, (astng.Comprehension, astng.Comprehension)):
|
639
|
+
self._check_name('inlinevar', node.name, node)
|
640
|
+
elif isinstance(frame, astng.Module):
|
641
|
+
if isinstance(ass_type, astng.Assign) and not in_loop(ass_type):
|
642
|
+
self._check_name('const', node.name, node)
|
643
|
+
elif isinstance(frame, astng.Function):
|
644
|
+
# global introduced variable aren't in the function locals
|
645
|
+
if node.name in frame:
|
646
|
+
self._check_name('variable', node.name, node)
|
647
|
+
|
648
|
+
def _recursive_check_names(self, args, node):
|
649
|
+
"""check names in a possibly recursive list <arg>"""
|
650
|
+
for arg in args:
|
651
|
+
#if type(arg) is type(''):
|
652
|
+
if isinstance(arg, astng.AssName):
|
653
|
+
self._check_name('argument', arg.name, node)
|
654
|
+
else:
|
655
|
+
self._recursive_check_names(arg.elts, node)
|
656
|
+
|
657
|
+
def _check_name(self, node_type, name, node):
|
658
|
+
"""check for a name using the type's regexp"""
|
659
|
+
if name in self.config.good_names:
|
660
|
+
return
|
661
|
+
if name in self.config.bad_names:
|
662
|
+
self.stats['badname_' + node_type] += 1
|
663
|
+
self.add_message('C0102', node=node, args=name)
|
664
|
+
return
|
665
|
+
regexp = getattr(self.config, node_type + '_rgx')
|
666
|
+
if regexp.match(name) is None:
|
667
|
+
self.add_message('C0103', node=node, args=(name, regexp.pattern))
|
668
|
+
self.stats['badname_' + node_type] += 1
|
669
|
+
|
670
|
+
|
671
|
+
|
672
|
+
class DocStringChecker(_BasicChecker):
|
673
|
+
msgs = {
|
674
|
+
'C0111': ('Missing docstring', # W0131
|
675
|
+
'Used when a module, function, class or method has no docstring.\
|
676
|
+
Some special methods like __init__ doesn\'t necessary require a \
|
677
|
+
docstring.'),
|
678
|
+
'C0112': ('Empty docstring', # W0132
|
679
|
+
'Used when a module, function, class or method has an empty \
|
680
|
+
docstring (it would be too easy ;).'),
|
681
|
+
}
|
682
|
+
options = (('no-docstring-rgx',
|
683
|
+
{'default' : NO_REQUIRED_DOC_RGX,
|
684
|
+
'type' : 'regexp', 'metavar' : '<regexp>',
|
685
|
+
'help' : 'Regular expression which should only match '
|
686
|
+
'functions or classes name which do not require a '
|
687
|
+
'docstring'}
|
688
|
+
),
|
689
|
+
)
|
690
|
+
|
691
|
+
def open(self):
|
692
|
+
self.stats = self.linter.add_stats(undocumented_module=0,
|
693
|
+
undocumented_function=0,
|
694
|
+
undocumented_method=0,
|
695
|
+
undocumented_class=0)
|
696
|
+
|
697
|
+
def visit_module(self, node):
|
698
|
+
self._check_docstring('module', node)
|
699
|
+
|
700
|
+
def visit_class(self, node):
|
701
|
+
if self.config.no_docstring_rgx.match(node.name) is None:
|
702
|
+
self._check_docstring('class', node)
|
703
|
+
|
704
|
+
def visit_function(self, node):
|
705
|
+
if self.config.no_docstring_rgx.match(node.name) is None:
|
706
|
+
ftype = node.is_method() and 'method' or 'function'
|
707
|
+
if isinstance(node.parent.frame(), astng.Class):
|
708
|
+
overridden = False
|
709
|
+
# check if node is from a method overridden by its ancestor
|
710
|
+
for ancestor in node.parent.frame().ancestors():
|
711
|
+
if node.name in ancestor and \
|
712
|
+
isinstance(ancestor[node.name], astng.Function):
|
713
|
+
overridden = True
|
714
|
+
break
|
715
|
+
if not overridden:
|
716
|
+
self._check_docstring(ftype, node)
|
717
|
+
else:
|
718
|
+
self._check_docstring(ftype, node)
|
719
|
+
|
720
|
+
def _check_docstring(self, node_type, node):
|
721
|
+
"""check the node has a non empty docstring"""
|
722
|
+
docstring = node.doc
|
723
|
+
if docstring is None:
|
724
|
+
self.stats['undocumented_'+node_type] += 1
|
725
|
+
self.add_message('C0111', node=node)
|
726
|
+
elif not docstring.strip():
|
727
|
+
self.stats['undocumented_'+node_type] += 1
|
728
|
+
self.add_message('C0112', node=node)
|
729
|
+
|
730
|
+
|
731
|
+
class PassChecker(_BasicChecker):
|
732
|
+
"""check is the pass statement is really necessary"""
|
733
|
+
msgs = {'W0107': ('Unnecessary pass statement',
|
734
|
+
'Used when a "pass" statement that can be avoided is '
|
735
|
+
'encountered.)'),
|
736
|
+
}
|
737
|
+
|
738
|
+
def visit_pass(self, node):
|
739
|
+
if len(node.parent.child_sequence(node)) > 1:
|
740
|
+
self.add_message('W0107', node=node)
|
741
|
+
|
742
|
+
|
743
|
+
def register(linter):
|
744
|
+
"""required method to auto register this checker"""
|
745
|
+
linter.register_checker(BasicErrorChecker(linter))
|
746
|
+
linter.register_checker(BasicChecker(linter))
|
747
|
+
linter.register_checker(NameChecker(linter))
|
748
|
+
linter.register_checker(DocStringChecker(linter))
|
749
|
+
linter.register_checker(PassChecker(linter))
|