libv8 5.7.492.65.1 → 5.9.211.38.0beta0
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 +8 -2
- data/CHANGELOG.md +4 -0
- data/README.md +4 -3
- data/Rakefile +27 -10
- data/ext/libv8/builder.rb +4 -0
- data/lib/libv8/version.rb +1 -1
- data/libv8.gemspec +1 -1
- data/patches/0001-Build-a-standalone-static-library.patch +5 -5
- data/patches/0002-Don-t-compile-unnecessary-stuff.patch +20 -24
- data/patches/0003-Use-the-fPIC-flag-for-the-static-library.patch +5 -5
- data/patches/0004-Do-not-embed-debug-symbols-in-macOS-libraries.patch +5 -5
- data/patches/0005-Fix-GCC-7-build-errors.patch +147 -0
- data/scaleway.png +0 -0
- data/vendor/depot_tools/.gitattributes +52 -0
- data/vendor/depot_tools/.gitignore +10 -0
- data/vendor/depot_tools/README.md +7 -3
- data/vendor/depot_tools/apply_issue.bat +4 -3
- data/vendor/depot_tools/apply_issue.py +0 -10
- data/vendor/depot_tools/autoninja +12 -0
- data/vendor/depot_tools/autoninja.bat +9 -0
- data/vendor/depot_tools/autoninja.py +70 -0
- data/vendor/depot_tools/bootstrap/win/README.md +108 -26
- data/vendor/depot_tools/bootstrap/win/git-bash.template.sh +3 -3
- data/vendor/depot_tools/bootstrap/win/git.template.bat +2 -2
- data/vendor/depot_tools/bootstrap/win/manifest.txt +18 -0
- data/vendor/depot_tools/bootstrap/win/manifest_bleeding_edge.txt +18 -0
- data/vendor/depot_tools/bootstrap/win/python27.new.bat +49 -0
- data/vendor/depot_tools/bootstrap/win/win_tools.bat +55 -59
- data/vendor/depot_tools/bootstrap/win/win_tools.py +335 -0
- data/vendor/depot_tools/cipd +16 -2
- data/vendor/depot_tools/cipd.bat +20 -2
- data/vendor/depot_tools/cipd.ps1 +36 -22
- data/vendor/depot_tools/cipd_bin_setup.bat +6 -0
- data/vendor/depot_tools/cipd_bin_setup.sh +10 -0
- data/vendor/depot_tools/cipd_client_version +1 -1
- data/vendor/depot_tools/cipd_manifest.txt +9 -0
- data/vendor/depot_tools/cit.bat +12 -11
- data/vendor/depot_tools/clang-format.bat +4 -3
- data/vendor/depot_tools/clang_format_merge_driver.bat +12 -11
- data/vendor/depot_tools/commit_queue.bat +4 -3
- data/vendor/depot_tools/cpplint.bat +9 -3
- data/vendor/depot_tools/cpplint.py +3 -3
- data/vendor/depot_tools/depot-tools-auth.bat +4 -3
- data/vendor/depot_tools/download_from_google_storage.bat +5 -3
- data/vendor/depot_tools/download_from_google_storage.py +6 -1
- data/vendor/depot_tools/fetch.bat +5 -4
- data/vendor/depot_tools/fetch.py +4 -5
- data/vendor/depot_tools/gclient-new-workdir.py +82 -46
- data/vendor/depot_tools/gclient.bat +5 -4
- data/vendor/depot_tools/gclient.py +713 -319
- data/vendor/depot_tools/gclient_eval.py +284 -0
- data/vendor/depot_tools/gclient_utils.py +70 -4
- data/vendor/depot_tools/gerrit_client.py +26 -1
- data/vendor/depot_tools/gerrit_util.py +120 -127
- data/vendor/depot_tools/git-crrev-parse +1 -0
- data/vendor/depot_tools/git-gs +1 -1
- data/vendor/depot_tools/git_cl.py +731 -415
- data/vendor/depot_tools/git_common.py +23 -3
- data/vendor/depot_tools/git_drover.py +10 -1
- data/vendor/depot_tools/git_footers.py +62 -22
- data/vendor/depot_tools/git_hyper_blame.py +3 -2
- data/vendor/depot_tools/git_map.py +30 -3
- data/vendor/depot_tools/git_map_branches.py +18 -4
- data/vendor/depot_tools/git_number.py +8 -2
- data/vendor/depot_tools/git_retry.py +21 -0
- data/vendor/depot_tools/gn.bat +4 -3
- data/vendor/depot_tools/infra/config/cq.cfg +1 -5
- data/vendor/depot_tools/infra/config/recipes.cfg +18 -16
- data/vendor/depot_tools/led +12 -0
- data/vendor/depot_tools/led.bat +7 -0
- data/vendor/depot_tools/man/html/git-cl.html +9 -1
- data/vendor/depot_tools/man/html/git-drover.html +22 -18
- data/vendor/depot_tools/man/man1/git-cl.1 +8 -3
- data/vendor/depot_tools/man/man1/git-drover.1 +22 -20
- data/vendor/depot_tools/man/src/git-cl.txt +3 -0
- data/vendor/depot_tools/man/src/git-drover.txt +8 -0
- data/vendor/depot_tools/my_activity.py +8 -5
- data/vendor/depot_tools/owners.py +103 -11
- data/vendor/depot_tools/owners_finder.py +14 -2
- data/vendor/depot_tools/presubmit_canned_checks.py +25 -67
- data/vendor/depot_tools/presubmit_support.py +87 -35
- data/vendor/depot_tools/recipes/OWNERS +2 -0
- data/vendor/depot_tools/recipes/README.recipes.md +842 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/__init__.py +5 -3
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/api.py +181 -60
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/{example.expected → examples/full.expected}/apply_gerrit_ref.json +4 -2
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic.json +82 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic_with_branch_heads.json +149 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/buildbot.json +82 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/clobber.json +149 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/deprecated_got_revision_mapping.json +122 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/gerrit_no_rebase_patch_ref.json +149 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/gerrit_no_reset.json +149 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_shallow.json +149 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/reset_root_solution_revision.json +148 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/trychange.json +150 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/{example.expected → examples/full.expected}/trychange_oauth2.json +0 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/trychange_oauth2_buildbot.json +152 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/trychange_oauth2_json.json +150 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/trychange_oauth2_json_win.json +150 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob.json +156 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail.json +91 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch.json +118 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch_download.json +118 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_angle.json +202 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_angle_deprecated.json +158 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_feature_branch.json +196 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8.json +202 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8_feature_branch.json +202 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8.json +162 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8_head_by_default.json +162 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_tags.json +149 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/{example.py → examples/full.py} +46 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/resources/bot_update.py +139 -133
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/test_api.py +25 -13
- data/vendor/depot_tools/recipes/recipe_modules/cipd/api.py +40 -9
- data/vendor/depot_tools/recipes/recipe_modules/cipd/{example.expected → examples/full.expected}/basic.json +0 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/{example.expected → examples/full.expected}/basic_pkg.json +1 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/{example.expected → examples/full.expected}/describe-failed.json +0 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/{example.expected → examples/full.expected}/describe-many-instances.json +0 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/{example.expected → examples/full.expected}/mac64.json +0 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/{example.expected → examples/full.expected}/pkg_bad_file.json +1 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/{example.expected → examples/full.expected}/pkg_bad_mode.json +0 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/{example.expected → examples/full.expected}/pkg_bad_verfile.json +0 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/{example.expected → examples/full.expected}/win64.json +0 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/{example.py → examples/full.py} +1 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/junk arch.json +7 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/junk bits.json +7 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_arm_32.json +14 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_arm_64.json +14 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_intel_32.json +14 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_intel_64.json +14 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_mips_64.json +14 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/mac_intel_64.json +14 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/win_intel_32.json +14 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/win_intel_64.json +14 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.py +59 -0
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/api.py +5 -0
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/{example.expected → examples/full.expected}/basic.json +7 -0
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/{example.expected → examples/full.expected}/win.json +7 -0
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/{example.py → examples/full.py} +2 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/__init__.py +1 -4
- data/vendor/depot_tools/recipes/recipe_modules/gclient/api.py +28 -14
- data/vendor/depot_tools/recipes/recipe_modules/gclient/config.py +10 -235
- data/vendor/depot_tools/recipes/recipe_modules/gclient/{example.expected → examples/full.expected}/basic.json +9 -9
- data/vendor/depot_tools/recipes/recipe_modules/gclient/{example.expected → examples/full.expected}/buildbot.json +9 -9
- data/vendor/depot_tools/recipes/recipe_modules/gclient/{example.expected → examples/full.expected}/revision.json +9 -9
- data/vendor/depot_tools/recipes/recipe_modules/gclient/{example.expected → examples/full.expected}/tryserver.json +9 -9
- data/vendor/depot_tools/recipes/recipe_modules/gclient/{example.py → examples/full.py} +5 -21
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/patch_project.py +45 -0
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/__init__.py +1 -0
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/api.py +97 -2
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/examples/full.expected/basic.json +283 -0
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/{example.py → examples/full.py} +31 -2
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/test_api.py +30 -1
- data/vendor/depot_tools/recipes/recipe_modules/git/__init__.py +1 -4
- data/vendor/depot_tools/recipes/recipe_modules/git/api.py +7 -35
- data/vendor/depot_tools/recipes/recipe_modules/git/{example.expected → examples/full.expected}/basic.json +3 -3
- data/vendor/depot_tools/recipes/recipe_modules/git/{example.expected → examples/full.expected}/basic_branch.json +3 -3
- data/vendor/depot_tools/recipes/recipe_modules/git/{example.expected → examples/full.expected}/basic_file_name.json +3 -3
- data/vendor/depot_tools/recipes/recipe_modules/git/{example.expected → examples/full.expected}/basic_hash.json +3 -3
- data/vendor/depot_tools/recipes/recipe_modules/git/{example.expected → examples/full.expected}/basic_ref.json +3 -3
- data/vendor/depot_tools/recipes/recipe_modules/git/{example.expected → examples/full.expected}/basic_submodule_update_force.json +3 -3
- data/vendor/depot_tools/recipes/recipe_modules/git/{example.expected → examples/full.expected}/can_fail_build.json +1 -1
- data/vendor/depot_tools/recipes/recipe_modules/git/{example.expected → examples/full.expected}/cannot_fail_build.json +3 -3
- data/vendor/depot_tools/recipes/recipe_modules/git/{example.expected → examples/full.expected}/cat-file_test.json +3 -3
- data/vendor/depot_tools/recipes/recipe_modules/git/{example.expected → examples/full.expected}/count-objects_delta.json +3 -3
- data/vendor/depot_tools/recipes/recipe_modules/git/{example.expected → examples/full.expected}/count-objects_failed.json +3 -3
- data/vendor/depot_tools/recipes/recipe_modules/git/{example.expected → examples/full.expected}/count-objects_with_bad_output.json +3 -3
- data/vendor/depot_tools/recipes/recipe_modules/git/{example.expected → examples/full.expected}/count-objects_with_bad_output_fails_build.json +1 -1
- data/vendor/depot_tools/recipes/recipe_modules/git/{example.expected → examples/full.expected}/curl_trace_file.json +3 -3
- data/vendor/depot_tools/recipes/recipe_modules/git/{example.expected → examples/full.expected}/git-cache-checkout.json +6 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/platform_win.json +223 -0
- data/vendor/depot_tools/recipes/recipe_modules/git/{example.expected → examples/full.expected}/rebase_failed.json +3 -3
- data/vendor/depot_tools/recipes/recipe_modules/git/{example.expected → examples/full.expected}/remote_not_origin.json +3 -3
- data/vendor/depot_tools/recipes/recipe_modules/git/{example.expected → examples/full.expected}/set_got_revision.json +3 -3
- data/vendor/depot_tools/recipes/recipe_modules/git/{example.py → examples/full.py} +2 -1
- data/vendor/depot_tools/recipes/recipe_modules/git/resources/git_setup.py +12 -21
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/__init__.py +1 -4
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/api.py +13 -11
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/{example.expected → examples/full.expected}/basic.json +0 -0
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/{example.py → examples/full.py} +4 -2
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/OWNERS +3 -0
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/__init__.py +7 -0
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/api.py +135 -0
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/examples/full.expected/basic.json +537 -0
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/examples/full.py +61 -0
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/resources/gerrit_client.py +192 -0
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/test_api.py +95 -0
- data/vendor/depot_tools/recipes/recipe_modules/gsutil/{example.expected → examples/full.expected}/basic.json +0 -0
- data/vendor/depot_tools/recipes/recipe_modules/gsutil/{example.py → examples/full.py} +0 -0
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/__init__.py +0 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/{example.expected → examples/full.expected}/basic.json +3 -2
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/{example.expected → examples/full.expected}/paths_buildbot_linux.json +3 -2
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/{example.expected → examples/full.expected}/paths_buildbot_mac.json +3 -2
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/{example.expected → examples/full.expected}/paths_buildbot_win.json +3 -2
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/{example.expected → examples/full.expected}/paths_generic_linux.json +3 -2
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/{example.expected → examples/full.expected}/paths_generic_mac.json +3 -2
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_win.json +16 -0
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_linux.json +16 -0
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_mac.json +16 -0
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_win.json +16 -0
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/{example.py → examples/full.py} +2 -1
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/path_config.py +12 -3
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/__init__.py +1 -0
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/api.py +2 -2
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/{example.expected → examples/full.expected}/basic.json +1 -1
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/{example.py → examples/full.py} +0 -0
- data/vendor/depot_tools/recipes/recipe_modules/rietveld/__init__.py +0 -4
- data/vendor/depot_tools/recipes/recipe_modules/rietveld/{example.expected → examples/full.expected}/basic.json +0 -0
- data/vendor/depot_tools/recipes/recipe_modules/rietveld/{example.expected → examples/full.expected}/buildbot.json +0 -0
- data/vendor/depot_tools/recipes/recipe_modules/rietveld/examples/full.expected/no_auth.json +27 -0
- data/vendor/depot_tools/recipes/recipe_modules/rietveld/{example.py → examples/full.py} +9 -1
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/__init__.py +3 -5
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/api.py +21 -96
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/{example.expected → examples/full.expected}/basic_tags.json +0 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/{example.expected → examples/full.expected}/set_failure_hash_with_no_steps.json +0 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch.json +56 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/{example.expected/with_gerrit_patch_deprecated.json → examples/full.expected/with_git_patch.json} +2 -2
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/{example.expected/with_gerrit_patch.json → examples/full.expected/with_git_patch_luci.json} +2 -2
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/{example.expected → examples/full.expected}/with_rietveld_patch.json +0 -20
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/{example.expected → examples/full.expected}/with_rietveld_patch_new.json +0 -20
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/{example.expected → examples/full.expected}/with_wrong_patch.json +1 -13
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/{example.expected → examples/full.expected}/with_wrong_patch_new.json +1 -13
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/{example.py → examples/full.py} +3 -17
- data/vendor/depot_tools/recipes/recipes.py +141 -96
- data/vendor/depot_tools/rietveld.py +8 -1
- data/vendor/depot_tools/roll-dep-svn.bat +12 -10
- data/vendor/depot_tools/roll-dep.bat +5 -3
- data/vendor/depot_tools/scm.py +8 -1
- data/vendor/depot_tools/setup_color.py +0 -0
- data/vendor/depot_tools/split_cl.py +193 -0
- data/vendor/depot_tools/third_party/schema/.editorconfig +15 -0
- data/vendor/depot_tools/third_party/schema/.gitignore +174 -0
- data/vendor/depot_tools/third_party/schema/.travis.yml +37 -0
- data/vendor/depot_tools/third_party/schema/LICENSE-MIT +19 -0
- data/vendor/depot_tools/third_party/schema/MANIFEST.in +1 -0
- data/vendor/depot_tools/third_party/schema/README.chromium +12 -0
- data/vendor/depot_tools/third_party/schema/README.rst +382 -0
- data/vendor/depot_tools/third_party/schema/__init__.py +1 -0
- data/vendor/depot_tools/third_party/schema/schema.py +338 -0
- data/vendor/depot_tools/third_party/schema/setup.cfg +5 -0
- data/vendor/depot_tools/third_party/schema/setup.py +30 -0
- data/vendor/depot_tools/third_party/schema/test_schema.py +556 -0
- data/vendor/depot_tools/third_party/schema/tox.ini +33 -0
- data/vendor/depot_tools/third_party/upload.py +4 -0
- data/vendor/depot_tools/update_depot_tools +4 -16
- data/vendor/depot_tools/update_depot_tools.bat +4 -17
- data/vendor/depot_tools/update_depot_tools_toggle.py +38 -0
- data/vendor/depot_tools/vpython +12 -0
- data/vendor/depot_tools/vpython.bat +7 -0
- data/vendor/depot_tools/win_toolchain/get_toolchain_if_necessary.py +17 -5
- data/vendor/depot_tools/win_toolchain/package_from_installed.py +63 -33
- metadata +161 -113
- data/vendor/depot_tools/bootstrap/gclient.bat +0 -22
- data/vendor/depot_tools/bootstrap/win/get_file.js +0 -119
- data/vendor/depot_tools/bootstrap/win/git_bootstrap.py +0 -193
- data/vendor/depot_tools/bootstrap/win/git_version.txt +0 -1
- data/vendor/depot_tools/bootstrap/win/git_version_bleeding_edge.txt +0 -1
- data/vendor/depot_tools/bootstrap/win/python276.new.bat +0 -8
- data/vendor/depot_tools/bootstrap/win/svn.new.bat +0 -4
- data/vendor/depot_tools/bootstrap/win/svnversion.new.bat +0 -4
- data/vendor/depot_tools/bootstrap/win/unzip.js +0 -91
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/example.expected/basic.json +0 -53
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/example.expected/basic_output_manifest.json +0 -60
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/example.expected/basic_with_branch_heads.json +0 -54
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/example.expected/buildbot.json +0 -53
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/example.expected/clobber.json +0 -54
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/example.expected/gerrit_no_rebase_patch_ref.json +0 -54
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/example.expected/gerrit_no_reset.json +0 -54
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/example.expected/no_shallow.json +0 -54
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/example.expected/reset_root_solution_revision.json +0 -53
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/example.expected/trychange.json +0 -55
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/example.expected/trychange_oauth2_buildbot.json +0 -57
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/example.expected/trychange_oauth2_json.json +0 -55
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/example.expected/trychange_oauth2_json_win.json +0 -55
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/example.expected/tryjob.json +0 -59
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/example.expected/tryjob_fail.json +0 -62
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/example.expected/tryjob_fail_patch.json +0 -83
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/example.expected/tryjob_fail_patch_download.json +0 -84
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/example.expected/tryjob_gerrit_angle.json +0 -60
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/example.expected/tryjob_gerrit_angle_deprecated.json +0 -60
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/example.expected/tryjob_v8.json +0 -62
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/example.expected/tryjob_v8_head_by_default.json +0 -62
- data/vendor/depot_tools/recipes/recipe_modules/gclient/bundle_extra_paths.txt +0 -4
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/example.expected/basic.json +0 -66
- data/vendor/depot_tools/recipes/recipe_modules/git/bundle_extra_paths.txt +0 -28
- data/vendor/depot_tools/recipes/recipe_modules/git/example.expected/platform_win.json +0 -237
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/example.expected/paths_generic_win.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/example.expected/paths_kitchen_linux.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/example.expected/paths_kitchen_mac.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/example.expected/paths_kitchen_win.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/bundle_extra_paths.txt +0 -30
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/example.expected/with_git_patch.json +0 -109
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/example.expected/with_git_patch_luci.json +0 -8
@@ -0,0 +1,37 @@
|
|
1
|
+
# use new container-based infrastructure
|
2
|
+
sudo: false
|
3
|
+
|
4
|
+
language: python
|
5
|
+
|
6
|
+
addons:
|
7
|
+
apt:
|
8
|
+
sources:
|
9
|
+
- deadsnakes
|
10
|
+
packages:
|
11
|
+
- python3.5
|
12
|
+
|
13
|
+
cache:
|
14
|
+
pip: true
|
15
|
+
directories:
|
16
|
+
- .tox
|
17
|
+
|
18
|
+
install: pip install codecov tox
|
19
|
+
|
20
|
+
env:
|
21
|
+
- TOX_ENV=py26
|
22
|
+
- TOX_ENV=py27
|
23
|
+
- TOX_ENV=py33
|
24
|
+
- TOX_ENV=py34
|
25
|
+
- TOX_ENV=py35
|
26
|
+
- TOX_ENV=pypy
|
27
|
+
- TOX_ENV=pypy3
|
28
|
+
- TOX_ENV=coverage
|
29
|
+
- TOX_ENV=pep8
|
30
|
+
|
31
|
+
script:
|
32
|
+
- tox -e $TOX_ENV
|
33
|
+
|
34
|
+
# publish coverage only after a successful build
|
35
|
+
after_success:
|
36
|
+
- codecov
|
37
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2012 Vladimir Keleshev, <vladimir@keleshev.com>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
8
|
+
so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
@@ -0,0 +1 @@
|
|
1
|
+
include README.rst LICENSE-MIT *.py
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Name: schema
|
2
|
+
URL: https://github.com/keleshev/schema
|
3
|
+
Version: 0.6.6
|
4
|
+
License: MIT
|
5
|
+
|
6
|
+
Description:
|
7
|
+
schema is a library for validating Python data structures, such as those
|
8
|
+
obtained from config-files, forms, external services or command-line parsing,
|
9
|
+
converted from JSON/YAML (or something else) to Python data-types.
|
10
|
+
|
11
|
+
Modifications:
|
12
|
+
None.
|
@@ -0,0 +1,382 @@
|
|
1
|
+
Schema validation just got Pythonic
|
2
|
+
===============================================================================
|
3
|
+
|
4
|
+
**schema** is a library for validating Python data structures, such as those
|
5
|
+
obtained from config-files, forms, external services or command-line
|
6
|
+
parsing, converted from JSON/YAML (or something else) to Python data-types.
|
7
|
+
|
8
|
+
|
9
|
+
.. image:: https://secure.travis-ci.org/keleshev/schema.png?branch=master
|
10
|
+
:target: https://travis-ci.org/keleshev/schema
|
11
|
+
|
12
|
+
.. image:: https://img.shields.io/codecov/c/github/keleshev/schema.svg
|
13
|
+
:target: http://codecov.io/github/keleshev/schema
|
14
|
+
|
15
|
+
Example
|
16
|
+
----------------------------------------------------------------------------
|
17
|
+
|
18
|
+
Here is a quick example to get a feeling of **schema**, validating a list of
|
19
|
+
entries with personal information:
|
20
|
+
|
21
|
+
.. code:: python
|
22
|
+
|
23
|
+
>>> from schema import Schema, And, Use, Optional
|
24
|
+
|
25
|
+
>>> schema = Schema([{'name': And(str, len),
|
26
|
+
... 'age': And(Use(int), lambda n: 18 <= n <= 99),
|
27
|
+
... Optional('sex'): And(str, Use(str.lower),
|
28
|
+
... lambda s: s in ('male', 'female'))}])
|
29
|
+
|
30
|
+
>>> data = [{'name': 'Sue', 'age': '28', 'sex': 'FEMALE'},
|
31
|
+
... {'name': 'Sam', 'age': '42'},
|
32
|
+
... {'name': 'Sacha', 'age': '20', 'sex': 'Male'}]
|
33
|
+
|
34
|
+
>>> validated = schema.validate(data)
|
35
|
+
|
36
|
+
>>> assert validated == [{'name': 'Sue', 'age': 28, 'sex': 'female'},
|
37
|
+
... {'name': 'Sam', 'age': 42},
|
38
|
+
... {'name': 'Sacha', 'age' : 20, 'sex': 'male'}]
|
39
|
+
|
40
|
+
|
41
|
+
If data is valid, ``Schema.validate`` will return the validated data
|
42
|
+
(optionally converted with `Use` calls, see below).
|
43
|
+
|
44
|
+
If data is invalid, ``Schema`` will raise ``SchemaError`` exception.
|
45
|
+
|
46
|
+
|
47
|
+
Installation
|
48
|
+
-------------------------------------------------------------------------------
|
49
|
+
|
50
|
+
Use `pip <http://pip-installer.org>`_ or easy_install::
|
51
|
+
|
52
|
+
pip install schema
|
53
|
+
|
54
|
+
Alternatively, you can just drop ``schema.py`` file into your project—it is
|
55
|
+
self-contained.
|
56
|
+
|
57
|
+
- **schema** is tested with Python 2.6, 2.7, 3.2, 3.3 and PyPy.
|
58
|
+
- **schema** follows `semantic versioning <http://semver.org>`_.
|
59
|
+
|
60
|
+
How ``Schema`` validates data
|
61
|
+
-------------------------------------------------------------------------------
|
62
|
+
|
63
|
+
Types
|
64
|
+
~~~~~
|
65
|
+
|
66
|
+
If ``Schema(...)`` encounters a type (such as ``int``, ``str``, ``object``,
|
67
|
+
etc.), it will check if the corresponding piece of data is an instance of that type,
|
68
|
+
otherwise it will raise ``SchemaError``.
|
69
|
+
|
70
|
+
.. code:: python
|
71
|
+
|
72
|
+
>>> from schema import Schema
|
73
|
+
|
74
|
+
>>> Schema(int).validate(123)
|
75
|
+
123
|
76
|
+
|
77
|
+
>>> Schema(int).validate('123')
|
78
|
+
Traceback (most recent call last):
|
79
|
+
...
|
80
|
+
SchemaUnexpectedTypeError: '123' should be instance of 'int'
|
81
|
+
|
82
|
+
>>> Schema(object).validate('hai')
|
83
|
+
'hai'
|
84
|
+
|
85
|
+
Callables
|
86
|
+
~~~~~~~~~
|
87
|
+
|
88
|
+
If ``Schema(...)`` encounters a callable (function, class, or object with
|
89
|
+
``__call__`` method) it will call it, and if its return value evaluates to
|
90
|
+
``True`` it will continue validating, else—it will raise ``SchemaError``.
|
91
|
+
|
92
|
+
.. code:: python
|
93
|
+
|
94
|
+
>>> import os
|
95
|
+
|
96
|
+
>>> Schema(os.path.exists).validate('./')
|
97
|
+
'./'
|
98
|
+
|
99
|
+
>>> Schema(os.path.exists).validate('./non-existent/')
|
100
|
+
Traceback (most recent call last):
|
101
|
+
...
|
102
|
+
SchemaError: exists('./non-existent/') should evaluate to True
|
103
|
+
|
104
|
+
>>> Schema(lambda n: n > 0).validate(123)
|
105
|
+
123
|
106
|
+
|
107
|
+
>>> Schema(lambda n: n > 0).validate(-12)
|
108
|
+
Traceback (most recent call last):
|
109
|
+
...
|
110
|
+
SchemaError: <lambda>(-12) should evaluate to True
|
111
|
+
|
112
|
+
"Validatables"
|
113
|
+
~~~~~~~~~~~~~~
|
114
|
+
|
115
|
+
If ``Schema(...)`` encounters an object with method ``validate`` it will run
|
116
|
+
this method on corresponding data as ``data = obj.validate(data)``. This method
|
117
|
+
may raise ``SchemaError`` exception, which will tell ``Schema`` that that piece
|
118
|
+
of data is invalid, otherwise—it will continue validating.
|
119
|
+
|
120
|
+
An example of "validatable" is ``Regex``, that tries to match a string or a
|
121
|
+
buffer with the given regular expression (itself as a string, buffer or
|
122
|
+
compiled regex ``SRE_Pattern``):
|
123
|
+
|
124
|
+
.. code:: python
|
125
|
+
|
126
|
+
>>> from schema import Regex
|
127
|
+
>>> import re
|
128
|
+
|
129
|
+
>>> Regex(r'^foo').validate('foobar')
|
130
|
+
'foobar'
|
131
|
+
|
132
|
+
>>> Regex(r'^[A-Z]+$', flags=re.I).validate('those-dashes-dont-match')
|
133
|
+
Traceback (most recent call last):
|
134
|
+
...
|
135
|
+
SchemaError: Regex('^[A-Z]+$', flags=re.IGNORECASE) does not match 'those-dashes-dont-match'
|
136
|
+
|
137
|
+
For a more general case, you can use ``Use`` for creating such objects.
|
138
|
+
``Use`` helps to use a function or type to convert a value while validating it:
|
139
|
+
|
140
|
+
.. code:: python
|
141
|
+
|
142
|
+
>>> from schema import Use
|
143
|
+
|
144
|
+
>>> Schema(Use(int)).validate('123')
|
145
|
+
123
|
146
|
+
|
147
|
+
>>> Schema(Use(lambda f: open(f, 'a'))).validate('LICENSE-MIT')
|
148
|
+
<open file 'LICENSE-MIT', mode 'a' at 0x...>
|
149
|
+
|
150
|
+
Dropping the details, ``Use`` is basically:
|
151
|
+
|
152
|
+
.. code:: python
|
153
|
+
|
154
|
+
class Use(object):
|
155
|
+
|
156
|
+
def __init__(self, callable_):
|
157
|
+
self._callable = callable_
|
158
|
+
|
159
|
+
def validate(self, data):
|
160
|
+
try:
|
161
|
+
return self._callable(data)
|
162
|
+
except Exception as e:
|
163
|
+
raise SchemaError('%r raised %r' % (self._callable.__name__, e))
|
164
|
+
|
165
|
+
Now you can write your own validation-aware classes and data types.
|
166
|
+
|
167
|
+
Lists, similar containers
|
168
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
169
|
+
|
170
|
+
If ``Schema(...)`` encounters an instance of ``list``, ``tuple``, ``set`` or
|
171
|
+
``frozenset``, it will validate contents of corresponding data container
|
172
|
+
against schemas listed inside that container:
|
173
|
+
|
174
|
+
|
175
|
+
.. code:: python
|
176
|
+
|
177
|
+
>>> Schema([1, 0]).validate([1, 1, 0, 1])
|
178
|
+
[1, 1, 0, 1]
|
179
|
+
|
180
|
+
>>> Schema((int, float)).validate((5, 7, 8, 'not int or float here'))
|
181
|
+
Traceback (most recent call last):
|
182
|
+
...
|
183
|
+
SchemaError: Or(<type 'int'>, <type 'float'>) did not validate 'not int or float here'
|
184
|
+
'not int or float here' should be instance of 'float'
|
185
|
+
|
186
|
+
Dictionaries
|
187
|
+
~~~~~~~~~~~~
|
188
|
+
|
189
|
+
If ``Schema(...)`` encounters an instance of ``dict``, it will validate data
|
190
|
+
key-value pairs:
|
191
|
+
|
192
|
+
.. code:: python
|
193
|
+
|
194
|
+
>>> d = Schema({'name': str,
|
195
|
+
... 'age': lambda n: 18 <= n <= 99}).validate({'name': 'Sue', 'age': 28})
|
196
|
+
|
197
|
+
>>> assert d == {'name': 'Sue', 'age': 28}
|
198
|
+
|
199
|
+
You can specify keys as schemas too:
|
200
|
+
|
201
|
+
.. code:: python
|
202
|
+
|
203
|
+
>>> schema = Schema({str: int, # string keys should have integer values
|
204
|
+
... int: None}) # int keys should be always None
|
205
|
+
|
206
|
+
>>> data = schema.validate({'key1': 1, 'key2': 2,
|
207
|
+
... 10: None, 20: None})
|
208
|
+
|
209
|
+
>>> schema.validate({'key1': 1,
|
210
|
+
... 10: 'not None here'})
|
211
|
+
Traceback (most recent call last):
|
212
|
+
...
|
213
|
+
SchemaError: Key '10' error:
|
214
|
+
None does not match 'not None here'
|
215
|
+
|
216
|
+
This is useful if you want to check certain key-values, but don't care
|
217
|
+
about other:
|
218
|
+
|
219
|
+
.. code:: python
|
220
|
+
|
221
|
+
>>> schema = Schema({'<id>': int,
|
222
|
+
... '<file>': Use(open),
|
223
|
+
... str: object}) # don't care about other str keys
|
224
|
+
|
225
|
+
>>> data = schema.validate({'<id>': 10,
|
226
|
+
... '<file>': 'README.rst',
|
227
|
+
... '--verbose': True})
|
228
|
+
|
229
|
+
You can mark a key as optional as follows:
|
230
|
+
|
231
|
+
.. code:: python
|
232
|
+
|
233
|
+
>>> from schema import Optional
|
234
|
+
>>> Schema({'name': str,
|
235
|
+
... Optional('occupation'): str}).validate({'name': 'Sam'})
|
236
|
+
{'name': 'Sam'}
|
237
|
+
|
238
|
+
``Optional`` keys can also carry a ``default``, to be used when no key in the
|
239
|
+
data matches:
|
240
|
+
|
241
|
+
.. code:: python
|
242
|
+
|
243
|
+
>>> from schema import Optional
|
244
|
+
>>> Schema({Optional('color', default='blue'): str,
|
245
|
+
... str: str}).validate({'texture': 'furry'}
|
246
|
+
... ) == {'color': 'blue', 'texture': 'furry'}
|
247
|
+
True
|
248
|
+
|
249
|
+
Defaults are used verbatim, not passed through any validators specified in the
|
250
|
+
value.
|
251
|
+
|
252
|
+
**schema** has classes ``And`` and ``Or`` that help validating several schemas
|
253
|
+
for the same data:
|
254
|
+
|
255
|
+
.. code:: python
|
256
|
+
|
257
|
+
>>> from schema import And, Or
|
258
|
+
|
259
|
+
>>> Schema({'age': And(int, lambda n: 0 < n < 99)}).validate({'age': 7})
|
260
|
+
{'age': 7}
|
261
|
+
|
262
|
+
>>> Schema({'password': And(str, lambda s: len(s) > 6)}).validate({'password': 'hai'})
|
263
|
+
Traceback (most recent call last):
|
264
|
+
...
|
265
|
+
SchemaError: Key 'password' error:
|
266
|
+
<lambda>('hai') should evaluate to True
|
267
|
+
|
268
|
+
>>> Schema(And(Or(int, float), lambda x: x > 0)).validate(3.1415)
|
269
|
+
3.1415
|
270
|
+
|
271
|
+
Extra Keys
|
272
|
+
~~~~~~~~~~
|
273
|
+
|
274
|
+
The ``Schema(...)`` parameter ``ignore_extra_keys`` causes validation to ignore extra keys in a dictionary, and also to not return them after validating.
|
275
|
+
|
276
|
+
.. code:: python
|
277
|
+
|
278
|
+
>>> schema = Schema({'name': str}, ignore_extra_keys=True)
|
279
|
+
>>> schema.validate({'name': 'Sam', 'age': '42'})
|
280
|
+
{'name': 'Sam'}
|
281
|
+
|
282
|
+
If you would like any extra keys returned, use ``object: object`` as one of the key/value pairs, which will match any key and any value.
|
283
|
+
Otherwise, extra keys will raise a ``SchemaError``.
|
284
|
+
|
285
|
+
User-friendly error reporting
|
286
|
+
-------------------------------------------------------------------------------
|
287
|
+
|
288
|
+
You can pass a keyword argument ``error`` to any of validatable classes
|
289
|
+
(such as ``Schema``, ``And``, ``Or``, ``Regex``, ``Use``) to report this error
|
290
|
+
instead of a built-in one.
|
291
|
+
|
292
|
+
.. code:: python
|
293
|
+
|
294
|
+
>>> Schema(Use(int, error='Invalid year')).validate('XVII')
|
295
|
+
Traceback (most recent call last):
|
296
|
+
...
|
297
|
+
SchemaError: Invalid year
|
298
|
+
|
299
|
+
You can see all errors that occurred by accessing exception's ``exc.autos``
|
300
|
+
for auto-generated error messages, and ``exc.errors`` for errors
|
301
|
+
which had ``error`` text passed to them.
|
302
|
+
|
303
|
+
You can exit with ``sys.exit(exc.code)`` if you want to show the messages
|
304
|
+
to the user without traceback. ``error`` messages are given precedence in that
|
305
|
+
case.
|
306
|
+
|
307
|
+
A JSON API example
|
308
|
+
-------------------------------------------------------------------------------
|
309
|
+
|
310
|
+
Here is a quick example: validation of
|
311
|
+
`create a gist <http://developer.github.com/v3/gists/>`_
|
312
|
+
request from github API.
|
313
|
+
|
314
|
+
.. code:: python
|
315
|
+
|
316
|
+
>>> gist = '''{"description": "the description for this gist",
|
317
|
+
... "public": true,
|
318
|
+
... "files": {
|
319
|
+
... "file1.txt": {"content": "String file contents"},
|
320
|
+
... "other.txt": {"content": "Another file contents"}}}'''
|
321
|
+
|
322
|
+
>>> from schema import Schema, And, Use, Optional
|
323
|
+
|
324
|
+
>>> import json
|
325
|
+
|
326
|
+
>>> gist_schema = Schema(And(Use(json.loads), # first convert from JSON
|
327
|
+
... # use basestring since json returns unicode
|
328
|
+
... {Optional('description'): basestring,
|
329
|
+
... 'public': bool,
|
330
|
+
... 'files': {basestring: {'content': basestring}}}))
|
331
|
+
|
332
|
+
>>> gist = gist_schema.validate(gist)
|
333
|
+
|
334
|
+
# gist:
|
335
|
+
{u'description': u'the description for this gist',
|
336
|
+
u'files': {u'file1.txt': {u'content': u'String file contents'},
|
337
|
+
u'other.txt': {u'content': u'Another file contents'}},
|
338
|
+
u'public': True}
|
339
|
+
|
340
|
+
Using **schema** with `docopt <http://github.com/docopt/docopt>`_
|
341
|
+
-------------------------------------------------------------------------------
|
342
|
+
|
343
|
+
Assume you are using **docopt** with the following usage-pattern:
|
344
|
+
|
345
|
+
Usage: my_program.py [--count=N] <path> <files>...
|
346
|
+
|
347
|
+
and you would like to validate that ``<files>`` are readable, and that
|
348
|
+
``<path>`` exists, and that ``--count`` is either integer from 0 to 5, or
|
349
|
+
``None``.
|
350
|
+
|
351
|
+
Assuming **docopt** returns the following dict:
|
352
|
+
|
353
|
+
.. code:: python
|
354
|
+
|
355
|
+
>>> args = {'<files>': ['LICENSE-MIT', 'setup.py'],
|
356
|
+
... '<path>': '../',
|
357
|
+
... '--count': '3'}
|
358
|
+
|
359
|
+
this is how you validate it using ``schema``:
|
360
|
+
|
361
|
+
.. code:: python
|
362
|
+
|
363
|
+
>>> from schema import Schema, And, Or, Use
|
364
|
+
>>> import os
|
365
|
+
|
366
|
+
>>> s = Schema({'<files>': [Use(open)],
|
367
|
+
... '<path>': os.path.exists,
|
368
|
+
... '--count': Or(None, And(Use(int), lambda n: 0 < n < 5))})
|
369
|
+
|
370
|
+
>>> args = s.validate(args)
|
371
|
+
|
372
|
+
>>> args['<files>']
|
373
|
+
[<open file 'LICENSE-MIT', mode 'r' at 0x...>, <open file 'setup.py', mode 'r' at 0x...>]
|
374
|
+
|
375
|
+
>>> args['<path>']
|
376
|
+
'../'
|
377
|
+
|
378
|
+
>>> args['--count']
|
379
|
+
3
|
380
|
+
|
381
|
+
As you can see, **schema** validated data successfully, opened files and
|
382
|
+
converted ``'3'`` to ``int``.
|