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,118 @@
|
|
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
|
+
"""Deprecation utilities.
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
"""
|
24
|
+
__docformat__ = "restructuredtext en"
|
25
|
+
|
26
|
+
import sys
|
27
|
+
from warnings import warn
|
28
|
+
|
29
|
+
class class_deprecated(type):
|
30
|
+
"""metaclass to print a warning on instantiation of a deprecated class"""
|
31
|
+
|
32
|
+
def __call__(cls, *args, **kwargs):
|
33
|
+
msg = getattr(cls, "__deprecation_warning__",
|
34
|
+
"%s is deprecated" % cls.__name__)
|
35
|
+
warn(msg, DeprecationWarning, stacklevel=2)
|
36
|
+
return type.__call__(cls, *args, **kwargs)
|
37
|
+
|
38
|
+
|
39
|
+
def class_renamed(old_name, new_class, message=None):
|
40
|
+
"""automatically creates a class which fires a DeprecationWarning
|
41
|
+
when instantiated.
|
42
|
+
|
43
|
+
>>> Set = class_renamed('Set', set, 'Set is now replaced by set')
|
44
|
+
>>> s = Set()
|
45
|
+
sample.py:57: DeprecationWarning: Set is now replaced by set
|
46
|
+
s = Set()
|
47
|
+
>>>
|
48
|
+
"""
|
49
|
+
clsdict = {}
|
50
|
+
if message is None:
|
51
|
+
message = '%s is deprecated, use %s' % (old_name, new_class.__name__)
|
52
|
+
clsdict['__deprecation_warning__'] = message
|
53
|
+
try:
|
54
|
+
# new-style class
|
55
|
+
return class_deprecated(old_name, (new_class,), clsdict)
|
56
|
+
except (NameError, TypeError):
|
57
|
+
# old-style class
|
58
|
+
class DeprecatedClass(new_class):
|
59
|
+
"""FIXME: There might be a better way to handle old/new-style class
|
60
|
+
"""
|
61
|
+
def __init__(self, *args, **kwargs):
|
62
|
+
warn(message, DeprecationWarning, stacklevel=2)
|
63
|
+
new_class.__init__(self, *args, **kwargs)
|
64
|
+
return DeprecatedClass
|
65
|
+
|
66
|
+
|
67
|
+
def class_moved(new_class, old_name=None, message=None):
|
68
|
+
"""nice wrapper around class_renamed when a class has been moved into
|
69
|
+
another module
|
70
|
+
"""
|
71
|
+
if old_name is None:
|
72
|
+
old_name = new_class.__name__
|
73
|
+
if message is None:
|
74
|
+
message = 'class %s is now available as %s.%s' % (
|
75
|
+
old_name, new_class.__module__, new_class.__name__)
|
76
|
+
return class_renamed(old_name, new_class, message)
|
77
|
+
|
78
|
+
def deprecated(reason=None, stacklevel=2):
|
79
|
+
"""Decorator that raises a DeprecationWarning to print a message
|
80
|
+
when the decorated function is called.
|
81
|
+
"""
|
82
|
+
def deprecated_decorator(func):
|
83
|
+
message = reason or 'this function is deprecated, use %s instead'
|
84
|
+
if '%s' in message:
|
85
|
+
message = message % func.func_name
|
86
|
+
def wrapped(*args, **kwargs):
|
87
|
+
warn(message, DeprecationWarning, stacklevel=stacklevel)
|
88
|
+
return func(*args, **kwargs)
|
89
|
+
wrapped.__name__ = func.__name__
|
90
|
+
wrapped.__doc__ = func.__doc__
|
91
|
+
return wrapped
|
92
|
+
return deprecated_decorator
|
93
|
+
|
94
|
+
@deprecated('replace deprecated_function(f,m) with deprecated(m)(f)')
|
95
|
+
def deprecated_function(func, message=None):
|
96
|
+
return deprecated(message)(func)
|
97
|
+
|
98
|
+
def moved(modpath, objname):
|
99
|
+
"""use to tell that a callable has been moved to a new module.
|
100
|
+
|
101
|
+
It returns a callable wrapper, so that when its called a warning is printed
|
102
|
+
telling where the object can be found, import is done (and not before) and
|
103
|
+
the actual object is called.
|
104
|
+
|
105
|
+
NOTE: the usage is somewhat limited on classes since it will fail if the
|
106
|
+
wrapper is use in a class ancestors list, use the `class_moved` function
|
107
|
+
instead (which has no lazy import feature though).
|
108
|
+
"""
|
109
|
+
def callnew(*args, **kwargs):
|
110
|
+
from logilab.common.modutils import load_module_from_name
|
111
|
+
message = "object %s has been moved to module %s" % (objname, modpath)
|
112
|
+
warn(message, DeprecationWarning, stacklevel=2)
|
113
|
+
m = load_module_from_name(modpath)
|
114
|
+
return getattr(m, objname)(*args, **kwargs)
|
115
|
+
return callnew
|
116
|
+
|
117
|
+
obsolete = deprecated('obsolete is deprecated, use deprecated instead')(deprecated)
|
118
|
+
|
@@ -0,0 +1,409 @@
|
|
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
|
+
"""File and file-path manipulation utilities.
|
19
|
+
|
20
|
+
:group path manipulation: first_level_directory, relative_path, is_binary,\
|
21
|
+
get_by_ext, remove_dead_links
|
22
|
+
:group file manipulation: norm_read, norm_open, lines, stream_lines, lines,\
|
23
|
+
write_open_mode, ensure_fs_mode, export
|
24
|
+
:sort: path manipulation, file manipulation
|
25
|
+
"""
|
26
|
+
__docformat__ = "restructuredtext en"
|
27
|
+
|
28
|
+
import sys
|
29
|
+
import shutil
|
30
|
+
import mimetypes
|
31
|
+
from os.path import isabs, isdir, islink, split, exists, walk, normpath, join
|
32
|
+
from os.path import abspath
|
33
|
+
from os import sep, mkdir, remove, listdir, stat, chmod
|
34
|
+
from stat import ST_MODE, S_IWRITE
|
35
|
+
from cStringIO import StringIO
|
36
|
+
|
37
|
+
from logilab.common import STD_BLACKLIST as BASE_BLACKLIST, IGNORED_EXTENSIONS
|
38
|
+
from logilab.common.shellutils import find
|
39
|
+
|
40
|
+
def first_level_directory(path):
|
41
|
+
"""Return the first level directory of a path.
|
42
|
+
|
43
|
+
>>> first_level_directory('home/syt/work')
|
44
|
+
'home'
|
45
|
+
>>> first_level_directory('/home/syt/work')
|
46
|
+
'/'
|
47
|
+
>>> first_level_directory('work')
|
48
|
+
'work'
|
49
|
+
>>>
|
50
|
+
|
51
|
+
:type path: str
|
52
|
+
:param path: the path for which we want the first level directory
|
53
|
+
|
54
|
+
:rtype: str
|
55
|
+
:return: the first level directory appearing in `path`
|
56
|
+
"""
|
57
|
+
head, tail = split(path)
|
58
|
+
while head and tail:
|
59
|
+
head, tail = split(head)
|
60
|
+
if tail:
|
61
|
+
return tail
|
62
|
+
# path was absolute, head is the fs root
|
63
|
+
return head
|
64
|
+
|
65
|
+
def abspath_listdir(path):
|
66
|
+
"""Lists path's content using absolute paths.
|
67
|
+
|
68
|
+
>>> os.listdir('/home')
|
69
|
+
['adim', 'alf', 'arthur', 'auc']
|
70
|
+
>>> abspath_listdir('/home')
|
71
|
+
['/home/adim', '/home/alf', '/home/arthur', '/home/auc']
|
72
|
+
"""
|
73
|
+
path = abspath(path)
|
74
|
+
return [join(path, filename) for filename in listdir(path)]
|
75
|
+
|
76
|
+
|
77
|
+
def is_binary(filename):
|
78
|
+
"""Return true if filename may be a binary file, according to it's
|
79
|
+
extension.
|
80
|
+
|
81
|
+
:type filename: str
|
82
|
+
:param filename: the name of the file
|
83
|
+
|
84
|
+
:rtype: bool
|
85
|
+
:return:
|
86
|
+
true if the file is a binary file (actually if it's mime type
|
87
|
+
isn't beginning by text/)
|
88
|
+
"""
|
89
|
+
try:
|
90
|
+
return not mimetypes.guess_type(filename)[0].startswith('text')
|
91
|
+
except AttributeError:
|
92
|
+
return 1
|
93
|
+
|
94
|
+
|
95
|
+
def write_open_mode(filename):
|
96
|
+
"""Return the write mode that should used to open file.
|
97
|
+
|
98
|
+
:type filename: str
|
99
|
+
:param filename: the name of the file
|
100
|
+
|
101
|
+
:rtype: str
|
102
|
+
:return: the mode that should be use to open the file ('w' or 'wb')
|
103
|
+
"""
|
104
|
+
if is_binary(filename):
|
105
|
+
return 'wb'
|
106
|
+
return 'w'
|
107
|
+
|
108
|
+
|
109
|
+
def ensure_fs_mode(filepath, desired_mode=S_IWRITE):
|
110
|
+
"""Check that the given file has the given mode(s) set, else try to
|
111
|
+
set it.
|
112
|
+
|
113
|
+
:type filepath: str
|
114
|
+
:param filepath: path of the file
|
115
|
+
|
116
|
+
:type desired_mode: int
|
117
|
+
:param desired_mode:
|
118
|
+
ORed flags describing the desired mode. Use constants from the
|
119
|
+
`stat` module for file permission's modes
|
120
|
+
"""
|
121
|
+
mode = stat(filepath)[ST_MODE]
|
122
|
+
if not mode & desired_mode:
|
123
|
+
chmod(filepath, mode | desired_mode)
|
124
|
+
|
125
|
+
|
126
|
+
class ProtectedFile(file):
|
127
|
+
"""A special file-object class that automatically that automatically
|
128
|
+
does a 'chmod +w' when needed.
|
129
|
+
|
130
|
+
XXX: for now, the way it is done allows 'normal file-objects' to be
|
131
|
+
created during the ProtectedFile object lifetime.
|
132
|
+
One way to circumvent this would be to chmod / unchmod on each
|
133
|
+
write operation.
|
134
|
+
|
135
|
+
One other way would be to :
|
136
|
+
|
137
|
+
- catch the IOError in the __init__
|
138
|
+
|
139
|
+
- if IOError, then create a StringIO object
|
140
|
+
|
141
|
+
- each write operation writes in this StringIO object
|
142
|
+
|
143
|
+
- on close()/del(), write/append the StringIO content to the file and
|
144
|
+
do the chmod only once
|
145
|
+
"""
|
146
|
+
def __init__(self, filepath, mode):
|
147
|
+
self.original_mode = stat(filepath)[ST_MODE]
|
148
|
+
self.mode_changed = False
|
149
|
+
if mode in ('w', 'a', 'wb', 'ab'):
|
150
|
+
if not self.original_mode & S_IWRITE:
|
151
|
+
chmod(filepath, self.original_mode | S_IWRITE)
|
152
|
+
self.mode_changed = True
|
153
|
+
file.__init__(self, filepath, mode)
|
154
|
+
|
155
|
+
def _restore_mode(self):
|
156
|
+
"""restores the original mode if needed"""
|
157
|
+
if self.mode_changed:
|
158
|
+
chmod(self.name, self.original_mode)
|
159
|
+
# Don't re-chmod in case of several restore
|
160
|
+
self.mode_changed = False
|
161
|
+
|
162
|
+
def close(self):
|
163
|
+
"""restore mode before closing"""
|
164
|
+
self._restore_mode()
|
165
|
+
file.close(self)
|
166
|
+
|
167
|
+
def __del__(self):
|
168
|
+
if not self.closed:
|
169
|
+
self.close()
|
170
|
+
|
171
|
+
|
172
|
+
class UnresolvableError(Exception):
|
173
|
+
"""Exception raised by relative path when it's unable to compute relative
|
174
|
+
path between two paths.
|
175
|
+
"""
|
176
|
+
|
177
|
+
def relative_path(from_file, to_file):
|
178
|
+
"""Try to get a relative path from `from_file` to `to_file`
|
179
|
+
(path will be absolute if to_file is an absolute file). This function
|
180
|
+
is useful to create link in `from_file` to `to_file`. This typical use
|
181
|
+
case is used in this function description.
|
182
|
+
|
183
|
+
If both files are relative, they're expected to be relative to the same
|
184
|
+
directory.
|
185
|
+
|
186
|
+
>>> relative_path( from_file='toto/index.html', to_file='index.html')
|
187
|
+
'../index.html'
|
188
|
+
>>> relative_path( from_file='index.html', to_file='toto/index.html')
|
189
|
+
'toto/index.html'
|
190
|
+
>>> relative_path( from_file='tutu/index.html', to_file='toto/index.html')
|
191
|
+
'../toto/index.html'
|
192
|
+
>>> relative_path( from_file='toto/index.html', to_file='/index.html')
|
193
|
+
'/index.html'
|
194
|
+
>>> relative_path( from_file='/toto/index.html', to_file='/index.html')
|
195
|
+
'../index.html'
|
196
|
+
>>> relative_path( from_file='/toto/index.html', to_file='/toto/summary.html')
|
197
|
+
'summary.html'
|
198
|
+
>>> relative_path( from_file='index.html', to_file='index.html')
|
199
|
+
''
|
200
|
+
>>> relative_path( from_file='/index.html', to_file='toto/index.html')
|
201
|
+
Traceback (most recent call last):
|
202
|
+
File "<string>", line 1, in ?
|
203
|
+
File "<stdin>", line 37, in relative_path
|
204
|
+
UnresolvableError
|
205
|
+
>>> relative_path( from_file='/index.html', to_file='/index.html')
|
206
|
+
''
|
207
|
+
>>>
|
208
|
+
|
209
|
+
:type from_file: str
|
210
|
+
:param from_file: source file (where links will be inserted)
|
211
|
+
|
212
|
+
:type to_file: str
|
213
|
+
:param to_file: target file (on which links point)
|
214
|
+
|
215
|
+
:raise UnresolvableError: if it has been unable to guess a correct path
|
216
|
+
|
217
|
+
:rtype: str
|
218
|
+
:return: the relative path of `to_file` from `from_file`
|
219
|
+
"""
|
220
|
+
from_file = normpath(from_file)
|
221
|
+
to_file = normpath(to_file)
|
222
|
+
if from_file == to_file:
|
223
|
+
return ''
|
224
|
+
if isabs(to_file):
|
225
|
+
if not isabs(from_file):
|
226
|
+
return to_file
|
227
|
+
elif isabs(from_file):
|
228
|
+
raise UnresolvableError()
|
229
|
+
from_parts = from_file.split(sep)
|
230
|
+
to_parts = to_file.split(sep)
|
231
|
+
idem = 1
|
232
|
+
result = []
|
233
|
+
while len(from_parts) > 1:
|
234
|
+
dirname = from_parts.pop(0)
|
235
|
+
if idem and len(to_parts) > 1 and dirname == to_parts[0]:
|
236
|
+
to_parts.pop(0)
|
237
|
+
else:
|
238
|
+
idem = 0
|
239
|
+
result.append('..')
|
240
|
+
result += to_parts
|
241
|
+
return sep.join(result)
|
242
|
+
|
243
|
+
|
244
|
+
from logilab.common.textutils import _LINE_RGX
|
245
|
+
from sys import version_info
|
246
|
+
_HAS_UNIV_OPEN = version_info[:2] >= (2, 3)
|
247
|
+
del version_info
|
248
|
+
|
249
|
+
def norm_read(path):
|
250
|
+
"""Return the content of the file with normalized line feeds.
|
251
|
+
|
252
|
+
:type path: str
|
253
|
+
:param path: path to the file to read
|
254
|
+
|
255
|
+
:rtype: str
|
256
|
+
:return: the content of the file with normalized line feeds
|
257
|
+
"""
|
258
|
+
if _HAS_UNIV_OPEN:
|
259
|
+
return open(path, 'U').read()
|
260
|
+
return _LINE_RGX.sub('\n', open(path).read())
|
261
|
+
|
262
|
+
|
263
|
+
def norm_open(path):
|
264
|
+
"""Return a stream for a file with content with normalized line feeds.
|
265
|
+
|
266
|
+
:type path: str
|
267
|
+
:param path: path to the file to open
|
268
|
+
|
269
|
+
:rtype: file or StringIO
|
270
|
+
:return: the opened file with normalized line feeds
|
271
|
+
"""
|
272
|
+
if _HAS_UNIV_OPEN:
|
273
|
+
return open(path, 'U')
|
274
|
+
return StringIO(_LINE_RGX.sub('\n', open(path).read()))
|
275
|
+
|
276
|
+
|
277
|
+
def lines(path, comments=None):
|
278
|
+
"""Return a list of non empty lines in the file located at `path`.
|
279
|
+
|
280
|
+
:type path: str
|
281
|
+
:param path: path to the file
|
282
|
+
|
283
|
+
:type comments: str or None
|
284
|
+
:param comments:
|
285
|
+
optional string which can be used to comment a line in the file
|
286
|
+
(i.e. lines starting with this string won't be returned)
|
287
|
+
|
288
|
+
:rtype: list
|
289
|
+
:return:
|
290
|
+
a list of stripped line in the file, without empty and commented
|
291
|
+
lines
|
292
|
+
|
293
|
+
:warning: at some point this function will probably return an iterator
|
294
|
+
"""
|
295
|
+
stream = norm_open(path)
|
296
|
+
result = stream_lines(stream, comments)
|
297
|
+
stream.close()
|
298
|
+
return result
|
299
|
+
|
300
|
+
|
301
|
+
def stream_lines(stream, comments=None):
|
302
|
+
"""Return a list of non empty lines in the given `stream`.
|
303
|
+
|
304
|
+
:type stream: object implementing 'xreadlines' or 'readlines'
|
305
|
+
:param stream: file like object
|
306
|
+
|
307
|
+
:type comments: str or None
|
308
|
+
:param comments:
|
309
|
+
optional string which can be used to comment a line in the file
|
310
|
+
(i.e. lines starting with this string won't be returned)
|
311
|
+
|
312
|
+
:rtype: list
|
313
|
+
:return:
|
314
|
+
a list of stripped line in the file, without empty and commented
|
315
|
+
lines
|
316
|
+
|
317
|
+
:warning: at some point this function will probably return an iterator
|
318
|
+
"""
|
319
|
+
try:
|
320
|
+
readlines = stream.xreadlines
|
321
|
+
except AttributeError:
|
322
|
+
readlines = stream.readlines
|
323
|
+
result = []
|
324
|
+
for line in readlines():
|
325
|
+
line = line.strip()
|
326
|
+
if line and (comments is None or not line.startswith(comments)):
|
327
|
+
result.append(line)
|
328
|
+
return result
|
329
|
+
|
330
|
+
|
331
|
+
def export(from_dir, to_dir,
|
332
|
+
blacklist=BASE_BLACKLIST, ignore_ext=IGNORED_EXTENSIONS,
|
333
|
+
verbose=0):
|
334
|
+
"""Make a mirror of `from_dir` in `to_dir`, omitting directories and
|
335
|
+
files listed in the black list or ending with one of the given
|
336
|
+
extensions.
|
337
|
+
|
338
|
+
:type from_dir: str
|
339
|
+
:param from_dir: directory to export
|
340
|
+
|
341
|
+
:type to_dir: str
|
342
|
+
:param to_dir: destination directory
|
343
|
+
|
344
|
+
:type blacklist: list or tuple
|
345
|
+
:param blacklist:
|
346
|
+
list of files or directories to ignore, default to the content of
|
347
|
+
`BASE_BLACKLIST`
|
348
|
+
|
349
|
+
:type ignore_ext: list or tuple
|
350
|
+
:param ignore_ext:
|
351
|
+
list of extensions to ignore, default to the content of
|
352
|
+
`IGNORED_EXTENSIONS`
|
353
|
+
|
354
|
+
:type verbose: bool
|
355
|
+
:param verbose:
|
356
|
+
flag indicating whether information about exported files should be
|
357
|
+
printed to stderr, default to False
|
358
|
+
"""
|
359
|
+
def make_mirror(_, directory, fnames):
|
360
|
+
"""walk handler"""
|
361
|
+
for norecurs in blacklist:
|
362
|
+
try:
|
363
|
+
fnames.remove(norecurs)
|
364
|
+
except ValueError:
|
365
|
+
continue
|
366
|
+
for filename in fnames:
|
367
|
+
# don't include binary files
|
368
|
+
for ext in ignore_ext:
|
369
|
+
if filename.endswith(ext):
|
370
|
+
break
|
371
|
+
else:
|
372
|
+
src = join(directory, filename)
|
373
|
+
dest = to_dir + src[len(from_dir):]
|
374
|
+
if verbose:
|
375
|
+
print >> sys.stderr, src, '->', dest
|
376
|
+
if isdir(src):
|
377
|
+
if not exists(dest):
|
378
|
+
mkdir(dest)
|
379
|
+
else:
|
380
|
+
if exists(dest):
|
381
|
+
remove(dest)
|
382
|
+
shutil.copy2(src, dest)
|
383
|
+
try:
|
384
|
+
mkdir(to_dir)
|
385
|
+
except OSError:
|
386
|
+
pass
|
387
|
+
walk(from_dir, make_mirror, None)
|
388
|
+
|
389
|
+
|
390
|
+
def remove_dead_links(directory, verbose=0):
|
391
|
+
"""Recursively traverse directory and remove all dead links.
|
392
|
+
|
393
|
+
:type directory: str
|
394
|
+
:param directory: directory to cleanup
|
395
|
+
|
396
|
+
:type verbose: bool
|
397
|
+
:param verbose:
|
398
|
+
flag indicating whether information about deleted links should be
|
399
|
+
printed to stderr, default to False
|
400
|
+
"""
|
401
|
+
def _remove_dead_link(_, directory, fnames):
|
402
|
+
"""walk handler"""
|
403
|
+
for filename in fnames:
|
404
|
+
src = join(directory, filename)
|
405
|
+
if islink(src) and not exists(src):
|
406
|
+
if verbose:
|
407
|
+
print 'remove dead link', src
|
408
|
+
remove(src)
|
409
|
+
walk(directory, _remove_dead_link, None)
|