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,476 @@
|
|
1
|
+
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
|
2
|
+
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
|
3
|
+
#
|
4
|
+
# This file is part of logilab-common.
|
5
|
+
#
|
6
|
+
# logilab-common is free software: you can redistribute it and/or modify it under
|
7
|
+
# the terms of the GNU Lesser General Public License as published by the Free
|
8
|
+
# Software Foundation, either version 2.1 of the License, or (at your option) any
|
9
|
+
# later version.
|
10
|
+
#
|
11
|
+
# logilab-common is distributed in the hope that it will be useful, but WITHOUT
|
12
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
13
|
+
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
14
|
+
# details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License along
|
17
|
+
# with logilab-common. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
"""Some text manipulation utility functions.
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
:group text formatting: normalize_text, normalize_paragraph, pretty_match,\
|
26
|
+
unquote, colorize_ansi
|
27
|
+
:group text manipulation: searchall, splitstrip
|
28
|
+
:sort: text formatting, text manipulation
|
29
|
+
|
30
|
+
:type ANSI_STYLES: dict(str)
|
31
|
+
:var ANSI_STYLES: dictionary mapping style identifier to ANSI terminal code
|
32
|
+
|
33
|
+
:type ANSI_COLORS: dict(str)
|
34
|
+
:var ANSI_COLORS: dictionary mapping color identifier to ANSI terminal code
|
35
|
+
|
36
|
+
:type ANSI_PREFIX: str
|
37
|
+
:var ANSI_PREFIX:
|
38
|
+
ANSI terminal code notifying the start of an ANSI escape sequence
|
39
|
+
|
40
|
+
:type ANSI_END: str
|
41
|
+
:var ANSI_END:
|
42
|
+
ANSI terminal code notifying the end of an ANSI escape sequence
|
43
|
+
|
44
|
+
:type ANSI_RESET: str
|
45
|
+
:var ANSI_RESET:
|
46
|
+
ANSI terminal code resetting format defined by a previous ANSI escape sequence
|
47
|
+
"""
|
48
|
+
__docformat__ = "restructuredtext en"
|
49
|
+
|
50
|
+
import sys
|
51
|
+
import re
|
52
|
+
from unicodedata import normalize as _uninormalize
|
53
|
+
try:
|
54
|
+
from os import linesep
|
55
|
+
except ImportError:
|
56
|
+
linesep = '\n' # gae
|
57
|
+
|
58
|
+
from logilab.common.deprecation import deprecated
|
59
|
+
|
60
|
+
MANUAL_UNICODE_MAP = {
|
61
|
+
u'\xa1': u'!', # INVERTED EXCLAMATION MARK
|
62
|
+
u'\u0142': u'l', # LATIN SMALL LETTER L WITH STROKE
|
63
|
+
u'\u2044': u'/', # FRACTION SLASH
|
64
|
+
u'\xc6': u'AE', # LATIN CAPITAL LETTER AE
|
65
|
+
u'\xa9': u'(c)', # COPYRIGHT SIGN
|
66
|
+
u'\xab': u'"', # LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
67
|
+
u'\xe6': u'ae', # LATIN SMALL LETTER AE
|
68
|
+
u'\xae': u'(r)', # REGISTERED SIGN
|
69
|
+
u'\u0153': u'oe', # LATIN SMALL LIGATURE OE
|
70
|
+
u'\u0152': u'OE', # LATIN CAPITAL LIGATURE OE
|
71
|
+
u'\xd8': u'O', # LATIN CAPITAL LETTER O WITH STROKE
|
72
|
+
u'\xf8': u'o', # LATIN SMALL LETTER O WITH STROKE
|
73
|
+
u'\xbb': u'"', # RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
74
|
+
u'\xdf': u'ss', # LATIN SMALL LETTER SHARP S
|
75
|
+
}
|
76
|
+
|
77
|
+
def unormalize(ustring, ignorenonascii=False):
|
78
|
+
"""replace diacritical characters with their corresponding ascii characters
|
79
|
+
"""
|
80
|
+
res = []
|
81
|
+
for letter in ustring[:]:
|
82
|
+
try:
|
83
|
+
replacement = MANUAL_UNICODE_MAP[letter]
|
84
|
+
except KeyError:
|
85
|
+
if ord(letter) >= 2**8:
|
86
|
+
if ignorenonascii:
|
87
|
+
continue
|
88
|
+
raise ValueError("can't deal with non-ascii based characters")
|
89
|
+
replacement = _uninormalize('NFD', letter)[0]
|
90
|
+
res.append(replacement)
|
91
|
+
return u''.join(res)
|
92
|
+
|
93
|
+
def unquote(string):
|
94
|
+
"""remove optional quotes (simple or double) from the string
|
95
|
+
|
96
|
+
:type string: str or unicode
|
97
|
+
:param string: an optionally quoted string
|
98
|
+
|
99
|
+
:rtype: str or unicode
|
100
|
+
:return: the unquoted string (or the input string if it wasn't quoted)
|
101
|
+
"""
|
102
|
+
if not string:
|
103
|
+
return string
|
104
|
+
if string[0] in '"\'':
|
105
|
+
string = string[1:]
|
106
|
+
if string[-1] in '"\'':
|
107
|
+
string = string[:-1]
|
108
|
+
return string
|
109
|
+
|
110
|
+
|
111
|
+
_BLANKLINES_RGX = re.compile('\r?\n\r?\n')
|
112
|
+
_NORM_SPACES_RGX = re.compile('\s+')
|
113
|
+
|
114
|
+
def normalize_text(text, line_len=80, indent='', rest=False):
|
115
|
+
"""normalize a text to display it with a maximum line size and
|
116
|
+
optionally arbitrary indentation. Line jumps are normalized but blank
|
117
|
+
lines are kept. The indentation string may be used to insert a
|
118
|
+
comment (#) or a quoting (>) mark for instance.
|
119
|
+
|
120
|
+
:type text: str or unicode
|
121
|
+
:param text: the input text to normalize
|
122
|
+
|
123
|
+
:type line_len: int
|
124
|
+
:param line_len: expected maximum line's length, default to 80
|
125
|
+
|
126
|
+
:type indent: str or unicode
|
127
|
+
:param indent: optional string to use as indentation
|
128
|
+
|
129
|
+
:rtype: str or unicode
|
130
|
+
:return:
|
131
|
+
the input text normalized to fit on lines with a maximized size
|
132
|
+
inferior to `line_len`, and optionally prefixed by an
|
133
|
+
indentation string
|
134
|
+
"""
|
135
|
+
if rest:
|
136
|
+
normp = normalize_rest_paragraph
|
137
|
+
else:
|
138
|
+
normp = normalize_paragraph
|
139
|
+
result = []
|
140
|
+
for text in _BLANKLINES_RGX.split(text):
|
141
|
+
result.append(normp(text, line_len, indent))
|
142
|
+
return ('%s%s%s' % (linesep, indent, linesep)).join(result)
|
143
|
+
|
144
|
+
|
145
|
+
def normalize_paragraph(text, line_len=80, indent=''):
|
146
|
+
"""normalize a text to display it with a maximum line size and
|
147
|
+
optionally arbitrary indentation. Line jumps are normalized. The
|
148
|
+
indentation string may be used top insert a comment mark for
|
149
|
+
instance.
|
150
|
+
|
151
|
+
:type text: str or unicode
|
152
|
+
:param text: the input text to normalize
|
153
|
+
|
154
|
+
:type line_len: int
|
155
|
+
:param line_len: expected maximum line's length, default to 80
|
156
|
+
|
157
|
+
:type indent: str or unicode
|
158
|
+
:param indent: optional string to use as indentation
|
159
|
+
|
160
|
+
:rtype: str or unicode
|
161
|
+
:return:
|
162
|
+
the input text normalized to fit on lines with a maximized size
|
163
|
+
inferior to `line_len`, and optionally prefixed by an
|
164
|
+
indentation string
|
165
|
+
"""
|
166
|
+
text = _NORM_SPACES_RGX.sub(' ', text)
|
167
|
+
line_len = line_len - len(indent)
|
168
|
+
lines = []
|
169
|
+
while text:
|
170
|
+
aline, text = splittext(text.strip(), line_len)
|
171
|
+
lines.append(indent + aline)
|
172
|
+
return linesep.join(lines)
|
173
|
+
|
174
|
+
def normalize_rest_paragraph(text, line_len=80, indent=''):
|
175
|
+
"""normalize a ReST text to display it with a maximum line size and
|
176
|
+
optionally arbitrary indentation. Line jumps are normalized. The
|
177
|
+
indentation string may be used top insert a comment mark for
|
178
|
+
instance.
|
179
|
+
|
180
|
+
:type text: str or unicode
|
181
|
+
:param text: the input text to normalize
|
182
|
+
|
183
|
+
:type line_len: int
|
184
|
+
:param line_len: expected maximum line's length, default to 80
|
185
|
+
|
186
|
+
:type indent: str or unicode
|
187
|
+
:param indent: optional string to use as indentation
|
188
|
+
|
189
|
+
:rtype: str or unicode
|
190
|
+
:return:
|
191
|
+
the input text normalized to fit on lines with a maximized size
|
192
|
+
inferior to `line_len`, and optionally prefixed by an
|
193
|
+
indentation string
|
194
|
+
"""
|
195
|
+
toreport = ''
|
196
|
+
lines = []
|
197
|
+
line_len = line_len - len(indent)
|
198
|
+
for line in text.splitlines():
|
199
|
+
line = toreport + _NORM_SPACES_RGX.sub(' ', line.strip())
|
200
|
+
toreport = ''
|
201
|
+
while len(line) > line_len:
|
202
|
+
# too long line, need split
|
203
|
+
line, toreport = splittext(line, line_len)
|
204
|
+
lines.append(indent + line)
|
205
|
+
if toreport:
|
206
|
+
line = toreport + ' '
|
207
|
+
toreport = ''
|
208
|
+
else:
|
209
|
+
line = ''
|
210
|
+
if line:
|
211
|
+
lines.append(indent + line.strip())
|
212
|
+
return linesep.join(lines)
|
213
|
+
|
214
|
+
def splittext(text, line_len):
|
215
|
+
"""split the given text on space according to the given max line size
|
216
|
+
|
217
|
+
return a 2-uple:
|
218
|
+
* a line <= line_len if possible
|
219
|
+
* the rest of the text which has to be reported on another line
|
220
|
+
"""
|
221
|
+
if len(text) <= line_len:
|
222
|
+
return text, ''
|
223
|
+
pos = min(len(text)-1, line_len)
|
224
|
+
while pos > 0 and text[pos] != ' ':
|
225
|
+
pos -= 1
|
226
|
+
if pos == 0:
|
227
|
+
pos = min(len(text), line_len)
|
228
|
+
while len(text) > pos and text[pos] != ' ':
|
229
|
+
pos += 1
|
230
|
+
return text[:pos], text[pos+1:].strip()
|
231
|
+
|
232
|
+
|
233
|
+
def splitstrip(string, sep=','):
|
234
|
+
"""return a list of stripped string by splitting the string given as
|
235
|
+
argument on `sep` (',' by default). Empty string are discarded.
|
236
|
+
|
237
|
+
>>> splitstrip('a, b, c , 4,,')
|
238
|
+
['a', 'b', 'c', '4']
|
239
|
+
>>> splitstrip('a')
|
240
|
+
['a']
|
241
|
+
>>>
|
242
|
+
|
243
|
+
:type string: str or unicode
|
244
|
+
:param string: a csv line
|
245
|
+
|
246
|
+
:type sep: str or unicode
|
247
|
+
:param sep: field separator, default to the comma (',')
|
248
|
+
|
249
|
+
:rtype: str or unicode
|
250
|
+
:return: the unquoted string (or the input string if it wasn't quoted)
|
251
|
+
"""
|
252
|
+
return [word.strip() for word in string.split(sep) if word.strip()]
|
253
|
+
|
254
|
+
get_csv = deprecated()(splitstrip)
|
255
|
+
|
256
|
+
_BLANK_URE = r'(\s|,)+'
|
257
|
+
_BLANK_RE = re.compile(_BLANK_URE)
|
258
|
+
__VALUE_URE = r'-?(([0-9]+\.[0-9]*)|((0x?)?[0-9]+))'
|
259
|
+
__UNITS_URE = r'[a-zA-Z]+'
|
260
|
+
_VALUE_RE = re.compile(r'(?P<value>%s)(?P<unit>%s)?'%(__VALUE_URE,__UNITS_URE))
|
261
|
+
|
262
|
+
BYTE_UNITS = {
|
263
|
+
"b": 1,
|
264
|
+
"kb": 1024,
|
265
|
+
"mb": 1024 ** 2,
|
266
|
+
"gb": 1024 ** 3,
|
267
|
+
"tb": 1024 ** 4,
|
268
|
+
}
|
269
|
+
|
270
|
+
TIME_UNITS = {
|
271
|
+
"ms": 0.0001,
|
272
|
+
"s": 1,
|
273
|
+
"min": 60,
|
274
|
+
"h": 60 * 60,
|
275
|
+
"d": 60 * 60 *24,
|
276
|
+
}
|
277
|
+
|
278
|
+
def apply_units( string, units, inter=None, final=float, blank_reg=_BLANK_RE,
|
279
|
+
value_reg=_VALUE_RE):
|
280
|
+
"""Parse the string applying the units defined in units
|
281
|
+
(e.g.: "1.5m",{'m',60} -> 80).
|
282
|
+
|
283
|
+
:type string: str or unicode
|
284
|
+
:param string: the string to parse
|
285
|
+
|
286
|
+
:type units: dict (or any object with __getitem__ using basestring key)
|
287
|
+
:param units: a dict mapping a unit string repr to its value
|
288
|
+
|
289
|
+
:type inter: type
|
290
|
+
:param inter: used to parse every intermediate value (need __sum__)
|
291
|
+
|
292
|
+
:type blank_reg: regexp
|
293
|
+
:param blank_reg: should match every blank char to ignore.
|
294
|
+
|
295
|
+
:type value_reg: regexp with "value" and optional "unit" group
|
296
|
+
:param value_reg: match a value and it's unit into the
|
297
|
+
"""
|
298
|
+
if inter is None:
|
299
|
+
inter = final
|
300
|
+
string = _BLANK_RE.sub('',string)
|
301
|
+
values = []
|
302
|
+
for match in value_reg.finditer(string):
|
303
|
+
dic = match.groupdict()
|
304
|
+
#import sys
|
305
|
+
#print >> sys.stderr, dic
|
306
|
+
lit, unit = dic["value"], dic.get("unit")
|
307
|
+
value = inter(lit)
|
308
|
+
if unit is not None:
|
309
|
+
try:
|
310
|
+
value *= units[unit.lower()]
|
311
|
+
except KeyError:
|
312
|
+
raise KeyError('invalid unit %s. valid units are %s' %
|
313
|
+
(unit, units.keys()))
|
314
|
+
values.append(value)
|
315
|
+
return final(sum(values))
|
316
|
+
|
317
|
+
_LINE_RGX = re.compile('\r\n|\r+|\n')
|
318
|
+
|
319
|
+
def pretty_match(match, string, underline_char='^'):
|
320
|
+
"""return a string with the match location underlined:
|
321
|
+
|
322
|
+
>>> import re
|
323
|
+
>>> print pretty_match(re.search('mange', 'il mange du bacon'), 'il mange du bacon')
|
324
|
+
il mange du bacon
|
325
|
+
^^^^^
|
326
|
+
>>>
|
327
|
+
|
328
|
+
:type match: _sre.SRE_match
|
329
|
+
:param match: object returned by re.match, re.search or re.finditer
|
330
|
+
|
331
|
+
:type string: str or unicode
|
332
|
+
:param string:
|
333
|
+
the string on which the regular expression has been applied to
|
334
|
+
obtain the `match` object
|
335
|
+
|
336
|
+
:type underline_char: str or unicode
|
337
|
+
:param underline_char:
|
338
|
+
character to use to underline the matched section, default to the
|
339
|
+
carret '^'
|
340
|
+
|
341
|
+
:rtype: str or unicode
|
342
|
+
:return:
|
343
|
+
the original string with an inserted line to underline the match
|
344
|
+
location
|
345
|
+
"""
|
346
|
+
start = match.start()
|
347
|
+
end = match.end()
|
348
|
+
string = _LINE_RGX.sub(linesep, string)
|
349
|
+
start_line_pos = string.rfind(linesep, 0, start)
|
350
|
+
if start_line_pos == -1:
|
351
|
+
start_line_pos = 0
|
352
|
+
result = []
|
353
|
+
else:
|
354
|
+
result = [string[:start_line_pos]]
|
355
|
+
start_line_pos += len(linesep)
|
356
|
+
offset = start - start_line_pos
|
357
|
+
underline = ' ' * offset + underline_char * (end - start)
|
358
|
+
end_line_pos = string.find(linesep, end)
|
359
|
+
if end_line_pos == -1:
|
360
|
+
string = string[start_line_pos:]
|
361
|
+
result.append(string)
|
362
|
+
result.append(underline)
|
363
|
+
else:
|
364
|
+
end = string[end_line_pos + len(linesep):]
|
365
|
+
string = string[start_line_pos:end_line_pos]
|
366
|
+
result.append(string)
|
367
|
+
result.append(underline)
|
368
|
+
result.append(end)
|
369
|
+
return linesep.join(result).rstrip()
|
370
|
+
|
371
|
+
|
372
|
+
# Ansi colorization ###########################################################
|
373
|
+
|
374
|
+
ANSI_PREFIX = '\033['
|
375
|
+
ANSI_END = 'm'
|
376
|
+
ANSI_RESET = '\033[0m'
|
377
|
+
ANSI_STYLES = {
|
378
|
+
'reset' : "0",
|
379
|
+
'bold' : "1",
|
380
|
+
'italic' : "3",
|
381
|
+
'underline' : "4",
|
382
|
+
'blink' : "5",
|
383
|
+
'inverse' : "7",
|
384
|
+
'strike' : "9",
|
385
|
+
}
|
386
|
+
ANSI_COLORS = {
|
387
|
+
'reset' : "0",
|
388
|
+
'black' : "30",
|
389
|
+
'red' : "31",
|
390
|
+
'green' : "32",
|
391
|
+
'yellow' : "33",
|
392
|
+
'blue' : "34",
|
393
|
+
'magenta' : "35",
|
394
|
+
'cyan' : "36",
|
395
|
+
'white' : "37",
|
396
|
+
}
|
397
|
+
|
398
|
+
def _get_ansi_code(color=None, style=None):
|
399
|
+
"""return ansi escape code corresponding to color and style
|
400
|
+
|
401
|
+
:type color: str or None
|
402
|
+
:param color:
|
403
|
+
the color name (see `ANSI_COLORS` for available values)
|
404
|
+
or the color number when 256 colors are available
|
405
|
+
|
406
|
+
:type style: str or None
|
407
|
+
:param style:
|
408
|
+
style string (see `ANSI_COLORS` for available values). To get
|
409
|
+
several style effects at the same time, use a coma as separator.
|
410
|
+
|
411
|
+
:raise KeyError: if an unexistent color or style identifier is given
|
412
|
+
|
413
|
+
:rtype: str
|
414
|
+
:return: the built escape code
|
415
|
+
"""
|
416
|
+
ansi_code = []
|
417
|
+
if style:
|
418
|
+
style_attrs = splitstrip(style)
|
419
|
+
for effect in style_attrs:
|
420
|
+
ansi_code.append(ANSI_STYLES[effect])
|
421
|
+
if color:
|
422
|
+
if color.isdigit():
|
423
|
+
ansi_code.extend(['38','5'])
|
424
|
+
ansi_code.append(color)
|
425
|
+
else:
|
426
|
+
ansi_code.append(ANSI_COLORS[color])
|
427
|
+
if ansi_code:
|
428
|
+
return ANSI_PREFIX + ';'.join(ansi_code) + ANSI_END
|
429
|
+
return ''
|
430
|
+
|
431
|
+
def colorize_ansi(msg, color=None, style=None):
|
432
|
+
"""colorize message by wrapping it with ansi escape codes
|
433
|
+
|
434
|
+
:type msg: str or unicode
|
435
|
+
:param msg: the message string to colorize
|
436
|
+
|
437
|
+
:type color: str or None
|
438
|
+
:param color:
|
439
|
+
the color identifier (see `ANSI_COLORS` for available values)
|
440
|
+
|
441
|
+
:type style: str or None
|
442
|
+
:param style:
|
443
|
+
style string (see `ANSI_COLORS` for available values). To get
|
444
|
+
several style effects at the same time, use a coma as separator.
|
445
|
+
|
446
|
+
:raise KeyError: if an unexistent color or style identifier is given
|
447
|
+
|
448
|
+
:rtype: str or unicode
|
449
|
+
:return: the ansi escaped string
|
450
|
+
"""
|
451
|
+
# If both color and style are not defined, then leave the text as is
|
452
|
+
if color is None and style is None:
|
453
|
+
return msg
|
454
|
+
escape_code = _get_ansi_code(color, style)
|
455
|
+
# If invalid (or unknown) color, don't wrap msg with ansi codes
|
456
|
+
if escape_code:
|
457
|
+
return '%s%s%s' % (escape_code, msg, ANSI_RESET)
|
458
|
+
return msg
|
459
|
+
|
460
|
+
DIFF_STYLE = {'separator': 'cyan', 'remove': 'red', 'add': 'green'}
|
461
|
+
|
462
|
+
def diff_colorize_ansi(lines, out=sys.stdout, style=DIFF_STYLE):
|
463
|
+
for line in lines:
|
464
|
+
if line[:4] in ('--- ', '+++ '):
|
465
|
+
out.write(colorize_ansi(line, style['separator']))
|
466
|
+
elif line[0] == '-':
|
467
|
+
out.write(colorize_ansi(line, style['remove']))
|
468
|
+
elif line[0] == '+':
|
469
|
+
out.write(colorize_ansi(line, style['add']))
|
470
|
+
elif line[:4] == '--- ':
|
471
|
+
out.write(colorize_ansi(line, style['separator']))
|
472
|
+
elif line[:4] == '+++ ':
|
473
|
+
out.write(colorize_ansi(line, style['separator']))
|
474
|
+
else:
|
475
|
+
out.write(line)
|
476
|
+
|