chef 16.11.7-universal-mingw32 → 17.2.29-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +9 -21
- data/README.md +1 -1
- data/Rakefile +13 -2
- data/chef-universal-mingw32.gemspec +1 -1
- data/chef.gemspec +11 -24
- data/distro/ruby_bin_folder/AMD64/Chef.PowerShell.Wrapper.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/Chef.PowerShell.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/Newtonsoft.Json.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.PowerShell.Wrapper.Core.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.pdb +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.NETCore.App.deps.json +153 -149
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Commands.Diagnostics.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Commands.Management.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Commands.Utility.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.ConsoleHost.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.CoreCLR.Eventing.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.MarkdownRender.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Security.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.WSMan.Management.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Microsoft.WSMan.Runtime.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Newtonsoft.Json.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.EventLog.Messages.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.EventLog.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Drawing.Common.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Management.Automation.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/System.Security.Cryptography.Pkcs.dll +0 -0
- data/distro/ruby_bin_folder/x86/Chef.PowerShell.dll +0 -0
- data/distro/ruby_bin_folder/x86/Chef.Powershell.Wrapper.dll +0 -0
- data/distro/ruby_bin_folder/x86/Newtonsoft.Json.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Chef.PowerShell.Wrapper.Core.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.pdb +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.NETCore.App.deps.json +153 -149
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Commands.Diagnostics.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Commands.Management.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Commands.Utility.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.ConsoleHost.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.CoreCLR.Eventing.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.MarkdownRender.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.PowerShell.Security.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.WSMan.Management.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Microsoft.WSMan.Runtime.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Newtonsoft.Json.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.EventLog.Messages.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Diagnostics.EventLog.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Drawing.Common.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Management.Automation.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/System.Security.Cryptography.Pkcs.dll +0 -0
- data/lib/chef/action_collection.rb +6 -26
- data/lib/chef/application.rb +1 -1
- data/lib/chef/application/base.rb +16 -1
- data/lib/chef/applications.rb +0 -1
- data/lib/chef/chef_fs/command_line.rb +5 -2
- data/lib/chef/chef_fs/file_pattern.rb +2 -2
- data/lib/chef/chef_fs/file_system.rb +9 -10
- data/lib/chef/client.rb +8 -2
- data/lib/chef/compliance/default_attributes.rb +5 -4
- data/lib/chef/compliance/fetcher/automate.rb +0 -7
- data/lib/chef/compliance/reporter/automate.rb +17 -7
- data/lib/chef/compliance/reporter/chef_server_automate.rb +11 -6
- data/lib/chef/compliance/reporter/cli.rb +77 -0
- data/lib/chef/compliance/reporter/compliance_enforcer.rb +4 -0
- data/lib/chef/compliance/reporter/json_file.rb +8 -1
- data/lib/chef/compliance/runner.rb +65 -27
- data/lib/chef/cookbook/cookbook_version_loader.rb +3 -3
- data/lib/chef/cookbook/gem_installer.rb +5 -1
- data/lib/chef/cookbook/synchronizer.rb +3 -5
- data/lib/chef/cookbook_loader.rb +2 -4
- data/lib/chef/cookbook_uploader.rb +0 -1
- data/lib/chef/cookbook_version.rb +26 -4
- data/lib/chef/data_bag.rb +2 -1
- data/lib/chef/data_bag_item.rb +13 -3
- data/lib/chef/data_collector.rb +0 -1
- data/lib/chef/data_collector/run_end_message.rb +1 -1
- data/lib/chef/delayed_evaluator.rb +4 -0
- data/lib/chef/deprecated.rb +8 -0
- data/lib/chef/dsl/chef_vault.rb +6 -6
- data/lib/chef/dsl/declare_resource.rb +5 -10
- data/lib/chef/dsl/reboot_pending.rb +1 -2
- data/lib/chef/event_dispatch/base.rb +2 -1
- data/lib/chef/exceptions.rb +3 -0
- data/lib/chef/formatters/doc.rb +2 -1
- data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +20 -22
- data/lib/chef/group.rb +75 -0
- data/lib/chef/handler.rb +46 -8
- data/lib/chef/handler/slow_report.rb +66 -0
- data/lib/chef/mixin/get_source_from_package.rb +1 -1
- data/lib/chef/node.rb +21 -20
- data/lib/chef/node/attribute.rb +6 -4
- data/lib/chef/node/immutable_collections.rb +13 -0
- data/lib/chef/node/mixin/deep_merge_cache.rb +11 -7
- data/lib/chef/org.rb +3 -2
- data/lib/chef/property.rb +18 -0
- data/lib/chef/provider.rb +1 -1
- data/lib/chef/provider/cron.rb +1 -1
- data/lib/chef/provider/directory.rb +6 -6
- data/lib/chef/provider/execute.rb +2 -1
- data/lib/chef/provider/file.rb +2 -2
- data/lib/chef/provider/git.rb +5 -7
- data/lib/chef/provider/group/groupadd.rb +3 -3
- data/lib/chef/provider/group/groupmod.rb +3 -3
- data/lib/chef/provider/group/pw.rb +3 -3
- data/lib/chef/provider/ifconfig.rb +2 -2
- data/lib/chef/provider/link.rb +3 -3
- data/lib/chef/provider/mount.rb +12 -7
- data/lib/chef/provider/mount/aix.rb +3 -3
- data/lib/chef/provider/mount/mount.rb +5 -5
- data/lib/chef/provider/mount/windows.rb +1 -1
- data/lib/chef/provider/package.rb +17 -21
- data/lib/chef/provider/package/apt.rb +27 -1
- data/lib/chef/provider/package/deb.rb +3 -3
- data/lib/chef/provider/package/dnf/dnf_helper.py +12 -11
- data/lib/chef/provider/package/dnf/python_helper.rb +9 -8
- data/lib/chef/provider/package/portage.rb +2 -2
- data/lib/chef/provider/package/rubygems.rb +11 -17
- data/lib/chef/provider/package/windows.rb +2 -4
- data/lib/chef/provider/package/yum.rb +1 -4
- data/lib/chef/provider/package/yum/python_helper.rb +15 -10
- data/lib/chef/provider/package/yum/yum_helper.py +47 -63
- data/lib/chef/provider/registry_key.rb +1 -1
- data/lib/chef/provider/route.rb +2 -2
- data/lib/chef/provider/service.rb +6 -6
- data/lib/chef/provider/service/aixinit.rb +1 -1
- data/lib/chef/provider/service/debian.rb +1 -1
- data/lib/chef/provider/service/freebsd.rb +15 -21
- data/lib/chef/provider/service/macosx.rb +7 -7
- data/lib/chef/provider/service/systemd.rb +43 -14
- data/lib/chef/provider/service/upstart.rb +2 -13
- data/lib/chef/provider/service/windows.rb +12 -12
- data/lib/chef/provider/subversion.rb +10 -12
- data/lib/chef/provider/support/zypper_repo.erb +4 -2
- data/lib/chef/provider/systemd_unit.rb +36 -10
- data/lib/chef/provider/template/content.rb +3 -7
- data/lib/chef/provider/user.rb +2 -2
- data/lib/chef/provider/user/dscl.rb +1 -1
- data/lib/chef/provider/user/mac.rb +17 -20
- data/lib/chef/provider/user/pw.rb +1 -1
- data/lib/chef/provider/user/windows.rb +1 -1
- data/lib/chef/provider/windows_script.rb +1 -1
- data/lib/chef/provider/zypper_repository.rb +28 -32
- data/lib/chef/providers.rb +0 -1
- data/lib/chef/resource.rb +6 -7
- data/lib/chef/resource/alternatives.rb +6 -6
- data/lib/chef/resource/apt_package.rb +1 -1
- data/lib/chef/resource/apt_preference.rb +2 -2
- data/lib/chef/resource/apt_repository.rb +6 -6
- data/lib/chef/resource/apt_update.rb +5 -4
- data/lib/chef/resource/archive_file.rb +2 -3
- data/lib/chef/resource/breakpoint.rb +1 -1
- data/lib/chef/resource/build_essential.rb +2 -6
- data/lib/chef/resource/chef_client_config.rb +3 -3
- data/lib/chef/resource/chef_client_cron.rb +4 -4
- data/lib/chef/resource/chef_client_launchd.rb +6 -6
- data/lib/chef/resource/chef_client_scheduled_task.rb +15 -15
- data/lib/chef/resource/chef_client_systemd_timer.rb +4 -4
- data/lib/chef/resource/chef_handler.rb +3 -7
- data/lib/chef/resource/chef_sleep.rb +1 -1
- data/lib/chef/resource/chef_vault_secret.rb +3 -8
- data/lib/chef/resource/chocolatey_config.rb +2 -6
- data/lib/chef/resource/chocolatey_feature.rb +2 -6
- data/lib/chef/resource/chocolatey_source.rb +4 -10
- data/lib/chef/resource/cron/_cron_shared.rb +2 -2
- data/lib/chef/resource/cron/cron_d.rb +4 -6
- data/lib/chef/resource/cron_access.rb +2 -4
- data/lib/chef/resource/dmg_package.rb +6 -10
- data/lib/chef/resource/dpkg_package.rb +1 -1
- data/lib/chef/resource/execute.rb +8 -3
- data/lib/chef/resource/file.rb +1 -1
- data/lib/chef/resource/group.rb +6 -6
- data/lib/chef/resource/homebrew_cask.rb +17 -10
- data/lib/chef/resource/homebrew_package.rb +1 -1
- data/lib/chef/resource/homebrew_tap.rb +4 -7
- data/lib/chef/resource/homebrew_update.rb +2 -2
- data/lib/chef/resource/hostname.rb +68 -22
- data/lib/chef/resource/http_request.rb +1 -1
- data/lib/chef/resource/inspec_waiver_file_entry.rb +156 -0
- data/lib/chef/resource/kernel_module.rb +6 -17
- data/lib/chef/resource/locale.rb +2 -3
- data/lib/chef/resource/lwrp_base.rb +19 -0
- data/lib/chef/resource/macos_userdefaults.rb +10 -14
- data/lib/chef/resource/mdadm.rb +53 -7
- data/lib/chef/resource/mount.rb +2 -1
- data/lib/chef/resource/ohai_hint.rb +2 -6
- data/lib/chef/resource/openbsd_package.rb +17 -0
- data/lib/chef/resource/openssl_dhparam.rb +1 -2
- data/lib/chef/resource/openssl_ec_private_key.rb +3 -5
- data/lib/chef/resource/openssl_ec_public_key.rb +1 -3
- data/lib/chef/resource/openssl_rsa_private_key.rb +2 -4
- data/lib/chef/resource/openssl_rsa_public_key.rb +1 -3
- data/lib/chef/resource/openssl_x509_certificate.rb +3 -6
- data/lib/chef/resource/openssl_x509_crl.rb +1 -3
- data/lib/chef/resource/openssl_x509_request.rb +1 -3
- data/lib/chef/resource/osx_profile.rb +3 -3
- data/lib/chef/resource/plist.rb +8 -8
- data/lib/chef/resource/powershell_package_source.rb +2 -4
- data/lib/chef/resource/powershell_script.rb +1 -1
- data/lib/chef/resource/reboot.rb +38 -9
- data/lib/chef/resource/remote_directory.rb +2 -2
- data/lib/chef/resource/remote_file.rb +3 -3
- data/lib/chef/resource/rhsm_errata.rb +16 -3
- data/lib/chef/resource/rhsm_errata_level.rb +11 -6
- data/lib/chef/resource/rhsm_register.rb +12 -6
- data/lib/chef/resource/rhsm_repo.rb +17 -6
- data/lib/chef/resource/rhsm_subscription.rb +2 -6
- data/lib/chef/resource/scm/git.rb +1 -1
- data/lib/chef/resource/ssh_known_hosts_entry.rb +4 -7
- data/lib/chef/resource/sudo.rb +8 -12
- data/lib/chef/resource/swap_file.rb +2 -6
- data/lib/chef/resource/sysctl.rb +2 -6
- data/lib/chef/resource/systemd_unit.rb +2 -2
- data/lib/chef/resource/template.rb +1 -1
- data/lib/chef/resource/timezone.rb +1 -3
- data/lib/chef/resource/user/mac_user.rb +1 -1
- data/lib/chef/resource/user_ulimit.rb +2 -2
- data/lib/chef/resource/windows_ad_join.rb +2 -6
- data/lib/chef/resource/windows_audit_policy.rb +2 -2
- data/lib/chef/resource/windows_auto_run.rb +2 -5
- data/lib/chef/resource/windows_certificate.rb +207 -73
- data/lib/chef/resource/windows_dfs_folder.rb +2 -6
- data/lib/chef/resource/windows_dfs_namespace.rb +2 -6
- data/lib/chef/resource/windows_dfs_server.rb +1 -3
- data/lib/chef/resource/windows_dns_record.rb +2 -6
- data/lib/chef/resource/windows_dns_zone.rb +2 -6
- data/lib/chef/resource/windows_env.rb +6 -5
- data/lib/chef/resource/windows_feature.rb +3 -9
- data/lib/chef/resource/windows_feature_dism.rb +3 -9
- data/lib/chef/resource/windows_feature_powershell.rb +3 -3
- data/lib/chef/resource/windows_firewall_profile.rb +4 -4
- data/lib/chef/resource/windows_firewall_rule.rb +20 -9
- data/lib/chef/resource/windows_font.rb +3 -5
- data/lib/chef/resource/windows_pagefile.rb +104 -69
- data/lib/chef/resource/windows_path.rb +4 -4
- data/lib/chef/resource/windows_printer.rb +8 -23
- data/lib/chef/resource/windows_printer_port.rb +49 -66
- data/lib/chef/resource/windows_security_policy.rb +56 -40
- data/lib/chef/resource/windows_share.rb +14 -21
- data/lib/chef/resource/windows_shortcut.rb +4 -6
- data/lib/chef/resource/windows_task.rb +19 -7
- data/lib/chef/resource/windows_uac.rb +3 -5
- data/lib/chef/resource/windows_user_privilege.rb +4 -4
- data/lib/chef/resource/windows_workgroup.rb +3 -4
- data/lib/chef/resource/yum_package.rb +10 -10
- data/lib/chef/resource/zypper_package.rb +4 -4
- data/lib/chef/resource/zypper_repository.rb +28 -8
- data/lib/chef/resource_builder.rb +8 -2
- data/lib/chef/resource_reporter.rb +0 -1
- data/lib/chef/resources.rb +1 -1
- data/lib/chef/run_lock.rb +1 -1
- data/lib/chef/runner.rb +1 -1
- data/lib/chef/shell/ext.rb +3 -3
- data/lib/chef/user.rb +0 -1
- data/lib/chef/user_v1.rb +3 -4
- data/lib/chef/util/dsc/configuration_generator.rb +1 -0
- data/lib/chef/util/dsc/local_configuration_manager.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api.rb +9 -2
- data/lib/chef/win32/registry.rb +4 -2
- data/spec/data/cookbooks/openldap/libraries/openldap.rb +1 -1
- data/spec/data/lwrp/resources/bar.rb +2 -0
- data/spec/data/lwrp/resources/buck_passer.rb +1 -0
- data/spec/data/lwrp/resources/buck_passer_2.rb +1 -0
- data/spec/data/lwrp/resources/embedded_resource_accesses_providers_scope.rb +1 -0
- data/spec/data/lwrp/resources/foo.rb +2 -0
- data/spec/data/lwrp/resources/inline_compiler.rb +1 -0
- data/spec/data/lwrp/resources/monkey_name_printer.rb +1 -0
- data/spec/data/lwrp/resources/paint_drying_watcher.rb +1 -0
- data/spec/data/lwrp/resources/thumb_twiddler.rb +1 -0
- data/spec/data/lwrp/resources_with_default_attributes/nodeattr.rb +2 -0
- data/spec/data/lwrp_const_scoping/resources/conflict.rb +1 -0
- data/spec/data/lwrp_override/resources/foo.rb +1 -0
- data/spec/data/rubygems.org/nonexistent_gem-info +1 -0
- data/spec/data/rubygems.org/sexp_processor-info +49 -0
- data/spec/data/run_context/cookbooks/circular-dep1/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep2/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency1/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency2/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/no-default-attr/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/resources/resource.rb +2 -0
- data/spec/data/run_context/cookbooks/test-with-deps/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/test/resources/resource.rb +2 -0
- data/spec/functional/dsl/registry_helper_spec.rb +1 -1
- data/spec/functional/resource/aixinit_service_spec.rb +7 -7
- data/spec/functional/resource/apt_package_spec.rb +1 -1
- data/spec/functional/resource/chocolatey_package_spec.rb +13 -0
- data/spec/functional/resource/cron_spec.rb +1 -1
- data/spec/functional/resource/dnf_package_spec.rb +857 -534
- data/spec/functional/resource/group_spec.rb +1 -1
- data/spec/functional/resource/link_spec.rb +1 -1
- data/spec/functional/resource/registry_spec.rb +8 -8
- data/spec/functional/resource/remote_file_spec.rb +1 -1
- data/spec/functional/resource/user/mac_user_spec.rb +2 -2
- data/spec/functional/resource/windows_certificate_spec.rb +92 -35
- data/spec/functional/resource/windows_env_spec.rb +2 -2
- data/spec/functional/resource/windows_hostname_spec.rb +91 -0
- data/spec/functional/resource/windows_pagefile_spec.rb +98 -0
- data/spec/functional/resource/yum_package_spec.rb +495 -428
- data/spec/functional/version_spec.rb +1 -1
- data/spec/functional/win32/registry_spec.rb +1 -1
- data/spec/integration/client/client_spec.rb +5 -22
- data/spec/integration/client/exit_code_spec.rb +1 -1
- data/spec/integration/client/ipv6_spec.rb +1 -1
- data/spec/integration/compliance/compliance_spec.rb +1 -1
- data/spec/integration/ohai/ohai_spec.rb +7 -6
- data/spec/integration/recipes/accumulator_spec.rb +13 -1
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +5 -1
- data/spec/integration/recipes/lwrp_spec.rb +3 -1
- data/spec/integration/recipes/notifies_spec.rb +15 -1
- data/spec/integration/recipes/notifying_block_spec.rb +2 -1
- data/spec/integration/recipes/recipe_dsl_spec.rb +9 -9
- data/spec/integration/recipes/unified_mode_spec.rb +71 -1
- data/spec/integration/recipes/use_partial_spec.rb +4 -1
- data/spec/spec_helper.rb +14 -13
- data/spec/support/chef_helpers.rb +1 -17
- data/spec/support/lib/chef/resource/with_state.rb +0 -1
- data/spec/support/lib/chef/resource/zen_follower.rb +0 -1
- data/spec/support/lib/chef/resource/zen_master.rb +0 -1
- data/spec/support/matchers/leak.rb +7 -9
- data/spec/support/platform_helpers.rb +5 -8
- data/spec/support/shared/functional/execute_resource.rb +1 -1
- data/spec/support/shared/integration/integration_helper.rb +0 -1
- data/spec/support/shared/unit/provider/file.rb +15 -1
- data/spec/support/shared/unit/script_resource.rb +2 -2
- data/spec/unit/application/solo_spec.rb +2 -2
- data/spec/unit/chef_fs/diff_spec.rb +1 -1
- data/spec/unit/chef_fs/file_system/repository/directory_spec.rb +1 -1
- data/spec/unit/chef_fs/file_system_spec.rb +1 -1
- data/spec/unit/compliance/fetcher/automate_spec.rb +0 -16
- data/spec/unit/compliance/reporter/automate_spec.rb +26 -2
- data/spec/unit/compliance/reporter/chef_server_automate_spec.rb +20 -0
- data/spec/unit/compliance/reporter/compliance_enforcer_spec.rb +1 -0
- data/spec/unit/compliance/runner_spec.rb +31 -5
- data/spec/unit/cookbook_version_spec.rb +52 -0
- data/spec/unit/data_bag_item_spec.rb +3 -8
- data/spec/unit/data_bag_spec.rb +1 -1
- data/spec/unit/data_collector_spec.rb +47 -1
- data/spec/unit/dsl/reboot_pending_spec.rb +2 -2
- data/spec/unit/dsl/registry_helper_spec.rb +1 -1
- data/spec/unit/handler_spec.rb +8 -2
- data/spec/unit/lwrp_spec.rb +1 -1
- data/spec/unit/mixin/params_validate_spec.rb +4 -3
- data/spec/unit/node/attribute_spec.rb +1 -1
- data/spec/unit/node_spec.rb +78 -0
- data/spec/unit/org_group_spec.rb +45 -0
- data/spec/unit/property_spec.rb +23 -22
- data/spec/unit/provider/cron_spec.rb +1 -1
- data/spec/unit/provider/group/gpasswd_spec.rb +2 -2
- data/spec/unit/provider/group/groupmod_spec.rb +2 -2
- data/spec/unit/provider/group/pw_spec.rb +2 -2
- data/spec/unit/provider/group_spec.rb +1 -1
- data/spec/unit/provider/link_spec.rb +1 -1
- data/spec/unit/provider/mount/mount_spec.rb +51 -0
- data/spec/unit/provider/package/apt_spec.rb +84 -18
- data/spec/unit/provider/package/deb_spec.rb +3 -3
- data/spec/unit/provider/package/dnf/python_helper_spec.rb +1 -0
- data/spec/unit/provider/package/rubygems_spec.rb +21 -33
- data/spec/unit/provider/package/yum/python_helper_spec.rb +1 -0
- data/spec/unit/provider/service/arch_service_spec.rb +1 -0
- data/spec/unit/provider/service/debian_service_spec.rb +1 -0
- data/spec/unit/provider/service/macosx_spec.rb +5 -5
- data/spec/unit/provider/service/systemd_service_spec.rb +138 -23
- data/spec/unit/provider/service/upstart_service_spec.rb +0 -29
- data/spec/unit/provider/service/windows_spec.rb +2 -2
- data/spec/unit/provider/subversion_spec.rb +2 -2
- data/spec/unit/provider/systemd_unit_spec.rb +79 -60
- data/spec/unit/provider/zypper_repository_spec.rb +5 -12
- data/spec/unit/provider_spec.rb +0 -8
- data/spec/unit/resource/inspec_waiver_file_entry_spec.rb +80 -0
- data/spec/unit/resource/powershell_script_spec.rb +2 -2
- data/spec/unit/resource/windows_firewall_rule_spec.rb +12 -7
- data/spec/unit/resource/windows_pagefile_spec.rb +4 -9
- data/spec/unit/resource/windows_task_spec.rb +1 -1
- data/spec/unit/resource/zypper_repository_spec.rb +1 -1
- data/spec/unit/user_spec.rb +1 -1
- data/spec/unit/user_v1_spec.rb +6 -4
- data/tasks/rspec.rb +9 -6
- metadata +26 -528
- data/bin/knife +0 -24
- data/lib/chef/application/knife.rb +0 -234
- data/lib/chef/application/windows_service.rb +0 -338
- data/lib/chef/application/windows_service_manager.rb +0 -205
- data/lib/chef/chef_fs/knife.rb +0 -160
- data/lib/chef/chef_fs/parallelizer.rb +0 -102
- data/lib/chef/chef_fs/parallelizer/flatten_enumerable.rb +0 -35
- data/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +0 -278
- data/lib/chef/cookbook_site_streaming_uploader.rb +0 -244
- data/lib/chef/knife.rb +0 -665
- data/lib/chef/knife/acl_add.rb +0 -57
- data/lib/chef/knife/acl_base.rb +0 -183
- data/lib/chef/knife/acl_bulk_add.rb +0 -78
- data/lib/chef/knife/acl_bulk_remove.rb +0 -83
- data/lib/chef/knife/acl_remove.rb +0 -62
- data/lib/chef/knife/acl_show.rb +0 -56
- data/lib/chef/knife/bootstrap.rb +0 -1192
- data/lib/chef/knife/bootstrap/chef_vault_handler.rb +0 -162
- data/lib/chef/knife/bootstrap/client_builder.rb +0 -212
- data/lib/chef/knife/bootstrap/templates/README.md +0 -11
- data/lib/chef/knife/bootstrap/templates/chef-full.erb +0 -242
- data/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +0 -278
- data/lib/chef/knife/bootstrap/train_connector.rb +0 -336
- data/lib/chef/knife/client_bulk_delete.rb +0 -104
- data/lib/chef/knife/client_create.rb +0 -101
- data/lib/chef/knife/client_delete.rb +0 -62
- data/lib/chef/knife/client_edit.rb +0 -52
- data/lib/chef/knife/client_key_create.rb +0 -73
- data/lib/chef/knife/client_key_delete.rb +0 -80
- data/lib/chef/knife/client_key_edit.rb +0 -83
- data/lib/chef/knife/client_key_list.rb +0 -73
- data/lib/chef/knife/client_key_show.rb +0 -80
- data/lib/chef/knife/client_list.rb +0 -41
- data/lib/chef/knife/client_reregister.rb +0 -58
- data/lib/chef/knife/client_show.rb +0 -48
- data/lib/chef/knife/config_get.rb +0 -39
- data/lib/chef/knife/config_get_profile.rb +0 -37
- data/lib/chef/knife/config_list.rb +0 -139
- data/lib/chef/knife/config_list_profiles.rb +0 -37
- data/lib/chef/knife/config_show.rb +0 -127
- data/lib/chef/knife/config_use.rb +0 -61
- data/lib/chef/knife/config_use_profile.rb +0 -47
- data/lib/chef/knife/configure.rb +0 -150
- data/lib/chef/knife/configure_client.rb +0 -48
- data/lib/chef/knife/cookbook_bulk_delete.rb +0 -71
- data/lib/chef/knife/cookbook_delete.rb +0 -151
- data/lib/chef/knife/cookbook_download.rb +0 -142
- data/lib/chef/knife/cookbook_list.rb +0 -47
- data/lib/chef/knife/cookbook_metadata.rb +0 -106
- data/lib/chef/knife/cookbook_metadata_from_file.rb +0 -49
- data/lib/chef/knife/cookbook_show.rb +0 -98
- data/lib/chef/knife/cookbook_upload.rb +0 -292
- data/lib/chef/knife/core/bootstrap_context.rb +0 -264
- data/lib/chef/knife/core/cookbook_scm_repo.rb +0 -159
- data/lib/chef/knife/core/formatting_options.rb +0 -49
- data/lib/chef/knife/core/gem_glob_loader.rb +0 -138
- data/lib/chef/knife/core/generic_presenter.rb +0 -232
- data/lib/chef/knife/core/hashed_command_loader.rb +0 -100
- data/lib/chef/knife/core/node_editor.rb +0 -130
- data/lib/chef/knife/core/node_presenter.rb +0 -133
- data/lib/chef/knife/core/object_loader.rb +0 -115
- data/lib/chef/knife/core/status_presenter.rb +0 -147
- data/lib/chef/knife/core/subcommand_loader.rb +0 -203
- data/lib/chef/knife/core/text_formatter.rb +0 -85
- data/lib/chef/knife/core/ui.rb +0 -338
- data/lib/chef/knife/core/windows_bootstrap_context.rb +0 -406
- data/lib/chef/knife/data_bag_create.rb +0 -81
- data/lib/chef/knife/data_bag_delete.rb +0 -49
- data/lib/chef/knife/data_bag_edit.rb +0 -74
- data/lib/chef/knife/data_bag_from_file.rb +0 -113
- data/lib/chef/knife/data_bag_list.rb +0 -42
- data/lib/chef/knife/data_bag_secret_options.rb +0 -122
- data/lib/chef/knife/data_bag_show.rb +0 -69
- data/lib/chef/knife/delete.rb +0 -125
- data/lib/chef/knife/deps.rb +0 -156
- data/lib/chef/knife/diff.rb +0 -83
- data/lib/chef/knife/download.rb +0 -84
- data/lib/chef/knife/edit.rb +0 -88
- data/lib/chef/knife/environment_compare.rb +0 -128
- data/lib/chef/knife/environment_create.rb +0 -52
- data/lib/chef/knife/environment_delete.rb +0 -44
- data/lib/chef/knife/environment_edit.rb +0 -44
- data/lib/chef/knife/environment_from_file.rb +0 -84
- data/lib/chef/knife/environment_list.rb +0 -41
- data/lib/chef/knife/environment_show.rb +0 -47
- data/lib/chef/knife/exec.rb +0 -99
- data/lib/chef/knife/group_add.rb +0 -55
- data/lib/chef/knife/group_create.rb +0 -49
- data/lib/chef/knife/group_destroy.rb +0 -53
- data/lib/chef/knife/group_list.rb +0 -43
- data/lib/chef/knife/group_remove.rb +0 -56
- data/lib/chef/knife/group_show.rb +0 -49
- data/lib/chef/knife/key_create.rb +0 -112
- data/lib/chef/knife/key_create_base.rb +0 -50
- data/lib/chef/knife/key_delete.rb +0 -55
- data/lib/chef/knife/key_edit.rb +0 -118
- data/lib/chef/knife/key_edit_base.rb +0 -55
- data/lib/chef/knife/key_list.rb +0 -90
- data/lib/chef/knife/key_list_base.rb +0 -45
- data/lib/chef/knife/key_show.rb +0 -53
- data/lib/chef/knife/list.rb +0 -177
- data/lib/chef/knife/node_bulk_delete.rb +0 -75
- data/lib/chef/knife/node_create.rb +0 -47
- data/lib/chef/knife/node_delete.rb +0 -46
- data/lib/chef/knife/node_edit.rb +0 -70
- data/lib/chef/knife/node_environment_set.rb +0 -53
- data/lib/chef/knife/node_from_file.rb +0 -51
- data/lib/chef/knife/node_list.rb +0 -44
- data/lib/chef/knife/node_policy_set.rb +0 -79
- data/lib/chef/knife/node_run_list_add.rb +0 -104
- data/lib/chef/knife/node_run_list_remove.rb +0 -67
- data/lib/chef/knife/node_run_list_set.rb +0 -66
- data/lib/chef/knife/node_show.rb +0 -63
- data/lib/chef/knife/null.rb +0 -12
- data/lib/chef/knife/raw.rb +0 -123
- data/lib/chef/knife/recipe_list.rb +0 -32
- data/lib/chef/knife/rehash.rb +0 -50
- data/lib/chef/knife/role_bulk_delete.rb +0 -66
- data/lib/chef/knife/role_create.rb +0 -53
- data/lib/chef/knife/role_delete.rb +0 -46
- data/lib/chef/knife/role_edit.rb +0 -45
- data/lib/chef/knife/role_env_run_list_add.rb +0 -87
- data/lib/chef/knife/role_env_run_list_clear.rb +0 -55
- data/lib/chef/knife/role_env_run_list_remove.rb +0 -57
- data/lib/chef/knife/role_env_run_list_replace.rb +0 -60
- data/lib/chef/knife/role_env_run_list_set.rb +0 -70
- data/lib/chef/knife/role_from_file.rb +0 -51
- data/lib/chef/knife/role_list.rb +0 -42
- data/lib/chef/knife/role_run_list_add.rb +0 -87
- data/lib/chef/knife/role_run_list_clear.rb +0 -55
- data/lib/chef/knife/role_run_list_remove.rb +0 -56
- data/lib/chef/knife/role_run_list_replace.rb +0 -60
- data/lib/chef/knife/role_run_list_set.rb +0 -69
- data/lib/chef/knife/role_show.rb +0 -48
- data/lib/chef/knife/search.rb +0 -194
- data/lib/chef/knife/serve.rb +0 -65
- data/lib/chef/knife/show.rb +0 -72
- data/lib/chef/knife/ssh.rb +0 -645
- data/lib/chef/knife/ssl_check.rb +0 -284
- data/lib/chef/knife/ssl_fetch.rb +0 -161
- data/lib/chef/knife/status.rb +0 -95
- data/lib/chef/knife/supermarket_download.rb +0 -121
- data/lib/chef/knife/supermarket_install.rb +0 -192
- data/lib/chef/knife/supermarket_list.rb +0 -76
- data/lib/chef/knife/supermarket_search.rb +0 -53
- data/lib/chef/knife/supermarket_share.rb +0 -166
- data/lib/chef/knife/supermarket_show.rb +0 -66
- data/lib/chef/knife/supermarket_unshare.rb +0 -61
- data/lib/chef/knife/tag_create.rb +0 -52
- data/lib/chef/knife/tag_delete.rb +0 -60
- data/lib/chef/knife/tag_list.rb +0 -47
- data/lib/chef/knife/upload.rb +0 -86
- data/lib/chef/knife/user_create.rb +0 -107
- data/lib/chef/knife/user_delete.rb +0 -44
- data/lib/chef/knife/user_dissociate.rb +0 -42
- data/lib/chef/knife/user_edit.rb +0 -52
- data/lib/chef/knife/user_invite_add.rb +0 -43
- data/lib/chef/knife/user_invite_list.rb +0 -34
- data/lib/chef/knife/user_invite_rescind.rb +0 -63
- data/lib/chef/knife/user_key_create.rb +0 -73
- data/lib/chef/knife/user_key_delete.rb +0 -80
- data/lib/chef/knife/user_key_edit.rb +0 -83
- data/lib/chef/knife/user_key_list.rb +0 -73
- data/lib/chef/knife/user_key_show.rb +0 -80
- data/lib/chef/knife/user_list.rb +0 -42
- data/lib/chef/knife/user_reregister.rb +0 -59
- data/lib/chef/knife/user_show.rb +0 -48
- data/lib/chef/knife/xargs.rb +0 -282
- data/lib/chef/knife/yaml_convert.rb +0 -91
- data/lib/chef/provider/package/yum/simplejson/LICENSE.txt +0 -79
- data/lib/chef/provider/package/yum/simplejson/__init__.py +0 -318
- data/lib/chef/provider/package/yum/simplejson/__init__.pyc +0 -0
- data/lib/chef/provider/package/yum/simplejson/decoder.py +0 -354
- data/lib/chef/provider/package/yum/simplejson/decoder.pyc +0 -0
- data/lib/chef/provider/package/yum/simplejson/encoder.py +0 -440
- data/lib/chef/provider/package/yum/simplejson/encoder.pyc +0 -0
- data/lib/chef/provider/package/yum/simplejson/scanner.py +0 -65
- data/lib/chef/provider/package/yum/simplejson/scanner.pyc +0 -0
- data/lib/chef/provider/package/yum/simplejson/tool.py +0 -37
- data/lib/chef/resource/user/dscl_user.rb +0 -35
- data/spec/functional/knife/configure_spec.rb +0 -33
- data/spec/functional/knife/cookbook_delete_spec.rb +0 -156
- data/spec/functional/knife/exec_spec.rb +0 -55
- data/spec/functional/knife/rehash_spec.rb +0 -39
- data/spec/functional/knife/smoke_test.rb +0 -42
- data/spec/functional/knife/ssh_spec.rb +0 -352
- data/spec/functional/resource/user/dscl_spec.rb +0 -188
- data/spec/functional/resource/windows_service_spec.rb +0 -105
- data/spec/functional/win32/service_manager_spec.rb +0 -220
- data/spec/integration/knife/chef_fs_data_store_spec.rb +0 -557
- data/spec/integration/knife/chef_repo_path_spec.rb +0 -962
- data/spec/integration/knife/chef_repository_file_system_spec.rb +0 -200
- data/spec/integration/knife/chefignore_spec.rb +0 -301
- data/spec/integration/knife/client_bulk_delete_spec.rb +0 -131
- data/spec/integration/knife/client_create_spec.rb +0 -70
- data/spec/integration/knife/client_delete_spec.rb +0 -64
- data/spec/integration/knife/client_key_create_spec.rb +0 -66
- data/spec/integration/knife/client_key_delete_spec.rb +0 -43
- data/spec/integration/knife/client_key_list_spec.rb +0 -61
- data/spec/integration/knife/client_key_show_spec.rb +0 -45
- data/spec/integration/knife/client_list_spec.rb +0 -49
- data/spec/integration/knife/client_show_spec.rb +0 -37
- data/spec/integration/knife/common_options_spec.rb +0 -174
- data/spec/integration/knife/config_list_spec.rb +0 -220
- data/spec/integration/knife/config_show_spec.rb +0 -192
- data/spec/integration/knife/config_use_spec.rb +0 -198
- data/spec/integration/knife/cookbook_api_ipv6_spec.rb +0 -113
- data/spec/integration/knife/cookbook_bulk_delete_spec.rb +0 -65
- data/spec/integration/knife/cookbook_download_spec.rb +0 -72
- data/spec/integration/knife/cookbook_list_spec.rb +0 -55
- data/spec/integration/knife/cookbook_show_spec.rb +0 -149
- data/spec/integration/knife/cookbook_upload_spec.rb +0 -128
- data/spec/integration/knife/data_bag_create_spec.rb +0 -125
- data/spec/integration/knife/data_bag_delete_spec.rb +0 -59
- data/spec/integration/knife/data_bag_edit_spec.rb +0 -105
- data/spec/integration/knife/data_bag_from_file_spec.rb +0 -116
- data/spec/integration/knife/data_bag_list_spec.rb +0 -44
- data/spec/integration/knife/data_bag_show_spec.rb +0 -95
- data/spec/integration/knife/delete_spec.rb +0 -1018
- data/spec/integration/knife/deps_spec.rb +0 -703
- data/spec/integration/knife/diff_spec.rb +0 -605
- data/spec/integration/knife/download_spec.rb +0 -1336
- data/spec/integration/knife/environment_compare_spec.rb +0 -75
- data/spec/integration/knife/environment_create_spec.rb +0 -41
- data/spec/integration/knife/environment_delete_spec.rb +0 -37
- data/spec/integration/knife/environment_from_file_spec.rb +0 -116
- data/spec/integration/knife/environment_list_spec.rb +0 -42
- data/spec/integration/knife/environment_show_spec.rb +0 -77
- data/spec/integration/knife/list_spec.rb +0 -1060
- data/spec/integration/knife/node_bulk_delete_spec.rb +0 -52
- data/spec/integration/knife/node_create_spec.rb +0 -47
- data/spec/integration/knife/node_delete_spec.rb +0 -48
- data/spec/integration/knife/node_environment_set_spec.rb +0 -46
- data/spec/integration/knife/node_from_file_spec.rb +0 -59
- data/spec/integration/knife/node_list_spec.rb +0 -45
- data/spec/integration/knife/node_run_list_add_spec.rb +0 -54
- data/spec/integration/knife/node_run_list_remove_spec.rb +0 -36
- data/spec/integration/knife/node_run_list_set_spec.rb +0 -41
- data/spec/integration/knife/node_show_spec.rb +0 -36
- data/spec/integration/knife/raw_spec.rb +0 -297
- data/spec/integration/knife/redirection_spec.rb +0 -64
- data/spec/integration/knife/role_bulk_delete_spec.rb +0 -52
- data/spec/integration/knife/role_create_spec.rb +0 -41
- data/spec/integration/knife/role_delete_spec.rb +0 -48
- data/spec/integration/knife/role_from_file_spec.rb +0 -96
- data/spec/integration/knife/role_list_spec.rb +0 -45
- data/spec/integration/knife/role_show_spec.rb +0 -51
- data/spec/integration/knife/search_node_spec.rb +0 -40
- data/spec/integration/knife/serve_spec.rb +0 -92
- data/spec/integration/knife/show_spec.rb +0 -197
- data/spec/integration/knife/upload_spec.rb +0 -1617
- data/spec/support/shared/functional/win32_service.rb +0 -57
- data/spec/unit/application/knife_spec.rb +0 -241
- data/spec/unit/chef_fs/parallelizer_spec.rb +0 -479
- data/spec/unit/cookbook_site_streaming_uploader_spec.rb +0 -198
- data/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb +0 -152
- data/spec/unit/knife/bootstrap/client_builder_spec.rb +0 -207
- data/spec/unit/knife/bootstrap/train_connector_spec.rb +0 -244
- data/spec/unit/knife/bootstrap_spec.rb +0 -2220
- data/spec/unit/knife/client_bulk_delete_spec.rb +0 -166
- data/spec/unit/knife/client_create_spec.rb +0 -169
- data/spec/unit/knife/client_delete_spec.rb +0 -99
- data/spec/unit/knife/client_edit_spec.rb +0 -53
- data/spec/unit/knife/client_list_spec.rb +0 -34
- data/spec/unit/knife/client_reregister_spec.rb +0 -62
- data/spec/unit/knife/client_show_spec.rb +0 -52
- data/spec/unit/knife/configure_client_spec.rb +0 -81
- data/spec/unit/knife/configure_spec.rb +0 -190
- data/spec/unit/knife/cookbook_bulk_delete_spec.rb +0 -87
- data/spec/unit/knife/cookbook_delete_spec.rb +0 -239
- data/spec/unit/knife/cookbook_download_spec.rb +0 -255
- data/spec/unit/knife/cookbook_list_spec.rb +0 -88
- data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +0 -72
- data/spec/unit/knife/cookbook_metadata_spec.rb +0 -182
- data/spec/unit/knife/cookbook_show_spec.rb +0 -253
- data/spec/unit/knife/cookbook_upload_spec.rb +0 -364
- data/spec/unit/knife/core/bootstrap_context_spec.rb +0 -287
- data/spec/unit/knife/core/cookbook_scm_repo_spec.rb +0 -187
- data/spec/unit/knife/core/gem_glob_loader_spec.rb +0 -209
- data/spec/unit/knife/core/hashed_command_loader_spec.rb +0 -112
- data/spec/unit/knife/core/node_editor_spec.rb +0 -211
- data/spec/unit/knife/core/object_loader_spec.rb +0 -81
- data/spec/unit/knife/core/status_presenter_spec.rb +0 -54
- data/spec/unit/knife/core/subcommand_loader_spec.rb +0 -64
- data/spec/unit/knife/core/ui_spec.rb +0 -656
- data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +0 -238
- data/spec/unit/knife/data_bag_create_spec.rb +0 -175
- data/spec/unit/knife/data_bag_edit_spec.rb +0 -126
- data/spec/unit/knife/data_bag_from_file_spec.rb +0 -174
- data/spec/unit/knife/data_bag_secret_options_spec.rb +0 -173
- data/spec/unit/knife/data_bag_show_spec.rb +0 -139
- data/spec/unit/knife/environment_compare_spec.rb +0 -112
- data/spec/unit/knife/environment_create_spec.rb +0 -91
- data/spec/unit/knife/environment_delete_spec.rb +0 -71
- data/spec/unit/knife/environment_edit_spec.rb +0 -79
- data/spec/unit/knife/environment_from_file_spec.rb +0 -90
- data/spec/unit/knife/environment_list_spec.rb +0 -54
- data/spec/unit/knife/environment_show_spec.rb +0 -52
- data/spec/unit/knife/key_create_spec.rb +0 -223
- data/spec/unit/knife/key_delete_spec.rb +0 -133
- data/spec/unit/knife/key_edit_spec.rb +0 -264
- data/spec/unit/knife/key_helper.rb +0 -74
- data/spec/unit/knife/key_list_spec.rb +0 -216
- data/spec/unit/knife/key_show_spec.rb +0 -126
- data/spec/unit/knife/node_bulk_delete_spec.rb +0 -94
- data/spec/unit/knife/node_delete_spec.rb +0 -77
- data/spec/unit/knife/node_edit_spec.rb +0 -116
- data/spec/unit/knife/node_environment_set_spec.rb +0 -61
- data/spec/unit/knife/node_from_file_spec.rb +0 -59
- data/spec/unit/knife/node_list_spec.rb +0 -62
- data/spec/unit/knife/node_policy_set_spec.rb +0 -122
- data/spec/unit/knife/node_run_list_add_spec.rb +0 -145
- data/spec/unit/knife/node_run_list_remove_spec.rb +0 -106
- data/spec/unit/knife/node_run_list_set_spec.rb +0 -115
- data/spec/unit/knife/node_show_spec.rb +0 -65
- data/spec/unit/knife/raw_spec.rb +0 -43
- data/spec/unit/knife/role_bulk_delete_spec.rb +0 -80
- data/spec/unit/knife/role_create_spec.rb +0 -80
- data/spec/unit/knife/role_delete_spec.rb +0 -67
- data/spec/unit/knife/role_edit_spec.rb +0 -77
- data/spec/unit/knife/role_env_run_list_add_spec.rb +0 -217
- data/spec/unit/knife/role_env_run_list_clear_spec.rb +0 -94
- data/spec/unit/knife/role_env_run_list_remove_spec.rb +0 -102
- data/spec/unit/knife/role_env_run_list_replace_spec.rb +0 -105
- data/spec/unit/knife/role_env_run_list_set_spec.rb +0 -99
- data/spec/unit/knife/role_from_file_spec.rb +0 -69
- data/spec/unit/knife/role_list_spec.rb +0 -54
- data/spec/unit/knife/role_run_list_add_spec.rb +0 -179
- data/spec/unit/knife/role_run_list_clear_spec.rb +0 -84
- data/spec/unit/knife/role_run_list_remove_spec.rb +0 -92
- data/spec/unit/knife/role_run_list_replace_spec.rb +0 -98
- data/spec/unit/knife/role_run_list_set_spec.rb +0 -89
- data/spec/unit/knife/role_show_spec.rb +0 -59
- data/spec/unit/knife/ssh_spec.rb +0 -403
- data/spec/unit/knife/ssl_check_spec.rb +0 -256
- data/spec/unit/knife/ssl_fetch_spec.rb +0 -222
- data/spec/unit/knife/status_spec.rb +0 -112
- data/spec/unit/knife/supermarket_download_spec.rb +0 -152
- data/spec/unit/knife/supermarket_install_spec.rb +0 -202
- data/spec/unit/knife/supermarket_list_spec.rb +0 -70
- data/spec/unit/knife/supermarket_search_spec.rb +0 -85
- data/spec/unit/knife/supermarket_share_spec.rb +0 -208
- data/spec/unit/knife/supermarket_unshare_spec.rb +0 -78
- data/spec/unit/knife/tag_create_spec.rb +0 -23
- data/spec/unit/knife/tag_delete_spec.rb +0 -25
- data/spec/unit/knife/tag_list_spec.rb +0 -23
- data/spec/unit/knife/user_create_spec.rb +0 -184
- data/spec/unit/knife/user_delete_spec.rb +0 -46
- data/spec/unit/knife/user_edit_spec.rb +0 -48
- data/spec/unit/knife/user_list_spec.rb +0 -36
- data/spec/unit/knife/user_reregister_spec.rb +0 -56
- data/spec/unit/knife/user_show_spec.rb +0 -46
- data/spec/unit/knife_spec.rb +0 -634
- data/spec/unit/provider/user/dscl_spec.rb +0 -699
- data/spec/unit/windows_service_spec.rb +0 -118
Binary file
|
@@ -1,354 +0,0 @@
|
|
1
|
-
"""Implementation of JSONDecoder
|
2
|
-
"""
|
3
|
-
import re
|
4
|
-
import sys
|
5
|
-
import struct
|
6
|
-
|
7
|
-
from simplejson.scanner import make_scanner
|
8
|
-
try:
|
9
|
-
from simplejson._speedups import scanstring as c_scanstring
|
10
|
-
except ImportError:
|
11
|
-
c_scanstring = None
|
12
|
-
|
13
|
-
__all__ = ['JSONDecoder']
|
14
|
-
|
15
|
-
FLAGS = re.VERBOSE | re.MULTILINE | re.DOTALL
|
16
|
-
|
17
|
-
def _floatconstants():
|
18
|
-
_BYTES = '7FF80000000000007FF0000000000000'.decode('hex')
|
19
|
-
if sys.byteorder != 'big':
|
20
|
-
_BYTES = _BYTES[:8][::-1] + _BYTES[8:][::-1]
|
21
|
-
nan, inf = struct.unpack('dd', _BYTES)
|
22
|
-
return nan, inf, -inf
|
23
|
-
|
24
|
-
NaN, PosInf, NegInf = _floatconstants()
|
25
|
-
|
26
|
-
|
27
|
-
def linecol(doc, pos):
|
28
|
-
lineno = doc.count('\n', 0, pos) + 1
|
29
|
-
if lineno == 1:
|
30
|
-
colno = pos
|
31
|
-
else:
|
32
|
-
colno = pos - doc.rindex('\n', 0, pos)
|
33
|
-
return lineno, colno
|
34
|
-
|
35
|
-
|
36
|
-
def errmsg(msg, doc, pos, end=None):
|
37
|
-
# Note that this function is called from _speedups
|
38
|
-
lineno, colno = linecol(doc, pos)
|
39
|
-
if end is None:
|
40
|
-
#fmt = '{0}: line {1} column {2} (char {3})'
|
41
|
-
#return fmt.format(msg, lineno, colno, pos)
|
42
|
-
fmt = '%s: line %d column %d (char %d)'
|
43
|
-
return fmt % (msg, lineno, colno, pos)
|
44
|
-
endlineno, endcolno = linecol(doc, end)
|
45
|
-
#fmt = '{0}: line {1} column {2} - line {3} column {4} (char {5} - {6})'
|
46
|
-
#return fmt.format(msg, lineno, colno, endlineno, endcolno, pos, end)
|
47
|
-
fmt = '%s: line %d column %d - line %d column %d (char %d - %d)'
|
48
|
-
return fmt % (msg, lineno, colno, endlineno, endcolno, pos, end)
|
49
|
-
|
50
|
-
|
51
|
-
_CONSTANTS = {
|
52
|
-
'-Infinity': NegInf,
|
53
|
-
'Infinity': PosInf,
|
54
|
-
'NaN': NaN,
|
55
|
-
}
|
56
|
-
|
57
|
-
STRINGCHUNK = re.compile(r'(.*?)(["\\\x00-\x1f])', FLAGS)
|
58
|
-
BACKSLASH = {
|
59
|
-
'"': u'"', '\\': u'\\', '/': u'/',
|
60
|
-
'b': u'\b', 'f': u'\f', 'n': u'\n', 'r': u'\r', 't': u'\t',
|
61
|
-
}
|
62
|
-
|
63
|
-
DEFAULT_ENCODING = "utf-8"
|
64
|
-
|
65
|
-
def py_scanstring(s, end, encoding=None, strict=True, _b=BACKSLASH, _m=STRINGCHUNK.match):
|
66
|
-
"""Scan the string s for a JSON string. End is the index of the
|
67
|
-
character in s after the quote that started the JSON string.
|
68
|
-
Unescapes all valid JSON string escape sequences and raises ValueError
|
69
|
-
on attempt to decode an invalid string. If strict is False then literal
|
70
|
-
control characters are allowed in the string.
|
71
|
-
|
72
|
-
Returns a tuple of the decoded string and the index of the character in s
|
73
|
-
after the end quote."""
|
74
|
-
if encoding is None:
|
75
|
-
encoding = DEFAULT_ENCODING
|
76
|
-
chunks = []
|
77
|
-
_append = chunks.append
|
78
|
-
begin = end - 1
|
79
|
-
while 1:
|
80
|
-
chunk = _m(s, end)
|
81
|
-
if chunk is None:
|
82
|
-
raise ValueError(
|
83
|
-
errmsg("Unterminated string starting at", s, begin))
|
84
|
-
end = chunk.end()
|
85
|
-
content, terminator = chunk.groups()
|
86
|
-
# Content is contains zero or more unescaped string characters
|
87
|
-
if content:
|
88
|
-
if not isinstance(content, unicode):
|
89
|
-
content = unicode(content, encoding)
|
90
|
-
_append(content)
|
91
|
-
# Terminator is the end of string, a literal control character,
|
92
|
-
# or a backslash denoting that an escape sequence follows
|
93
|
-
if terminator == '"':
|
94
|
-
break
|
95
|
-
elif terminator != '\\':
|
96
|
-
if strict:
|
97
|
-
msg = "Invalid control character %r at" % (terminator,)
|
98
|
-
#msg = "Invalid control character {0!r} at".format(terminator)
|
99
|
-
raise ValueError(errmsg(msg, s, end))
|
100
|
-
else:
|
101
|
-
_append(terminator)
|
102
|
-
continue
|
103
|
-
try:
|
104
|
-
esc = s[end]
|
105
|
-
except IndexError:
|
106
|
-
raise ValueError(
|
107
|
-
errmsg("Unterminated string starting at", s, begin))
|
108
|
-
# If not a unicode escape sequence, must be in the lookup table
|
109
|
-
if esc != 'u':
|
110
|
-
try:
|
111
|
-
char = _b[esc]
|
112
|
-
except KeyError:
|
113
|
-
msg = "Invalid \\escape: " + repr(esc)
|
114
|
-
raise ValueError(errmsg(msg, s, end))
|
115
|
-
end += 1
|
116
|
-
else:
|
117
|
-
# Unicode escape sequence
|
118
|
-
esc = s[end + 1:end + 5]
|
119
|
-
next_end = end + 5
|
120
|
-
if len(esc) != 4:
|
121
|
-
msg = "Invalid \\uXXXX escape"
|
122
|
-
raise ValueError(errmsg(msg, s, end))
|
123
|
-
uni = int(esc, 16)
|
124
|
-
# Check for surrogate pair on UCS-4 systems
|
125
|
-
if 0xd800 <= uni <= 0xdbff and sys.maxunicode > 65535:
|
126
|
-
msg = "Invalid \\uXXXX\\uXXXX surrogate pair"
|
127
|
-
if not s[end + 5:end + 7] == '\\u':
|
128
|
-
raise ValueError(errmsg(msg, s, end))
|
129
|
-
esc2 = s[end + 7:end + 11]
|
130
|
-
if len(esc2) != 4:
|
131
|
-
raise ValueError(errmsg(msg, s, end))
|
132
|
-
uni2 = int(esc2, 16)
|
133
|
-
uni = 0x10000 + (((uni - 0xd800) << 10) | (uni2 - 0xdc00))
|
134
|
-
next_end += 6
|
135
|
-
char = unichr(uni)
|
136
|
-
end = next_end
|
137
|
-
# Append the unescaped character
|
138
|
-
_append(char)
|
139
|
-
return u''.join(chunks), end
|
140
|
-
|
141
|
-
|
142
|
-
# Use speedup if available
|
143
|
-
scanstring = c_scanstring or py_scanstring
|
144
|
-
|
145
|
-
WHITESPACE = re.compile(r'[ \t\n\r]*', FLAGS)
|
146
|
-
WHITESPACE_STR = ' \t\n\r'
|
147
|
-
|
148
|
-
def JSONObject((s, end), encoding, strict, scan_once, object_hook, _w=WHITESPACE.match, _ws=WHITESPACE_STR):
|
149
|
-
pairs = {}
|
150
|
-
# Use a slice to prevent IndexError from being raised, the following
|
151
|
-
# check will raise a more specific ValueError if the string is empty
|
152
|
-
nextchar = s[end:end + 1]
|
153
|
-
# Normally we expect nextchar == '"'
|
154
|
-
if nextchar != '"':
|
155
|
-
if nextchar in _ws:
|
156
|
-
end = _w(s, end).end()
|
157
|
-
nextchar = s[end:end + 1]
|
158
|
-
# Trivial empty object
|
159
|
-
if nextchar == '}':
|
160
|
-
return pairs, end + 1
|
161
|
-
elif nextchar != '"':
|
162
|
-
raise ValueError(errmsg("Expecting property name", s, end))
|
163
|
-
end += 1
|
164
|
-
while True:
|
165
|
-
key, end = scanstring(s, end, encoding, strict)
|
166
|
-
|
167
|
-
# To skip some function call overhead we optimize the fast paths where
|
168
|
-
# the JSON key separator is ": " or just ":".
|
169
|
-
if s[end:end + 1] != ':':
|
170
|
-
end = _w(s, end).end()
|
171
|
-
if s[end:end + 1] != ':':
|
172
|
-
raise ValueError(errmsg("Expecting : delimiter", s, end))
|
173
|
-
|
174
|
-
end += 1
|
175
|
-
|
176
|
-
try:
|
177
|
-
if s[end] in _ws:
|
178
|
-
end += 1
|
179
|
-
if s[end] in _ws:
|
180
|
-
end = _w(s, end + 1).end()
|
181
|
-
except IndexError:
|
182
|
-
pass
|
183
|
-
|
184
|
-
try:
|
185
|
-
value, end = scan_once(s, end)
|
186
|
-
except StopIteration:
|
187
|
-
raise ValueError(errmsg("Expecting object", s, end))
|
188
|
-
pairs[key] = value
|
189
|
-
|
190
|
-
try:
|
191
|
-
nextchar = s[end]
|
192
|
-
if nextchar in _ws:
|
193
|
-
end = _w(s, end + 1).end()
|
194
|
-
nextchar = s[end]
|
195
|
-
except IndexError:
|
196
|
-
nextchar = ''
|
197
|
-
end += 1
|
198
|
-
|
199
|
-
if nextchar == '}':
|
200
|
-
break
|
201
|
-
elif nextchar != ',':
|
202
|
-
raise ValueError(errmsg("Expecting , delimiter", s, end - 1))
|
203
|
-
|
204
|
-
try:
|
205
|
-
nextchar = s[end]
|
206
|
-
if nextchar in _ws:
|
207
|
-
end += 1
|
208
|
-
nextchar = s[end]
|
209
|
-
if nextchar in _ws:
|
210
|
-
end = _w(s, end + 1).end()
|
211
|
-
nextchar = s[end]
|
212
|
-
except IndexError:
|
213
|
-
nextchar = ''
|
214
|
-
|
215
|
-
end += 1
|
216
|
-
if nextchar != '"':
|
217
|
-
raise ValueError(errmsg("Expecting property name", s, end - 1))
|
218
|
-
|
219
|
-
if object_hook is not None:
|
220
|
-
pairs = object_hook(pairs)
|
221
|
-
return pairs, end
|
222
|
-
|
223
|
-
def JSONArray((s, end), scan_once, _w=WHITESPACE.match, _ws=WHITESPACE_STR):
|
224
|
-
values = []
|
225
|
-
nextchar = s[end:end + 1]
|
226
|
-
if nextchar in _ws:
|
227
|
-
end = _w(s, end + 1).end()
|
228
|
-
nextchar = s[end:end + 1]
|
229
|
-
# Look-ahead for trivial empty array
|
230
|
-
if nextchar == ']':
|
231
|
-
return values, end + 1
|
232
|
-
_append = values.append
|
233
|
-
while True:
|
234
|
-
try:
|
235
|
-
value, end = scan_once(s, end)
|
236
|
-
except StopIteration:
|
237
|
-
raise ValueError(errmsg("Expecting object", s, end))
|
238
|
-
_append(value)
|
239
|
-
nextchar = s[end:end + 1]
|
240
|
-
if nextchar in _ws:
|
241
|
-
end = _w(s, end + 1).end()
|
242
|
-
nextchar = s[end:end + 1]
|
243
|
-
end += 1
|
244
|
-
if nextchar == ']':
|
245
|
-
break
|
246
|
-
elif nextchar != ',':
|
247
|
-
raise ValueError(errmsg("Expecting , delimiter", s, end))
|
248
|
-
|
249
|
-
try:
|
250
|
-
if s[end] in _ws:
|
251
|
-
end += 1
|
252
|
-
if s[end] in _ws:
|
253
|
-
end = _w(s, end + 1).end()
|
254
|
-
except IndexError:
|
255
|
-
pass
|
256
|
-
|
257
|
-
return values, end
|
258
|
-
|
259
|
-
class JSONDecoder(object):
|
260
|
-
"""Simple JSON <http://json.org> decoder
|
261
|
-
|
262
|
-
Performs the following translations in decoding by default:
|
263
|
-
|
264
|
-
+---------------+-------------------+
|
265
|
-
| JSON | Python |
|
266
|
-
+===============+===================+
|
267
|
-
| object | dict |
|
268
|
-
+---------------+-------------------+
|
269
|
-
| array | list |
|
270
|
-
+---------------+-------------------+
|
271
|
-
| string | unicode |
|
272
|
-
+---------------+-------------------+
|
273
|
-
| number (int) | int, long |
|
274
|
-
+---------------+-------------------+
|
275
|
-
| number (real) | float |
|
276
|
-
+---------------+-------------------+
|
277
|
-
| true | True |
|
278
|
-
+---------------+-------------------+
|
279
|
-
| false | False |
|
280
|
-
+---------------+-------------------+
|
281
|
-
| null | None |
|
282
|
-
+---------------+-------------------+
|
283
|
-
|
284
|
-
It also understands ``NaN``, ``Infinity``, and ``-Infinity`` as
|
285
|
-
their corresponding ``float`` values, which is outside the JSON spec.
|
286
|
-
|
287
|
-
"""
|
288
|
-
|
289
|
-
def __init__(self, encoding=None, object_hook=None, parse_float=None,
|
290
|
-
parse_int=None, parse_constant=None, strict=True):
|
291
|
-
"""``encoding`` determines the encoding used to interpret any ``str``
|
292
|
-
objects decoded by this instance (utf-8 by default). It has no
|
293
|
-
effect when decoding ``unicode`` objects.
|
294
|
-
|
295
|
-
Note that currently only encodings that are a superset of ASCII work,
|
296
|
-
strings of other encodings should be passed in as ``unicode``.
|
297
|
-
|
298
|
-
``object_hook``, if specified, will be called with the result
|
299
|
-
of every JSON object decoded and its return value will be used in
|
300
|
-
place of the given ``dict``. This can be used to provide custom
|
301
|
-
deserializations (e.g. to support JSON-RPC class hinting).
|
302
|
-
|
303
|
-
``parse_float``, if specified, will be called with the string
|
304
|
-
of every JSON float to be decoded. By default this is equivalent to
|
305
|
-
float(num_str). This can be used to use another datatype or parser
|
306
|
-
for JSON floats (e.g. decimal.Decimal).
|
307
|
-
|
308
|
-
``parse_int``, if specified, will be called with the string
|
309
|
-
of every JSON int to be decoded. By default this is equivalent to
|
310
|
-
int(num_str). This can be used to use another datatype or parser
|
311
|
-
for JSON integers (e.g. float).
|
312
|
-
|
313
|
-
``parse_constant``, if specified, will be called with one of the
|
314
|
-
following strings: -Infinity, Infinity, NaN.
|
315
|
-
This can be used to raise an exception if invalid JSON numbers
|
316
|
-
are encountered.
|
317
|
-
|
318
|
-
"""
|
319
|
-
self.encoding = encoding
|
320
|
-
self.object_hook = object_hook
|
321
|
-
self.parse_float = parse_float or float
|
322
|
-
self.parse_int = parse_int or int
|
323
|
-
self.parse_constant = parse_constant or _CONSTANTS.__getitem__
|
324
|
-
self.strict = strict
|
325
|
-
self.parse_object = JSONObject
|
326
|
-
self.parse_array = JSONArray
|
327
|
-
self.parse_string = scanstring
|
328
|
-
self.scan_once = make_scanner(self)
|
329
|
-
|
330
|
-
def decode(self, s, _w=WHITESPACE.match):
|
331
|
-
"""Return the Python representation of ``s`` (a ``str`` or ``unicode``
|
332
|
-
instance containing a JSON document)
|
333
|
-
|
334
|
-
"""
|
335
|
-
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
|
336
|
-
end = _w(s, end).end()
|
337
|
-
if end != len(s):
|
338
|
-
raise ValueError(errmsg("Extra data", s, end, len(s)))
|
339
|
-
return obj
|
340
|
-
|
341
|
-
def raw_decode(self, s, idx=0):
|
342
|
-
"""Decode a JSON document from ``s`` (a ``str`` or ``unicode`` beginning
|
343
|
-
with a JSON document) and return a 2-tuple of the Python
|
344
|
-
representation and the index in ``s`` where the document ended.
|
345
|
-
|
346
|
-
This can be used to decode a JSON document from a string that may
|
347
|
-
have extraneous data at the end.
|
348
|
-
|
349
|
-
"""
|
350
|
-
try:
|
351
|
-
obj, end = self.scan_once(s, idx)
|
352
|
-
except StopIteration:
|
353
|
-
raise ValueError("No JSON object could be decoded")
|
354
|
-
return obj, end
|
Binary file
|
@@ -1,440 +0,0 @@
|
|
1
|
-
"""Implementation of JSONEncoder
|
2
|
-
"""
|
3
|
-
import re
|
4
|
-
|
5
|
-
try:
|
6
|
-
from simplejson._speedups import encode_basestring_ascii as c_encode_basestring_ascii
|
7
|
-
except ImportError:
|
8
|
-
c_encode_basestring_ascii = None
|
9
|
-
try:
|
10
|
-
from simplejson._speedups import make_encoder as c_make_encoder
|
11
|
-
except ImportError:
|
12
|
-
c_make_encoder = None
|
13
|
-
|
14
|
-
ESCAPE = re.compile(r'[\x00-\x1f\\"\b\f\n\r\t]')
|
15
|
-
ESCAPE_ASCII = re.compile(r'([\\"]|[^\ -~])')
|
16
|
-
HAS_UTF8 = re.compile(r'[\x80-\xff]')
|
17
|
-
ESCAPE_DCT = {
|
18
|
-
'\\': '\\\\',
|
19
|
-
'"': '\\"',
|
20
|
-
'\b': '\\b',
|
21
|
-
'\f': '\\f',
|
22
|
-
'\n': '\\n',
|
23
|
-
'\r': '\\r',
|
24
|
-
'\t': '\\t',
|
25
|
-
}
|
26
|
-
for i in range(0x20):
|
27
|
-
#ESCAPE_DCT.setdefault(chr(i), '\\u{0:04x}'.format(i))
|
28
|
-
ESCAPE_DCT.setdefault(chr(i), '\\u%04x' % (i,))
|
29
|
-
|
30
|
-
# Assume this produces an infinity on all machines (probably not guaranteed)
|
31
|
-
INFINITY = float('1e66666')
|
32
|
-
FLOAT_REPR = repr
|
33
|
-
|
34
|
-
def encode_basestring(s):
|
35
|
-
"""Return a JSON representation of a Python string
|
36
|
-
|
37
|
-
"""
|
38
|
-
def replace(match):
|
39
|
-
return ESCAPE_DCT[match.group(0)]
|
40
|
-
return '"' + ESCAPE.sub(replace, s) + '"'
|
41
|
-
|
42
|
-
|
43
|
-
def py_encode_basestring_ascii(s):
|
44
|
-
"""Return an ASCII-only JSON representation of a Python string
|
45
|
-
|
46
|
-
"""
|
47
|
-
if isinstance(s, str) and HAS_UTF8.search(s) is not None:
|
48
|
-
s = s.decode('utf-8')
|
49
|
-
def replace(match):
|
50
|
-
s = match.group(0)
|
51
|
-
try:
|
52
|
-
return ESCAPE_DCT[s]
|
53
|
-
except KeyError:
|
54
|
-
n = ord(s)
|
55
|
-
if n < 0x10000:
|
56
|
-
#return '\\u{0:04x}'.format(n)
|
57
|
-
return '\\u%04x' % (n,)
|
58
|
-
else:
|
59
|
-
# surrogate pair
|
60
|
-
n -= 0x10000
|
61
|
-
s1 = 0xd800 | ((n >> 10) & 0x3ff)
|
62
|
-
s2 = 0xdc00 | (n & 0x3ff)
|
63
|
-
#return '\\u{0:04x}\\u{1:04x}'.format(s1, s2)
|
64
|
-
return '\\u%04x\\u%04x' % (s1, s2)
|
65
|
-
return '"' + str(ESCAPE_ASCII.sub(replace, s)) + '"'
|
66
|
-
|
67
|
-
|
68
|
-
encode_basestring_ascii = c_encode_basestring_ascii or py_encode_basestring_ascii
|
69
|
-
|
70
|
-
class JSONEncoder(object):
|
71
|
-
"""Extensible JSON <http://json.org> encoder for Python data structures.
|
72
|
-
|
73
|
-
Supports the following objects and types by default:
|
74
|
-
|
75
|
-
+-------------------+---------------+
|
76
|
-
| Python | JSON |
|
77
|
-
+===================+===============+
|
78
|
-
| dict | object |
|
79
|
-
+-------------------+---------------+
|
80
|
-
| list, tuple | array |
|
81
|
-
+-------------------+---------------+
|
82
|
-
| str, unicode | string |
|
83
|
-
+-------------------+---------------+
|
84
|
-
| int, long, float | number |
|
85
|
-
+-------------------+---------------+
|
86
|
-
| True | true |
|
87
|
-
+-------------------+---------------+
|
88
|
-
| False | false |
|
89
|
-
+-------------------+---------------+
|
90
|
-
| None | null |
|
91
|
-
+-------------------+---------------+
|
92
|
-
|
93
|
-
To extend this to recognize other objects, subclass and implement a
|
94
|
-
``.default()`` method with another method that returns a serializable
|
95
|
-
object for ``o`` if possible, otherwise it should call the superclass
|
96
|
-
implementation (to raise ``TypeError``).
|
97
|
-
|
98
|
-
"""
|
99
|
-
item_separator = ', '
|
100
|
-
key_separator = ': '
|
101
|
-
def __init__(self, skipkeys=False, ensure_ascii=True,
|
102
|
-
check_circular=True, allow_nan=True, sort_keys=False,
|
103
|
-
indent=None, separators=None, encoding='utf-8', default=None):
|
104
|
-
"""Constructor for JSONEncoder, with sensible defaults.
|
105
|
-
|
106
|
-
If skipkeys is false, then it is a TypeError to attempt
|
107
|
-
encoding of keys that are not str, int, long, float or None. If
|
108
|
-
skipkeys is True, such items are simply skipped.
|
109
|
-
|
110
|
-
If ensure_ascii is true, the output is guaranteed to be str
|
111
|
-
objects with all incoming unicode characters escaped. If
|
112
|
-
ensure_ascii is false, the output will be unicode object.
|
113
|
-
|
114
|
-
If check_circular is true, then lists, dicts, and custom encoded
|
115
|
-
objects will be checked for circular references during encoding to
|
116
|
-
prevent an infinite recursion (which would cause an OverflowError).
|
117
|
-
Otherwise, no such check takes place.
|
118
|
-
|
119
|
-
If allow_nan is true, then NaN, Infinity, and -Infinity will be
|
120
|
-
encoded as such. This behavior is not JSON specification compliant,
|
121
|
-
but is consistent with most JavaScript based encoders and decoders.
|
122
|
-
Otherwise, it will be a ValueError to encode such floats.
|
123
|
-
|
124
|
-
If sort_keys is true, then the output of dictionaries will be
|
125
|
-
sorted by key; this is useful for regression tests to ensure
|
126
|
-
that JSON serializations can be compared on a day-to-day basis.
|
127
|
-
|
128
|
-
If indent is a non-negative integer, then JSON array
|
129
|
-
elements and object members will be pretty-printed with that
|
130
|
-
indent level. An indent level of 0 will only insert newlines.
|
131
|
-
None is the most compact representation.
|
132
|
-
|
133
|
-
If specified, separators should be a (item_separator, key_separator)
|
134
|
-
tuple. The default is (', ', ': '). To get the most compact JSON
|
135
|
-
representation you should specify (',', ':') to eliminate whitespace.
|
136
|
-
|
137
|
-
If specified, default is a function that gets called for objects
|
138
|
-
that can't otherwise be serialized. It should return a JSON encodable
|
139
|
-
version of the object or raise a ``TypeError``.
|
140
|
-
|
141
|
-
If encoding is not None, then all input strings will be
|
142
|
-
transformed into unicode using that encoding prior to JSON-encoding.
|
143
|
-
The default is UTF-8.
|
144
|
-
|
145
|
-
"""
|
146
|
-
|
147
|
-
self.skipkeys = skipkeys
|
148
|
-
self.ensure_ascii = ensure_ascii
|
149
|
-
self.check_circular = check_circular
|
150
|
-
self.allow_nan = allow_nan
|
151
|
-
self.sort_keys = sort_keys
|
152
|
-
self.indent = indent
|
153
|
-
if separators is not None:
|
154
|
-
self.item_separator, self.key_separator = separators
|
155
|
-
if default is not None:
|
156
|
-
self.default = default
|
157
|
-
self.encoding = encoding
|
158
|
-
|
159
|
-
def default(self, o):
|
160
|
-
"""Implement this method in a subclass such that it returns
|
161
|
-
a serializable object for ``o``, or calls the base implementation
|
162
|
-
(to raise a ``TypeError``).
|
163
|
-
|
164
|
-
For example, to support arbitrary iterators, you could
|
165
|
-
implement default like this::
|
166
|
-
|
167
|
-
def default(self, o):
|
168
|
-
try:
|
169
|
-
iterable = iter(o)
|
170
|
-
except TypeError:
|
171
|
-
pass
|
172
|
-
else:
|
173
|
-
return list(iterable)
|
174
|
-
return JSONEncoder.default(self, o)
|
175
|
-
|
176
|
-
"""
|
177
|
-
raise TypeError(repr(o) + " is not JSON serializable")
|
178
|
-
|
179
|
-
def encode(self, o):
|
180
|
-
"""Return a JSON string representation of a Python data structure.
|
181
|
-
|
182
|
-
>>> JSONEncoder().encode({"foo": ["bar", "baz"]})
|
183
|
-
'{"foo": ["bar", "baz"]}'
|
184
|
-
|
185
|
-
"""
|
186
|
-
# This is for extremely simple cases and benchmarks.
|
187
|
-
if isinstance(o, basestring):
|
188
|
-
if isinstance(o, str):
|
189
|
-
_encoding = self.encoding
|
190
|
-
if (_encoding is not None
|
191
|
-
and not (_encoding == 'utf-8')):
|
192
|
-
o = o.decode(_encoding)
|
193
|
-
if self.ensure_ascii:
|
194
|
-
return encode_basestring_ascii(o)
|
195
|
-
else:
|
196
|
-
return encode_basestring(o)
|
197
|
-
# This doesn't pass the iterator directly to ''.join() because the
|
198
|
-
# exceptions aren't as detailed. The list call should be roughly
|
199
|
-
# equivalent to the PySequence_Fast that ''.join() would do.
|
200
|
-
chunks = self.iterencode(o, _one_shot=True)
|
201
|
-
if not isinstance(chunks, (list, tuple)):
|
202
|
-
chunks = list(chunks)
|
203
|
-
return ''.join(chunks)
|
204
|
-
|
205
|
-
def iterencode(self, o, _one_shot=False):
|
206
|
-
"""Encode the given object and yield each string
|
207
|
-
representation as available.
|
208
|
-
|
209
|
-
For example::
|
210
|
-
|
211
|
-
for chunk in JSONEncoder().iterencode(bigobject):
|
212
|
-
mysocket.write(chunk)
|
213
|
-
|
214
|
-
"""
|
215
|
-
if self.check_circular:
|
216
|
-
markers = {}
|
217
|
-
else:
|
218
|
-
markers = None
|
219
|
-
if self.ensure_ascii:
|
220
|
-
_encoder = encode_basestring_ascii
|
221
|
-
else:
|
222
|
-
_encoder = encode_basestring
|
223
|
-
if self.encoding != 'utf-8':
|
224
|
-
def _encoder(o, _orig_encoder=_encoder, _encoding=self.encoding):
|
225
|
-
if isinstance(o, str):
|
226
|
-
o = o.decode(_encoding)
|
227
|
-
return _orig_encoder(o)
|
228
|
-
|
229
|
-
def floatstr(o, allow_nan=self.allow_nan, _repr=FLOAT_REPR, _inf=INFINITY, _neginf=-INFINITY):
|
230
|
-
# Check for specials. Note that this type of test is processor- and/or
|
231
|
-
# platform-specific, so do tests which don't depend on the internals.
|
232
|
-
|
233
|
-
if o != o:
|
234
|
-
text = 'NaN'
|
235
|
-
elif o == _inf:
|
236
|
-
text = 'Infinity'
|
237
|
-
elif o == _neginf:
|
238
|
-
text = '-Infinity'
|
239
|
-
else:
|
240
|
-
return _repr(o)
|
241
|
-
|
242
|
-
if not allow_nan:
|
243
|
-
raise ValueError(
|
244
|
-
"Out of range float values are not JSON compliant: " +
|
245
|
-
repr(o))
|
246
|
-
|
247
|
-
return text
|
248
|
-
|
249
|
-
|
250
|
-
if _one_shot and c_make_encoder is not None and not self.indent and not self.sort_keys:
|
251
|
-
_iterencode = c_make_encoder(
|
252
|
-
markers, self.default, _encoder, self.indent,
|
253
|
-
self.key_separator, self.item_separator, self.sort_keys,
|
254
|
-
self.skipkeys, self.allow_nan)
|
255
|
-
else:
|
256
|
-
_iterencode = _make_iterencode(
|
257
|
-
markers, self.default, _encoder, self.indent, floatstr,
|
258
|
-
self.key_separator, self.item_separator, self.sort_keys,
|
259
|
-
self.skipkeys, _one_shot)
|
260
|
-
return _iterencode(o, 0)
|
261
|
-
|
262
|
-
def _make_iterencode(markers, _default, _encoder, _indent, _floatstr, _key_separator, _item_separator, _sort_keys, _skipkeys, _one_shot,
|
263
|
-
## HACK: hand-optimized bytecode; turn globals into locals
|
264
|
-
False=False,
|
265
|
-
True=True,
|
266
|
-
ValueError=ValueError,
|
267
|
-
basestring=basestring,
|
268
|
-
dict=dict,
|
269
|
-
float=float,
|
270
|
-
id=id,
|
271
|
-
int=int,
|
272
|
-
isinstance=isinstance,
|
273
|
-
list=list,
|
274
|
-
long=long,
|
275
|
-
str=str,
|
276
|
-
tuple=tuple,
|
277
|
-
):
|
278
|
-
|
279
|
-
def _iterencode_list(lst, _current_indent_level):
|
280
|
-
if not lst:
|
281
|
-
yield '[]'
|
282
|
-
return
|
283
|
-
if markers is not None:
|
284
|
-
markerid = id(lst)
|
285
|
-
if markerid in markers:
|
286
|
-
raise ValueError("Circular reference detected")
|
287
|
-
markers[markerid] = lst
|
288
|
-
buf = '['
|
289
|
-
if _indent is not None:
|
290
|
-
_current_indent_level += 1
|
291
|
-
newline_indent = '\n' + (' ' * (_indent * _current_indent_level))
|
292
|
-
separator = _item_separator + newline_indent
|
293
|
-
buf += newline_indent
|
294
|
-
else:
|
295
|
-
newline_indent = None
|
296
|
-
separator = _item_separator
|
297
|
-
first = True
|
298
|
-
for value in lst:
|
299
|
-
if first:
|
300
|
-
first = False
|
301
|
-
else:
|
302
|
-
buf = separator
|
303
|
-
if isinstance(value, basestring):
|
304
|
-
yield buf + _encoder(value)
|
305
|
-
elif value is None:
|
306
|
-
yield buf + 'null'
|
307
|
-
elif value is True:
|
308
|
-
yield buf + 'true'
|
309
|
-
elif value is False:
|
310
|
-
yield buf + 'false'
|
311
|
-
elif isinstance(value, (int, long)):
|
312
|
-
yield buf + str(value)
|
313
|
-
elif isinstance(value, float):
|
314
|
-
yield buf + _floatstr(value)
|
315
|
-
else:
|
316
|
-
yield buf
|
317
|
-
if isinstance(value, (list, tuple)):
|
318
|
-
chunks = _iterencode_list(value, _current_indent_level)
|
319
|
-
elif isinstance(value, dict):
|
320
|
-
chunks = _iterencode_dict(value, _current_indent_level)
|
321
|
-
else:
|
322
|
-
chunks = _iterencode(value, _current_indent_level)
|
323
|
-
for chunk in chunks:
|
324
|
-
yield chunk
|
325
|
-
if newline_indent is not None:
|
326
|
-
_current_indent_level -= 1
|
327
|
-
yield '\n' + (' ' * (_indent * _current_indent_level))
|
328
|
-
yield ']'
|
329
|
-
if markers is not None:
|
330
|
-
del markers[markerid]
|
331
|
-
|
332
|
-
def _iterencode_dict(dct, _current_indent_level):
|
333
|
-
if not dct:
|
334
|
-
yield '{}'
|
335
|
-
return
|
336
|
-
if markers is not None:
|
337
|
-
markerid = id(dct)
|
338
|
-
if markerid in markers:
|
339
|
-
raise ValueError("Circular reference detected")
|
340
|
-
markers[markerid] = dct
|
341
|
-
yield '{'
|
342
|
-
if _indent is not None:
|
343
|
-
_current_indent_level += 1
|
344
|
-
newline_indent = '\n' + (' ' * (_indent * _current_indent_level))
|
345
|
-
item_separator = _item_separator + newline_indent
|
346
|
-
yield newline_indent
|
347
|
-
else:
|
348
|
-
newline_indent = None
|
349
|
-
item_separator = _item_separator
|
350
|
-
first = True
|
351
|
-
if _sort_keys:
|
352
|
-
items = dct.items()
|
353
|
-
items.sort(key=lambda kv: kv[0])
|
354
|
-
else:
|
355
|
-
items = dct.iteritems()
|
356
|
-
for key, value in items:
|
357
|
-
if isinstance(key, basestring):
|
358
|
-
pass
|
359
|
-
# JavaScript is weakly typed for these, so it makes sense to
|
360
|
-
# also allow them. Many encoders seem to do something like this.
|
361
|
-
elif isinstance(key, float):
|
362
|
-
key = _floatstr(key)
|
363
|
-
elif key is True:
|
364
|
-
key = 'true'
|
365
|
-
elif key is False:
|
366
|
-
key = 'false'
|
367
|
-
elif key is None:
|
368
|
-
key = 'null'
|
369
|
-
elif isinstance(key, (int, long)):
|
370
|
-
key = str(key)
|
371
|
-
elif _skipkeys:
|
372
|
-
continue
|
373
|
-
else:
|
374
|
-
raise TypeError("key " + repr(key) + " is not a string")
|
375
|
-
if first:
|
376
|
-
first = False
|
377
|
-
else:
|
378
|
-
yield item_separator
|
379
|
-
yield _encoder(key)
|
380
|
-
yield _key_separator
|
381
|
-
if isinstance(value, basestring):
|
382
|
-
yield _encoder(value)
|
383
|
-
elif value is None:
|
384
|
-
yield 'null'
|
385
|
-
elif value is True:
|
386
|
-
yield 'true'
|
387
|
-
elif value is False:
|
388
|
-
yield 'false'
|
389
|
-
elif isinstance(value, (int, long)):
|
390
|
-
yield str(value)
|
391
|
-
elif isinstance(value, float):
|
392
|
-
yield _floatstr(value)
|
393
|
-
else:
|
394
|
-
if isinstance(value, (list, tuple)):
|
395
|
-
chunks = _iterencode_list(value, _current_indent_level)
|
396
|
-
elif isinstance(value, dict):
|
397
|
-
chunks = _iterencode_dict(value, _current_indent_level)
|
398
|
-
else:
|
399
|
-
chunks = _iterencode(value, _current_indent_level)
|
400
|
-
for chunk in chunks:
|
401
|
-
yield chunk
|
402
|
-
if newline_indent is not None:
|
403
|
-
_current_indent_level -= 1
|
404
|
-
yield '\n' + (' ' * (_indent * _current_indent_level))
|
405
|
-
yield '}'
|
406
|
-
if markers is not None:
|
407
|
-
del markers[markerid]
|
408
|
-
|
409
|
-
def _iterencode(o, _current_indent_level):
|
410
|
-
if isinstance(o, basestring):
|
411
|
-
yield _encoder(o)
|
412
|
-
elif o is None:
|
413
|
-
yield 'null'
|
414
|
-
elif o is True:
|
415
|
-
yield 'true'
|
416
|
-
elif o is False:
|
417
|
-
yield 'false'
|
418
|
-
elif isinstance(o, (int, long)):
|
419
|
-
yield str(o)
|
420
|
-
elif isinstance(o, float):
|
421
|
-
yield _floatstr(o)
|
422
|
-
elif isinstance(o, (list, tuple)):
|
423
|
-
for chunk in _iterencode_list(o, _current_indent_level):
|
424
|
-
yield chunk
|
425
|
-
elif isinstance(o, dict):
|
426
|
-
for chunk in _iterencode_dict(o, _current_indent_level):
|
427
|
-
yield chunk
|
428
|
-
else:
|
429
|
-
if markers is not None:
|
430
|
-
markerid = id(o)
|
431
|
-
if markerid in markers:
|
432
|
-
raise ValueError("Circular reference detected")
|
433
|
-
markers[markerid] = o
|
434
|
-
o = _default(o)
|
435
|
-
for chunk in _iterencode(o, _current_indent_level):
|
436
|
-
yield chunk
|
437
|
-
if markers is not None:
|
438
|
-
del markers[markerid]
|
439
|
-
|
440
|
-
return _iterencode
|