libv8 7.3.492.27.1 → 8.4.255.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +11 -14
- data/CHANGELOG.md +10 -0
- data/README.md +10 -11
- data/Rakefile +30 -36
- data/ext/libv8/builder.rb +1 -1
- data/lib/libv8/version.rb +1 -1
- data/libv8.gemspec +1 -3
- data/vendor/depot_tools/{cipd.ps1 → .cipd_impl.ps1} +0 -0
- data/vendor/depot_tools/.gitattributes +1 -1
- data/vendor/depot_tools/.gitignore +7 -2
- data/vendor/depot_tools/.style.yapf +3 -1
- data/vendor/depot_tools/.vpython +55 -0
- data/vendor/depot_tools/.vpython3 +23 -0
- data/vendor/depot_tools/CROS_OWNERS +3 -1
- data/vendor/depot_tools/GOMA_OWNERS +9 -0
- data/vendor/depot_tools/LUCI_OWNERS +5 -0
- data/vendor/depot_tools/OWNERS +21 -6
- data/vendor/depot_tools/PRESUBMIT.py +35 -18
- data/vendor/depot_tools/README.git-cl.md +0 -14
- data/vendor/depot_tools/README.md +1 -1
- data/vendor/depot_tools/WATCHLISTS +2 -2
- data/vendor/depot_tools/auth.py +60 -772
- data/vendor/depot_tools/autoninja +12 -6
- data/vendor/depot_tools/autoninja.bat +14 -6
- data/vendor/depot_tools/autoninja.py +64 -27
- data/vendor/depot_tools/bb +1 -1
- data/vendor/depot_tools/bootstrap/{win/README.md → README.md} +28 -14
- data/vendor/depot_tools/bootstrap/{win/win_tools.py → bootstrap.py} +60 -43
- data/vendor/depot_tools/bootstrap/{win/git-bash.template.sh → git-bash.template.sh} +1 -1
- data/vendor/depot_tools/bootstrap/{win/git.template.bat → git.template.bat} +0 -0
- data/vendor/depot_tools/bootstrap/manifest.txt +27 -0
- data/vendor/depot_tools/bootstrap/manifest_bleeding_edge.txt +27 -0
- data/vendor/depot_tools/bootstrap/{win/profile.d.python.sh → profile.d.python.sh} +0 -0
- data/vendor/depot_tools/bootstrap/{win/python27.bleeding_edge.bat → python27.bat} +0 -0
- data/vendor/depot_tools/bootstrap/{win/python27.new.bat → python3.bat} +3 -3
- data/vendor/depot_tools/bootstrap/{win/win_tools.bat → win_tools.bat} +21 -16
- data/vendor/depot_tools/bootstrap_python3 +35 -0
- data/vendor/depot_tools/cbuildbot +1 -1
- data/vendor/depot_tools/chrome_set_ver +1 -1
- data/vendor/depot_tools/cipd +43 -39
- data/vendor/depot_tools/cipd.bat +2 -2
- data/vendor/depot_tools/cipd_client_version +1 -1
- data/vendor/depot_tools/cipd_client_version.digests +15 -14
- data/vendor/depot_tools/cipd_manifest.txt +31 -8
- data/vendor/depot_tools/cipd_manifest.versions +278 -158
- data/vendor/depot_tools/cit.py +9 -7
- data/vendor/depot_tools/clang_format.py +4 -1
- data/vendor/depot_tools/clang_format_merge_driver.py +10 -8
- data/vendor/depot_tools/compile_single_file.py +7 -2
- data/vendor/depot_tools/cpplint.py +51 -45
- data/vendor/depot_tools/cros +87 -0
- data/vendor/depot_tools/cros_sdk +1 -1
- data/vendor/depot_tools/crosjobs +13 -0
- data/vendor/depot_tools/detect_host_arch.py +0 -1
- data/vendor/depot_tools/dirmd +12 -0
- data/vendor/depot_tools/dirmd.bat +7 -0
- data/vendor/depot_tools/download_from_google_storage.py +47 -27
- data/vendor/depot_tools/ensure_bootstrap +14 -0
- data/vendor/depot_tools/fetch +14 -1
- data/vendor/depot_tools/fetch.bat +14 -1
- data/vendor/depot_tools/fetch.py +5 -7
- data/vendor/depot_tools/fetch_configs/chromium.py +6 -4
- data/vendor/depot_tools/fetch_configs/devtools-frontend.py +44 -0
- data/vendor/depot_tools/fetch_configs/ios_internal.py +10 -19
- data/vendor/depot_tools/fix_encoding.py +19 -5
- data/vendor/depot_tools/gclient +28 -12
- data/vendor/depot_tools/gclient-new-workdir.py +2 -0
- data/vendor/depot_tools/gclient.bat +18 -1
- data/vendor/depot_tools/gclient.py +160 -119
- data/vendor/depot_tools/gclient_eval.py +119 -107
- data/vendor/depot_tools/gclient_paths.py +67 -57
- data/vendor/depot_tools/gclient_scm.py +181 -159
- data/vendor/depot_tools/gclient_utils.py +177 -124
- data/vendor/depot_tools/gerrit_client.py +21 -13
- data/vendor/depot_tools/gerrit_util.py +188 -228
- data/vendor/depot_tools/git-cache +1 -1
- data/vendor/depot_tools/git-cl +1 -1
- data/vendor/depot_tools/git-drover +1 -1
- data/vendor/depot_tools/git-find-releases +1 -1
- data/vendor/depot_tools/git-footers +1 -1
- data/vendor/depot_tools/git-freeze +1 -1
- data/vendor/depot_tools/git-hyper-blame +1 -1
- data/vendor/depot_tools/git-map +1 -1
- data/vendor/depot_tools/git-map-branches +1 -1
- data/vendor/depot_tools/git-mark-merge-base +1 -1
- data/vendor/depot_tools/git-nav-downstream +1 -1
- data/vendor/depot_tools/git-new-branch +1 -1
- data/vendor/depot_tools/git-number +1 -1
- data/vendor/depot_tools/git-rebase-update +1 -1
- data/vendor/depot_tools/git-rename-branch +1 -1
- data/vendor/depot_tools/git-reparent-branch +1 -1
- data/vendor/depot_tools/git-retry +1 -1
- data/vendor/depot_tools/git-squash-branch +1 -1
- data/vendor/depot_tools/git-thaw +1 -1
- data/vendor/depot_tools/git-upstream-diff +1 -1
- data/vendor/depot_tools/git_cache.py +255 -360
- data/vendor/depot_tools/git_cl.py +1562 -2059
- data/vendor/depot_tools/git_cl_completion.sh +16 -2
- data/vendor/depot_tools/git_common.py +77 -32
- data/vendor/depot_tools/git_drover.py +17 -8
- data/vendor/depot_tools/git_find_releases.py +11 -9
- data/vendor/depot_tools/git_footers.py +13 -9
- data/vendor/depot_tools/git_freezer.py +3 -1
- data/vendor/depot_tools/git_hyper_blame.py +25 -32
- data/vendor/depot_tools/git_map.py +115 -93
- data/vendor/depot_tools/git_map_branches.py +11 -10
- data/vendor/depot_tools/git_mark_merge_base.py +8 -6
- data/vendor/depot_tools/git_nav_downstream.py +9 -6
- data/vendor/depot_tools/git_new_branch.py +39 -33
- data/vendor/depot_tools/git_number.py +28 -17
- data/vendor/depot_tools/git_rebase_update.py +50 -49
- data/vendor/depot_tools/git_rename_branch.py +2 -2
- data/vendor/depot_tools/git_reparent_branch.py +8 -6
- data/vendor/depot_tools/git_upstream_diff.py +4 -2
- data/vendor/depot_tools/gn.py +6 -4
- data/vendor/depot_tools/goma_auth +12 -0
- data/vendor/depot_tools/goma_auth.bat +8 -0
- data/vendor/depot_tools/goma_ctl +12 -0
- data/vendor/depot_tools/goma_ctl.bat +8 -0
- data/vendor/depot_tools/gsutil.py +5 -2
- data/vendor/depot_tools/gsutil.py.bat +8 -0
- data/vendor/depot_tools/gsutil.vpython +3 -1
- data/vendor/depot_tools/infra/config/OWNERS +2 -2
- data/vendor/depot_tools/infra/config/recipes.cfg +3 -2
- data/vendor/depot_tools/led +1 -1
- data/vendor/depot_tools/lockfile.py +116 -0
- data/vendor/depot_tools/luci-auth +1 -1
- data/vendor/depot_tools/lucicfg +1 -1
- data/vendor/depot_tools/mac_toolchain +1 -1
- data/vendor/depot_tools/man/html/depot_tools.html +1 -1
- data/vendor/depot_tools/man/html/depot_tools_tutorial.html +31 -25
- data/vendor/depot_tools/man/html/git-cl.html +1 -1
- data/vendor/depot_tools/man/html/git-drover.html +18 -18
- data/vendor/depot_tools/man/html/git-footers.html +1 -1
- data/vendor/depot_tools/man/html/git-freeze.html +3 -3
- data/vendor/depot_tools/man/html/git-hyper-blame.html +1 -1
- data/vendor/depot_tools/man/html/git-map-branches.html +2 -2
- data/vendor/depot_tools/man/html/git-map.html +1 -1
- data/vendor/depot_tools/man/html/git-mark-merge-base.html +1 -1
- data/vendor/depot_tools/man/html/git-nav-downstream.html +3 -3
- data/vendor/depot_tools/man/html/git-nav-upstream.html +12 -6
- data/vendor/depot_tools/man/html/git-new-branch.html +1 -1
- data/vendor/depot_tools/man/html/git-rebase-update.html +20 -1
- data/vendor/depot_tools/man/html/git-rename-branch.html +1 -1
- data/vendor/depot_tools/man/html/git-reparent-branch.html +1 -1
- data/vendor/depot_tools/man/html/git-retry.html +1 -1
- data/vendor/depot_tools/man/html/git-squash-branch.html +1 -1
- data/vendor/depot_tools/man/html/git-thaw.html +1 -1
- data/vendor/depot_tools/man/html/git-upstream-diff.html +10 -6
- data/vendor/depot_tools/man/man1/git-cl.1 +4 -4
- data/vendor/depot_tools/man/man1/git-drover.1 +21 -21
- data/vendor/depot_tools/man/man1/git-footers.1 +4 -4
- data/vendor/depot_tools/man/man1/git-freeze.1 +6 -6
- data/vendor/depot_tools/man/man1/git-hyper-blame.1 +4 -4
- data/vendor/depot_tools/man/man1/git-map-branches.1 +4 -4
- data/vendor/depot_tools/man/man1/git-map.1 +4 -4
- data/vendor/depot_tools/man/man1/git-mark-merge-base.1 +4 -4
- data/vendor/depot_tools/man/man1/git-nav-downstream.1 +6 -6
- data/vendor/depot_tools/man/man1/git-nav-upstream.1 +15 -9
- data/vendor/depot_tools/man/man1/git-new-branch.1 +3 -3
- data/vendor/depot_tools/man/man1/git-rebase-update.1 +14 -4
- data/vendor/depot_tools/man/man1/git-rename-branch.1 +4 -4
- data/vendor/depot_tools/man/man1/git-reparent-branch.1 +4 -4
- data/vendor/depot_tools/man/man1/git-retry.1 +4 -4
- data/vendor/depot_tools/man/man1/git-squash-branch.1 +4 -4
- data/vendor/depot_tools/man/man1/git-thaw.1 +4 -4
- data/vendor/depot_tools/man/man1/git-upstream-diff.1 +7 -13
- data/vendor/depot_tools/man/man7/depot_tools.7 +4 -4
- data/vendor/depot_tools/man/man7/depot_tools_tutorial.7 +31 -25
- data/vendor/depot_tools/man/src/common_demo_functions.sh +2 -2
- data/vendor/depot_tools/man/src/depot_tools_tutorial.txt +3 -3
- data/vendor/depot_tools/man/src/filter_demo_output.py +4 -2
- data/vendor/depot_tools/man/src/git-new-branch.txt +2 -1
- data/vendor/depot_tools/man/src/git-rebase-update.txt +8 -1
- data/vendor/depot_tools/metrics.README.md +8 -5
- data/vendor/depot_tools/metrics.py +7 -6
- data/vendor/depot_tools/metrics_utils.py +4 -14
- data/vendor/depot_tools/my_activity.py +85 -251
- data/vendor/depot_tools/ninja +1 -0
- data/vendor/depot_tools/ninja-mac +0 -0
- data/vendor/depot_tools/ninjalog_uploader.py +146 -145
- data/vendor/depot_tools/ninjalog_uploader_wrapper.py +69 -60
- data/vendor/depot_tools/owners.py +156 -43
- data/vendor/depot_tools/owners_finder.py +28 -14
- data/vendor/depot_tools/post_build_ninja_summary.py +76 -48
- data/vendor/depot_tools/presubmit_canned_checks.py +293 -106
- data/vendor/depot_tools/presubmit_support.py +527 -333
- data/vendor/depot_tools/prpc +1 -1
- data/vendor/depot_tools/pylint +2 -12
- data/vendor/depot_tools/pylint-1.5 +78 -0
- data/vendor/depot_tools/pylint-1.6 +78 -0
- data/vendor/depot_tools/pylint-1.7 +78 -0
- data/vendor/depot_tools/pylint-1.8 +78 -0
- data/vendor/depot_tools/pylint-1.9 +78 -0
- data/vendor/depot_tools/{depot-tools-auth.bat → pylint.bat} +2 -2
- data/vendor/depot_tools/pylint_main.py +45 -0
- data/vendor/depot_tools/pylintrc +14 -1
- data/vendor/depot_tools/python-bin/python3 +7 -0
- data/vendor/depot_tools/python_runner.sh +13 -8
- data/vendor/depot_tools/rdb +12 -0
- data/vendor/depot_tools/rdb.bat +7 -0
- data/vendor/depot_tools/recipes/OWNERS +0 -1
- data/vendor/depot_tools/recipes/README.recipes.md +218 -151
- data/vendor/depot_tools/recipes/recipe_modules/OWNERS +1 -1
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/__init__.py +17 -16
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/api.py +127 -78
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic.json +19 -4
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic_luci.json +18 -3
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic_with_branch_heads.json +19 -4
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/clobber.json +29 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/deprecated_got_revision_mapping.json +28 -10
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/gerrit_no_rebase_patch_ref.json +29 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/gerrit_no_reset.json +29 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/input_commit_with_id_without_repo.json +29 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/multiple_patch_refs.json +29 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_apply_patch_on_gclient.json +35 -10
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/{with_manifest_name.json → no_cp_checkout_HEAD.json} +25 -15
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_cp_checkout_a_branch_head.json +65 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_cp_checkout_a_specific_commit.json +65 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_cp_checkout_master.json +65 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/refs.json +29 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/reset_root_solution_revision.json +29 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/resolve_chromium_fixed_version.json +117 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail.json +17 -11
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch.json +41 -10
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch_download.json +24 -11
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_angle.json +35 -10
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_branch_heads.json +35 -10
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_feature_branch.json +38 -11
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8_feature_branch.json +36 -11
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_webrtc.json +35 -10
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8.json +35 -10
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8_head_by_default.json +35 -10
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/unrecognized_commit_repo.json +0 -5
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_tags.json +29 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.py +95 -22
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/resources/bot_update.py +187 -114
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/test_api.py +2 -2
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/tests/do_not_retry_patch_failures_in_cq.py +42 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/tests/ensure_checkout.py +1 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/__init__.py +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/api.py +2 -2
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/basic.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/basic_pkg.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/describe-failed.json +2 -4
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/describe-many-instances.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/mac64.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_file.json +26 -6
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_mode.json +23 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_verfile.json +23 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/win64.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/junk arch.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/junk bits.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_arm_32.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_arm_64.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_intel_32.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_intel_64.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_mips_64.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/mac_intel_64.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/win_intel_32.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/win_intel_64.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/test_api.py +1 -1
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/api.py +4 -1
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/basic.json +4 -2
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/basic_luci.json +3 -1
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/win.json +4 -2
- data/vendor/depot_tools/recipes/recipe_modules/gclient/__init__.py +2 -1
- data/vendor/depot_tools/recipes/recipe_modules/gclient/api.py +82 -13
- data/vendor/depot_tools/recipes/recipe_modules/gclient/config.py +23 -11
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/basic.json +3 -4
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/revision.json +3 -6
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/tryserver.json +3 -4
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.py +7 -7
- data/vendor/depot_tools/recipes/recipe_modules/gclient/resources/diff_deps.py +16 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/test_api.py +4 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/diff_deps.expected/basic.json +55 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/diff_deps.expected/dont have revision yet.json +84 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/diff_deps.expected/no change, exception.json +83 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/diff_deps.expected/windows.json +55 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/diff_deps.py +88 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/patch_project.py +9 -21
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/sync_failure.py +24 -0
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/api.py +2 -1
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/examples/full.expected/basic.json +7 -12
- data/vendor/depot_tools/recipes/recipe_modules/git/__init__.py +0 -2
- data/vendor/depot_tools/recipes/recipe_modules/git/api.py +9 -17
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_branch.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_file_name.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_hash.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_ref.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_submodule_update_force.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_tags.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/can_fail_build.json +3 -13
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/cannot_fail_build.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/cat-file_test.json +4 -12
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_delta.json +2 -10
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_failed.json +1 -7
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_with_bad_output.json +1 -7
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_with_bad_output_fails_build.json +0 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/curl_trace_file.json +3 -10
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/git-cache-checkout.json +3 -11
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/platform_win.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/rebase_failed.json +3 -13
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/remote_not_origin.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/set_got_revision.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.py +0 -5
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/__init__.py +1 -1
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/api.py +7 -13
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/examples/full.expected/basic.json +21 -16
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/examples/full.py +1 -2
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/api.py +1 -1
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/examples/full.expected/basic.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/resources/gerrit_client.py +2 -2
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/tests/parse_repo_url.expected/basic.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/gsutil/api.py +23 -8
- data/vendor/depot_tools/recipes/recipe_modules/gsutil/examples/full.expected/basic.json +52 -1
- data/vendor/depot_tools/recipes/recipe_modules/gsutil/examples/full.py +15 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/__init__.py +1 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/api.py +32 -8
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/ancient_version.json +83 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/automatic_version.json +83 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/explicit_version.json +83 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/linux.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/mac.json +5 -4
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/win.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.py +21 -2
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/__init__.py +20 -0
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/api.py +235 -3
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/examples/full.expected/basic.json +13 -5
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/examples/full.py +5 -1
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/properties.proto +14 -0
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/test_api.py +19 -0
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/tests/execute.py +247 -0
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/tests/prepare.py +49 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/api.py +33 -45
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/basic_tags.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch.json +64 -21
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch_and_target_ref.json +64 -21
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_wrong_patch.json +1 -22
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_wrong_patch_new.json +1 -22
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.py +5 -32
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/tests/gerrit_change_fetch_ref_timeout.py +29 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/tests/gerrit_change_owner.expected/basic.json +5 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/tests/gerrit_change_owner.py +22 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/tests/gerrit_change_target_ref.py +32 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/linux.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/mac.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/win.json +2 -1
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.py +1 -6
- data/vendor/depot_tools/recipes/recipes.py +49 -28
- data/vendor/depot_tools/recipes/recipes/fetch_end_to_end_test.expected/basic.json +11 -6
- data/vendor/depot_tools/repo +698 -540
- data/vendor/depot_tools/roll-dep +14 -1
- data/vendor/depot_tools/roll-dep.bat +10 -1
- data/vendor/depot_tools/roll_dep.py +15 -10
- data/vendor/depot_tools/scm.py +95 -75
- data/vendor/depot_tools/setup_color.py +36 -2
- data/vendor/depot_tools/split_cl.py +44 -32
- data/vendor/depot_tools/subcommand.py +6 -6
- data/vendor/depot_tools/subprocess2.py +38 -322
- data/vendor/depot_tools/third_party/colorama/LICENSE.txt +0 -1
- data/vendor/depot_tools/third_party/colorama/README.chromium +4 -5
- data/vendor/depot_tools/third_party/colorama/README.rst +346 -0
- data/vendor/depot_tools/third_party/colorama/__init__.py +3 -4
- data/vendor/depot_tools/third_party/colorama/ansi.py +82 -30
- data/vendor/depot_tools/third_party/colorama/ansitowin32.py +105 -37
- data/vendor/depot_tools/third_party/colorama/initialise.py +39 -15
- data/vendor/depot_tools/third_party/colorama/win32.py +46 -28
- data/vendor/depot_tools/third_party/colorama/winterm.py +80 -31
- data/vendor/depot_tools/update_depot_tools +18 -8
- data/vendor/depot_tools/update_depot_tools.bat +19 -15
- data/vendor/depot_tools/upload_metrics.py +7 -6
- data/vendor/depot_tools/upload_to_google_storage.py +23 -16
- data/vendor/depot_tools/vpython +4 -4
- data/vendor/depot_tools/vpython.bat +1 -1
- data/vendor/depot_tools/vpython3 +55 -0
- data/vendor/depot_tools/vpython3.bat +12 -0
- data/vendor/depot_tools/watchlists.py +14 -11
- data/vendor/depot_tools/weekly +4 -2
- data/vendor/depot_tools/win32imports.py +61 -0
- data/vendor/depot_tools/win_toolchain/get_toolchain_if_necessary.py +49 -41
- data/vendor/depot_tools/win_toolchain/package_from_installed.py +142 -149
- data/vendor/depot_tools/wtf +5 -3
- data/vendor/depot_tools/yapf +5 -1
- metadata +68 -343
- data/vendor/depot_tools/README.testing +0 -23
- data/vendor/depot_tools/annotated_gclient.py +0 -89
- data/vendor/depot_tools/appengine_mapper.py +0 -23
- data/vendor/depot_tools/bootstrap/win/manifest.txt +0 -20
- data/vendor/depot_tools/bootstrap/win/manifest_bleeding_edge.txt +0 -20
- data/vendor/depot_tools/bootstrap/win/pylint.new.bat +0 -7
- data/vendor/depot_tools/buildbucket.py +0 -186
- data/vendor/depot_tools/checkout.py +0 -431
- data/vendor/depot_tools/cros +0 -1
- data/vendor/depot_tools/dart_format.py +0 -58
- data/vendor/depot_tools/depot-tools-auth +0 -8
- data/vendor/depot_tools/depot-tools-auth.py +0 -102
- data/vendor/depot_tools/my_reviews.py +0 -396
- data/vendor/depot_tools/patch.py +0 -548
- data/vendor/depot_tools/pylint.py +0 -30
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/buildbot.json +0 -239
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_luci.json +0 -222
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/__init__.py +0 -4
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/api.py +0 -29
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/basic.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_linux.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_mac.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_win.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_linux.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_mac.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_win.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_linux.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_mac.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_win.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.py +0 -33
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/path_config.py +0 -66
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/set_failure_hash_with_no_steps.json +0 -11
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_git_patch.json +0 -45
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_git_patch_luci.json +0 -45
- data/vendor/depot_tools/rietveld.py +0 -779
- data/vendor/depot_tools/roll-dep-svn +0 -8
- data/vendor/depot_tools/roll-dep-svn.bat +0 -12
- data/vendor/depot_tools/roll_dep_svn.py +0 -430
- data/vendor/depot_tools/support/chromite_wrapper +0 -96
- data/vendor/depot_tools/third_party/boto/LICENSE +0 -18
- data/vendor/depot_tools/third_party/boto/README.chromium +0 -43
- data/vendor/depot_tools/third_party/boto/README.rst +0 -163
- data/vendor/depot_tools/third_party/boto/__init__.py +0 -793
- data/vendor/depot_tools/third_party/boto/auth.py +0 -682
- data/vendor/depot_tools/third_party/boto/auth_handler.py +0 -58
- data/vendor/depot_tools/third_party/boto/cacerts/__init__.py +0 -22
- data/vendor/depot_tools/third_party/boto/cacerts/cacerts.txt +0 -2183
- data/vendor/depot_tools/third_party/boto/compat.py +0 -28
- data/vendor/depot_tools/third_party/boto/connection.py +0 -1081
- data/vendor/depot_tools/third_party/boto/contrib/__init__.py +0 -22
- data/vendor/depot_tools/third_party/boto/contrib/ymlmessage.py +0 -52
- data/vendor/depot_tools/third_party/boto/core/README +0 -58
- data/vendor/depot_tools/third_party/boto/core/__init__.py +0 -23
- data/vendor/depot_tools/third_party/boto/core/auth.py +0 -78
- data/vendor/depot_tools/third_party/boto/core/credentials.py +0 -154
- data/vendor/depot_tools/third_party/boto/core/dictresponse.py +0 -178
- data/vendor/depot_tools/third_party/boto/core/service.py +0 -67
- data/vendor/depot_tools/third_party/boto/datapipeline/__init__.py +0 -0
- data/vendor/depot_tools/third_party/boto/datapipeline/exceptions.py +0 -42
- data/vendor/depot_tools/third_party/boto/datapipeline/layer1.py +0 -546
- data/vendor/depot_tools/third_party/boto/ecs/__init__.py +0 -90
- data/vendor/depot_tools/third_party/boto/ecs/item.py +0 -153
- data/vendor/depot_tools/third_party/boto/exception.py +0 -476
- data/vendor/depot_tools/third_party/boto/file/README +0 -49
- data/vendor/depot_tools/third_party/boto/file/__init__.py +0 -28
- data/vendor/depot_tools/third_party/boto/file/bucket.py +0 -112
- data/vendor/depot_tools/third_party/boto/file/connection.py +0 -33
- data/vendor/depot_tools/third_party/boto/file/key.py +0 -199
- data/vendor/depot_tools/third_party/boto/file/simpleresultset.py +0 -30
- data/vendor/depot_tools/third_party/boto/fps/__init__.py +0 -21
- data/vendor/depot_tools/third_party/boto/fps/connection.py +0 -369
- data/vendor/depot_tools/third_party/boto/fps/exception.py +0 -344
- data/vendor/depot_tools/third_party/boto/fps/response.py +0 -175
- data/vendor/depot_tools/third_party/boto/gs/__init__.py +0 -22
- data/vendor/depot_tools/third_party/boto/gs/acl.py +0 -304
- data/vendor/depot_tools/third_party/boto/gs/bucket.py +0 -870
- data/vendor/depot_tools/third_party/boto/gs/bucketlistresultset.py +0 -64
- data/vendor/depot_tools/third_party/boto/gs/connection.py +0 -103
- data/vendor/depot_tools/third_party/boto/gs/cors.py +0 -169
- data/vendor/depot_tools/third_party/boto/gs/key.py +0 -704
- data/vendor/depot_tools/third_party/boto/gs/resumable_upload_handler.py +0 -659
- data/vendor/depot_tools/third_party/boto/gs/user.py +0 -54
- data/vendor/depot_tools/third_party/boto/handler.py +0 -44
- data/vendor/depot_tools/third_party/boto/https_connection.py +0 -124
- data/vendor/depot_tools/third_party/boto/jsonresponse.py +0 -163
- data/vendor/depot_tools/third_party/boto/manage/__init__.py +0 -23
- data/vendor/depot_tools/third_party/boto/manage/cmdshell.py +0 -241
- data/vendor/depot_tools/third_party/boto/manage/propget.py +0 -64
- data/vendor/depot_tools/third_party/boto/manage/server.py +0 -556
- data/vendor/depot_tools/third_party/boto/manage/task.py +0 -175
- data/vendor/depot_tools/third_party/boto/manage/test_manage.py +0 -34
- data/vendor/depot_tools/third_party/boto/manage/volume.py +0 -420
- data/vendor/depot_tools/third_party/boto/mashups/__init__.py +0 -23
- data/vendor/depot_tools/third_party/boto/mashups/interactive.py +0 -97
- data/vendor/depot_tools/third_party/boto/mashups/iobject.py +0 -115
- data/vendor/depot_tools/third_party/boto/mashups/order.py +0 -211
- data/vendor/depot_tools/third_party/boto/mashups/server.py +0 -395
- data/vendor/depot_tools/third_party/boto/plugin.py +0 -90
- data/vendor/depot_tools/third_party/boto/provider.py +0 -337
- data/vendor/depot_tools/third_party/boto/pyami/__init__.py +0 -22
- data/vendor/depot_tools/third_party/boto/pyami/bootstrap.py +0 -134
- data/vendor/depot_tools/third_party/boto/pyami/config.py +0 -229
- data/vendor/depot_tools/third_party/boto/pyami/copybot.cfg +0 -60
- data/vendor/depot_tools/third_party/boto/pyami/copybot.py +0 -97
- data/vendor/depot_tools/third_party/boto/pyami/helloworld.py +0 -28
- data/vendor/depot_tools/third_party/boto/pyami/launch_ami.py +0 -178
- data/vendor/depot_tools/third_party/boto/pyami/scriptbase.py +0 -44
- data/vendor/depot_tools/third_party/boto/pyami/startup.py +0 -60
- data/vendor/depot_tools/third_party/boto/regioninfo.py +0 -63
- data/vendor/depot_tools/third_party/boto/resultset.py +0 -169
- data/vendor/depot_tools/third_party/boto/roboto/__init__.py +0 -1
- data/vendor/depot_tools/third_party/boto/roboto/awsqueryrequest.py +0 -504
- data/vendor/depot_tools/third_party/boto/roboto/awsqueryservice.py +0 -121
- data/vendor/depot_tools/third_party/boto/roboto/param.py +0 -147
- data/vendor/depot_tools/third_party/boto/s3/__init__.py +0 -84
- data/vendor/depot_tools/third_party/boto/s3/acl.py +0 -164
- data/vendor/depot_tools/third_party/boto/s3/bucket.py +0 -1634
- data/vendor/depot_tools/third_party/boto/s3/bucketlistresultset.py +0 -139
- data/vendor/depot_tools/third_party/boto/s3/bucketlogging.py +0 -83
- data/vendor/depot_tools/third_party/boto/s3/connection.py +0 -540
- data/vendor/depot_tools/third_party/boto/s3/cors.py +0 -210
- data/vendor/depot_tools/third_party/boto/s3/deletemarker.py +0 -55
- data/vendor/depot_tools/third_party/boto/s3/key.py +0 -1712
- data/vendor/depot_tools/third_party/boto/s3/keyfile.py +0 -134
- data/vendor/depot_tools/third_party/boto/s3/lifecycle.py +0 -231
- data/vendor/depot_tools/third_party/boto/s3/multidelete.py +0 -138
- data/vendor/depot_tools/third_party/boto/s3/multipart.py +0 -315
- data/vendor/depot_tools/third_party/boto/s3/prefix.py +0 -42
- data/vendor/depot_tools/third_party/boto/s3/resumable_download_handler.py +0 -339
- data/vendor/depot_tools/third_party/boto/s3/tagging.py +0 -71
- data/vendor/depot_tools/third_party/boto/s3/user.py +0 -49
- data/vendor/depot_tools/third_party/boto/s3/website.py +0 -237
- data/vendor/depot_tools/third_party/boto/services/__init__.py +0 -23
- data/vendor/depot_tools/third_party/boto/services/bs.py +0 -179
- data/vendor/depot_tools/third_party/boto/services/message.py +0 -58
- data/vendor/depot_tools/third_party/boto/services/result.py +0 -136
- data/vendor/depot_tools/third_party/boto/services/service.py +0 -161
- data/vendor/depot_tools/third_party/boto/services/servicedef.py +0 -91
- data/vendor/depot_tools/third_party/boto/services/sonofmmm.cfg +0 -43
- data/vendor/depot_tools/third_party/boto/services/sonofmmm.py +0 -81
- data/vendor/depot_tools/third_party/boto/services/submit.py +0 -88
- data/vendor/depot_tools/third_party/boto/ses/__init__.py +0 -54
- data/vendor/depot_tools/third_party/boto/ses/connection.py +0 -521
- data/vendor/depot_tools/third_party/boto/ses/exceptions.py +0 -77
- data/vendor/depot_tools/third_party/boto/storage_uri.py +0 -835
- data/vendor/depot_tools/third_party/boto/sts/__init__.py +0 -55
- data/vendor/depot_tools/third_party/boto/sts/connection.py +0 -207
- data/vendor/depot_tools/third_party/boto/sts/credentials.py +0 -215
- data/vendor/depot_tools/third_party/boto/utils.py +0 -927
- data/vendor/depot_tools/third_party/colorama/README.txt +0 -304
- data/vendor/depot_tools/third_party/fancy_urllib/README +0 -22
- data/vendor/depot_tools/third_party/fancy_urllib/__init__.py +0 -460
- data/vendor/depot_tools/third_party/logilab/README.chromium +0 -6
- data/vendor/depot_tools/third_party/logilab/__init__.py +0 -0
- data/vendor/depot_tools/third_party/logilab/astroid/LICENSE.txt +0 -340
- data/vendor/depot_tools/third_party/logilab/astroid/README.chromium +0 -11
- data/vendor/depot_tools/third_party/logilab/astroid/__init__.py +0 -136
- data/vendor/depot_tools/third_party/logilab/astroid/__pkginfo__.py +0 -42
- data/vendor/depot_tools/third_party/logilab/astroid/arguments.py +0 -233
- data/vendor/depot_tools/third_party/logilab/astroid/as_string.py +0 -548
- data/vendor/depot_tools/third_party/logilab/astroid/astpeephole.py +0 -86
- data/vendor/depot_tools/third_party/logilab/astroid/bases.py +0 -636
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_builtin_inference.py +0 -336
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_dateutil.py +0 -15
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_gi.py +0 -195
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_mechanize.py +0 -18
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_nose.py +0 -82
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_numpy.py +0 -62
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_pytest.py +0 -76
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_qt.py +0 -44
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_six.py +0 -288
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_ssl.py +0 -65
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_stdlib.py +0 -473
- data/vendor/depot_tools/third_party/logilab/astroid/builder.py +0 -263
- data/vendor/depot_tools/third_party/logilab/astroid/context.py +0 -81
- data/vendor/depot_tools/third_party/logilab/astroid/decorators.py +0 -75
- data/vendor/depot_tools/third_party/logilab/astroid/exceptions.py +0 -71
- data/vendor/depot_tools/third_party/logilab/astroid/inference.py +0 -359
- data/vendor/depot_tools/third_party/logilab/astroid/manager.py +0 -267
- data/vendor/depot_tools/third_party/logilab/astroid/mixins.py +0 -147
- data/vendor/depot_tools/third_party/logilab/astroid/modutils.py +0 -741
- data/vendor/depot_tools/third_party/logilab/astroid/node_classes.py +0 -1053
- data/vendor/depot_tools/third_party/logilab/astroid/nodes.py +0 -87
- data/vendor/depot_tools/third_party/logilab/astroid/objects.py +0 -186
- data/vendor/depot_tools/third_party/logilab/astroid/protocols.py +0 -470
- data/vendor/depot_tools/third_party/logilab/astroid/raw_building.py +0 -390
- data/vendor/depot_tools/third_party/logilab/astroid/rebuilder.py +0 -989
- data/vendor/depot_tools/third_party/logilab/astroid/scoped_nodes.py +0 -1716
- data/vendor/depot_tools/third_party/logilab/astroid/test_utils.py +0 -201
- data/vendor/depot_tools/third_party/logilab/astroid/transforms.py +0 -96
- data/vendor/depot_tools/third_party/logilab/astroid/util.py +0 -89
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/LICENSE +0 -19
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/README.chromium +0 -11
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/__init__.py +0 -20
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/cext.c +0 -1421
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/compat.py +0 -9
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/simple.py +0 -246
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/slots.py +0 -414
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/utils.py +0 -13
- data/vendor/depot_tools/third_party/logilab/wrapt/LICENSE +0 -24
- data/vendor/depot_tools/third_party/logilab/wrapt/README.chromium +0 -11
- data/vendor/depot_tools/third_party/logilab/wrapt/__init__.py +0 -19
- data/vendor/depot_tools/third_party/logilab/wrapt/_wrappers.c +0 -2729
- data/vendor/depot_tools/third_party/logilab/wrapt/arguments.py +0 -96
- data/vendor/depot_tools/third_party/logilab/wrapt/decorators.py +0 -512
- data/vendor/depot_tools/third_party/logilab/wrapt/importer.py +0 -228
- data/vendor/depot_tools/third_party/logilab/wrapt/wrappers.py +0 -901
- data/vendor/depot_tools/third_party/mock/LICENSE.txt +0 -26
- data/vendor/depot_tools/third_party/mock/README.chromium +0 -24
- data/vendor/depot_tools/third_party/mock/__init__.py +0 -2366
- data/vendor/depot_tools/third_party/oauth2client/LICENSE +0 -202
- data/vendor/depot_tools/third_party/oauth2client/MODIFICATIONS.diff +0 -66
- data/vendor/depot_tools/third_party/oauth2client/README.chromium +0 -15
- data/vendor/depot_tools/third_party/oauth2client/__init__.py +0 -5
- data/vendor/depot_tools/third_party/oauth2client/anyjson.py +0 -32
- data/vendor/depot_tools/third_party/oauth2client/appengine.py +0 -963
- data/vendor/depot_tools/third_party/oauth2client/client.py +0 -1363
- data/vendor/depot_tools/third_party/oauth2client/clientsecrets.py +0 -153
- data/vendor/depot_tools/third_party/oauth2client/crypt.py +0 -377
- data/vendor/depot_tools/third_party/oauth2client/django_orm.py +0 -134
- data/vendor/depot_tools/third_party/oauth2client/file.py +0 -124
- data/vendor/depot_tools/third_party/oauth2client/gce.py +0 -90
- data/vendor/depot_tools/third_party/oauth2client/keyring_storage.py +0 -109
- data/vendor/depot_tools/third_party/oauth2client/locked_file.py +0 -373
- data/vendor/depot_tools/third_party/oauth2client/multistore_file.py +0 -465
- data/vendor/depot_tools/third_party/oauth2client/old_run.py +0 -160
- data/vendor/depot_tools/third_party/oauth2client/tools.py +0 -243
- data/vendor/depot_tools/third_party/oauth2client/util.py +0 -196
- data/vendor/depot_tools/third_party/oauth2client/xsrfutil.py +0 -113
- data/vendor/depot_tools/third_party/protobuf26/README.chromium +0 -23
- data/vendor/depot_tools/third_party/protobuf26/__init__.py +0 -0
- data/vendor/depot_tools/third_party/protobuf26/compiler/__init__.py +0 -0
- data/vendor/depot_tools/third_party/protobuf26/compiler/plugin_pb2.py +0 -184
- data/vendor/depot_tools/third_party/protobuf26/descriptor.py +0 -849
- data/vendor/depot_tools/third_party/protobuf26/descriptor_database.py +0 -137
- data/vendor/depot_tools/third_party/protobuf26/descriptor_pb2.py +0 -1522
- data/vendor/depot_tools/third_party/protobuf26/descriptor_pool.py +0 -643
- data/vendor/depot_tools/third_party/protobuf26/internal/__init__.py +0 -0
- data/vendor/depot_tools/third_party/protobuf26/internal/api_implementation.py +0 -89
- data/vendor/depot_tools/third_party/protobuf26/internal/containers.py +0 -269
- data/vendor/depot_tools/third_party/protobuf26/internal/cpp_message.py +0 -663
- data/vendor/depot_tools/third_party/protobuf26/internal/decoder.py +0 -831
- data/vendor/depot_tools/third_party/protobuf26/internal/encoder.py +0 -788
- data/vendor/depot_tools/third_party/protobuf26/internal/enum_type_wrapper.py +0 -89
- data/vendor/depot_tools/third_party/protobuf26/internal/message_listener.py +0 -78
- data/vendor/depot_tools/third_party/protobuf26/internal/python_message.py +0 -1247
- data/vendor/depot_tools/third_party/protobuf26/internal/type_checkers.py +0 -328
- data/vendor/depot_tools/third_party/protobuf26/internal/wire_format.py +0 -268
- data/vendor/depot_tools/third_party/protobuf26/message.py +0 -284
- data/vendor/depot_tools/third_party/protobuf26/message_factory.py +0 -155
- data/vendor/depot_tools/third_party/protobuf26/reflection.py +0 -205
- data/vendor/depot_tools/third_party/protobuf26/service.py +0 -226
- data/vendor/depot_tools/third_party/protobuf26/service_reflection.py +0 -284
- data/vendor/depot_tools/third_party/protobuf26/symbol_database.py +0 -185
- data/vendor/depot_tools/third_party/protobuf26/text_encoding.py +0 -110
- data/vendor/depot_tools/third_party/protobuf26/text_format.py +0 -873
- data/vendor/depot_tools/third_party/pylint.py +0 -37
- data/vendor/depot_tools/third_party/pylint/LICENSE.txt +0 -340
- data/vendor/depot_tools/third_party/pylint/README.chromium +0 -30
- data/vendor/depot_tools/third_party/pylint/__init__.py +0 -46
- data/vendor/depot_tools/third_party/pylint/__main__.py +0 -3
- data/vendor/depot_tools/third_party/pylint/__pkginfo__.py +0 -80
- data/vendor/depot_tools/third_party/pylint/checkers/__init__.py +0 -123
- data/vendor/depot_tools/third_party/pylint/checkers/async.py +0 -82
- data/vendor/depot_tools/third_party/pylint/checkers/base.py +0 -2010
- data/vendor/depot_tools/third_party/pylint/checkers/classes.py +0 -1120
- data/vendor/depot_tools/third_party/pylint/checkers/design_analysis.py +0 -348
- data/vendor/depot_tools/third_party/pylint/checkers/exceptions.py +0 -369
- data/vendor/depot_tools/third_party/pylint/checkers/format.py +0 -993
- data/vendor/depot_tools/third_party/pylint/checkers/imports.py +0 -654
- data/vendor/depot_tools/third_party/pylint/checkers/logging.py +0 -258
- data/vendor/depot_tools/third_party/pylint/checkers/misc.py +0 -105
- data/vendor/depot_tools/third_party/pylint/checkers/newstyle.py +0 -169
- data/vendor/depot_tools/third_party/pylint/checkers/python3.py +0 -591
- data/vendor/depot_tools/third_party/pylint/checkers/raw_metrics.py +0 -129
- data/vendor/depot_tools/third_party/pylint/checkers/similar.py +0 -371
- data/vendor/depot_tools/third_party/pylint/checkers/spelling.py +0 -264
- data/vendor/depot_tools/third_party/pylint/checkers/stdlib.py +0 -280
- data/vendor/depot_tools/third_party/pylint/checkers/strings.py +0 -618
- data/vendor/depot_tools/third_party/pylint/checkers/typecheck.py +0 -974
- data/vendor/depot_tools/third_party/pylint/checkers/utils.py +0 -741
- data/vendor/depot_tools/third_party/pylint/checkers/variables.py +0 -1191
- data/vendor/depot_tools/third_party/pylint/config.py +0 -820
- data/vendor/depot_tools/third_party/pylint/epylint.py +0 -181
- data/vendor/depot_tools/third_party/pylint/extensions/__init__.py +0 -0
- data/vendor/depot_tools/third_party/pylint/extensions/check_docs.py +0 -311
- data/vendor/depot_tools/third_party/pylint/extensions/check_elif.py +0 -62
- data/vendor/depot_tools/third_party/pylint/graph.py +0 -179
- data/vendor/depot_tools/third_party/pylint/gui.py +0 -531
- data/vendor/depot_tools/third_party/pylint/interfaces.py +0 -102
- data/vendor/depot_tools/third_party/pylint/lint.py +0 -1381
- data/vendor/depot_tools/third_party/pylint/pyreverse/__init__.py +0 -5
- data/vendor/depot_tools/third_party/pylint/pyreverse/diadefslib.py +0 -230
- data/vendor/depot_tools/third_party/pylint/pyreverse/diagrams.py +0 -258
- data/vendor/depot_tools/third_party/pylint/pyreverse/inspector.py +0 -372
- data/vendor/depot_tools/third_party/pylint/pyreverse/main.py +0 -147
- data/vendor/depot_tools/third_party/pylint/pyreverse/utils.py +0 -210
- data/vendor/depot_tools/third_party/pylint/pyreverse/vcgutils.py +0 -198
- data/vendor/depot_tools/third_party/pylint/pyreverse/writer.py +0 -198
- data/vendor/depot_tools/third_party/pylint/reporters/__init__.py +0 -149
- data/vendor/depot_tools/third_party/pylint/reporters/guireporter.py +0 -27
- data/vendor/depot_tools/third_party/pylint/reporters/html.py +0 -108
- data/vendor/depot_tools/third_party/pylint/reporters/json.py +0 -64
- data/vendor/depot_tools/third_party/pylint/reporters/text.py +0 -237
- data/vendor/depot_tools/third_party/pylint/reporters/ureports/__init__.py +0 -106
- data/vendor/depot_tools/third_party/pylint/reporters/ureports/html_writer.py +0 -93
- data/vendor/depot_tools/third_party/pylint/reporters/ureports/nodes.py +0 -181
- data/vendor/depot_tools/third_party/pylint/reporters/ureports/text_writer.py +0 -99
- data/vendor/depot_tools/third_party/pylint/testutils.py +0 -414
- data/vendor/depot_tools/third_party/pylint/utils.py +0 -1148
- data/vendor/depot_tools/third_party/pymox/COPYING +0 -202
- data/vendor/depot_tools/third_party/pymox/MANIFEST.in +0 -5
- data/vendor/depot_tools/third_party/pymox/README +0 -56
- data/vendor/depot_tools/third_party/pymox/__init__.py +0 -0
- data/vendor/depot_tools/third_party/pymox/mox.py +0 -1643
- data/vendor/depot_tools/third_party/pymox/mox_test.py +0 -1708
- data/vendor/depot_tools/third_party/pymox/mox_test_helper.py +0 -76
- data/vendor/depot_tools/third_party/pymox/setup.py +0 -14
- data/vendor/depot_tools/third_party/pymox/stubout.py +0 -142
- data/vendor/depot_tools/third_party/pymox/stubout_test.py +0 -47
- data/vendor/depot_tools/third_party/pymox/stubout_testee.py +0 -2
- data/vendor/depot_tools/third_party/simplejson/LICENSE.txt +0 -19
- data/vendor/depot_tools/third_party/simplejson/PKG-INFO +0 -29
- data/vendor/depot_tools/third_party/simplejson/__init__.py +0 -437
- data/vendor/depot_tools/third_party/simplejson/decoder.py +0 -421
- data/vendor/depot_tools/third_party/simplejson/encoder.py +0 -501
- data/vendor/depot_tools/third_party/simplejson/ordered_dict.py +0 -119
- data/vendor/depot_tools/third_party/simplejson/scanner.py +0 -77
- data/vendor/depot_tools/third_party/simplejson/tool.py +0 -39
- data/vendor/depot_tools/third_party/upload.py +0 -2565
@@ -1,89 +0,0 @@
|
|
1
|
-
# Protocol Buffers - Google's data interchange format
|
2
|
-
# Copyright 2008 Google Inc. All rights reserved.
|
3
|
-
# http://code.google.com/p/protobuf/
|
4
|
-
#
|
5
|
-
# Redistribution and use in source and binary forms, with or without
|
6
|
-
# modification, are permitted provided that the following conditions are
|
7
|
-
# met:
|
8
|
-
#
|
9
|
-
# * Redistributions of source code must retain the above copyright
|
10
|
-
# notice, this list of conditions and the following disclaimer.
|
11
|
-
# * Redistributions in binary form must reproduce the above
|
12
|
-
# copyright notice, this list of conditions and the following disclaimer
|
13
|
-
# in the documentation and/or other materials provided with the
|
14
|
-
# distribution.
|
15
|
-
# * Neither the name of Google Inc. nor the names of its
|
16
|
-
# contributors may be used to endorse or promote products derived from
|
17
|
-
# this software without specific prior written permission.
|
18
|
-
#
|
19
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
20
|
-
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
21
|
-
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
22
|
-
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
-
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
-
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
25
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
26
|
-
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
27
|
-
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
-
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
-
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
-
|
31
|
-
"""A simple wrapper around enum types to expose utility functions.
|
32
|
-
|
33
|
-
Instances are created as properties with the same name as the enum they wrap
|
34
|
-
on proto classes. For usage, see:
|
35
|
-
reflection_test.py
|
36
|
-
"""
|
37
|
-
|
38
|
-
__author__ = 'rabsatt@google.com (Kevin Rabsatt)'
|
39
|
-
|
40
|
-
|
41
|
-
class EnumTypeWrapper(object):
|
42
|
-
"""A utility for finding the names of enum values."""
|
43
|
-
|
44
|
-
DESCRIPTOR = None
|
45
|
-
|
46
|
-
def __init__(self, enum_type):
|
47
|
-
"""Inits EnumTypeWrapper with an EnumDescriptor."""
|
48
|
-
self._enum_type = enum_type
|
49
|
-
self.DESCRIPTOR = enum_type;
|
50
|
-
|
51
|
-
def Name(self, number):
|
52
|
-
"""Returns a string containing the name of an enum value."""
|
53
|
-
if number in self._enum_type.values_by_number:
|
54
|
-
return self._enum_type.values_by_number[number].name
|
55
|
-
raise ValueError('Enum %s has no name defined for value %d' % (
|
56
|
-
self._enum_type.name, number))
|
57
|
-
|
58
|
-
def Value(self, name):
|
59
|
-
"""Returns the value coresponding to the given enum name."""
|
60
|
-
if name in self._enum_type.values_by_name:
|
61
|
-
return self._enum_type.values_by_name[name].number
|
62
|
-
raise ValueError('Enum %s has no value defined for name %s' % (
|
63
|
-
self._enum_type.name, name))
|
64
|
-
|
65
|
-
def keys(self):
|
66
|
-
"""Return a list of the string names in the enum.
|
67
|
-
|
68
|
-
These are returned in the order they were defined in the .proto file.
|
69
|
-
"""
|
70
|
-
|
71
|
-
return [value_descriptor.name
|
72
|
-
for value_descriptor in self._enum_type.values]
|
73
|
-
|
74
|
-
def values(self):
|
75
|
-
"""Return a list of the integer values in the enum.
|
76
|
-
|
77
|
-
These are returned in the order they were defined in the .proto file.
|
78
|
-
"""
|
79
|
-
|
80
|
-
return [value_descriptor.number
|
81
|
-
for value_descriptor in self._enum_type.values]
|
82
|
-
|
83
|
-
def items(self):
|
84
|
-
"""Return a list of the (name, value) pairs of the enum.
|
85
|
-
|
86
|
-
These are returned in the order they were defined in the .proto file.
|
87
|
-
"""
|
88
|
-
return [(value_descriptor.name, value_descriptor.number)
|
89
|
-
for value_descriptor in self._enum_type.values]
|
@@ -1,78 +0,0 @@
|
|
1
|
-
# Protocol Buffers - Google's data interchange format
|
2
|
-
# Copyright 2008 Google Inc. All rights reserved.
|
3
|
-
# http://code.google.com/p/protobuf/
|
4
|
-
#
|
5
|
-
# Redistribution and use in source and binary forms, with or without
|
6
|
-
# modification, are permitted provided that the following conditions are
|
7
|
-
# met:
|
8
|
-
#
|
9
|
-
# * Redistributions of source code must retain the above copyright
|
10
|
-
# notice, this list of conditions and the following disclaimer.
|
11
|
-
# * Redistributions in binary form must reproduce the above
|
12
|
-
# copyright notice, this list of conditions and the following disclaimer
|
13
|
-
# in the documentation and/or other materials provided with the
|
14
|
-
# distribution.
|
15
|
-
# * Neither the name of Google Inc. nor the names of its
|
16
|
-
# contributors may be used to endorse or promote products derived from
|
17
|
-
# this software without specific prior written permission.
|
18
|
-
#
|
19
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
20
|
-
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
21
|
-
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
22
|
-
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
-
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
-
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
25
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
26
|
-
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
27
|
-
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
-
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
-
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
-
|
31
|
-
"""Defines a listener interface for observing certain
|
32
|
-
state transitions on Message objects.
|
33
|
-
|
34
|
-
Also defines a null implementation of this interface.
|
35
|
-
"""
|
36
|
-
|
37
|
-
__author__ = 'robinson@google.com (Will Robinson)'
|
38
|
-
|
39
|
-
|
40
|
-
class MessageListener(object):
|
41
|
-
|
42
|
-
"""Listens for modifications made to a message. Meant to be registered via
|
43
|
-
Message._SetListener().
|
44
|
-
|
45
|
-
Attributes:
|
46
|
-
dirty: If True, then calling Modified() would be a no-op. This can be
|
47
|
-
used to avoid these calls entirely in the common case.
|
48
|
-
"""
|
49
|
-
|
50
|
-
def Modified(self):
|
51
|
-
"""Called every time the message is modified in such a way that the parent
|
52
|
-
message may need to be updated. This currently means either:
|
53
|
-
(a) The message was modified for the first time, so the parent message
|
54
|
-
should henceforth mark the message as present.
|
55
|
-
(b) The message's cached byte size became dirty -- i.e. the message was
|
56
|
-
modified for the first time after a previous call to ByteSize().
|
57
|
-
Therefore the parent should also mark its byte size as dirty.
|
58
|
-
Note that (a) implies (b), since new objects start out with a client cached
|
59
|
-
size (zero). However, we document (a) explicitly because it is important.
|
60
|
-
|
61
|
-
Modified() will *only* be called in response to one of these two events --
|
62
|
-
not every time the sub-message is modified.
|
63
|
-
|
64
|
-
Note that if the listener's |dirty| attribute is true, then calling
|
65
|
-
Modified at the moment would be a no-op, so it can be skipped. Performance-
|
66
|
-
sensitive callers should check this attribute directly before calling since
|
67
|
-
it will be true most of the time.
|
68
|
-
"""
|
69
|
-
|
70
|
-
raise NotImplementedError
|
71
|
-
|
72
|
-
|
73
|
-
class NullMessageListener(object):
|
74
|
-
|
75
|
-
"""No-op MessageListener implementation."""
|
76
|
-
|
77
|
-
def Modified(self):
|
78
|
-
pass
|
@@ -1,1247 +0,0 @@
|
|
1
|
-
# Protocol Buffers - Google's data interchange format
|
2
|
-
# Copyright 2008 Google Inc. All rights reserved.
|
3
|
-
# http://code.google.com/p/protobuf/
|
4
|
-
#
|
5
|
-
# Redistribution and use in source and binary forms, with or without
|
6
|
-
# modification, are permitted provided that the following conditions are
|
7
|
-
# met:
|
8
|
-
#
|
9
|
-
# * Redistributions of source code must retain the above copyright
|
10
|
-
# notice, this list of conditions and the following disclaimer.
|
11
|
-
# * Redistributions in binary form must reproduce the above
|
12
|
-
# copyright notice, this list of conditions and the following disclaimer
|
13
|
-
# in the documentation and/or other materials provided with the
|
14
|
-
# distribution.
|
15
|
-
# * Neither the name of Google Inc. nor the names of its
|
16
|
-
# contributors may be used to endorse or promote products derived from
|
17
|
-
# this software without specific prior written permission.
|
18
|
-
#
|
19
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
20
|
-
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
21
|
-
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
22
|
-
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
-
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
-
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
25
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
26
|
-
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
27
|
-
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
-
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
-
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
-
|
31
|
-
# Keep it Python2.5 compatible for GAE.
|
32
|
-
#
|
33
|
-
# Copyright 2007 Google Inc. All Rights Reserved.
|
34
|
-
#
|
35
|
-
# This code is meant to work on Python 2.4 and above only.
|
36
|
-
#
|
37
|
-
# TODO(robinson): Helpers for verbose, common checks like seeing if a
|
38
|
-
# descriptor's cpp_type is CPPTYPE_MESSAGE.
|
39
|
-
|
40
|
-
"""Contains a metaclass and helper functions used to create
|
41
|
-
protocol message classes from Descriptor objects at runtime.
|
42
|
-
|
43
|
-
Recall that a metaclass is the "type" of a class.
|
44
|
-
(A class is to a metaclass what an instance is to a class.)
|
45
|
-
|
46
|
-
In this case, we use the GeneratedProtocolMessageType metaclass
|
47
|
-
to inject all the useful functionality into the classes
|
48
|
-
output by the protocol compiler at compile-time.
|
49
|
-
|
50
|
-
The upshot of all this is that the real implementation
|
51
|
-
details for ALL pure-Python protocol buffers are *here in
|
52
|
-
this file*.
|
53
|
-
"""
|
54
|
-
|
55
|
-
__author__ = 'robinson@google.com (Will Robinson)'
|
56
|
-
|
57
|
-
import sys
|
58
|
-
if sys.version_info[0] < 3:
|
59
|
-
try:
|
60
|
-
from cStringIO import StringIO as BytesIO
|
61
|
-
except ImportError:
|
62
|
-
from StringIO import StringIO as BytesIO
|
63
|
-
import copy_reg as copyreg
|
64
|
-
else:
|
65
|
-
from io import BytesIO
|
66
|
-
import copyreg
|
67
|
-
import struct
|
68
|
-
import weakref
|
69
|
-
|
70
|
-
# We use "as" to avoid name collisions with variables.
|
71
|
-
from protobuf26.internal import containers
|
72
|
-
from protobuf26.internal import decoder
|
73
|
-
from protobuf26.internal import encoder
|
74
|
-
from protobuf26.internal import enum_type_wrapper
|
75
|
-
from protobuf26.internal import message_listener as message_listener_mod
|
76
|
-
from protobuf26.internal import type_checkers
|
77
|
-
from protobuf26.internal import wire_format
|
78
|
-
from protobuf26 import descriptor as descriptor_mod
|
79
|
-
from protobuf26 import message as message_mod
|
80
|
-
from protobuf26 import text_format
|
81
|
-
|
82
|
-
_FieldDescriptor = descriptor_mod.FieldDescriptor
|
83
|
-
|
84
|
-
|
85
|
-
def NewMessage(bases, descriptor, dictionary):
|
86
|
-
_AddClassAttributesForNestedExtensions(descriptor, dictionary)
|
87
|
-
_AddSlots(descriptor, dictionary)
|
88
|
-
return bases
|
89
|
-
|
90
|
-
|
91
|
-
def InitMessage(descriptor, cls):
|
92
|
-
cls._decoders_by_tag = {}
|
93
|
-
cls._extensions_by_name = {}
|
94
|
-
cls._extensions_by_number = {}
|
95
|
-
if (descriptor.has_options and
|
96
|
-
descriptor.GetOptions().message_set_wire_format):
|
97
|
-
cls._decoders_by_tag[decoder.MESSAGE_SET_ITEM_TAG] = (
|
98
|
-
decoder.MessageSetItemDecoder(cls._extensions_by_number))
|
99
|
-
|
100
|
-
# Attach stuff to each FieldDescriptor for quick lookup later on.
|
101
|
-
for field in descriptor.fields:
|
102
|
-
_AttachFieldHelpers(cls, field)
|
103
|
-
|
104
|
-
_AddEnumValues(descriptor, cls)
|
105
|
-
_AddInitMethod(descriptor, cls)
|
106
|
-
_AddPropertiesForFields(descriptor, cls)
|
107
|
-
_AddPropertiesForExtensions(descriptor, cls)
|
108
|
-
_AddStaticMethods(cls)
|
109
|
-
_AddMessageMethods(descriptor, cls)
|
110
|
-
_AddPrivateHelperMethods(descriptor, cls)
|
111
|
-
copyreg.pickle(cls, lambda obj: (cls, (), obj.__getstate__()))
|
112
|
-
|
113
|
-
|
114
|
-
# Stateless helpers for GeneratedProtocolMessageType below.
|
115
|
-
# Outside clients should not access these directly.
|
116
|
-
#
|
117
|
-
# I opted not to make any of these methods on the metaclass, to make it more
|
118
|
-
# clear that I'm not really using any state there and to keep clients from
|
119
|
-
# thinking that they have direct access to these construction helpers.
|
120
|
-
|
121
|
-
|
122
|
-
def _PropertyName(proto_field_name):
|
123
|
-
"""Returns the name of the public property attribute which
|
124
|
-
clients can use to get and (in some cases) set the value
|
125
|
-
of a protocol message field.
|
126
|
-
|
127
|
-
Args:
|
128
|
-
proto_field_name: The protocol message field name, exactly
|
129
|
-
as it appears (or would appear) in a .proto file.
|
130
|
-
"""
|
131
|
-
# TODO(robinson): Escape Python keywords (e.g., yield), and test this support.
|
132
|
-
# nnorwitz makes my day by writing:
|
133
|
-
# """
|
134
|
-
# FYI. See the keyword module in the stdlib. This could be as simple as:
|
135
|
-
#
|
136
|
-
# if keyword.iskeyword(proto_field_name):
|
137
|
-
# return proto_field_name + "_"
|
138
|
-
# return proto_field_name
|
139
|
-
# """
|
140
|
-
# Kenton says: The above is a BAD IDEA. People rely on being able to use
|
141
|
-
# getattr() and setattr() to reflectively manipulate field values. If we
|
142
|
-
# rename the properties, then every such user has to also make sure to apply
|
143
|
-
# the same transformation. Note that currently if you name a field "yield",
|
144
|
-
# you can still access it just fine using getattr/setattr -- it's not even
|
145
|
-
# that cumbersome to do so.
|
146
|
-
# TODO(kenton): Remove this method entirely if/when everyone agrees with my
|
147
|
-
# position.
|
148
|
-
return proto_field_name
|
149
|
-
|
150
|
-
|
151
|
-
def _VerifyExtensionHandle(message, extension_handle):
|
152
|
-
"""Verify that the given extension handle is valid."""
|
153
|
-
|
154
|
-
if not isinstance(extension_handle, _FieldDescriptor):
|
155
|
-
raise KeyError('HasExtension() expects an extension handle, got: %s' %
|
156
|
-
extension_handle)
|
157
|
-
|
158
|
-
if not extension_handle.is_extension:
|
159
|
-
raise KeyError('"%s" is not an extension.' % extension_handle.full_name)
|
160
|
-
|
161
|
-
if not extension_handle.containing_type:
|
162
|
-
raise KeyError('"%s" is missing a containing_type.'
|
163
|
-
% extension_handle.full_name)
|
164
|
-
|
165
|
-
if extension_handle.containing_type is not message.DESCRIPTOR:
|
166
|
-
raise KeyError('Extension "%s" extends message type "%s", but this '
|
167
|
-
'message is of type "%s".' %
|
168
|
-
(extension_handle.full_name,
|
169
|
-
extension_handle.containing_type.full_name,
|
170
|
-
message.DESCRIPTOR.full_name))
|
171
|
-
|
172
|
-
|
173
|
-
def _AddSlots(message_descriptor, dictionary):
|
174
|
-
"""Adds a __slots__ entry to dictionary, containing the names of all valid
|
175
|
-
attributes for this message type.
|
176
|
-
|
177
|
-
Args:
|
178
|
-
message_descriptor: A Descriptor instance describing this message type.
|
179
|
-
dictionary: Class dictionary to which we'll add a '__slots__' entry.
|
180
|
-
"""
|
181
|
-
dictionary['__slots__'] = ['_cached_byte_size',
|
182
|
-
'_cached_byte_size_dirty',
|
183
|
-
'_fields',
|
184
|
-
'_unknown_fields',
|
185
|
-
'_is_present_in_parent',
|
186
|
-
'_listener',
|
187
|
-
'_listener_for_children',
|
188
|
-
'__weakref__',
|
189
|
-
'_oneofs']
|
190
|
-
|
191
|
-
|
192
|
-
def _IsMessageSetExtension(field):
|
193
|
-
return (field.is_extension and
|
194
|
-
field.containing_type.has_options and
|
195
|
-
field.containing_type.GetOptions().message_set_wire_format and
|
196
|
-
field.type == _FieldDescriptor.TYPE_MESSAGE and
|
197
|
-
field.message_type == field.extension_scope and
|
198
|
-
field.label == _FieldDescriptor.LABEL_OPTIONAL)
|
199
|
-
|
200
|
-
|
201
|
-
def _AttachFieldHelpers(cls, field_descriptor):
|
202
|
-
is_repeated = (field_descriptor.label == _FieldDescriptor.LABEL_REPEATED)
|
203
|
-
is_packed = (field_descriptor.has_options and
|
204
|
-
field_descriptor.GetOptions().packed)
|
205
|
-
|
206
|
-
if _IsMessageSetExtension(field_descriptor):
|
207
|
-
field_encoder = encoder.MessageSetItemEncoder(field_descriptor.number)
|
208
|
-
sizer = encoder.MessageSetItemSizer(field_descriptor.number)
|
209
|
-
else:
|
210
|
-
field_encoder = type_checkers.TYPE_TO_ENCODER[field_descriptor.type](
|
211
|
-
field_descriptor.number, is_repeated, is_packed)
|
212
|
-
sizer = type_checkers.TYPE_TO_SIZER[field_descriptor.type](
|
213
|
-
field_descriptor.number, is_repeated, is_packed)
|
214
|
-
|
215
|
-
field_descriptor._encoder = field_encoder
|
216
|
-
field_descriptor._sizer = sizer
|
217
|
-
field_descriptor._default_constructor = _DefaultValueConstructorForField(
|
218
|
-
field_descriptor)
|
219
|
-
|
220
|
-
def AddDecoder(wiretype, is_packed):
|
221
|
-
tag_bytes = encoder.TagBytes(field_descriptor.number, wiretype)
|
222
|
-
cls._decoders_by_tag[tag_bytes] = (
|
223
|
-
type_checkers.TYPE_TO_DECODER[field_descriptor.type](
|
224
|
-
field_descriptor.number, is_repeated, is_packed,
|
225
|
-
field_descriptor, field_descriptor._default_constructor))
|
226
|
-
|
227
|
-
AddDecoder(type_checkers.FIELD_TYPE_TO_WIRE_TYPE[field_descriptor.type],
|
228
|
-
False)
|
229
|
-
|
230
|
-
if is_repeated and wire_format.IsTypePackable(field_descriptor.type):
|
231
|
-
# To support wire compatibility of adding packed = true, add a decoder for
|
232
|
-
# packed values regardless of the field's options.
|
233
|
-
AddDecoder(wire_format.WIRETYPE_LENGTH_DELIMITED, True)
|
234
|
-
|
235
|
-
|
236
|
-
def _AddClassAttributesForNestedExtensions(descriptor, dictionary):
|
237
|
-
extension_dict = descriptor.extensions_by_name
|
238
|
-
for extension_name, extension_field in extension_dict.iteritems():
|
239
|
-
assert extension_name not in dictionary
|
240
|
-
dictionary[extension_name] = extension_field
|
241
|
-
|
242
|
-
|
243
|
-
def _AddEnumValues(descriptor, cls):
|
244
|
-
"""Sets class-level attributes for all enum fields defined in this message.
|
245
|
-
|
246
|
-
Also exporting a class-level object that can name enum values.
|
247
|
-
|
248
|
-
Args:
|
249
|
-
descriptor: Descriptor object for this message type.
|
250
|
-
cls: Class we're constructing for this message type.
|
251
|
-
"""
|
252
|
-
for enum_type in descriptor.enum_types:
|
253
|
-
setattr(cls, enum_type.name, enum_type_wrapper.EnumTypeWrapper(enum_type))
|
254
|
-
for enum_value in enum_type.values:
|
255
|
-
setattr(cls, enum_value.name, enum_value.number)
|
256
|
-
|
257
|
-
|
258
|
-
def _DefaultValueConstructorForField(field):
|
259
|
-
"""Returns a function which returns a default value for a field.
|
260
|
-
|
261
|
-
Args:
|
262
|
-
field: FieldDescriptor object for this field.
|
263
|
-
|
264
|
-
The returned function has one argument:
|
265
|
-
message: Message instance containing this field, or a weakref proxy
|
266
|
-
of same.
|
267
|
-
|
268
|
-
That function in turn returns a default value for this field. The default
|
269
|
-
value may refer back to |message| via a weak reference.
|
270
|
-
"""
|
271
|
-
|
272
|
-
if field.label == _FieldDescriptor.LABEL_REPEATED:
|
273
|
-
if field.has_default_value and field.default_value != []:
|
274
|
-
raise ValueError('Repeated field default value not empty list: %s' % (
|
275
|
-
field.default_value))
|
276
|
-
if field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
|
277
|
-
# We can't look at _concrete_class yet since it might not have
|
278
|
-
# been set. (Depends on order in which we initialize the classes).
|
279
|
-
message_type = field.message_type
|
280
|
-
def MakeRepeatedMessageDefault(message):
|
281
|
-
return containers.RepeatedCompositeFieldContainer(
|
282
|
-
message._listener_for_children, field.message_type)
|
283
|
-
return MakeRepeatedMessageDefault
|
284
|
-
else:
|
285
|
-
type_checker = type_checkers.GetTypeChecker(field)
|
286
|
-
def MakeRepeatedScalarDefault(message):
|
287
|
-
return containers.RepeatedScalarFieldContainer(
|
288
|
-
message._listener_for_children, type_checker)
|
289
|
-
return MakeRepeatedScalarDefault
|
290
|
-
|
291
|
-
if field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
|
292
|
-
# _concrete_class may not yet be initialized.
|
293
|
-
message_type = field.message_type
|
294
|
-
def MakeSubMessageDefault(message):
|
295
|
-
result = message_type._concrete_class()
|
296
|
-
result._SetListener(message._listener_for_children)
|
297
|
-
return result
|
298
|
-
return MakeSubMessageDefault
|
299
|
-
|
300
|
-
def MakeScalarDefault(message):
|
301
|
-
# TODO(protobuf-team): This may be broken since there may not be
|
302
|
-
# default_value. Combine with has_default_value somehow.
|
303
|
-
return field.default_value
|
304
|
-
return MakeScalarDefault
|
305
|
-
|
306
|
-
|
307
|
-
def _AddInitMethod(message_descriptor, cls):
|
308
|
-
"""Adds an __init__ method to cls."""
|
309
|
-
fields = message_descriptor.fields
|
310
|
-
def init(self, **kwargs):
|
311
|
-
self._cached_byte_size = 0
|
312
|
-
self._cached_byte_size_dirty = len(kwargs) > 0
|
313
|
-
self._fields = {}
|
314
|
-
# Contains a mapping from oneof field descriptors to the descriptor
|
315
|
-
# of the currently set field in that oneof field.
|
316
|
-
self._oneofs = {}
|
317
|
-
|
318
|
-
# _unknown_fields is () when empty for efficiency, and will be turned into
|
319
|
-
# a list if fields are added.
|
320
|
-
self._unknown_fields = ()
|
321
|
-
self._is_present_in_parent = False
|
322
|
-
self._listener = message_listener_mod.NullMessageListener()
|
323
|
-
self._listener_for_children = _Listener(self)
|
324
|
-
for field_name, field_value in kwargs.iteritems():
|
325
|
-
field = _GetFieldByName(message_descriptor, field_name)
|
326
|
-
if field is None:
|
327
|
-
raise TypeError("%s() got an unexpected keyword argument '%s'" %
|
328
|
-
(message_descriptor.name, field_name))
|
329
|
-
if field.label == _FieldDescriptor.LABEL_REPEATED:
|
330
|
-
copy = field._default_constructor(self)
|
331
|
-
if field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE: # Composite
|
332
|
-
for val in field_value:
|
333
|
-
copy.add().MergeFrom(val)
|
334
|
-
else: # Scalar
|
335
|
-
copy.extend(field_value)
|
336
|
-
self._fields[field] = copy
|
337
|
-
elif field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
|
338
|
-
copy = field._default_constructor(self)
|
339
|
-
copy.MergeFrom(field_value)
|
340
|
-
self._fields[field] = copy
|
341
|
-
else:
|
342
|
-
setattr(self, field_name, field_value)
|
343
|
-
|
344
|
-
init.__module__ = None
|
345
|
-
init.__doc__ = None
|
346
|
-
cls.__init__ = init
|
347
|
-
|
348
|
-
|
349
|
-
def _GetFieldByName(message_descriptor, field_name):
|
350
|
-
"""Returns a field descriptor by field name.
|
351
|
-
|
352
|
-
Args:
|
353
|
-
message_descriptor: A Descriptor describing all fields in message.
|
354
|
-
field_name: The name of the field to retrieve.
|
355
|
-
Returns:
|
356
|
-
The field descriptor associated with the field name.
|
357
|
-
"""
|
358
|
-
try:
|
359
|
-
return message_descriptor.fields_by_name[field_name]
|
360
|
-
except KeyError:
|
361
|
-
raise ValueError('Protocol message has no "%s" field.' % field_name)
|
362
|
-
|
363
|
-
|
364
|
-
def _AddPropertiesForFields(descriptor, cls):
|
365
|
-
"""Adds properties for all fields in this protocol message type."""
|
366
|
-
for field in descriptor.fields:
|
367
|
-
_AddPropertiesForField(field, cls)
|
368
|
-
|
369
|
-
if descriptor.is_extendable:
|
370
|
-
# _ExtensionDict is just an adaptor with no state so we allocate a new one
|
371
|
-
# every time it is accessed.
|
372
|
-
cls.Extensions = property(lambda self: _ExtensionDict(self))
|
373
|
-
|
374
|
-
|
375
|
-
def _AddPropertiesForField(field, cls):
|
376
|
-
"""Adds a public property for a protocol message field.
|
377
|
-
Clients can use this property to get and (in the case
|
378
|
-
of non-repeated scalar fields) directly set the value
|
379
|
-
of a protocol message field.
|
380
|
-
|
381
|
-
Args:
|
382
|
-
field: A FieldDescriptor for this field.
|
383
|
-
cls: The class we're constructing.
|
384
|
-
"""
|
385
|
-
# Catch it if we add other types that we should
|
386
|
-
# handle specially here.
|
387
|
-
assert _FieldDescriptor.MAX_CPPTYPE == 10
|
388
|
-
|
389
|
-
constant_name = field.name.upper() + "_FIELD_NUMBER"
|
390
|
-
setattr(cls, constant_name, field.number)
|
391
|
-
|
392
|
-
if field.label == _FieldDescriptor.LABEL_REPEATED:
|
393
|
-
_AddPropertiesForRepeatedField(field, cls)
|
394
|
-
elif field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
|
395
|
-
_AddPropertiesForNonRepeatedCompositeField(field, cls)
|
396
|
-
else:
|
397
|
-
_AddPropertiesForNonRepeatedScalarField(field, cls)
|
398
|
-
|
399
|
-
|
400
|
-
def _AddPropertiesForRepeatedField(field, cls):
|
401
|
-
"""Adds a public property for a "repeated" protocol message field. Clients
|
402
|
-
can use this property to get the value of the field, which will be either a
|
403
|
-
_RepeatedScalarFieldContainer or _RepeatedCompositeFieldContainer (see
|
404
|
-
below).
|
405
|
-
|
406
|
-
Note that when clients add values to these containers, we perform
|
407
|
-
type-checking in the case of repeated scalar fields, and we also set any
|
408
|
-
necessary "has" bits as a side-effect.
|
409
|
-
|
410
|
-
Args:
|
411
|
-
field: A FieldDescriptor for this field.
|
412
|
-
cls: The class we're constructing.
|
413
|
-
"""
|
414
|
-
proto_field_name = field.name
|
415
|
-
property_name = _PropertyName(proto_field_name)
|
416
|
-
|
417
|
-
def getter(self):
|
418
|
-
field_value = self._fields.get(field)
|
419
|
-
if field_value is None:
|
420
|
-
# Construct a new object to represent this field.
|
421
|
-
field_value = field._default_constructor(self)
|
422
|
-
|
423
|
-
# Atomically check if another thread has preempted us and, if not, swap
|
424
|
-
# in the new object we just created. If someone has preempted us, we
|
425
|
-
# take that object and discard ours.
|
426
|
-
# WARNING: We are relying on setdefault() being atomic. This is true
|
427
|
-
# in CPython but we haven't investigated others. This warning appears
|
428
|
-
# in several other locations in this file.
|
429
|
-
field_value = self._fields.setdefault(field, field_value)
|
430
|
-
return field_value
|
431
|
-
getter.__module__ = None
|
432
|
-
getter.__doc__ = 'Getter for %s.' % proto_field_name
|
433
|
-
|
434
|
-
# We define a setter just so we can throw an exception with a more
|
435
|
-
# helpful error message.
|
436
|
-
def setter(self, new_value):
|
437
|
-
raise AttributeError('Assignment not allowed to repeated field '
|
438
|
-
'"%s" in protocol message object.' % proto_field_name)
|
439
|
-
|
440
|
-
doc = 'Magic attribute generated for "%s" proto field.' % proto_field_name
|
441
|
-
setattr(cls, property_name, property(getter, setter, doc=doc))
|
442
|
-
|
443
|
-
|
444
|
-
def _AddPropertiesForNonRepeatedScalarField(field, cls):
|
445
|
-
"""Adds a public property for a nonrepeated, scalar protocol message field.
|
446
|
-
Clients can use this property to get and directly set the value of the field.
|
447
|
-
Note that when the client sets the value of a field by using this property,
|
448
|
-
all necessary "has" bits are set as a side-effect, and we also perform
|
449
|
-
type-checking.
|
450
|
-
|
451
|
-
Args:
|
452
|
-
field: A FieldDescriptor for this field.
|
453
|
-
cls: The class we're constructing.
|
454
|
-
"""
|
455
|
-
proto_field_name = field.name
|
456
|
-
property_name = _PropertyName(proto_field_name)
|
457
|
-
type_checker = type_checkers.GetTypeChecker(field)
|
458
|
-
default_value = field.default_value
|
459
|
-
valid_values = set()
|
460
|
-
|
461
|
-
def getter(self):
|
462
|
-
# TODO(protobuf-team): This may be broken since there may not be
|
463
|
-
# default_value. Combine with has_default_value somehow.
|
464
|
-
return self._fields.get(field, default_value)
|
465
|
-
getter.__module__ = None
|
466
|
-
getter.__doc__ = 'Getter for %s.' % proto_field_name
|
467
|
-
def field_setter(self, new_value):
|
468
|
-
# pylint: disable=protected-access
|
469
|
-
self._fields[field] = type_checker.CheckValue(new_value)
|
470
|
-
# Check _cached_byte_size_dirty inline to improve performance, since scalar
|
471
|
-
# setters are called frequently.
|
472
|
-
if not self._cached_byte_size_dirty:
|
473
|
-
self._Modified()
|
474
|
-
|
475
|
-
if field.containing_oneof is not None:
|
476
|
-
def setter(self, new_value):
|
477
|
-
field_setter(self, new_value)
|
478
|
-
self._UpdateOneofState(field)
|
479
|
-
else:
|
480
|
-
setter = field_setter
|
481
|
-
|
482
|
-
setter.__module__ = None
|
483
|
-
setter.__doc__ = 'Setter for %s.' % proto_field_name
|
484
|
-
|
485
|
-
# Add a property to encapsulate the getter/setter.
|
486
|
-
doc = 'Magic attribute generated for "%s" proto field.' % proto_field_name
|
487
|
-
setattr(cls, property_name, property(getter, setter, doc=doc))
|
488
|
-
|
489
|
-
|
490
|
-
def _AddPropertiesForNonRepeatedCompositeField(field, cls):
|
491
|
-
"""Adds a public property for a nonrepeated, composite protocol message field.
|
492
|
-
A composite field is a "group" or "message" field.
|
493
|
-
|
494
|
-
Clients can use this property to get the value of the field, but cannot
|
495
|
-
assign to the property directly.
|
496
|
-
|
497
|
-
Args:
|
498
|
-
field: A FieldDescriptor for this field.
|
499
|
-
cls: The class we're constructing.
|
500
|
-
"""
|
501
|
-
# TODO(robinson): Remove duplication with similar method
|
502
|
-
# for non-repeated scalars.
|
503
|
-
proto_field_name = field.name
|
504
|
-
property_name = _PropertyName(proto_field_name)
|
505
|
-
|
506
|
-
# TODO(komarek): Can anyone explain to me why we cache the message_type this
|
507
|
-
# way, instead of referring to field.message_type inside of getter(self)?
|
508
|
-
# What if someone sets message_type later on (which makes for simpler
|
509
|
-
# dyanmic proto descriptor and class creation code).
|
510
|
-
message_type = field.message_type
|
511
|
-
|
512
|
-
def getter(self):
|
513
|
-
field_value = self._fields.get(field)
|
514
|
-
if field_value is None:
|
515
|
-
# Construct a new object to represent this field.
|
516
|
-
field_value = message_type._concrete_class() # use field.message_type?
|
517
|
-
field_value._SetListener(
|
518
|
-
_OneofListener(self, field)
|
519
|
-
if field.containing_oneof is not None
|
520
|
-
else self._listener_for_children)
|
521
|
-
|
522
|
-
# Atomically check if another thread has preempted us and, if not, swap
|
523
|
-
# in the new object we just created. If someone has preempted us, we
|
524
|
-
# take that object and discard ours.
|
525
|
-
# WARNING: We are relying on setdefault() being atomic. This is true
|
526
|
-
# in CPython but we haven't investigated others. This warning appears
|
527
|
-
# in several other locations in this file.
|
528
|
-
field_value = self._fields.setdefault(field, field_value)
|
529
|
-
return field_value
|
530
|
-
getter.__module__ = None
|
531
|
-
getter.__doc__ = 'Getter for %s.' % proto_field_name
|
532
|
-
|
533
|
-
# We define a setter just so we can throw an exception with a more
|
534
|
-
# helpful error message.
|
535
|
-
def setter(self, new_value):
|
536
|
-
raise AttributeError('Assignment not allowed to composite field '
|
537
|
-
'"%s" in protocol message object.' % proto_field_name)
|
538
|
-
|
539
|
-
# Add a property to encapsulate the getter.
|
540
|
-
doc = 'Magic attribute generated for "%s" proto field.' % proto_field_name
|
541
|
-
setattr(cls, property_name, property(getter, setter, doc=doc))
|
542
|
-
|
543
|
-
|
544
|
-
def _AddPropertiesForExtensions(descriptor, cls):
|
545
|
-
"""Adds properties for all fields in this protocol message type."""
|
546
|
-
extension_dict = descriptor.extensions_by_name
|
547
|
-
for extension_name, extension_field in extension_dict.iteritems():
|
548
|
-
constant_name = extension_name.upper() + "_FIELD_NUMBER"
|
549
|
-
setattr(cls, constant_name, extension_field.number)
|
550
|
-
|
551
|
-
|
552
|
-
def _AddStaticMethods(cls):
|
553
|
-
# TODO(robinson): This probably needs to be thread-safe(?)
|
554
|
-
def RegisterExtension(extension_handle):
|
555
|
-
extension_handle.containing_type = cls.DESCRIPTOR
|
556
|
-
_AttachFieldHelpers(cls, extension_handle)
|
557
|
-
|
558
|
-
# Try to insert our extension, failing if an extension with the same number
|
559
|
-
# already exists.
|
560
|
-
actual_handle = cls._extensions_by_number.setdefault(
|
561
|
-
extension_handle.number, extension_handle)
|
562
|
-
if actual_handle is not extension_handle:
|
563
|
-
raise AssertionError(
|
564
|
-
'Extensions "%s" and "%s" both try to extend message type "%s" with '
|
565
|
-
'field number %d.' %
|
566
|
-
(extension_handle.full_name, actual_handle.full_name,
|
567
|
-
cls.DESCRIPTOR.full_name, extension_handle.number))
|
568
|
-
|
569
|
-
cls._extensions_by_name[extension_handle.full_name] = extension_handle
|
570
|
-
|
571
|
-
handle = extension_handle # avoid line wrapping
|
572
|
-
if _IsMessageSetExtension(handle):
|
573
|
-
# MessageSet extension. Also register under type name.
|
574
|
-
cls._extensions_by_name[
|
575
|
-
extension_handle.message_type.full_name] = extension_handle
|
576
|
-
|
577
|
-
cls.RegisterExtension = staticmethod(RegisterExtension)
|
578
|
-
|
579
|
-
def FromString(s):
|
580
|
-
message = cls()
|
581
|
-
message.MergeFromString(s)
|
582
|
-
return message
|
583
|
-
cls.FromString = staticmethod(FromString)
|
584
|
-
|
585
|
-
|
586
|
-
def _IsPresent(item):
|
587
|
-
"""Given a (FieldDescriptor, value) tuple from _fields, return true if the
|
588
|
-
value should be included in the list returned by ListFields()."""
|
589
|
-
|
590
|
-
if item[0].label == _FieldDescriptor.LABEL_REPEATED:
|
591
|
-
return bool(item[1])
|
592
|
-
elif item[0].cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
|
593
|
-
return item[1]._is_present_in_parent
|
594
|
-
else:
|
595
|
-
return True
|
596
|
-
|
597
|
-
|
598
|
-
def _AddListFieldsMethod(message_descriptor, cls):
|
599
|
-
"""Helper for _AddMessageMethods()."""
|
600
|
-
|
601
|
-
def ListFields(self):
|
602
|
-
all_fields = [item for item in self._fields.iteritems() if _IsPresent(item)]
|
603
|
-
all_fields.sort(key = lambda item: item[0].number)
|
604
|
-
return all_fields
|
605
|
-
|
606
|
-
cls.ListFields = ListFields
|
607
|
-
|
608
|
-
|
609
|
-
def _AddHasFieldMethod(message_descriptor, cls):
|
610
|
-
"""Helper for _AddMessageMethods()."""
|
611
|
-
|
612
|
-
singular_fields = {}
|
613
|
-
for field in message_descriptor.fields:
|
614
|
-
if field.label != _FieldDescriptor.LABEL_REPEATED:
|
615
|
-
singular_fields[field.name] = field
|
616
|
-
# Fields inside oneofs are never repeated (enforced by the compiler).
|
617
|
-
for field in message_descriptor.oneofs:
|
618
|
-
singular_fields[field.name] = field
|
619
|
-
|
620
|
-
def HasField(self, field_name):
|
621
|
-
try:
|
622
|
-
field = singular_fields[field_name]
|
623
|
-
except KeyError:
|
624
|
-
raise ValueError(
|
625
|
-
'Protocol message has no singular "%s" field.' % field_name)
|
626
|
-
|
627
|
-
if isinstance(field, descriptor_mod.OneofDescriptor):
|
628
|
-
try:
|
629
|
-
return HasField(self, self._oneofs[field].name)
|
630
|
-
except KeyError:
|
631
|
-
return False
|
632
|
-
else:
|
633
|
-
if field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
|
634
|
-
value = self._fields.get(field)
|
635
|
-
return value is not None and value._is_present_in_parent
|
636
|
-
else:
|
637
|
-
return field in self._fields
|
638
|
-
|
639
|
-
cls.HasField = HasField
|
640
|
-
|
641
|
-
|
642
|
-
def _AddClearFieldMethod(message_descriptor, cls):
|
643
|
-
"""Helper for _AddMessageMethods()."""
|
644
|
-
def ClearField(self, field_name):
|
645
|
-
try:
|
646
|
-
field = message_descriptor.fields_by_name[field_name]
|
647
|
-
except KeyError:
|
648
|
-
try:
|
649
|
-
field = message_descriptor.oneofs_by_name[field_name]
|
650
|
-
if field in self._oneofs:
|
651
|
-
field = self._oneofs[field]
|
652
|
-
else:
|
653
|
-
return
|
654
|
-
except KeyError:
|
655
|
-
raise ValueError('Protocol message has no "%s" field.' % field_name)
|
656
|
-
|
657
|
-
if field in self._fields:
|
658
|
-
# Note: If the field is a sub-message, its listener will still point
|
659
|
-
# at us. That's fine, because the worst than can happen is that it
|
660
|
-
# will call _Modified() and invalidate our byte size. Big deal.
|
661
|
-
del self._fields[field]
|
662
|
-
|
663
|
-
if self._oneofs.get(field.containing_oneof, None) is field:
|
664
|
-
del self._oneofs[field.containing_oneof]
|
665
|
-
|
666
|
-
# Always call _Modified() -- even if nothing was changed, this is
|
667
|
-
# a mutating method, and thus calling it should cause the field to become
|
668
|
-
# present in the parent message.
|
669
|
-
self._Modified()
|
670
|
-
|
671
|
-
cls.ClearField = ClearField
|
672
|
-
|
673
|
-
|
674
|
-
def _AddClearExtensionMethod(cls):
|
675
|
-
"""Helper for _AddMessageMethods()."""
|
676
|
-
def ClearExtension(self, extension_handle):
|
677
|
-
_VerifyExtensionHandle(self, extension_handle)
|
678
|
-
|
679
|
-
# Similar to ClearField(), above.
|
680
|
-
if extension_handle in self._fields:
|
681
|
-
del self._fields[extension_handle]
|
682
|
-
self._Modified()
|
683
|
-
cls.ClearExtension = ClearExtension
|
684
|
-
|
685
|
-
|
686
|
-
def _AddClearMethod(message_descriptor, cls):
|
687
|
-
"""Helper for _AddMessageMethods()."""
|
688
|
-
def Clear(self):
|
689
|
-
# Clear fields.
|
690
|
-
self._fields = {}
|
691
|
-
self._unknown_fields = ()
|
692
|
-
self._Modified()
|
693
|
-
cls.Clear = Clear
|
694
|
-
|
695
|
-
|
696
|
-
def _AddHasExtensionMethod(cls):
|
697
|
-
"""Helper for _AddMessageMethods()."""
|
698
|
-
def HasExtension(self, extension_handle):
|
699
|
-
_VerifyExtensionHandle(self, extension_handle)
|
700
|
-
if extension_handle.label == _FieldDescriptor.LABEL_REPEATED:
|
701
|
-
raise KeyError('"%s" is repeated.' % extension_handle.full_name)
|
702
|
-
|
703
|
-
if extension_handle.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
|
704
|
-
value = self._fields.get(extension_handle)
|
705
|
-
return value is not None and value._is_present_in_parent
|
706
|
-
else:
|
707
|
-
return extension_handle in self._fields
|
708
|
-
cls.HasExtension = HasExtension
|
709
|
-
|
710
|
-
|
711
|
-
def _AddEqualsMethod(message_descriptor, cls):
|
712
|
-
"""Helper for _AddMessageMethods()."""
|
713
|
-
def __eq__(self, other):
|
714
|
-
if (not isinstance(other, message_mod.Message) or
|
715
|
-
other.DESCRIPTOR != self.DESCRIPTOR):
|
716
|
-
return False
|
717
|
-
|
718
|
-
if self is other:
|
719
|
-
return True
|
720
|
-
|
721
|
-
if not self.ListFields() == other.ListFields():
|
722
|
-
return False
|
723
|
-
|
724
|
-
# Sort unknown fields because their order shouldn't affect equality test.
|
725
|
-
unknown_fields = list(self._unknown_fields)
|
726
|
-
unknown_fields.sort()
|
727
|
-
other_unknown_fields = list(other._unknown_fields)
|
728
|
-
other_unknown_fields.sort()
|
729
|
-
|
730
|
-
return unknown_fields == other_unknown_fields
|
731
|
-
|
732
|
-
cls.__eq__ = __eq__
|
733
|
-
|
734
|
-
|
735
|
-
def _AddStrMethod(message_descriptor, cls):
|
736
|
-
"""Helper for _AddMessageMethods()."""
|
737
|
-
def __str__(self):
|
738
|
-
return text_format.MessageToString(self)
|
739
|
-
cls.__str__ = __str__
|
740
|
-
|
741
|
-
|
742
|
-
def _AddUnicodeMethod(unused_message_descriptor, cls):
|
743
|
-
"""Helper for _AddMessageMethods()."""
|
744
|
-
|
745
|
-
def __unicode__(self):
|
746
|
-
return text_format.MessageToString(self, as_utf8=True).decode('utf-8')
|
747
|
-
cls.__unicode__ = __unicode__
|
748
|
-
|
749
|
-
|
750
|
-
def _AddSetListenerMethod(cls):
|
751
|
-
"""Helper for _AddMessageMethods()."""
|
752
|
-
def SetListener(self, listener):
|
753
|
-
if listener is None:
|
754
|
-
self._listener = message_listener_mod.NullMessageListener()
|
755
|
-
else:
|
756
|
-
self._listener = listener
|
757
|
-
cls._SetListener = SetListener
|
758
|
-
|
759
|
-
|
760
|
-
def _BytesForNonRepeatedElement(value, field_number, field_type):
|
761
|
-
"""Returns the number of bytes needed to serialize a non-repeated element.
|
762
|
-
The returned byte count includes space for tag information and any
|
763
|
-
other additional space associated with serializing value.
|
764
|
-
|
765
|
-
Args:
|
766
|
-
value: Value we're serializing.
|
767
|
-
field_number: Field number of this value. (Since the field number
|
768
|
-
is stored as part of a varint-encoded tag, this has an impact
|
769
|
-
on the total bytes required to serialize the value).
|
770
|
-
field_type: The type of the field. One of the TYPE_* constants
|
771
|
-
within FieldDescriptor.
|
772
|
-
"""
|
773
|
-
try:
|
774
|
-
fn = type_checkers.TYPE_TO_BYTE_SIZE_FN[field_type]
|
775
|
-
return fn(field_number, value)
|
776
|
-
except KeyError:
|
777
|
-
raise message_mod.EncodeError('Unrecognized field type: %d' % field_type)
|
778
|
-
|
779
|
-
|
780
|
-
def _AddByteSizeMethod(message_descriptor, cls):
|
781
|
-
"""Helper for _AddMessageMethods()."""
|
782
|
-
|
783
|
-
def ByteSize(self):
|
784
|
-
if not self._cached_byte_size_dirty:
|
785
|
-
return self._cached_byte_size
|
786
|
-
|
787
|
-
size = 0
|
788
|
-
for field_descriptor, field_value in self.ListFields():
|
789
|
-
size += field_descriptor._sizer(field_value)
|
790
|
-
|
791
|
-
for tag_bytes, value_bytes in self._unknown_fields:
|
792
|
-
size += len(tag_bytes) + len(value_bytes)
|
793
|
-
|
794
|
-
self._cached_byte_size = size
|
795
|
-
self._cached_byte_size_dirty = False
|
796
|
-
self._listener_for_children.dirty = False
|
797
|
-
return size
|
798
|
-
|
799
|
-
cls.ByteSize = ByteSize
|
800
|
-
|
801
|
-
|
802
|
-
def _AddSerializeToStringMethod(message_descriptor, cls):
|
803
|
-
"""Helper for _AddMessageMethods()."""
|
804
|
-
|
805
|
-
def SerializeToString(self):
|
806
|
-
# Check if the message has all of its required fields set.
|
807
|
-
errors = []
|
808
|
-
if not self.IsInitialized():
|
809
|
-
raise message_mod.EncodeError(
|
810
|
-
'Message %s is missing required fields: %s' % (
|
811
|
-
self.DESCRIPTOR.full_name, ','.join(self.FindInitializationErrors())))
|
812
|
-
return self.SerializePartialToString()
|
813
|
-
cls.SerializeToString = SerializeToString
|
814
|
-
|
815
|
-
|
816
|
-
def _AddSerializePartialToStringMethod(message_descriptor, cls):
|
817
|
-
"""Helper for _AddMessageMethods()."""
|
818
|
-
|
819
|
-
def SerializePartialToString(self):
|
820
|
-
out = BytesIO()
|
821
|
-
self._InternalSerialize(out.write)
|
822
|
-
return out.getvalue()
|
823
|
-
cls.SerializePartialToString = SerializePartialToString
|
824
|
-
|
825
|
-
def InternalSerialize(self, write_bytes):
|
826
|
-
for field_descriptor, field_value in self.ListFields():
|
827
|
-
field_descriptor._encoder(write_bytes, field_value)
|
828
|
-
for tag_bytes, value_bytes in self._unknown_fields:
|
829
|
-
write_bytes(tag_bytes)
|
830
|
-
write_bytes(value_bytes)
|
831
|
-
cls._InternalSerialize = InternalSerialize
|
832
|
-
|
833
|
-
|
834
|
-
def _AddMergeFromStringMethod(message_descriptor, cls):
|
835
|
-
"""Helper for _AddMessageMethods()."""
|
836
|
-
def MergeFromString(self, serialized):
|
837
|
-
length = len(serialized)
|
838
|
-
try:
|
839
|
-
if self._InternalParse(serialized, 0, length) != length:
|
840
|
-
# The only reason _InternalParse would return early is if it
|
841
|
-
# encountered an end-group tag.
|
842
|
-
raise message_mod.DecodeError('Unexpected end-group tag.')
|
843
|
-
except (IndexError, TypeError):
|
844
|
-
# Now ord(buf[p:p+1]) == ord('') gets TypeError.
|
845
|
-
raise message_mod.DecodeError('Truncated message.')
|
846
|
-
except struct.error, e:
|
847
|
-
raise message_mod.DecodeError(e)
|
848
|
-
return length # Return this for legacy reasons.
|
849
|
-
cls.MergeFromString = MergeFromString
|
850
|
-
|
851
|
-
local_ReadTag = decoder.ReadTag
|
852
|
-
local_SkipField = decoder.SkipField
|
853
|
-
decoders_by_tag = cls._decoders_by_tag
|
854
|
-
|
855
|
-
def InternalParse(self, buffer, pos, end):
|
856
|
-
self._Modified()
|
857
|
-
field_dict = self._fields
|
858
|
-
unknown_field_list = self._unknown_fields
|
859
|
-
while pos != end:
|
860
|
-
(tag_bytes, new_pos) = local_ReadTag(buffer, pos)
|
861
|
-
field_decoder = decoders_by_tag.get(tag_bytes)
|
862
|
-
if field_decoder is None:
|
863
|
-
value_start_pos = new_pos
|
864
|
-
new_pos = local_SkipField(buffer, new_pos, end, tag_bytes)
|
865
|
-
if new_pos == -1:
|
866
|
-
return pos
|
867
|
-
if not unknown_field_list:
|
868
|
-
unknown_field_list = self._unknown_fields = []
|
869
|
-
unknown_field_list.append((tag_bytes, buffer[value_start_pos:new_pos]))
|
870
|
-
pos = new_pos
|
871
|
-
else:
|
872
|
-
pos = field_decoder(buffer, new_pos, end, self, field_dict)
|
873
|
-
return pos
|
874
|
-
cls._InternalParse = InternalParse
|
875
|
-
|
876
|
-
|
877
|
-
def _AddIsInitializedMethod(message_descriptor, cls):
|
878
|
-
"""Adds the IsInitialized and FindInitializationError methods to the
|
879
|
-
protocol message class."""
|
880
|
-
|
881
|
-
required_fields = [field for field in message_descriptor.fields
|
882
|
-
if field.label == _FieldDescriptor.LABEL_REQUIRED]
|
883
|
-
|
884
|
-
def IsInitialized(self, errors=None):
|
885
|
-
"""Checks if all required fields of a message are set.
|
886
|
-
|
887
|
-
Args:
|
888
|
-
errors: A list which, if provided, will be populated with the field
|
889
|
-
paths of all missing required fields.
|
890
|
-
|
891
|
-
Returns:
|
892
|
-
True iff the specified message has all required fields set.
|
893
|
-
"""
|
894
|
-
|
895
|
-
# Performance is critical so we avoid HasField() and ListFields().
|
896
|
-
|
897
|
-
for field in required_fields:
|
898
|
-
if (field not in self._fields or
|
899
|
-
(field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE and
|
900
|
-
not self._fields[field]._is_present_in_parent)):
|
901
|
-
if errors is not None:
|
902
|
-
errors.extend(self.FindInitializationErrors())
|
903
|
-
return False
|
904
|
-
|
905
|
-
for field, value in list(self._fields.items()): # dict can change size!
|
906
|
-
if field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
|
907
|
-
if field.label == _FieldDescriptor.LABEL_REPEATED:
|
908
|
-
for element in value:
|
909
|
-
if not element.IsInitialized():
|
910
|
-
if errors is not None:
|
911
|
-
errors.extend(self.FindInitializationErrors())
|
912
|
-
return False
|
913
|
-
elif value._is_present_in_parent and not value.IsInitialized():
|
914
|
-
if errors is not None:
|
915
|
-
errors.extend(self.FindInitializationErrors())
|
916
|
-
return False
|
917
|
-
|
918
|
-
return True
|
919
|
-
|
920
|
-
cls.IsInitialized = IsInitialized
|
921
|
-
|
922
|
-
def FindInitializationErrors(self):
|
923
|
-
"""Finds required fields which are not initialized.
|
924
|
-
|
925
|
-
Returns:
|
926
|
-
A list of strings. Each string is a path to an uninitialized field from
|
927
|
-
the top-level message, e.g. "foo.bar[5].baz".
|
928
|
-
"""
|
929
|
-
|
930
|
-
errors = [] # simplify things
|
931
|
-
|
932
|
-
for field in required_fields:
|
933
|
-
if not self.HasField(field.name):
|
934
|
-
errors.append(field.name)
|
935
|
-
|
936
|
-
for field, value in self.ListFields():
|
937
|
-
if field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
|
938
|
-
if field.is_extension:
|
939
|
-
name = "(%s)" % field.full_name
|
940
|
-
else:
|
941
|
-
name = field.name
|
942
|
-
|
943
|
-
if field.label == _FieldDescriptor.LABEL_REPEATED:
|
944
|
-
for i in xrange(len(value)):
|
945
|
-
element = value[i]
|
946
|
-
prefix = "%s[%d]." % (name, i)
|
947
|
-
sub_errors = element.FindInitializationErrors()
|
948
|
-
errors += [ prefix + error for error in sub_errors ]
|
949
|
-
else:
|
950
|
-
prefix = name + "."
|
951
|
-
sub_errors = value.FindInitializationErrors()
|
952
|
-
errors += [ prefix + error for error in sub_errors ]
|
953
|
-
|
954
|
-
return errors
|
955
|
-
|
956
|
-
cls.FindInitializationErrors = FindInitializationErrors
|
957
|
-
|
958
|
-
|
959
|
-
def _AddMergeFromMethod(cls):
|
960
|
-
LABEL_REPEATED = _FieldDescriptor.LABEL_REPEATED
|
961
|
-
CPPTYPE_MESSAGE = _FieldDescriptor.CPPTYPE_MESSAGE
|
962
|
-
|
963
|
-
def MergeFrom(self, msg):
|
964
|
-
if not isinstance(msg, cls):
|
965
|
-
raise TypeError(
|
966
|
-
"Parameter to MergeFrom() must be instance of same class: "
|
967
|
-
"expected %s got %s." % (cls.__name__, type(msg).__name__))
|
968
|
-
|
969
|
-
assert msg is not self
|
970
|
-
self._Modified()
|
971
|
-
|
972
|
-
fields = self._fields
|
973
|
-
|
974
|
-
for field, value in msg._fields.iteritems():
|
975
|
-
if field.label == LABEL_REPEATED:
|
976
|
-
field_value = fields.get(field)
|
977
|
-
if field_value is None:
|
978
|
-
# Construct a new object to represent this field.
|
979
|
-
field_value = field._default_constructor(self)
|
980
|
-
fields[field] = field_value
|
981
|
-
field_value.MergeFrom(value)
|
982
|
-
elif field.cpp_type == CPPTYPE_MESSAGE:
|
983
|
-
if value._is_present_in_parent:
|
984
|
-
field_value = fields.get(field)
|
985
|
-
if field_value is None:
|
986
|
-
# Construct a new object to represent this field.
|
987
|
-
field_value = field._default_constructor(self)
|
988
|
-
fields[field] = field_value
|
989
|
-
field_value.MergeFrom(value)
|
990
|
-
else:
|
991
|
-
self._fields[field] = value
|
992
|
-
|
993
|
-
if msg._unknown_fields:
|
994
|
-
if not self._unknown_fields:
|
995
|
-
self._unknown_fields = []
|
996
|
-
self._unknown_fields.extend(msg._unknown_fields)
|
997
|
-
|
998
|
-
cls.MergeFrom = MergeFrom
|
999
|
-
|
1000
|
-
|
1001
|
-
def _AddWhichOneofMethod(message_descriptor, cls):
|
1002
|
-
def WhichOneof(self, oneof_name):
|
1003
|
-
"""Returns the name of the currently set field inside a oneof, or None."""
|
1004
|
-
try:
|
1005
|
-
field = message_descriptor.oneofs_by_name[oneof_name]
|
1006
|
-
except KeyError:
|
1007
|
-
raise ValueError(
|
1008
|
-
'Protocol message has no oneof "%s" field.' % oneof_name)
|
1009
|
-
|
1010
|
-
nested_field = self._oneofs.get(field, None)
|
1011
|
-
if nested_field is not None and self.HasField(nested_field.name):
|
1012
|
-
return nested_field.name
|
1013
|
-
else:
|
1014
|
-
return None
|
1015
|
-
|
1016
|
-
cls.WhichOneof = WhichOneof
|
1017
|
-
|
1018
|
-
|
1019
|
-
def _AddMessageMethods(message_descriptor, cls):
|
1020
|
-
"""Adds implementations of all Message methods to cls."""
|
1021
|
-
_AddListFieldsMethod(message_descriptor, cls)
|
1022
|
-
_AddHasFieldMethod(message_descriptor, cls)
|
1023
|
-
_AddClearFieldMethod(message_descriptor, cls)
|
1024
|
-
if message_descriptor.is_extendable:
|
1025
|
-
_AddClearExtensionMethod(cls)
|
1026
|
-
_AddHasExtensionMethod(cls)
|
1027
|
-
_AddClearMethod(message_descriptor, cls)
|
1028
|
-
_AddEqualsMethod(message_descriptor, cls)
|
1029
|
-
_AddStrMethod(message_descriptor, cls)
|
1030
|
-
_AddUnicodeMethod(message_descriptor, cls)
|
1031
|
-
_AddSetListenerMethod(cls)
|
1032
|
-
_AddByteSizeMethod(message_descriptor, cls)
|
1033
|
-
_AddSerializeToStringMethod(message_descriptor, cls)
|
1034
|
-
_AddSerializePartialToStringMethod(message_descriptor, cls)
|
1035
|
-
_AddMergeFromStringMethod(message_descriptor, cls)
|
1036
|
-
_AddIsInitializedMethod(message_descriptor, cls)
|
1037
|
-
_AddMergeFromMethod(cls)
|
1038
|
-
_AddWhichOneofMethod(message_descriptor, cls)
|
1039
|
-
|
1040
|
-
def _AddPrivateHelperMethods(message_descriptor, cls):
|
1041
|
-
"""Adds implementation of private helper methods to cls."""
|
1042
|
-
|
1043
|
-
def Modified(self):
|
1044
|
-
"""Sets the _cached_byte_size_dirty bit to true,
|
1045
|
-
and propagates this to our listener iff this was a state change.
|
1046
|
-
"""
|
1047
|
-
|
1048
|
-
# Note: Some callers check _cached_byte_size_dirty before calling
|
1049
|
-
# _Modified() as an extra optimization. So, if this method is ever
|
1050
|
-
# changed such that it does stuff even when _cached_byte_size_dirty is
|
1051
|
-
# already true, the callers need to be updated.
|
1052
|
-
if not self._cached_byte_size_dirty:
|
1053
|
-
self._cached_byte_size_dirty = True
|
1054
|
-
self._listener_for_children.dirty = True
|
1055
|
-
self._is_present_in_parent = True
|
1056
|
-
self._listener.Modified()
|
1057
|
-
|
1058
|
-
def _UpdateOneofState(self, field):
|
1059
|
-
"""Sets field as the active field in its containing oneof.
|
1060
|
-
|
1061
|
-
Will also delete currently active field in the oneof, if it is different
|
1062
|
-
from the argument. Does not mark the message as modified.
|
1063
|
-
"""
|
1064
|
-
other_field = self._oneofs.setdefault(field.containing_oneof, field)
|
1065
|
-
if other_field is not field:
|
1066
|
-
del self._fields[other_field]
|
1067
|
-
self._oneofs[field.containing_oneof] = field
|
1068
|
-
|
1069
|
-
cls._Modified = Modified
|
1070
|
-
cls.SetInParent = Modified
|
1071
|
-
cls._UpdateOneofState = _UpdateOneofState
|
1072
|
-
|
1073
|
-
|
1074
|
-
class _Listener(object):
|
1075
|
-
|
1076
|
-
"""MessageListener implementation that a parent message registers with its
|
1077
|
-
child message.
|
1078
|
-
|
1079
|
-
In order to support semantics like:
|
1080
|
-
|
1081
|
-
foo.bar.baz.qux = 23
|
1082
|
-
assert foo.HasField('bar')
|
1083
|
-
|
1084
|
-
...child objects must have back references to their parents.
|
1085
|
-
This helper class is at the heart of this support.
|
1086
|
-
"""
|
1087
|
-
|
1088
|
-
def __init__(self, parent_message):
|
1089
|
-
"""Args:
|
1090
|
-
parent_message: The message whose _Modified() method we should call when
|
1091
|
-
we receive Modified() messages.
|
1092
|
-
"""
|
1093
|
-
# This listener establishes a back reference from a child (contained) object
|
1094
|
-
# to its parent (containing) object. We make this a weak reference to avoid
|
1095
|
-
# creating cyclic garbage when the client finishes with the 'parent' object
|
1096
|
-
# in the tree.
|
1097
|
-
if isinstance(parent_message, weakref.ProxyType):
|
1098
|
-
self._parent_message_weakref = parent_message
|
1099
|
-
else:
|
1100
|
-
self._parent_message_weakref = weakref.proxy(parent_message)
|
1101
|
-
|
1102
|
-
# As an optimization, we also indicate directly on the listener whether
|
1103
|
-
# or not the parent message is dirty. This way we can avoid traversing
|
1104
|
-
# up the tree in the common case.
|
1105
|
-
self.dirty = False
|
1106
|
-
|
1107
|
-
def Modified(self):
|
1108
|
-
if self.dirty:
|
1109
|
-
return
|
1110
|
-
try:
|
1111
|
-
# Propagate the signal to our parents iff this is the first field set.
|
1112
|
-
self._parent_message_weakref._Modified()
|
1113
|
-
except ReferenceError:
|
1114
|
-
# We can get here if a client has kept a reference to a child object,
|
1115
|
-
# and is now setting a field on it, but the child's parent has been
|
1116
|
-
# garbage-collected. This is not an error.
|
1117
|
-
pass
|
1118
|
-
|
1119
|
-
|
1120
|
-
class _OneofListener(_Listener):
|
1121
|
-
"""Special listener implementation for setting composite oneof fields."""
|
1122
|
-
|
1123
|
-
def __init__(self, parent_message, field):
|
1124
|
-
"""Args:
|
1125
|
-
parent_message: The message whose _Modified() method we should call when
|
1126
|
-
we receive Modified() messages.
|
1127
|
-
field: The descriptor of the field being set in the parent message.
|
1128
|
-
"""
|
1129
|
-
super(_OneofListener, self).__init__(parent_message)
|
1130
|
-
self._field = field
|
1131
|
-
|
1132
|
-
def Modified(self):
|
1133
|
-
"""Also updates the state of the containing oneof in the parent message."""
|
1134
|
-
try:
|
1135
|
-
self._parent_message_weakref._UpdateOneofState(self._field)
|
1136
|
-
super(_OneofListener, self).Modified()
|
1137
|
-
except ReferenceError:
|
1138
|
-
pass
|
1139
|
-
|
1140
|
-
|
1141
|
-
# TODO(robinson): Move elsewhere? This file is getting pretty ridiculous...
|
1142
|
-
# TODO(robinson): Unify error handling of "unknown extension" crap.
|
1143
|
-
# TODO(robinson): Support iteritems()-style iteration over all
|
1144
|
-
# extensions with the "has" bits turned on?
|
1145
|
-
class _ExtensionDict(object):
|
1146
|
-
|
1147
|
-
"""Dict-like container for supporting an indexable "Extensions"
|
1148
|
-
field on proto instances.
|
1149
|
-
|
1150
|
-
Note that in all cases we expect extension handles to be
|
1151
|
-
FieldDescriptors.
|
1152
|
-
"""
|
1153
|
-
|
1154
|
-
def __init__(self, extended_message):
|
1155
|
-
"""extended_message: Message instance for which we are the Extensions dict.
|
1156
|
-
"""
|
1157
|
-
|
1158
|
-
self._extended_message = extended_message
|
1159
|
-
|
1160
|
-
def __getitem__(self, extension_handle):
|
1161
|
-
"""Returns the current value of the given extension handle."""
|
1162
|
-
|
1163
|
-
_VerifyExtensionHandle(self._extended_message, extension_handle)
|
1164
|
-
|
1165
|
-
result = self._extended_message._fields.get(extension_handle)
|
1166
|
-
if result is not None:
|
1167
|
-
return result
|
1168
|
-
|
1169
|
-
if extension_handle.label == _FieldDescriptor.LABEL_REPEATED:
|
1170
|
-
result = extension_handle._default_constructor(self._extended_message)
|
1171
|
-
elif extension_handle.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
|
1172
|
-
result = extension_handle.message_type._concrete_class()
|
1173
|
-
try:
|
1174
|
-
result._SetListener(self._extended_message._listener_for_children)
|
1175
|
-
except ReferenceError:
|
1176
|
-
pass
|
1177
|
-
else:
|
1178
|
-
# Singular scalar -- just return the default without inserting into the
|
1179
|
-
# dict.
|
1180
|
-
return extension_handle.default_value
|
1181
|
-
|
1182
|
-
# Atomically check if another thread has preempted us and, if not, swap
|
1183
|
-
# in the new object we just created. If someone has preempted us, we
|
1184
|
-
# take that object and discard ours.
|
1185
|
-
# WARNING: We are relying on setdefault() being atomic. This is true
|
1186
|
-
# in CPython but we haven't investigated others. This warning appears
|
1187
|
-
# in several other locations in this file.
|
1188
|
-
result = self._extended_message._fields.setdefault(
|
1189
|
-
extension_handle, result)
|
1190
|
-
|
1191
|
-
return result
|
1192
|
-
|
1193
|
-
def __eq__(self, other):
|
1194
|
-
if not isinstance(other, self.__class__):
|
1195
|
-
return False
|
1196
|
-
|
1197
|
-
my_fields = self._extended_message.ListFields()
|
1198
|
-
other_fields = other._extended_message.ListFields()
|
1199
|
-
|
1200
|
-
# Get rid of non-extension fields.
|
1201
|
-
my_fields = [ field for field in my_fields if field.is_extension ]
|
1202
|
-
other_fields = [ field for field in other_fields if field.is_extension ]
|
1203
|
-
|
1204
|
-
return my_fields == other_fields
|
1205
|
-
|
1206
|
-
def __ne__(self, other):
|
1207
|
-
return not self == other
|
1208
|
-
|
1209
|
-
def __hash__(self):
|
1210
|
-
raise TypeError('unhashable object')
|
1211
|
-
|
1212
|
-
# Note that this is only meaningful for non-repeated, scalar extension
|
1213
|
-
# fields. Note also that we may have to call _Modified() when we do
|
1214
|
-
# successfully set a field this way, to set any necssary "has" bits in the
|
1215
|
-
# ancestors of the extended message.
|
1216
|
-
def __setitem__(self, extension_handle, value):
|
1217
|
-
"""If extension_handle specifies a non-repeated, scalar extension
|
1218
|
-
field, sets the value of that field.
|
1219
|
-
"""
|
1220
|
-
|
1221
|
-
_VerifyExtensionHandle(self._extended_message, extension_handle)
|
1222
|
-
|
1223
|
-
if (extension_handle.label == _FieldDescriptor.LABEL_REPEATED or
|
1224
|
-
extension_handle.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE):
|
1225
|
-
raise TypeError(
|
1226
|
-
'Cannot assign to extension "%s" because it is a repeated or '
|
1227
|
-
'composite type.' % extension_handle.full_name)
|
1228
|
-
|
1229
|
-
# It's slightly wasteful to lookup the type checker each time,
|
1230
|
-
# but we expect this to be a vanishingly uncommon case anyway.
|
1231
|
-
type_checker = type_checkers.GetTypeChecker(
|
1232
|
-
extension_handle)
|
1233
|
-
# pylint: disable=protected-access
|
1234
|
-
self._extended_message._fields[extension_handle] = (
|
1235
|
-
type_checker.CheckValue(value))
|
1236
|
-
self._extended_message._Modified()
|
1237
|
-
|
1238
|
-
def _FindExtensionByName(self, name):
|
1239
|
-
"""Tries to find a known extension with the specified name.
|
1240
|
-
|
1241
|
-
Args:
|
1242
|
-
name: Extension full name.
|
1243
|
-
|
1244
|
-
Returns:
|
1245
|
-
Extension field descriptor.
|
1246
|
-
"""
|
1247
|
-
return self._extended_message._extensions_by_name.get(name, None)
|