libv8 6.7.288.46.1 → 7.3.492.27.0beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/CHANGELOG.md +4 -0
- data/README.md +2 -0
- data/ext/libv8/builder.rb +6 -2
- data/lib/libv8/version.rb +1 -1
- data/vendor/depot_tools/.gitattributes +1 -0
- data/vendor/depot_tools/.gitignore +7 -0
- data/vendor/depot_tools/CROS_OWNERS +5 -0
- data/vendor/depot_tools/OWNERS +12 -1
- data/vendor/depot_tools/PRESUBMIT.py +16 -9
- data/vendor/depot_tools/README.md +9 -2
- data/vendor/depot_tools/autoninja +14 -6
- data/vendor/depot_tools/autoninja.bat +11 -1
- data/vendor/depot_tools/autoninja.py +40 -18
- data/vendor/depot_tools/bb +12 -0
- data/vendor/depot_tools/bb.bat +7 -0
- data/vendor/depot_tools/bootstrap/win/manifest.txt +1 -1
- data/vendor/depot_tools/bootstrap/win/manifest_bleeding_edge.txt +1 -1
- data/vendor/depot_tools/bootstrap/win/win_tools.py +2 -1
- data/vendor/depot_tools/buildbucket.py +57 -4
- data/vendor/depot_tools/cipd +157 -44
- data/vendor/depot_tools/cipd.bat +51 -14
- data/vendor/depot_tools/cipd.ps1 +104 -42
- data/vendor/depot_tools/cipd_client_version +1 -1
- data/vendor/depot_tools/cipd_client_version.digests +21 -0
- data/vendor/depot_tools/cipd_manifest.txt +19 -6
- data/vendor/depot_tools/cipd_manifest.versions +318 -0
- data/vendor/depot_tools/clang_format.py +4 -4
- data/vendor/depot_tools/cpplint.py +44 -199
- data/vendor/depot_tools/dart_format.py +2 -2
- data/vendor/depot_tools/detect_host_arch.py +8 -3
- data/vendor/depot_tools/download_from_google_storage.py +47 -39
- data/vendor/depot_tools/fetch.py +30 -18
- data/vendor/depot_tools/fetch_configs/android_internal.py +34 -0
- data/vendor/depot_tools/fetch_configs/chromium.py +18 -1
- data/vendor/depot_tools/fetch_configs/config_util.py +4 -2
- data/vendor/depot_tools/fetch_configs/inspector_protocol.py +40 -0
- data/vendor/depot_tools/fetch_configs/node-ci.py +41 -0
- data/vendor/depot_tools/fix_encoding.py +3 -3
- data/vendor/depot_tools/gclient +1 -1
- data/vendor/depot_tools/gclient.py +415 -198
- data/vendor/depot_tools/gclient_eval.py +220 -171
- data/vendor/depot_tools/gclient_paths.py +142 -0
- data/vendor/depot_tools/gclient_scm.py +200 -51
- data/vendor/depot_tools/gclient_utils.py +88 -191
- data/vendor/depot_tools/gerrit_client.py +13 -0
- data/vendor/depot_tools/gerrit_util.py +158 -23
- data/vendor/depot_tools/git-nav-upstream +1 -1
- data/vendor/depot_tools/git_cache.py +77 -24
- data/vendor/depot_tools/git_cl.py +705 -1099
- data/vendor/depot_tools/git_common.py +9 -6
- data/vendor/depot_tools/git_map_branches.py +19 -2
- data/vendor/depot_tools/git_nav_downstream.py +3 -4
- data/vendor/depot_tools/git_rebase_update.py +14 -0
- data/vendor/depot_tools/git_reparent_branch.py +8 -2
- data/vendor/depot_tools/gn.py +38 -3
- data/vendor/depot_tools/gsutil.py +8 -3
- data/vendor/depot_tools/gsutil.py.bat +15 -0
- data/vendor/depot_tools/gsutil.vpython +16 -0
- data/vendor/depot_tools/infra/config/OWNERS +0 -1
- data/vendor/depot_tools/infra/config/recipes.cfg +3 -2
- data/vendor/depot_tools/lucicfg +12 -0
- data/vendor/depot_tools/lucicfg.bat +7 -0
- data/vendor/depot_tools/man/html/git-map-branches.html +34 -2
- data/vendor/depot_tools/man/html/git-new-branch.html +40 -32
- data/vendor/depot_tools/man/man1/git-map-branches.1 +24 -5
- data/vendor/depot_tools/man/man1/git-new-branch.1 +35 -27
- data/vendor/depot_tools/man/src/git-map-branches.demo.1.sh +1 -0
- data/vendor/depot_tools/man/src/git-map-branches.txt +10 -0
- data/vendor/depot_tools/man/src/git-new-branch.demo.1.sh +9 -4
- data/vendor/depot_tools/man/src/git-new-branch.txt +1 -1
- data/vendor/depot_tools/metrics.README.md +98 -0
- data/vendor/depot_tools/metrics.py +296 -0
- data/vendor/depot_tools/metrics_utils.py +303 -0
- data/vendor/depot_tools/my_activity.py +91 -29
- data/vendor/depot_tools/ninja +1 -1
- data/vendor/depot_tools/ninjalog.README.md +64 -0
- data/vendor/depot_tools/ninjalog_uploader.py +232 -0
- data/vendor/depot_tools/ninjalog_uploader_wrapper.py +116 -0
- data/vendor/depot_tools/owners.py +30 -13
- data/vendor/depot_tools/owners_finder.py +5 -2
- data/vendor/depot_tools/presubmit_canned_checks.py +188 -29
- data/vendor/depot_tools/presubmit_support.py +18 -41
- data/vendor/depot_tools/pylintrc +23 -19
- data/vendor/depot_tools/recipes/OWNERS +2 -0
- data/vendor/depot_tools/recipes/README.recipes.md +344 -151
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/OWNERS +2 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/__init__.py +2 -16
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/api.py +141 -99
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic.json +5 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic_luci.json +5 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic_with_branch_heads.json +6 -98
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/clobber.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/deprecated_got_revision_mapping.json +45 -5
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/gerrit_no_rebase_patch_ref.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/gerrit_no_reset.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/{tryjob.json → input_commit_with_id_without_repo.json} +6 -11
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/{tryjob_empty_revision.json → multiple_patch_refs.json} +8 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_apply_patch_on_gclient.json +19 -29
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/{trychange.json → refs.json} +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/reset_root_solution_revision.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail.json +51 -6
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch.json +50 -6
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch_download.json +51 -6
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_angle.json +17 -25
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_branch_heads.json +17 -25
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_feature_branch.json +18 -26
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8_feature_branch.json +18 -26
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_webrtc.json +26 -28
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8.json +45 -5
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8_head_by_default.json +17 -25
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/unrecognized_commit_repo.json +13 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_manifest_name.json +13 -152
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_tags.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.py +185 -202
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/resources/bot_update.py +52 -157
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/test_api.py +5 -14
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/tests/ensure_checkout.py +34 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/api.py +14 -2
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/basic.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/basic_pkg.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/describe-failed.json +7 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/describe-many-instances.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/mac64.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_file.json +9 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_mode.json +9 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_verfile.json +9 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/win64.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/junk arch.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/junk bits.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_arm_32.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_arm_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_intel_32.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_intel_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_mips_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/mac_intel_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/win_intel_32.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/win_intel_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/api.py +13 -8
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/basic.json +18 -12
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/basic_luci.json +18 -12
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/win.json +18 -12
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.py +3 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/__init__.py +1 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/api.py +58 -46
- data/vendor/depot_tools/recipes/recipe_modules/gclient/config.py +65 -22
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/basic.json +20 -21
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/buildbot.json +20 -21
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/revision.json +20 -21
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/tryserver.json +20 -21
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.py +5 -2
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/patch_project.py +62 -14
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/api.py +24 -38
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/examples/full.expected/basic.json +56 -50
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/examples/full.py +15 -9
- data/vendor/depot_tools/recipes/recipe_modules/git/__init__.py +4 -1
- data/vendor/depot_tools/recipes/recipe_modules/git/api.py +34 -22
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_branch.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_file_name.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_hash.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_luci.json +222 -0
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_ref.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_submodule_update_force.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_tags.json +224 -0
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/can_fail_build.json +10 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/cannot_fail_build.json +5 -7
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/cat-file_test.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_delta.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_failed.json +5 -7
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_with_bad_output.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_with_bad_output_fails_build.json +10 -5
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/curl_trace_file.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/git-cache-checkout.json +8 -9
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/platform_win.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/rebase_failed.json +12 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/remote_not_origin.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/set_got_revision.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.py +27 -11
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/api.py +1 -1
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/examples/full.expected/basic.json +12 -13
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/__init__.py +5 -0
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/api.py +120 -5
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/examples/full.expected/basic.json +45 -3
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/examples/full.py +25 -0
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/resources/gerrit_client.py +56 -4
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/tests/parse_repo_url.expected/basic.json +6 -0
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/tests/parse_repo_url.py +49 -0
- data/vendor/depot_tools/recipes/recipe_modules/gsutil/api.py +24 -13
- data/vendor/depot_tools/recipes/recipe_modules/gsutil/examples/full.expected/basic.json +13 -14
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/basic.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_linux.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_mac.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_win.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_linux.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_mac.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_win.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_linux.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_mac.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_win.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/path_config.py +1 -2
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/__init__.py +35 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/api.py +116 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/linux.json +22 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/mac.json +82 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/win.json +22 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.py +23 -0
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/__init__.py +1 -0
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/api.py +2 -7
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/examples/full.expected/basic.json +7 -6
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/__init__.py +1 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/api.py +117 -8
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/basic_tags.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/set_failure_hash_with_no_steps.json +7 -4
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch.json +98 -7
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch_and_target_ref.json +147 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_git_patch.json +8 -5
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_git_patch_luci.json +8 -5
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_wrong_patch.json +9 -6
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_wrong_patch_new.json +9 -6
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.py +27 -2
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/test_api.py +14 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/__init__.py +25 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/api.py +137 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/linux.json +22 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/mac.json +22 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/win.json +107 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.py +26 -0
- data/vendor/depot_tools/recipes/recipes.py +37 -27
- data/vendor/depot_tools/recipes/recipes/fetch_end_to_end_test.expected/basic.json +7 -10
- data/vendor/depot_tools/repo +34 -8
- data/vendor/depot_tools/roll_dep.py +52 -49
- data/vendor/depot_tools/scm.py +38 -23
- data/vendor/depot_tools/setup_color.py +4 -2
- data/vendor/depot_tools/split_cl.py +32 -4
- data/vendor/depot_tools/subprocess2.py +22 -4
- data/vendor/depot_tools/third_party/httplib2/README.chromium +2 -2
- data/vendor/depot_tools/third_party/httplib2/__init__.py +242 -158
- data/vendor/depot_tools/third_party/httplib2/cacerts.txt +57 -44
- data/vendor/depot_tools/third_party/httplib2/socks.py +15 -5
- data/vendor/depot_tools/third_party/logilab/README.chromium +2 -4
- data/vendor/depot_tools/third_party/logilab/astroid/README.chromium +2 -1
- data/vendor/depot_tools/third_party/logilab/astroid/__init__.py +10 -5
- data/vendor/depot_tools/third_party/logilab/astroid/__pkginfo__.py +5 -5
- data/vendor/depot_tools/third_party/logilab/astroid/arguments.py +233 -0
- data/vendor/depot_tools/third_party/logilab/astroid/as_string.py +82 -33
- data/vendor/depot_tools/third_party/logilab/astroid/bases.py +137 -153
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{builtin_inference.py → brain_builtin_inference.py} +117 -26
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_dateutil.py +15 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{py2gi.py → brain_gi.py} +48 -8
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{py2mechanize.py → brain_mechanize.py} +0 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{pynose.py → brain_nose.py} +4 -1
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_numpy.py +62 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_pytest.py +76 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_qt.py +44 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{pysix_moves.py → brain_six.py} +28 -1
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_ssl.py +65 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_stdlib.py +473 -0
- data/vendor/depot_tools/third_party/logilab/astroid/builder.py +104 -81
- data/vendor/depot_tools/third_party/logilab/astroid/context.py +81 -0
- data/vendor/depot_tools/third_party/logilab/astroid/decorators.py +75 -0
- data/vendor/depot_tools/third_party/logilab/astroid/exceptions.py +20 -0
- data/vendor/depot_tools/third_party/logilab/astroid/inference.py +137 -183
- data/vendor/depot_tools/third_party/logilab/astroid/manager.py +45 -169
- data/vendor/depot_tools/third_party/logilab/astroid/mixins.py +37 -14
- data/vendor/depot_tools/third_party/logilab/astroid/modutils.py +112 -41
- data/vendor/depot_tools/third_party/logilab/astroid/node_classes.py +243 -156
- data/vendor/depot_tools/third_party/logilab/astroid/nodes.py +35 -22
- data/vendor/depot_tools/third_party/logilab/astroid/objects.py +186 -0
- data/vendor/depot_tools/third_party/logilab/astroid/protocols.py +157 -102
- data/vendor/depot_tools/third_party/logilab/astroid/raw_building.py +32 -8
- data/vendor/depot_tools/third_party/logilab/astroid/rebuilder.py +372 -309
- data/vendor/depot_tools/third_party/logilab/astroid/scoped_nodes.py +652 -420
- data/vendor/depot_tools/third_party/logilab/astroid/test_utils.py +4 -21
- data/vendor/depot_tools/third_party/logilab/astroid/transforms.py +96 -0
- data/vendor/depot_tools/third_party/logilab/astroid/util.py +89 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/LICENSE +19 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/README.chromium +11 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/__init__.py +20 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/cext.c +1421 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/compat.py +9 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/simple.py +246 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/slots.py +414 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/utils.py +13 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/LICENSE +24 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/README.chromium +11 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/__init__.py +19 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/_wrappers.c +2729 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/arguments.py +96 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/decorators.py +512 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/importer.py +228 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/wrappers.py +901 -0
- data/vendor/depot_tools/third_party/pylint/README.chromium +2 -25
- data/vendor/depot_tools/third_party/pylint/__pkginfo__.py +13 -3
- data/vendor/depot_tools/third_party/pylint/checkers/__init__.py +1 -2
- data/vendor/depot_tools/third_party/pylint/checkers/async.py +82 -0
- data/vendor/depot_tools/third_party/pylint/checkers/base.py +893 -119
- data/vendor/depot_tools/third_party/pylint/checkers/classes.py +342 -204
- data/vendor/depot_tools/third_party/pylint/checkers/design_analysis.py +51 -34
- data/vendor/depot_tools/third_party/pylint/checkers/exceptions.py +84 -47
- data/vendor/depot_tools/third_party/pylint/checkers/format.py +55 -30
- data/vendor/depot_tools/third_party/pylint/checkers/imports.py +314 -73
- data/vendor/depot_tools/third_party/pylint/checkers/logging.py +10 -8
- data/vendor/depot_tools/third_party/pylint/checkers/misc.py +2 -1
- data/vendor/depot_tools/third_party/pylint/checkers/newstyle.py +45 -48
- data/vendor/depot_tools/third_party/pylint/checkers/python3.py +31 -21
- data/vendor/depot_tools/third_party/pylint/checkers/raw_metrics.py +3 -3
- data/vendor/depot_tools/third_party/pylint/checkers/similar.py +4 -5
- data/vendor/depot_tools/third_party/pylint/checkers/spelling.py +24 -10
- data/vendor/depot_tools/third_party/pylint/checkers/stdlib.py +120 -56
- data/vendor/depot_tools/third_party/pylint/checkers/strings.py +38 -35
- data/vendor/depot_tools/third_party/pylint/checkers/typecheck.py +485 -138
- data/vendor/depot_tools/third_party/pylint/checkers/utils.py +319 -142
- data/vendor/depot_tools/third_party/pylint/checkers/variables.py +329 -207
- data/vendor/depot_tools/third_party/pylint/config.py +739 -76
- data/vendor/depot_tools/third_party/pylint/epylint.py +9 -5
- data/vendor/depot_tools/third_party/pylint/extensions/__init__.py +0 -0
- data/vendor/depot_tools/third_party/pylint/extensions/check_docs.py +311 -0
- data/vendor/depot_tools/third_party/pylint/extensions/check_elif.py +62 -0
- data/vendor/depot_tools/third_party/{logilab/common → pylint}/graph.py +30 -133
- data/vendor/depot_tools/third_party/pylint/gui.py +2 -2
- data/vendor/depot_tools/third_party/pylint/interfaces.py +21 -3
- data/vendor/depot_tools/third_party/pylint/lint.py +123 -140
- data/vendor/depot_tools/third_party/pylint/pyreverse/diadefslib.py +10 -13
- data/vendor/depot_tools/third_party/pylint/pyreverse/diagrams.py +15 -4
- data/vendor/depot_tools/third_party/pylint/pyreverse/inspector.py +372 -0
- data/vendor/depot_tools/third_party/pylint/pyreverse/main.py +30 -7
- data/vendor/depot_tools/third_party/pylint/pyreverse/utils.py +80 -2
- data/vendor/depot_tools/third_party/{logilab/common → pylint/pyreverse}/vcgutils.py +19 -37
- data/vendor/depot_tools/third_party/pylint/pyreverse/writer.py +3 -4
- data/vendor/depot_tools/third_party/pylint/reporters/__init__.py +34 -18
- data/vendor/depot_tools/third_party/pylint/reporters/guireporter.py +1 -1
- data/vendor/depot_tools/third_party/pylint/reporters/html.py +10 -3
- data/vendor/depot_tools/third_party/pylint/reporters/json.py +10 -4
- data/vendor/depot_tools/third_party/pylint/reporters/text.py +94 -3
- data/vendor/depot_tools/third_party/pylint/reporters/ureports/__init__.py +106 -0
- data/vendor/depot_tools/third_party/{logilab/common → pylint/reporters}/ureports/html_writer.py +17 -57
- data/vendor/depot_tools/third_party/{logilab/common → pylint/reporters}/ureports/nodes.py +52 -74
- data/vendor/depot_tools/third_party/{logilab/common → pylint/reporters}/ureports/text_writer.py +14 -60
- data/vendor/depot_tools/third_party/pylint/testutils.py +22 -20
- data/vendor/depot_tools/third_party/pylint/utils.py +268 -44
- data/vendor/depot_tools/third_party/repo/progress.py +42 -0
- data/vendor/depot_tools/update_depot_tools +1 -1
- data/vendor/depot_tools/upload_metrics.py +25 -0
- data/vendor/depot_tools/win_toolchain/get_toolchain_if_necessary.py +45 -15
- data/vendor/depot_tools/win_toolchain/package_from_installed.py +71 -24
- data/vendor/depot_tools/yapf +1 -1
- data/vendor/depot_tools/yapf.bat +1 -1
- metadata +92 -77
- data/vendor/depot_tools/git-crsync +0 -3
- data/vendor/depot_tools/infra/config/cq.cfg +0 -32
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/apply_gerrit_ref.json +0 -29
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/apply_gerrit_ref_custom.json +0 -29
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/buildbot.json +0 -105
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/shallow.json +0 -195
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_angle_deprecated.json +0 -248
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8.json +0 -248
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_manifest_name_no_patch.json +0 -105
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/resources/apply_gerrit.py +0 -33
- data/vendor/depot_tools/third_party/logilab/astroid/brain/py2pytest.py +0 -31
- data/vendor/depot_tools/third_party/logilab/astroid/brain/py2qt4.py +0 -22
- data/vendor/depot_tools/third_party/logilab/astroid/brain/py2stdlib.py +0 -334
- data/vendor/depot_tools/third_party/logilab/astroid/inspector.py +0 -273
- data/vendor/depot_tools/third_party/logilab/astroid/utils.py +0 -239
- data/vendor/depot_tools/third_party/logilab/common/LICENSE.txt +0 -339
- data/vendor/depot_tools/third_party/logilab/common/README.chromium +0 -11
- data/vendor/depot_tools/third_party/logilab/common/__init__.py +0 -175
- data/vendor/depot_tools/third_party/logilab/common/__pkginfo__.py +0 -57
- data/vendor/depot_tools/third_party/logilab/common/cache.py +0 -114
- data/vendor/depot_tools/third_party/logilab/common/changelog.py +0 -238
- data/vendor/depot_tools/third_party/logilab/common/clcommands.py +0 -334
- data/vendor/depot_tools/third_party/logilab/common/cli.py +0 -211
- data/vendor/depot_tools/third_party/logilab/common/compat.py +0 -78
- data/vendor/depot_tools/third_party/logilab/common/configuration.py +0 -1105
- data/vendor/depot_tools/third_party/logilab/common/contexts.py +0 -5
- data/vendor/depot_tools/third_party/logilab/common/corbautils.py +0 -117
- data/vendor/depot_tools/third_party/logilab/common/daemon.py +0 -101
- data/vendor/depot_tools/third_party/logilab/common/date.py +0 -335
- data/vendor/depot_tools/third_party/logilab/common/dbf.py +0 -231
- data/vendor/depot_tools/third_party/logilab/common/debugger.py +0 -214
- data/vendor/depot_tools/third_party/logilab/common/decorators.py +0 -281
- data/vendor/depot_tools/third_party/logilab/common/deprecation.py +0 -189
- data/vendor/depot_tools/third_party/logilab/common/fileutils.py +0 -404
- data/vendor/depot_tools/third_party/logilab/common/interface.py +0 -71
- data/vendor/depot_tools/third_party/logilab/common/logging_ext.py +0 -195
- data/vendor/depot_tools/third_party/logilab/common/modutils.py +0 -702
- data/vendor/depot_tools/third_party/logilab/common/optik_ext.py +0 -392
- data/vendor/depot_tools/third_party/logilab/common/optparser.py +0 -92
- data/vendor/depot_tools/third_party/logilab/common/proc.py +0 -277
- data/vendor/depot_tools/third_party/logilab/common/pyro_ext.py +0 -180
- data/vendor/depot_tools/third_party/logilab/common/pytest.py +0 -1199
- data/vendor/depot_tools/third_party/logilab/common/registry.py +0 -1119
- data/vendor/depot_tools/third_party/logilab/common/shellutils.py +0 -462
- data/vendor/depot_tools/third_party/logilab/common/sphinx_ext.py +0 -87
- data/vendor/depot_tools/third_party/logilab/common/sphinxutils.py +0 -122
- data/vendor/depot_tools/third_party/logilab/common/table.py +0 -929
- data/vendor/depot_tools/third_party/logilab/common/tasksqueue.py +0 -101
- data/vendor/depot_tools/third_party/logilab/common/testlib.py +0 -1392
- data/vendor/depot_tools/third_party/logilab/common/textutils.py +0 -537
- data/vendor/depot_tools/third_party/logilab/common/tree.py +0 -369
- data/vendor/depot_tools/third_party/logilab/common/umessage.py +0 -194
- data/vendor/depot_tools/third_party/logilab/common/ureports/__init__.py +0 -172
- data/vendor/depot_tools/third_party/logilab/common/ureports/docbook_writer.py +0 -140
- data/vendor/depot_tools/third_party/logilab/common/urllib2ext.py +0 -89
- data/vendor/depot_tools/third_party/logilab/common/visitor.py +0 -109
- data/vendor/depot_tools/third_party/logilab/common/xmlrpcutils.py +0 -131
- data/vendor/depot_tools/third_party/logilab/common/xmlutils.py +0 -61
@@ -1,71 +0,0 @@
|
|
1
|
-
# copyright 2003-2011 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
|
-
"""Bases class for interfaces to provide 'light' interface handling.
|
19
|
-
|
20
|
-
TODO:
|
21
|
-
_ implements a check method which check that an object implements the
|
22
|
-
interface
|
23
|
-
_ Attribute objects
|
24
|
-
|
25
|
-
This module requires at least python 2.2
|
26
|
-
"""
|
27
|
-
__docformat__ = "restructuredtext en"
|
28
|
-
|
29
|
-
|
30
|
-
class Interface(object):
|
31
|
-
"""Base class for interfaces."""
|
32
|
-
def is_implemented_by(cls, instance):
|
33
|
-
return implements(instance, cls)
|
34
|
-
is_implemented_by = classmethod(is_implemented_by)
|
35
|
-
|
36
|
-
|
37
|
-
def implements(obj, interface):
|
38
|
-
"""Return true if the give object (maybe an instance or class) implements
|
39
|
-
the interface.
|
40
|
-
"""
|
41
|
-
kimplements = getattr(obj, '__implements__', ())
|
42
|
-
if not isinstance(kimplements, (list, tuple)):
|
43
|
-
kimplements = (kimplements,)
|
44
|
-
for implementedinterface in kimplements:
|
45
|
-
if issubclass(implementedinterface, interface):
|
46
|
-
return True
|
47
|
-
return False
|
48
|
-
|
49
|
-
|
50
|
-
def extend(klass, interface, _recurs=False):
|
51
|
-
"""Add interface to klass'__implements__ if not already implemented in.
|
52
|
-
|
53
|
-
If klass is subclassed, ensure subclasses __implements__ it as well.
|
54
|
-
|
55
|
-
NOTE: klass should be e new class.
|
56
|
-
"""
|
57
|
-
if not implements(klass, interface):
|
58
|
-
try:
|
59
|
-
kimplements = klass.__implements__
|
60
|
-
kimplementsklass = type(kimplements)
|
61
|
-
kimplements = list(kimplements)
|
62
|
-
except AttributeError:
|
63
|
-
kimplementsklass = tuple
|
64
|
-
kimplements = []
|
65
|
-
kimplements.append(interface)
|
66
|
-
klass.__implements__ = kimplementsklass(kimplements)
|
67
|
-
for subklass in klass.__subclasses__():
|
68
|
-
extend(subklass, interface, _recurs=True)
|
69
|
-
elif _recurs:
|
70
|
-
for subklass in klass.__subclasses__():
|
71
|
-
extend(subklass, interface, _recurs=True)
|
@@ -1,195 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
|
3
|
-
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
|
4
|
-
#
|
5
|
-
# This file is part of logilab-common.
|
6
|
-
#
|
7
|
-
# logilab-common is free software: you can redistribute it and/or modify it under
|
8
|
-
# the terms of the GNU Lesser General Public License as published by the Free
|
9
|
-
# Software Foundation, either version 2.1 of the License, or (at your option) any
|
10
|
-
# later version.
|
11
|
-
#
|
12
|
-
# logilab-common is distributed in the hope that it will be useful, but WITHOUT
|
13
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
14
|
-
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
15
|
-
# details.
|
16
|
-
#
|
17
|
-
# You should have received a copy of the GNU Lesser General Public License along
|
18
|
-
# with logilab-common. If not, see <http://www.gnu.org/licenses/>.
|
19
|
-
"""Extends the logging module from the standard library."""
|
20
|
-
|
21
|
-
__docformat__ = "restructuredtext en"
|
22
|
-
|
23
|
-
import os
|
24
|
-
import sys
|
25
|
-
import logging
|
26
|
-
|
27
|
-
from six import string_types
|
28
|
-
|
29
|
-
from logilab.common.textutils import colorize_ansi
|
30
|
-
|
31
|
-
|
32
|
-
def set_log_methods(cls, logger):
|
33
|
-
"""bind standard logger's methods as methods on the class"""
|
34
|
-
cls.__logger = logger
|
35
|
-
for attr in ('debug', 'info', 'warning', 'error', 'critical', 'exception'):
|
36
|
-
setattr(cls, attr, getattr(logger, attr))
|
37
|
-
|
38
|
-
|
39
|
-
def xxx_cyan(record):
|
40
|
-
if 'XXX' in record.message:
|
41
|
-
return 'cyan'
|
42
|
-
|
43
|
-
class ColorFormatter(logging.Formatter):
|
44
|
-
"""
|
45
|
-
A color Formatter for the logging standard module.
|
46
|
-
|
47
|
-
By default, colorize CRITICAL and ERROR in red, WARNING in orange, INFO in
|
48
|
-
green and DEBUG in yellow.
|
49
|
-
|
50
|
-
self.colors is customizable via the 'color' constructor argument (dictionary).
|
51
|
-
|
52
|
-
self.colorfilters is a list of functions that get the LogRecord
|
53
|
-
and return a color name or None.
|
54
|
-
"""
|
55
|
-
|
56
|
-
def __init__(self, fmt=None, datefmt=None, colors=None):
|
57
|
-
logging.Formatter.__init__(self, fmt, datefmt)
|
58
|
-
self.colorfilters = []
|
59
|
-
self.colors = {'CRITICAL': 'red',
|
60
|
-
'ERROR': 'red',
|
61
|
-
'WARNING': 'magenta',
|
62
|
-
'INFO': 'green',
|
63
|
-
'DEBUG': 'yellow',
|
64
|
-
}
|
65
|
-
if colors is not None:
|
66
|
-
assert isinstance(colors, dict)
|
67
|
-
self.colors.update(colors)
|
68
|
-
|
69
|
-
def format(self, record):
|
70
|
-
msg = logging.Formatter.format(self, record)
|
71
|
-
if record.levelname in self.colors:
|
72
|
-
color = self.colors[record.levelname]
|
73
|
-
return colorize_ansi(msg, color)
|
74
|
-
else:
|
75
|
-
for cf in self.colorfilters:
|
76
|
-
color = cf(record)
|
77
|
-
if color:
|
78
|
-
return colorize_ansi(msg, color)
|
79
|
-
return msg
|
80
|
-
|
81
|
-
def set_color_formatter(logger=None, **kw):
|
82
|
-
"""
|
83
|
-
Install a color formatter on the 'logger'. If not given, it will
|
84
|
-
defaults to the default logger.
|
85
|
-
|
86
|
-
Any additional keyword will be passed as-is to the ColorFormatter
|
87
|
-
constructor.
|
88
|
-
"""
|
89
|
-
if logger is None:
|
90
|
-
logger = logging.getLogger()
|
91
|
-
if not logger.handlers:
|
92
|
-
logging.basicConfig()
|
93
|
-
format_msg = logger.handlers[0].formatter._fmt
|
94
|
-
fmt = ColorFormatter(format_msg, **kw)
|
95
|
-
fmt.colorfilters.append(xxx_cyan)
|
96
|
-
logger.handlers[0].setFormatter(fmt)
|
97
|
-
|
98
|
-
|
99
|
-
LOG_FORMAT = '%(asctime)s - (%(name)s) %(levelname)s: %(message)s'
|
100
|
-
LOG_DATE_FORMAT = '%Y-%m-%d %H:%M:%S'
|
101
|
-
|
102
|
-
def get_handler(debug=False, syslog=False, logfile=None, rotation_parameters=None):
|
103
|
-
"""get an apropriate handler according to given parameters"""
|
104
|
-
if os.environ.get('APYCOT_ROOT'):
|
105
|
-
handler = logging.StreamHandler(sys.stdout)
|
106
|
-
if debug:
|
107
|
-
handler = logging.StreamHandler()
|
108
|
-
elif logfile is None:
|
109
|
-
if syslog:
|
110
|
-
from logging import handlers
|
111
|
-
handler = handlers.SysLogHandler()
|
112
|
-
else:
|
113
|
-
handler = logging.StreamHandler()
|
114
|
-
else:
|
115
|
-
try:
|
116
|
-
if rotation_parameters is None:
|
117
|
-
if os.name == 'posix' and sys.version_info >= (2, 6):
|
118
|
-
from logging.handlers import WatchedFileHandler
|
119
|
-
handler = WatchedFileHandler(logfile)
|
120
|
-
else:
|
121
|
-
handler = logging.FileHandler(logfile)
|
122
|
-
else:
|
123
|
-
from logging.handlers import TimedRotatingFileHandler
|
124
|
-
handler = TimedRotatingFileHandler(
|
125
|
-
logfile, **rotation_parameters)
|
126
|
-
except IOError:
|
127
|
-
handler = logging.StreamHandler()
|
128
|
-
return handler
|
129
|
-
|
130
|
-
def get_threshold(debug=False, logthreshold=None):
|
131
|
-
if logthreshold is None:
|
132
|
-
if debug:
|
133
|
-
logthreshold = logging.DEBUG
|
134
|
-
else:
|
135
|
-
logthreshold = logging.ERROR
|
136
|
-
elif isinstance(logthreshold, string_types):
|
137
|
-
logthreshold = getattr(logging, THRESHOLD_MAP.get(logthreshold,
|
138
|
-
logthreshold))
|
139
|
-
return logthreshold
|
140
|
-
|
141
|
-
def _colorable_terminal():
|
142
|
-
isatty = hasattr(sys.__stdout__, 'isatty') and sys.__stdout__.isatty()
|
143
|
-
if not isatty:
|
144
|
-
return False
|
145
|
-
if os.name == 'nt':
|
146
|
-
try:
|
147
|
-
from colorama import init as init_win32_colors
|
148
|
-
except ImportError:
|
149
|
-
return False
|
150
|
-
init_win32_colors()
|
151
|
-
return True
|
152
|
-
|
153
|
-
def get_formatter(logformat=LOG_FORMAT, logdateformat=LOG_DATE_FORMAT):
|
154
|
-
if _colorable_terminal():
|
155
|
-
fmt = ColorFormatter(logformat, logdateformat)
|
156
|
-
def col_fact(record):
|
157
|
-
if 'XXX' in record.message:
|
158
|
-
return 'cyan'
|
159
|
-
if 'kick' in record.message:
|
160
|
-
return 'red'
|
161
|
-
fmt.colorfilters.append(col_fact)
|
162
|
-
else:
|
163
|
-
fmt = logging.Formatter(logformat, logdateformat)
|
164
|
-
return fmt
|
165
|
-
|
166
|
-
def init_log(debug=False, syslog=False, logthreshold=None, logfile=None,
|
167
|
-
logformat=LOG_FORMAT, logdateformat=LOG_DATE_FORMAT, fmt=None,
|
168
|
-
rotation_parameters=None, handler=None):
|
169
|
-
"""init the log service"""
|
170
|
-
logger = logging.getLogger()
|
171
|
-
if handler is None:
|
172
|
-
handler = get_handler(debug, syslog, logfile, rotation_parameters)
|
173
|
-
# only addHandler and removeHandler method while I would like a setHandler
|
174
|
-
# method, so do it this way :$
|
175
|
-
logger.handlers = [handler]
|
176
|
-
logthreshold = get_threshold(debug, logthreshold)
|
177
|
-
logger.setLevel(logthreshold)
|
178
|
-
if fmt is None:
|
179
|
-
if debug:
|
180
|
-
fmt = get_formatter(logformat=logformat, logdateformat=logdateformat)
|
181
|
-
else:
|
182
|
-
fmt = logging.Formatter(logformat, logdateformat)
|
183
|
-
handler.setFormatter(fmt)
|
184
|
-
return handler
|
185
|
-
|
186
|
-
# map logilab.common.logger thresholds to logging thresholds
|
187
|
-
THRESHOLD_MAP = {'LOG_DEBUG': 'DEBUG',
|
188
|
-
'LOG_INFO': 'INFO',
|
189
|
-
'LOG_NOTICE': 'INFO',
|
190
|
-
'LOG_WARN': 'WARNING',
|
191
|
-
'LOG_WARNING': 'WARNING',
|
192
|
-
'LOG_ERR': 'ERROR',
|
193
|
-
'LOG_ERROR': 'ERROR',
|
194
|
-
'LOG_CRIT': 'CRITICAL',
|
195
|
-
}
|
@@ -1,702 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
|
3
|
-
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
|
4
|
-
#
|
5
|
-
# This file is part of logilab-common.
|
6
|
-
#
|
7
|
-
# logilab-common is free software: you can redistribute it and/or modify it under
|
8
|
-
# the terms of the GNU Lesser General Public License as published by the Free
|
9
|
-
# Software Foundation, either version 2.1 of the License, or (at your option) any
|
10
|
-
# later version.
|
11
|
-
#
|
12
|
-
# logilab-common is distributed in the hope that it will be useful, but WITHOUT
|
13
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
14
|
-
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
15
|
-
# details.
|
16
|
-
#
|
17
|
-
# You should have received a copy of the GNU Lesser General Public License along
|
18
|
-
# with logilab-common. If not, see <http://www.gnu.org/licenses/>.
|
19
|
-
"""Python modules manipulation utility functions.
|
20
|
-
|
21
|
-
:type PY_SOURCE_EXTS: tuple(str)
|
22
|
-
:var PY_SOURCE_EXTS: list of possible python source file extension
|
23
|
-
|
24
|
-
:type STD_LIB_DIR: str
|
25
|
-
:var STD_LIB_DIR: directory where standard modules are located
|
26
|
-
|
27
|
-
:type BUILTIN_MODULES: dict
|
28
|
-
:var BUILTIN_MODULES: dictionary with builtin module names has key
|
29
|
-
"""
|
30
|
-
|
31
|
-
__docformat__ = "restructuredtext en"
|
32
|
-
|
33
|
-
import sys
|
34
|
-
import os
|
35
|
-
from os.path import splitext, join, abspath, isdir, dirname, exists, basename
|
36
|
-
from imp import find_module, load_module, C_BUILTIN, PY_COMPILED, PKG_DIRECTORY
|
37
|
-
from distutils.sysconfig import get_config_var, get_python_lib, get_python_version
|
38
|
-
from distutils.errors import DistutilsPlatformError
|
39
|
-
|
40
|
-
from six.moves import range
|
41
|
-
|
42
|
-
try:
|
43
|
-
import zipimport
|
44
|
-
except ImportError:
|
45
|
-
zipimport = None
|
46
|
-
|
47
|
-
ZIPFILE = object()
|
48
|
-
|
49
|
-
from logilab.common import STD_BLACKLIST, _handle_blacklist
|
50
|
-
|
51
|
-
# Notes about STD_LIB_DIR
|
52
|
-
# Consider arch-specific installation for STD_LIB_DIR definition
|
53
|
-
# :mod:`distutils.sysconfig` contains to much hardcoded values to rely on
|
54
|
-
#
|
55
|
-
# :see: `Problems with /usr/lib64 builds <http://bugs.python.org/issue1294959>`_
|
56
|
-
# :see: `FHS <http://www.pathname.com/fhs/pub/fhs-2.3.html#LIBLTQUALGTALTERNATEFORMATESSENTIAL>`_
|
57
|
-
if sys.platform.startswith('win'):
|
58
|
-
PY_SOURCE_EXTS = ('py', 'pyw')
|
59
|
-
PY_COMPILED_EXTS = ('dll', 'pyd')
|
60
|
-
else:
|
61
|
-
PY_SOURCE_EXTS = ('py',)
|
62
|
-
PY_COMPILED_EXTS = ('so',)
|
63
|
-
|
64
|
-
try:
|
65
|
-
STD_LIB_DIR = get_python_lib(standard_lib=1)
|
66
|
-
# get_python_lib(standard_lib=1) is not available on pypy, set STD_LIB_DIR to
|
67
|
-
# non-valid path, see https://bugs.pypy.org/issue1164
|
68
|
-
except DistutilsPlatformError:
|
69
|
-
STD_LIB_DIR = '//'
|
70
|
-
|
71
|
-
EXT_LIB_DIR = get_python_lib()
|
72
|
-
|
73
|
-
BUILTIN_MODULES = dict(zip(sys.builtin_module_names,
|
74
|
-
[1]*len(sys.builtin_module_names)))
|
75
|
-
|
76
|
-
|
77
|
-
class NoSourceFile(Exception):
|
78
|
-
"""exception raised when we are not able to get a python
|
79
|
-
source file for a precompiled file
|
80
|
-
"""
|
81
|
-
|
82
|
-
class LazyObject(object):
|
83
|
-
def __init__(self, module, obj):
|
84
|
-
self.module = module
|
85
|
-
self.obj = obj
|
86
|
-
self._imported = None
|
87
|
-
|
88
|
-
def _getobj(self):
|
89
|
-
if self._imported is None:
|
90
|
-
self._imported = getattr(load_module_from_name(self.module),
|
91
|
-
self.obj)
|
92
|
-
return self._imported
|
93
|
-
|
94
|
-
def __getattribute__(self, attr):
|
95
|
-
try:
|
96
|
-
return super(LazyObject, self).__getattribute__(attr)
|
97
|
-
except AttributeError as ex:
|
98
|
-
return getattr(self._getobj(), attr)
|
99
|
-
|
100
|
-
def __call__(self, *args, **kwargs):
|
101
|
-
return self._getobj()(*args, **kwargs)
|
102
|
-
|
103
|
-
|
104
|
-
def load_module_from_name(dotted_name, path=None, use_sys=1):
|
105
|
-
"""Load a Python module from its name.
|
106
|
-
|
107
|
-
:type dotted_name: str
|
108
|
-
:param dotted_name: python name of a module or package
|
109
|
-
|
110
|
-
:type path: list or None
|
111
|
-
:param path:
|
112
|
-
optional list of path where the module or package should be
|
113
|
-
searched (use sys.path if nothing or None is given)
|
114
|
-
|
115
|
-
:type use_sys: bool
|
116
|
-
:param use_sys:
|
117
|
-
boolean indicating whether the sys.modules dictionary should be
|
118
|
-
used or not
|
119
|
-
|
120
|
-
|
121
|
-
:raise ImportError: if the module or package is not found
|
122
|
-
|
123
|
-
:rtype: module
|
124
|
-
:return: the loaded module
|
125
|
-
"""
|
126
|
-
return load_module_from_modpath(dotted_name.split('.'), path, use_sys)
|
127
|
-
|
128
|
-
|
129
|
-
def load_module_from_modpath(parts, path=None, use_sys=1):
|
130
|
-
"""Load a python module from its splitted name.
|
131
|
-
|
132
|
-
:type parts: list(str) or tuple(str)
|
133
|
-
:param parts:
|
134
|
-
python name of a module or package splitted on '.'
|
135
|
-
|
136
|
-
:type path: list or None
|
137
|
-
:param path:
|
138
|
-
optional list of path where the module or package should be
|
139
|
-
searched (use sys.path if nothing or None is given)
|
140
|
-
|
141
|
-
:type use_sys: bool
|
142
|
-
:param use_sys:
|
143
|
-
boolean indicating whether the sys.modules dictionary should be used or not
|
144
|
-
|
145
|
-
:raise ImportError: if the module or package is not found
|
146
|
-
|
147
|
-
:rtype: module
|
148
|
-
:return: the loaded module
|
149
|
-
"""
|
150
|
-
if use_sys:
|
151
|
-
try:
|
152
|
-
return sys.modules['.'.join(parts)]
|
153
|
-
except KeyError:
|
154
|
-
pass
|
155
|
-
modpath = []
|
156
|
-
prevmodule = None
|
157
|
-
for part in parts:
|
158
|
-
modpath.append(part)
|
159
|
-
curname = '.'.join(modpath)
|
160
|
-
module = None
|
161
|
-
if len(modpath) != len(parts):
|
162
|
-
# even with use_sys=False, should try to get outer packages from sys.modules
|
163
|
-
module = sys.modules.get(curname)
|
164
|
-
elif use_sys:
|
165
|
-
# because it may have been indirectly loaded through a parent
|
166
|
-
module = sys.modules.get(curname)
|
167
|
-
if module is None:
|
168
|
-
mp_file, mp_filename, mp_desc = find_module(part, path)
|
169
|
-
module = load_module(curname, mp_file, mp_filename, mp_desc)
|
170
|
-
if prevmodule:
|
171
|
-
setattr(prevmodule, part, module)
|
172
|
-
_file = getattr(module, '__file__', '')
|
173
|
-
if not _file and len(modpath) != len(parts):
|
174
|
-
raise ImportError('no module in %s' % '.'.join(parts[len(modpath):]) )
|
175
|
-
path = [dirname( _file )]
|
176
|
-
prevmodule = module
|
177
|
-
return module
|
178
|
-
|
179
|
-
|
180
|
-
def load_module_from_file(filepath, path=None, use_sys=1, extrapath=None):
|
181
|
-
"""Load a Python module from it's path.
|
182
|
-
|
183
|
-
:type filepath: str
|
184
|
-
:param filepath: path to the python module or package
|
185
|
-
|
186
|
-
:type path: list or None
|
187
|
-
:param path:
|
188
|
-
optional list of path where the module or package should be
|
189
|
-
searched (use sys.path if nothing or None is given)
|
190
|
-
|
191
|
-
:type use_sys: bool
|
192
|
-
:param use_sys:
|
193
|
-
boolean indicating whether the sys.modules dictionary should be
|
194
|
-
used or not
|
195
|
-
|
196
|
-
|
197
|
-
:raise ImportError: if the module or package is not found
|
198
|
-
|
199
|
-
:rtype: module
|
200
|
-
:return: the loaded module
|
201
|
-
"""
|
202
|
-
modpath = modpath_from_file(filepath, extrapath)
|
203
|
-
return load_module_from_modpath(modpath, path, use_sys)
|
204
|
-
|
205
|
-
|
206
|
-
def _check_init(path, mod_path):
|
207
|
-
"""check there are some __init__.py all along the way"""
|
208
|
-
for part in mod_path:
|
209
|
-
path = join(path, part)
|
210
|
-
if not _has_init(path):
|
211
|
-
return False
|
212
|
-
return True
|
213
|
-
|
214
|
-
|
215
|
-
def modpath_from_file(filename, extrapath=None):
|
216
|
-
"""given a file path return the corresponding splitted module's name
|
217
|
-
(i.e name of a module or package splitted on '.')
|
218
|
-
|
219
|
-
:type filename: str
|
220
|
-
:param filename: file's path for which we want the module's name
|
221
|
-
|
222
|
-
:type extrapath: dict
|
223
|
-
:param extrapath:
|
224
|
-
optional extra search path, with path as key and package name for the path
|
225
|
-
as value. This is usually useful to handle package splitted in multiple
|
226
|
-
directories using __path__ trick.
|
227
|
-
|
228
|
-
|
229
|
-
:raise ImportError:
|
230
|
-
if the corresponding module's name has not been found
|
231
|
-
|
232
|
-
:rtype: list(str)
|
233
|
-
:return: the corresponding splitted module's name
|
234
|
-
"""
|
235
|
-
base = splitext(abspath(filename))[0]
|
236
|
-
if extrapath is not None:
|
237
|
-
for path_ in extrapath:
|
238
|
-
path = abspath(path_)
|
239
|
-
if path and base[:len(path)] == path:
|
240
|
-
submodpath = [pkg for pkg in base[len(path):].split(os.sep)
|
241
|
-
if pkg]
|
242
|
-
if _check_init(path, submodpath[:-1]):
|
243
|
-
return extrapath[path_].split('.') + submodpath
|
244
|
-
for path in sys.path:
|
245
|
-
path = abspath(path)
|
246
|
-
if path and base.startswith(path):
|
247
|
-
modpath = [pkg for pkg in base[len(path):].split(os.sep) if pkg]
|
248
|
-
if _check_init(path, modpath[:-1]):
|
249
|
-
return modpath
|
250
|
-
raise ImportError('Unable to find module for %s in %s' % (
|
251
|
-
filename, ', \n'.join(sys.path)))
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
def file_from_modpath(modpath, path=None, context_file=None):
|
256
|
-
"""given a mod path (i.e. splitted module / package name), return the
|
257
|
-
corresponding file, giving priority to source file over precompiled
|
258
|
-
file if it exists
|
259
|
-
|
260
|
-
:type modpath: list or tuple
|
261
|
-
:param modpath:
|
262
|
-
splitted module's name (i.e name of a module or package splitted
|
263
|
-
on '.')
|
264
|
-
(this means explicit relative imports that start with dots have
|
265
|
-
empty strings in this list!)
|
266
|
-
|
267
|
-
:type path: list or None
|
268
|
-
:param path:
|
269
|
-
optional list of path where the module or package should be
|
270
|
-
searched (use sys.path if nothing or None is given)
|
271
|
-
|
272
|
-
:type context_file: str or None
|
273
|
-
:param context_file:
|
274
|
-
context file to consider, necessary if the identifier has been
|
275
|
-
introduced using a relative import unresolvable in the actual
|
276
|
-
context (i.e. modutils)
|
277
|
-
|
278
|
-
:raise ImportError: if there is no such module in the directory
|
279
|
-
|
280
|
-
:rtype: str or None
|
281
|
-
:return:
|
282
|
-
the path to the module's file or None if it's an integrated
|
283
|
-
builtin module such as 'sys'
|
284
|
-
"""
|
285
|
-
if context_file is not None:
|
286
|
-
context = dirname(context_file)
|
287
|
-
else:
|
288
|
-
context = context_file
|
289
|
-
if modpath[0] == 'xml':
|
290
|
-
# handle _xmlplus
|
291
|
-
try:
|
292
|
-
return _file_from_modpath(['_xmlplus'] + modpath[1:], path, context)
|
293
|
-
except ImportError:
|
294
|
-
return _file_from_modpath(modpath, path, context)
|
295
|
-
elif modpath == ['os', 'path']:
|
296
|
-
# FIXME: currently ignoring search_path...
|
297
|
-
return os.path.__file__
|
298
|
-
return _file_from_modpath(modpath, path, context)
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
def get_module_part(dotted_name, context_file=None):
|
303
|
-
"""given a dotted name return the module part of the name :
|
304
|
-
|
305
|
-
>>> get_module_part('logilab.common.modutils.get_module_part')
|
306
|
-
'logilab.common.modutils'
|
307
|
-
|
308
|
-
:type dotted_name: str
|
309
|
-
:param dotted_name: full name of the identifier we are interested in
|
310
|
-
|
311
|
-
:type context_file: str or None
|
312
|
-
:param context_file:
|
313
|
-
context file to consider, necessary if the identifier has been
|
314
|
-
introduced using a relative import unresolvable in the actual
|
315
|
-
context (i.e. modutils)
|
316
|
-
|
317
|
-
|
318
|
-
:raise ImportError: if there is no such module in the directory
|
319
|
-
|
320
|
-
:rtype: str or None
|
321
|
-
:return:
|
322
|
-
the module part of the name or None if we have not been able at
|
323
|
-
all to import the given name
|
324
|
-
|
325
|
-
XXX: deprecated, since it doesn't handle package precedence over module
|
326
|
-
(see #10066)
|
327
|
-
"""
|
328
|
-
# os.path trick
|
329
|
-
if dotted_name.startswith('os.path'):
|
330
|
-
return 'os.path'
|
331
|
-
parts = dotted_name.split('.')
|
332
|
-
if context_file is not None:
|
333
|
-
# first check for builtin module which won't be considered latter
|
334
|
-
# in that case (path != None)
|
335
|
-
if parts[0] in BUILTIN_MODULES:
|
336
|
-
if len(parts) > 2:
|
337
|
-
raise ImportError(dotted_name)
|
338
|
-
return parts[0]
|
339
|
-
# don't use += or insert, we want a new list to be created !
|
340
|
-
path = None
|
341
|
-
starti = 0
|
342
|
-
if parts[0] == '':
|
343
|
-
assert context_file is not None, \
|
344
|
-
'explicit relative import, but no context_file?'
|
345
|
-
path = [] # prevent resolving the import non-relatively
|
346
|
-
starti = 1
|
347
|
-
while parts[starti] == '': # for all further dots: change context
|
348
|
-
starti += 1
|
349
|
-
context_file = dirname(context_file)
|
350
|
-
for i in range(starti, len(parts)):
|
351
|
-
try:
|
352
|
-
file_from_modpath(parts[starti:i+1],
|
353
|
-
path=path, context_file=context_file)
|
354
|
-
except ImportError:
|
355
|
-
if not i >= max(1, len(parts) - 2):
|
356
|
-
raise
|
357
|
-
return '.'.join(parts[:i])
|
358
|
-
return dotted_name
|
359
|
-
|
360
|
-
|
361
|
-
def get_modules(package, src_directory, blacklist=STD_BLACKLIST):
|
362
|
-
"""given a package directory return a list of all available python
|
363
|
-
modules in the package and its subpackages
|
364
|
-
|
365
|
-
:type package: str
|
366
|
-
:param package: the python name for the package
|
367
|
-
|
368
|
-
:type src_directory: str
|
369
|
-
:param src_directory:
|
370
|
-
path of the directory corresponding to the package
|
371
|
-
|
372
|
-
:type blacklist: list or tuple
|
373
|
-
:param blacklist:
|
374
|
-
optional list of files or directory to ignore, default to
|
375
|
-
the value of `logilab.common.STD_BLACKLIST`
|
376
|
-
|
377
|
-
:rtype: list
|
378
|
-
:return:
|
379
|
-
the list of all available python modules in the package and its
|
380
|
-
subpackages
|
381
|
-
"""
|
382
|
-
modules = []
|
383
|
-
for directory, dirnames, filenames in os.walk(src_directory):
|
384
|
-
_handle_blacklist(blacklist, dirnames, filenames)
|
385
|
-
# check for __init__.py
|
386
|
-
if not '__init__.py' in filenames:
|
387
|
-
dirnames[:] = ()
|
388
|
-
continue
|
389
|
-
if directory != src_directory:
|
390
|
-
dir_package = directory[len(src_directory):].replace(os.sep, '.')
|
391
|
-
modules.append(package + dir_package)
|
392
|
-
for filename in filenames:
|
393
|
-
if _is_python_file(filename) and filename != '__init__.py':
|
394
|
-
src = join(directory, filename)
|
395
|
-
module = package + src[len(src_directory):-3]
|
396
|
-
modules.append(module.replace(os.sep, '.'))
|
397
|
-
return modules
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
def get_module_files(src_directory, blacklist=STD_BLACKLIST):
|
402
|
-
"""given a package directory return a list of all available python
|
403
|
-
module's files in the package and its subpackages
|
404
|
-
|
405
|
-
:type src_directory: str
|
406
|
-
:param src_directory:
|
407
|
-
path of the directory corresponding to the package
|
408
|
-
|
409
|
-
:type blacklist: list or tuple
|
410
|
-
:param blacklist:
|
411
|
-
optional list of files or directory to ignore, default to the value of
|
412
|
-
`logilab.common.STD_BLACKLIST`
|
413
|
-
|
414
|
-
:rtype: list
|
415
|
-
:return:
|
416
|
-
the list of all available python module's files in the package and
|
417
|
-
its subpackages
|
418
|
-
"""
|
419
|
-
files = []
|
420
|
-
for directory, dirnames, filenames in os.walk(src_directory):
|
421
|
-
_handle_blacklist(blacklist, dirnames, filenames)
|
422
|
-
# check for __init__.py
|
423
|
-
if not '__init__.py' in filenames:
|
424
|
-
dirnames[:] = ()
|
425
|
-
continue
|
426
|
-
for filename in filenames:
|
427
|
-
if _is_python_file(filename):
|
428
|
-
src = join(directory, filename)
|
429
|
-
files.append(src)
|
430
|
-
return files
|
431
|
-
|
432
|
-
|
433
|
-
def get_source_file(filename, include_no_ext=False):
|
434
|
-
"""given a python module's file name return the matching source file
|
435
|
-
name (the filename will be returned identically if it's a already an
|
436
|
-
absolute path to a python source file...)
|
437
|
-
|
438
|
-
:type filename: str
|
439
|
-
:param filename: python module's file name
|
440
|
-
|
441
|
-
|
442
|
-
:raise NoSourceFile: if no source file exists on the file system
|
443
|
-
|
444
|
-
:rtype: str
|
445
|
-
:return: the absolute path of the source file if it exists
|
446
|
-
"""
|
447
|
-
base, orig_ext = splitext(abspath(filename))
|
448
|
-
for ext in PY_SOURCE_EXTS:
|
449
|
-
source_path = '%s.%s' % (base, ext)
|
450
|
-
if exists(source_path):
|
451
|
-
return source_path
|
452
|
-
if include_no_ext and not orig_ext and exists(base):
|
453
|
-
return base
|
454
|
-
raise NoSourceFile(filename)
|
455
|
-
|
456
|
-
|
457
|
-
def cleanup_sys_modules(directories):
|
458
|
-
"""remove submodules of `directories` from `sys.modules`"""
|
459
|
-
cleaned = []
|
460
|
-
for modname, module in list(sys.modules.items()):
|
461
|
-
modfile = getattr(module, '__file__', None)
|
462
|
-
if modfile:
|
463
|
-
for directory in directories:
|
464
|
-
if modfile.startswith(directory):
|
465
|
-
cleaned.append(modname)
|
466
|
-
del sys.modules[modname]
|
467
|
-
break
|
468
|
-
return cleaned
|
469
|
-
|
470
|
-
|
471
|
-
def is_python_source(filename):
|
472
|
-
"""
|
473
|
-
rtype: bool
|
474
|
-
return: True if the filename is a python source file
|
475
|
-
"""
|
476
|
-
return splitext(filename)[1][1:] in PY_SOURCE_EXTS
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
def is_standard_module(modname, std_path=(STD_LIB_DIR,)):
|
481
|
-
"""try to guess if a module is a standard python module (by default,
|
482
|
-
see `std_path` parameter's description)
|
483
|
-
|
484
|
-
:type modname: str
|
485
|
-
:param modname: name of the module we are interested in
|
486
|
-
|
487
|
-
:type std_path: list(str) or tuple(str)
|
488
|
-
:param std_path: list of path considered has standard
|
489
|
-
|
490
|
-
|
491
|
-
:rtype: bool
|
492
|
-
:return:
|
493
|
-
true if the module:
|
494
|
-
- is located on the path listed in one of the directory in `std_path`
|
495
|
-
- is a built-in module
|
496
|
-
"""
|
497
|
-
modname = modname.split('.')[0]
|
498
|
-
try:
|
499
|
-
filename = file_from_modpath([modname])
|
500
|
-
except ImportError as ex:
|
501
|
-
# import failed, i'm probably not so wrong by supposing it's
|
502
|
-
# not standard...
|
503
|
-
return 0
|
504
|
-
# modules which are not living in a file are considered standard
|
505
|
-
# (sys and __builtin__ for instance)
|
506
|
-
if filename is None:
|
507
|
-
return 1
|
508
|
-
filename = abspath(filename)
|
509
|
-
if filename.startswith(EXT_LIB_DIR):
|
510
|
-
return 0
|
511
|
-
for path in std_path:
|
512
|
-
if filename.startswith(abspath(path)):
|
513
|
-
return 1
|
514
|
-
return False
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
def is_relative(modname, from_file):
|
519
|
-
"""return true if the given module name is relative to the given
|
520
|
-
file name
|
521
|
-
|
522
|
-
:type modname: str
|
523
|
-
:param modname: name of the module we are interested in
|
524
|
-
|
525
|
-
:type from_file: str
|
526
|
-
:param from_file:
|
527
|
-
path of the module from which modname has been imported
|
528
|
-
|
529
|
-
:rtype: bool
|
530
|
-
:return:
|
531
|
-
true if the module has been imported relatively to `from_file`
|
532
|
-
"""
|
533
|
-
if not isdir(from_file):
|
534
|
-
from_file = dirname(from_file)
|
535
|
-
if from_file in sys.path:
|
536
|
-
return False
|
537
|
-
try:
|
538
|
-
find_module(modname.split('.')[0], [from_file])
|
539
|
-
return True
|
540
|
-
except ImportError:
|
541
|
-
return False
|
542
|
-
|
543
|
-
|
544
|
-
# internal only functions #####################################################
|
545
|
-
|
546
|
-
def _file_from_modpath(modpath, path=None, context=None):
|
547
|
-
"""given a mod path (i.e. splitted module / package name), return the
|
548
|
-
corresponding file
|
549
|
-
|
550
|
-
this function is used internally, see `file_from_modpath`'s
|
551
|
-
documentation for more information
|
552
|
-
"""
|
553
|
-
assert len(modpath) > 0
|
554
|
-
if context is not None:
|
555
|
-
try:
|
556
|
-
mtype, mp_filename = _module_file(modpath, [context])
|
557
|
-
except ImportError:
|
558
|
-
mtype, mp_filename = _module_file(modpath, path)
|
559
|
-
else:
|
560
|
-
mtype, mp_filename = _module_file(modpath, path)
|
561
|
-
if mtype == PY_COMPILED:
|
562
|
-
try:
|
563
|
-
return get_source_file(mp_filename)
|
564
|
-
except NoSourceFile:
|
565
|
-
return mp_filename
|
566
|
-
elif mtype == C_BUILTIN:
|
567
|
-
# integrated builtin module
|
568
|
-
return None
|
569
|
-
elif mtype == PKG_DIRECTORY:
|
570
|
-
mp_filename = _has_init(mp_filename)
|
571
|
-
return mp_filename
|
572
|
-
|
573
|
-
def _search_zip(modpath, pic):
|
574
|
-
for filepath, importer in pic.items():
|
575
|
-
if importer is not None:
|
576
|
-
if importer.find_module(modpath[0]):
|
577
|
-
if not importer.find_module('/'.join(modpath)):
|
578
|
-
raise ImportError('No module named %s in %s/%s' % (
|
579
|
-
'.'.join(modpath[1:]), filepath, modpath))
|
580
|
-
return ZIPFILE, abspath(filepath) + '/' + '/'.join(modpath), filepath
|
581
|
-
raise ImportError('No module named %s' % '.'.join(modpath))
|
582
|
-
|
583
|
-
try:
|
584
|
-
import pkg_resources
|
585
|
-
except ImportError:
|
586
|
-
pkg_resources = None
|
587
|
-
|
588
|
-
def _module_file(modpath, path=None):
|
589
|
-
"""get a module type / file path
|
590
|
-
|
591
|
-
:type modpath: list or tuple
|
592
|
-
:param modpath:
|
593
|
-
splitted module's name (i.e name of a module or package splitted
|
594
|
-
on '.'), with leading empty strings for explicit relative import
|
595
|
-
|
596
|
-
:type path: list or None
|
597
|
-
:param path:
|
598
|
-
optional list of path where the module or package should be
|
599
|
-
searched (use sys.path if nothing or None is given)
|
600
|
-
|
601
|
-
|
602
|
-
:rtype: tuple(int, str)
|
603
|
-
:return: the module type flag and the file path for a module
|
604
|
-
"""
|
605
|
-
# egg support compat
|
606
|
-
try:
|
607
|
-
pic = sys.path_importer_cache
|
608
|
-
_path = (path is None and sys.path or path)
|
609
|
-
for __path in _path:
|
610
|
-
if not __path in pic:
|
611
|
-
try:
|
612
|
-
pic[__path] = zipimport.zipimporter(__path)
|
613
|
-
except zipimport.ZipImportError:
|
614
|
-
pic[__path] = None
|
615
|
-
checkeggs = True
|
616
|
-
except AttributeError:
|
617
|
-
checkeggs = False
|
618
|
-
# pkg_resources support (aka setuptools namespace packages)
|
619
|
-
if (pkg_resources is not None
|
620
|
-
and modpath[0] in pkg_resources._namespace_packages
|
621
|
-
and modpath[0] in sys.modules
|
622
|
-
and len(modpath) > 1):
|
623
|
-
# setuptools has added into sys.modules a module object with proper
|
624
|
-
# __path__, get back information from there
|
625
|
-
module = sys.modules[modpath.pop(0)]
|
626
|
-
path = module.__path__
|
627
|
-
imported = []
|
628
|
-
while modpath:
|
629
|
-
modname = modpath[0]
|
630
|
-
# take care to changes in find_module implementation wrt builtin modules
|
631
|
-
#
|
632
|
-
# Python 2.6.6 (r266:84292, Sep 11 2012, 08:34:23)
|
633
|
-
# >>> imp.find_module('posix')
|
634
|
-
# (None, 'posix', ('', '', 6))
|
635
|
-
#
|
636
|
-
# Python 3.3.1 (default, Apr 26 2013, 12:08:46)
|
637
|
-
# >>> imp.find_module('posix')
|
638
|
-
# (None, None, ('', '', 6))
|
639
|
-
try:
|
640
|
-
_, mp_filename, mp_desc = find_module(modname, path)
|
641
|
-
except ImportError:
|
642
|
-
if checkeggs:
|
643
|
-
return _search_zip(modpath, pic)[:2]
|
644
|
-
raise
|
645
|
-
else:
|
646
|
-
if checkeggs and mp_filename:
|
647
|
-
fullabspath = [abspath(x) for x in _path]
|
648
|
-
try:
|
649
|
-
pathindex = fullabspath.index(dirname(abspath(mp_filename)))
|
650
|
-
emtype, emp_filename, zippath = _search_zip(modpath, pic)
|
651
|
-
if pathindex > _path.index(zippath):
|
652
|
-
# an egg takes priority
|
653
|
-
return emtype, emp_filename
|
654
|
-
except ValueError:
|
655
|
-
# XXX not in _path
|
656
|
-
pass
|
657
|
-
except ImportError:
|
658
|
-
pass
|
659
|
-
checkeggs = False
|
660
|
-
imported.append(modpath.pop(0))
|
661
|
-
mtype = mp_desc[2]
|
662
|
-
if modpath:
|
663
|
-
if mtype != PKG_DIRECTORY:
|
664
|
-
raise ImportError('No module %s in %s' % ('.'.join(modpath),
|
665
|
-
'.'.join(imported)))
|
666
|
-
# XXX guess if package is using pkgutil.extend_path by looking for
|
667
|
-
# those keywords in the first four Kbytes
|
668
|
-
try:
|
669
|
-
with open(join(mp_filename, '__init__.py')) as stream:
|
670
|
-
data = stream.read(4096)
|
671
|
-
except IOError:
|
672
|
-
path = [mp_filename]
|
673
|
-
else:
|
674
|
-
if 'pkgutil' in data and 'extend_path' in data:
|
675
|
-
# extend_path is called, search sys.path for module/packages
|
676
|
-
# of this name see pkgutil.extend_path documentation
|
677
|
-
path = [join(p, *imported) for p in sys.path
|
678
|
-
if isdir(join(p, *imported))]
|
679
|
-
else:
|
680
|
-
path = [mp_filename]
|
681
|
-
return mtype, mp_filename
|
682
|
-
|
683
|
-
def _is_python_file(filename):
|
684
|
-
"""return true if the given filename should be considered as a python file
|
685
|
-
|
686
|
-
.pyc and .pyo are ignored
|
687
|
-
"""
|
688
|
-
for ext in ('.py', '.so', '.pyd', '.pyw'):
|
689
|
-
if filename.endswith(ext):
|
690
|
-
return True
|
691
|
-
return False
|
692
|
-
|
693
|
-
|
694
|
-
def _has_init(directory):
|
695
|
-
"""if the given directory has a valid __init__ file, return its path,
|
696
|
-
else return None
|
697
|
-
"""
|
698
|
-
mod_or_pack = join(directory, '__init__')
|
699
|
-
for ext in PY_SOURCE_EXTS + ('pyc', 'pyo'):
|
700
|
-
if exists(mod_or_pack + '.' + ext):
|
701
|
-
return mod_or_pack + '.' + ext
|
702
|
-
return None
|