oci 2.138.1__py3-none-any.whl → 2.139.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- oci/_vendor/idna/__init__.py +45 -2
- oci/_vendor/idna/codec.py +47 -43
- oci/_vendor/idna/compat.py +10 -7
- oci/_vendor/idna/core.py +210 -173
- oci/_vendor/idna/idnadata.py +3869 -1676
- oci/_vendor/idna/intranges.py +13 -9
- oci/_vendor/idna/package_data.py +2 -3
- oci/_vendor/idna/uts46data.py +8355 -8031
- oci/_vendor/urllib3/__init__.py +1 -1
- oci/_vendor/urllib3/_collections.py +19 -1
- oci/_vendor/urllib3/_version.py +2 -2
- oci/_vendor/urllib3/connection.py +8 -3
- oci/_vendor/urllib3/connectionpool.py +45 -13
- oci/_vendor/urllib3/contrib/__init__.py +1 -1
- oci/_vendor/urllib3/contrib/_appengine_environ.py +1 -1
- oci/_vendor/urllib3/contrib/_securetransport/__init__.py +1 -1
- oci/_vendor/urllib3/contrib/_securetransport/bindings.py +2 -2
- oci/_vendor/urllib3/contrib/_securetransport/low_level.py +1 -1
- oci/_vendor/urllib3/contrib/appengine.py +2 -2
- oci/_vendor/urllib3/contrib/ntlmpool.py +3 -3
- oci/_vendor/urllib3/contrib/pyopenssl.py +14 -7
- oci/_vendor/urllib3/contrib/securetransport.py +2 -4
- oci/_vendor/urllib3/contrib/socks.py +1 -1
- oci/_vendor/urllib3/exceptions.py +1 -1
- oci/_vendor/urllib3/fields.py +1 -1
- oci/_vendor/urllib3/filepost.py +1 -1
- oci/_vendor/urllib3/packages/__init__.py +2 -2
- oci/_vendor/urllib3/packages/backports/__init__.py +1 -1
- oci/_vendor/urllib3/packages/backports/makefile.py +1 -1
- oci/_vendor/urllib3/packages/backports/weakref_finalize.py +160 -0
- oci/_vendor/urllib3/packages/six.py +1 -2
- oci/_vendor/urllib3/poolmanager.py +7 -4
- oci/_vendor/urllib3/request.py +22 -1
- oci/_vendor/urllib3/response.py +65 -4
- oci/_vendor/urllib3/util/__init__.py +1 -1
- oci/_vendor/urllib3/util/connection.py +1 -1
- oci/_vendor/urllib3/util/proxy.py +1 -1
- oci/_vendor/urllib3/util/queue.py +1 -1
- oci/_vendor/urllib3/util/request.py +1 -1
- oci/_vendor/urllib3/util/response.py +1 -1
- oci/_vendor/urllib3/util/retry.py +5 -3
- oci/_vendor/urllib3/util/ssl_.py +14 -5
- oci/_vendor/urllib3/util/ssl_match_hostname.py +1 -1
- oci/_vendor/urllib3/util/ssltransport.py +1 -1
- oci/_vendor/urllib3/util/timeout.py +7 -4
- oci/_vendor/urllib3/util/url.py +8 -5
- oci/_vendor/urllib3/util/wait.py +1 -2
- oci/access_governance_cp/access_governance_cp_client.py +8 -8
- oci/adm/application_dependency_management_client.py +36 -36
- oci/ai_anomaly_detection/anomaly_detection_client.py +36 -36
- oci/ai_document/ai_service_document_client.py +26 -26
- oci/ai_language/ai_service_language_client.py +44 -44
- oci/ai_speech/ai_service_speech_client.py +19 -19
- oci/ai_vision/ai_service_vision_client.py +25 -25
- oci/analytics/analytics_client.py +24 -24
- oci/announcements_service/announcement_client.py +5 -5
- oci/announcements_service/announcement_subscription_client.py +9 -9
- oci/announcements_service/announcements_preferences_client.py +4 -4
- oci/announcements_service/service_client.py +1 -1
- oci/apigateway/api_gateway_client.py +21 -21
- oci/apigateway/deployment_client.py +6 -6
- oci/apigateway/gateway_client.py +6 -6
- oci/apigateway/subscribers_client.py +6 -6
- oci/apigateway/usage_plans_client.py +6 -6
- oci/apigateway/work_requests_client.py +5 -5
- oci/apm_config/config_client.py +9 -9
- oci/apm_control_plane/apm_domain_client.py +14 -14
- oci/apm_synthetics/apm_synthetic_client.py +28 -28
- oci/apm_traces/attributes_client.py +8 -8
- oci/apm_traces/query_client.py +2 -2
- oci/apm_traces/trace_client.py +4 -4
- oci/appmgmt_control/appmgmt_control_client.py +8 -8
- oci/artifacts/artifacts_client.py +32 -32
- oci/audit/audit_client.py +3 -3
- oci/autoscaling/auto_scaling_client.py +11 -11
- oci/bastion/bastion_client.py +15 -15
- oci/bds/bds_client.py +72 -72
- oci/blockchain/blockchain_platform_client.py +27 -27
- oci/budget/budget_client.py +10 -10
- oci/capacity_management/capacity_management_client.py +32 -32
- oci/certificates/certificates_client.py +5 -5
- oci/certificates_management/certificates_management_client.py +32 -32
- oci/cims/incident_client.py +13 -14
- oci/cims/models/__init__.py +4 -2
- oci/cims/models/cmos_user_group_info.py +103 -0
- oci/cims/models/create_incident.py +33 -2
- oci/cims/models/create_limit_item_details.py +2 -57
- oci/cims/models/create_user_details.py +4 -4
- oci/cims/models/incident.py +188 -0
- oci/cims/models/incident_resource_type.py +4 -4
- oci/cims/models/incident_summary.py +188 -0
- oci/cims/models/limit_item.py +2 -2
- oci/cims/models/{service_categories.py → services.py} +27 -27
- oci/cims/models/sub_categories.py +15 -15
- oci/cims/models/ticket.py +7 -3
- oci/cims/models/validation_response.py +33 -2
- oci/cloud_bridge/common_client.py +5 -5
- oci/cloud_bridge/discovery_client.py +15 -15
- oci/cloud_bridge/inventory_client.py +16 -16
- oci/cloud_bridge/ocb_agent_svc_client.py +22 -22
- oci/cloud_guard/cloud_guard_client.py +155 -155
- oci/cloud_migrations/migration_client.py +43 -43
- oci/cluster_placement_groups/cluster_placement_groups_cp_client.py +13 -13
- oci/compute_cloud_at_customer/compute_cloud_at_customer_client.py +12 -12
- oci/compute_instance_agent/compute_instance_agent_client.py +6 -6
- oci/compute_instance_agent/plugin_client.py +2 -2
- oci/compute_instance_agent/pluginconfig_client.py +1 -1
- oci/container_engine/container_engine_client.py +44 -44
- oci/container_instances/container_instance_client.py +18 -18
- oci/core/blockstorage_client.py +60 -60
- oci/core/compute_client.py +102 -102
- oci/core/compute_management_client.py +32 -32
- oci/core/virtual_network_client.py +247 -247
- oci/dashboard_service/dashboard_client.py +6 -6
- oci/dashboard_service/dashboard_group_client.py +6 -6
- oci/data_catalog/data_catalog_client.py +149 -149
- oci/data_flow/data_flow_client.py +44 -44
- oci/data_integration/data_integration_client.py +163 -163
- oci/data_labeling_service/data_labeling_management_client.py +17 -17
- oci/data_labeling_service_dataplane/data_labeling_client.py +15 -15
- oci/data_safe/data_safe_client.py +292 -292
- oci/data_science/data_science_client.py +92 -92
- oci/database/database_client.py +523 -398
- oci/database/database_client_composite_operations.py +88 -0
- oci/database/models/__init__.py +4 -0
- oci/database/models/autonomous_database.py +2 -2
- oci/database/models/autonomous_database_summary.py +2 -2
- oci/database/models/configure_exascale_exadata_infrastructure_details.py +72 -0
- oci/database/models/create_autonomous_database_base.py +2 -2
- oci/database/models/create_db_home_details.py +33 -2
- oci/database/models/create_db_home_from_backup_details.py +31 -0
- oci/database/models/create_db_home_from_database_details.py +31 -0
- oci/database/models/create_exascale_db_storage_vault_details.py +37 -2
- oci/database/models/create_pluggable_database_creation_type_details.py +2 -2
- oci/database/models/create_vm_cluster_details.py +37 -2
- oci/database/models/exadata_infrastructure.py +29 -2
- oci/database/models/exadata_infrastructure_summary.py +29 -2
- oci/database/models/exascale_config_details.py +103 -0
- oci/database/models/exascale_db_storage_vault.py +35 -0
- oci/database/models/exascale_db_storage_vault_summary.py +37 -2
- oci/database/models/update_autonomous_database_details.py +2 -2
- oci/database/models/vm_cluster.py +84 -2
- oci/database/models/vm_cluster_summary.py +84 -2
- oci/database_management/db_management_client.py +211 -211
- oci/database_management/diagnosability_client.py +4 -4
- oci/database_management/managed_my_sql_databases_client.py +7 -7
- oci/database_management/perfhub_client.py +1 -1
- oci/database_management/sql_tuning_client.py +17 -17
- oci/database_migration/database_migration_client.py +42 -42
- oci/database_tools/database_tools_client.py +23 -23
- oci/delegate_access_control/delegate_access_control_client.py +26 -26
- oci/delegate_access_control/work_request_client.py +4 -4
- oci/demand_signal/occ_demand_signal_client.py +7 -7
- oci/desktops/desktop_service_client.py +21 -21
- oci/devops/devops_client.py +141 -141
- oci/disaster_recovery/disaster_recovery_client.py +29 -29
- oci/dns/dns_client.py +54 -54
- oci/dts/appliance_export_job_client.py +6 -6
- oci/dts/shipping_vendors_client.py +1 -1
- oci/dts/transfer_appliance_client.py +8 -8
- oci/dts/transfer_appliance_entitlement_client.py +3 -3
- oci/dts/transfer_device_client.py +5 -5
- oci/dts/transfer_job_client.py +6 -6
- oci/dts/transfer_package_client.py +7 -7
- oci/em_warehouse/em_warehouse_client.py +13 -13
- oci/email/email_client.py +31 -31
- oci/email_data_plane/email_dp_client.py +1 -1
- oci/events/events_client.py +6 -6
- oci/file_storage/file_storage_client.py +68 -68
- oci/fleet_apps_management/fleet_apps_management_admin_client.py +25 -25
- oci/fleet_apps_management/fleet_apps_management_client.py +35 -35
- oci/fleet_apps_management/fleet_apps_management_maintenance_window_client.py +5 -5
- oci/fleet_apps_management/fleet_apps_management_operations_client.py +26 -26
- oci/fleet_apps_management/fleet_apps_management_runbooks_client.py +12 -12
- oci/fleet_software_update/fleet_software_update_client.py +46 -46
- oci/functions/functions_invoke_client.py +1 -1
- oci/functions/functions_management_client.py +16 -16
- oci/fusion_apps/fusion_applications_client.py +41 -41
- oci/generative_ai/generative_ai_client.py +22 -22
- oci/generative_ai_agent/generative_ai_agent_client.py +33 -33
- oci/generative_ai_agent_runtime/generative_ai_agent_runtime_client.py +5 -5
- oci/generative_ai_inference/generative_ai_inference_client.py +4 -4
- oci/generic_artifacts_content/generic_artifacts_content_client.py +3 -3
- oci/globally_distributed_database/sharded_database_service_client.py +30 -30
- oci/golden_gate/golden_gate_client.py +70 -70
- oci/governance_rules_control_plane/governance_rule_client.py +15 -15
- oci/governance_rules_control_plane/work_request_client.py +5 -5
- oci/healthchecks/health_checks_client.py +17 -17
- oci/identity/identity_client.py +145 -145
- oci/identity_data_plane/dataplane_client.py +2 -2
- oci/identity_domains/identity_domains_client.py +311 -311
- oci/integration/integration_instance_client.py +19 -19
- oci/jms/java_management_service_client.py +75 -75
- oci/jms_java_downloads/java_download_client.py +25 -25
- oci/key_management/ekm_client.py +5 -5
- oci/key_management/kms_crypto_client.py +6 -6
- oci/key_management/kms_hsm_cluster_client.py +12 -12
- oci/key_management/kms_management_client.py +21 -21
- oci/key_management/kms_vault_client.py +14 -14
- oci/license_manager/license_manager_client.py +18 -18
- oci/limits/limits_client.py +4 -4
- oci/limits/quotas_client.py +7 -7
- oci/load_balancer/load_balancer_client.py +61 -61
- oci/lockbox/lockbox_client.py +24 -24
- oci/log_analytics/log_analytics_client.py +193 -193
- oci/logging/logging_management_client.py +30 -30
- oci/loggingingestion/logging_client.py +1 -1
- oci/loggingsearch/log_search_client.py +1 -1
- oci/management_agent/management_agent_client.py +28 -28
- oci/management_dashboard/dashx_apis_client.py +14 -14
- oci/marketplace/account_client.py +2 -2
- oci/marketplace/marketplace_client.py +30 -30
- oci/marketplace_private_offer/attachment_client.py +5 -5
- oci/marketplace_private_offer/offer_client.py +6 -6
- oci/marketplace_publisher/attachment_client.py +5 -5
- oci/marketplace_publisher/marketplace_publisher_client.py +71 -71
- oci/marketplace_publisher/offer_client.py +6 -6
- oci/media_services/media_services_client.py +60 -60
- oci/media_services/media_stream_client.py +2 -2
- oci/monitoring/monitoring_client.py +18 -18
- oci/mysql/channels_client.py +7 -7
- oci/mysql/db_backups_client.py +7 -7
- oci/mysql/db_system_client.py +17 -17
- oci/mysql/mysqlaas_client.py +7 -7
- oci/mysql/replicas_client.py +5 -5
- oci/mysql/work_requests_client.py +4 -4
- oci/network_firewall/network_firewall_client.py +86 -86
- oci/network_load_balancer/network_load_balancer_client.py +34 -34
- oci/nosql/nosql_client.py +24 -24
- oci/object_storage/object_storage_client.py +153 -57
- oci/oce/oce_instance_client.py +10 -10
- oci/oci_control_center/occ_metrics_client.py +3 -3
- oci/ocvp/cluster_client.py +5 -5
- oci/ocvp/esxi_host_client.py +8 -8
- oci/ocvp/sddc_client.py +14 -14
- oci/ocvp/work_request_client.py +4 -4
- oci/oda/management_client.py +59 -59
- oci/oda/oda_client.py +17 -17
- oci/oda/odapackage_client.py +7 -7
- oci/onesubscription/billing_schedule_client.py +1 -1
- oci/onesubscription/commitment_client.py +2 -2
- oci/onesubscription/computed_usage_client.py +3 -3
- oci/onesubscription/invoice_summary_client.py +2 -2
- oci/onesubscription/organization_subscription_client.py +1 -1
- oci/onesubscription/ratecard_client.py +1 -1
- oci/onesubscription/subscribed_service_client.py +2 -2
- oci/onesubscription/subscription_client.py +1 -1
- oci/ons/notification_control_plane_client.py +6 -6
- oci/ons/notification_data_plane_client.py +10 -10
- oci/opa/opa_instance_client.py +13 -13
- oci/opensearch/opensearch_cluster_backup_client.py +4 -4
- oci/opensearch/opensearch_cluster_client.py +14 -14
- oci/operator_access_control/access_requests_client.py +10 -10
- oci/operator_access_control/operator_actions_client.py +2 -2
- oci/operator_access_control/operator_control_assignment_client.py +8 -8
- oci/operator_access_control/operator_control_client.py +6 -6
- oci/opsi/operations_insights_client.py +180 -180
- oci/optimizer/optimizer_client.py +26 -26
- oci/os_management/event_client.py +8 -8
- oci/os_management/os_management_client.py +69 -69
- oci/os_management_hub/event_client.py +8 -8
- oci/os_management_hub/lifecycle_environment_client.py +12 -12
- oci/os_management_hub/managed_instance_client.py +31 -31
- oci/os_management_hub/managed_instance_group_client.py +25 -25
- oci/os_management_hub/management_station_client.py +10 -10
- oci/os_management_hub/onboarding_client.py +6 -6
- oci/os_management_hub/reporting_managed_instance_client.py +3 -3
- oci/os_management_hub/scheduled_job_client.py +7 -7
- oci/os_management_hub/software_source_client.py +27 -27
- oci/os_management_hub/work_request_client.py +4 -4
- oci/osp_gateway/address_rule_service_client.py +1 -1
- oci/osp_gateway/address_service_client.py +2 -2
- oci/osp_gateway/invoice_service_client.py +5 -5
- oci/osp_gateway/subscription_service_client.py +5 -5
- oci/osub_billing_schedule/billing_schedule_client.py +1 -1
- oci/osub_organization_subscription/organization_subscription_client.py +1 -1
- oci/osub_subscription/commitment_client.py +2 -2
- oci/osub_subscription/ratecard_client.py +1 -1
- oci/osub_subscription/subscription_client.py +1 -1
- oci/osub_usage/computed_usage_client.py +3 -3
- oci/psql/models/connection_details.py +29 -2
- oci/psql/models/endpoint.py +1 -1
- oci/psql/models/network_details.py +33 -2
- oci/psql/models/update_network_details.py +33 -2
- oci/psql/postgresql_client.py +33 -33
- oci/queue/queue_admin_client.py +11 -11
- oci/queue/queue_client.py +8 -8
- oci/recovery/database_recovery_client.py +26 -26
- oci/redis/redis_cluster_client.py +12 -12
- oci/resource_manager/resource_manager_client.py +52 -52
- oci/resource_scheduler/schedule_client.py +13 -13
- oci/resource_search/resource_search_client.py +3 -3
- oci/rover/rover_bundle_client.py +8 -8
- oci/rover/rover_cluster_client.py +8 -8
- oci/rover/rover_entitlement_client.py +6 -6
- oci/rover/rover_node_client.py +15 -15
- oci/rover/shape_client.py +1 -1
- oci/rover/work_requests_client.py +5 -5
- oci/sch/connector_plugins_client.py +2 -2
- oci/sch/service_connector_client.py +12 -12
- oci/secrets/secrets_client.py +3 -3
- oci/security_attribute/security_attribute_client.py +18 -18
- oci/service_catalog/service_catalog_client.py +26 -26
- oci/service_manager_proxy/service_manager_proxy_client.py +2 -2
- oci/service_mesh/service_mesh_client.py +48 -48
- oci/stack_monitoring/stack_monitoring_client.py +71 -71
- oci/streaming/stream_admin_client.py +18 -18
- oci/streaming/stream_client.py +8 -8
- oci/tenant_manager_control_plane/domain_client.py +5 -5
- oci/tenant_manager_control_plane/domain_governance_client.py +5 -5
- oci/tenant_manager_control_plane/governance_client.py +2 -2
- oci/tenant_manager_control_plane/link_client.py +3 -3
- oci/tenant_manager_control_plane/orders_client.py +2 -2
- oci/tenant_manager_control_plane/organization_client.py +10 -10
- oci/tenant_manager_control_plane/recipient_invitation_client.py +5 -5
- oci/tenant_manager_control_plane/sender_invitation_client.py +5 -5
- oci/tenant_manager_control_plane/subscription_client.py +11 -11
- oci/tenant_manager_control_plane/work_request_client.py +4 -4
- oci/threat_intelligence/threatintel_client.py +5 -5
- oci/usage/resources_client.py +2 -2
- oci/usage/rewards_client.py +6 -6
- oci/usage/usagelimits_client.py +1 -1
- oci/usage_api/usageapi_client.py +33 -33
- oci/vault/vaults_client.py +13 -13
- oci/vbs_inst/vbs_instance_client.py +10 -10
- oci/version.py +1 -1
- oci/visual_builder/vb_instance_client.py +13 -13
- oci/vn_monitoring/vn_monitoring_client.py +12 -12
- oci/vulnerability_scanning/vulnerability_scanning_client.py +58 -58
- oci/waa/waa_client.py +13 -13
- oci/waa/work_request_client.py +4 -4
- oci/waas/redirect_client.py +6 -6
- oci/waas/waas_client.py +66 -66
- oci/waf/waf_client.py +24 -24
- oci/work_requests/work_request_client.py +4 -4
- oci/zpr/zpr_client.py +15 -15
- {oci-2.138.1.dist-info → oci-2.139.0.dist-info}/METADATA +1 -1
- {oci-2.138.1.dist-info → oci-2.139.0.dist-info}/RECORD +342 -338
- {oci-2.138.1.dist-info → oci-2.139.0.dist-info}/THIRD_PARTY_LICENSES.txt +1 -1
- {oci-2.138.1.dist-info → oci-2.139.0.dist-info}/LICENSE.txt +0 -0
- {oci-2.138.1.dist-info → oci-2.139.0.dist-info}/WHEEL +0 -0
- {oci-2.138.1.dist-info → oci-2.139.0.dist-info}/top_level.txt +0 -0
oci/_vendor/idna/core.py
CHANGED
@@ -1,366 +1,396 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# Modified Work: Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
3
3
|
# This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
|
4
|
-
# Copyright (c) 2013-
|
4
|
+
# Copyright (c) 2013-2024, Kim Davies and contributors. All rights reserved.
|
5
5
|
|
6
|
-
from . import idnadata
|
7
6
|
import bisect
|
8
|
-
import unicodedata
|
9
7
|
import re
|
10
|
-
import
|
8
|
+
import unicodedata
|
9
|
+
from typing import Optional, Union
|
10
|
+
|
11
|
+
from . import idnadata
|
11
12
|
from .intranges import intranges_contain
|
12
13
|
|
13
14
|
_virama_combining_class = 9
|
14
|
-
_alabel_prefix = b
|
15
|
-
_unicode_dots_re = re.compile(
|
15
|
+
_alabel_prefix = b"xn--"
|
16
|
+
_unicode_dots_re = re.compile("[\u002e\u3002\uff0e\uff61]")
|
16
17
|
|
17
|
-
if sys.version_info[0] >= 3:
|
18
|
-
unicode = str
|
19
|
-
unichr = chr
|
20
18
|
|
21
19
|
class IDNAError(UnicodeError):
|
22
|
-
"""
|
20
|
+
"""Base exception for all IDNA-encoding related problems"""
|
21
|
+
|
23
22
|
pass
|
24
23
|
|
25
24
|
|
26
25
|
class IDNABidiError(IDNAError):
|
27
|
-
"""
|
26
|
+
"""Exception when bidirectional requirements are not satisfied"""
|
27
|
+
|
28
28
|
pass
|
29
29
|
|
30
30
|
|
31
31
|
class InvalidCodepoint(IDNAError):
|
32
|
-
"""
|
32
|
+
"""Exception when a disallowed or unallocated codepoint is used"""
|
33
|
+
|
33
34
|
pass
|
34
35
|
|
35
36
|
|
36
37
|
class InvalidCodepointContext(IDNAError):
|
37
|
-
"""
|
38
|
+
"""Exception when the codepoint is not valid in the context it is used"""
|
39
|
+
|
38
40
|
pass
|
39
41
|
|
40
42
|
|
41
|
-
def _combining_class(cp):
|
42
|
-
v = unicodedata.combining(
|
43
|
+
def _combining_class(cp: int) -> int:
|
44
|
+
v = unicodedata.combining(chr(cp))
|
43
45
|
if v == 0:
|
44
|
-
if not unicodedata.name(
|
46
|
+
if not unicodedata.name(chr(cp)):
|
45
47
|
raise ValueError("Unknown character in unicodedata")
|
46
48
|
return v
|
47
49
|
|
48
|
-
|
50
|
+
|
51
|
+
def _is_script(cp: str, script: str) -> bool:
|
49
52
|
return intranges_contain(ord(cp), idnadata.scripts[script])
|
50
53
|
|
51
|
-
def _punycode(s):
|
52
|
-
return s.encode('punycode')
|
53
54
|
|
54
|
-
def
|
55
|
-
return
|
55
|
+
def _punycode(s: str) -> bytes:
|
56
|
+
return s.encode("punycode")
|
56
57
|
|
57
58
|
|
58
|
-
def
|
59
|
+
def _unot(s: int) -> str:
|
60
|
+
return "U+{:04X}".format(s)
|
59
61
|
|
62
|
+
|
63
|
+
def valid_label_length(label: Union[bytes, str]) -> bool:
|
60
64
|
if len(label) > 63:
|
61
65
|
return False
|
62
66
|
return True
|
63
67
|
|
64
68
|
|
65
|
-
def valid_string_length(label, trailing_dot):
|
66
|
-
|
69
|
+
def valid_string_length(label: Union[bytes, str], trailing_dot: bool) -> bool:
|
67
70
|
if len(label) > (254 if trailing_dot else 253):
|
68
71
|
return False
|
69
72
|
return True
|
70
73
|
|
71
74
|
|
72
|
-
def check_bidi(label, check_ltr=False):
|
73
|
-
|
75
|
+
def check_bidi(label: str, check_ltr: bool = False) -> bool:
|
74
76
|
# Bidi rules should only be applied if string contains RTL characters
|
75
77
|
bidi_label = False
|
76
|
-
for
|
78
|
+
for idx, cp in enumerate(label, 1):
|
77
79
|
direction = unicodedata.bidirectional(cp)
|
78
|
-
if direction ==
|
80
|
+
if direction == "":
|
79
81
|
# String likely comes from a newer version of Unicode
|
80
|
-
raise IDNABidiError(
|
81
|
-
if direction in [
|
82
|
+
raise IDNABidiError("Unknown directionality in label {} at position {}".format(repr(label), idx))
|
83
|
+
if direction in ["R", "AL", "AN"]:
|
82
84
|
bidi_label = True
|
83
85
|
if not bidi_label and not check_ltr:
|
84
86
|
return True
|
85
87
|
|
86
88
|
# Bidi rule 1
|
87
89
|
direction = unicodedata.bidirectional(label[0])
|
88
|
-
if direction in [
|
90
|
+
if direction in ["R", "AL"]:
|
89
91
|
rtl = True
|
90
|
-
elif direction ==
|
92
|
+
elif direction == "L":
|
91
93
|
rtl = False
|
92
94
|
else:
|
93
|
-
raise IDNABidiError(
|
95
|
+
raise IDNABidiError("First codepoint in label {} must be directionality L, R or AL".format(repr(label)))
|
94
96
|
|
95
97
|
valid_ending = False
|
96
|
-
number_type =
|
97
|
-
for
|
98
|
+
number_type: Optional[str] = None
|
99
|
+
for idx, cp in enumerate(label, 1):
|
98
100
|
direction = unicodedata.bidirectional(cp)
|
99
101
|
|
100
102
|
if rtl:
|
101
103
|
# Bidi rule 2
|
102
|
-
if not
|
103
|
-
|
104
|
+
if direction not in [
|
105
|
+
"R",
|
106
|
+
"AL",
|
107
|
+
"AN",
|
108
|
+
"EN",
|
109
|
+
"ES",
|
110
|
+
"CS",
|
111
|
+
"ET",
|
112
|
+
"ON",
|
113
|
+
"BN",
|
114
|
+
"NSM",
|
115
|
+
]:
|
116
|
+
raise IDNABidiError("Invalid direction for codepoint at position {} in a right-to-left label".format(idx))
|
104
117
|
# Bidi rule 3
|
105
|
-
if direction in [
|
118
|
+
if direction in ["R", "AL", "EN", "AN"]:
|
106
119
|
valid_ending = True
|
107
|
-
elif direction !=
|
120
|
+
elif direction != "NSM":
|
108
121
|
valid_ending = False
|
109
122
|
# Bidi rule 4
|
110
|
-
if direction in [
|
123
|
+
if direction in ["AN", "EN"]:
|
111
124
|
if not number_type:
|
112
125
|
number_type = direction
|
113
126
|
else:
|
114
127
|
if number_type != direction:
|
115
|
-
raise IDNABidiError(
|
128
|
+
raise IDNABidiError("Can not mix numeral types in a right-to-left label")
|
116
129
|
else:
|
117
130
|
# Bidi rule 5
|
118
|
-
if not
|
119
|
-
raise IDNABidiError(
|
131
|
+
if direction not in ["L", "EN", "ES", "CS", "ET", "ON", "BN", "NSM"]:
|
132
|
+
raise IDNABidiError("Invalid direction for codepoint at position {} in a left-to-right label".format(idx))
|
120
133
|
# Bidi rule 6
|
121
|
-
if direction in [
|
134
|
+
if direction in ["L", "EN"]:
|
122
135
|
valid_ending = True
|
123
|
-
elif direction !=
|
136
|
+
elif direction != "NSM":
|
124
137
|
valid_ending = False
|
125
138
|
|
126
139
|
if not valid_ending:
|
127
|
-
raise IDNABidiError(
|
140
|
+
raise IDNABidiError("Label ends with illegal codepoint directionality")
|
128
141
|
|
129
142
|
return True
|
130
143
|
|
131
144
|
|
132
|
-
def check_initial_combiner(label):
|
133
|
-
|
134
|
-
|
135
|
-
raise IDNAError('Label begins with an illegal combining character')
|
145
|
+
def check_initial_combiner(label: str) -> bool:
|
146
|
+
if unicodedata.category(label[0])[0] == "M":
|
147
|
+
raise IDNAError("Label begins with an illegal combining character")
|
136
148
|
return True
|
137
149
|
|
138
150
|
|
139
|
-
def check_hyphen_ok(label):
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
raise IDNAError('Label must not start or end with a hyphen')
|
151
|
+
def check_hyphen_ok(label: str) -> bool:
|
152
|
+
if label[2:4] == "--":
|
153
|
+
raise IDNAError("Label has disallowed hyphens in 3rd and 4th position")
|
154
|
+
if label[0] == "-" or label[-1] == "-":
|
155
|
+
raise IDNAError("Label must not start or end with a hyphen")
|
145
156
|
return True
|
146
157
|
|
147
158
|
|
148
|
-
def check_nfc(label):
|
159
|
+
def check_nfc(label: str) -> None:
|
160
|
+
if unicodedata.normalize("NFC", label) != label:
|
161
|
+
raise IDNAError("Label must be in Normalization Form C")
|
149
162
|
|
150
|
-
if unicodedata.normalize('NFC', label) != label:
|
151
|
-
raise IDNAError('Label must be in Normalization Form C')
|
152
|
-
|
153
|
-
|
154
|
-
def valid_contextj(label, pos):
|
155
163
|
|
164
|
+
def valid_contextj(label: str, pos: int) -> bool:
|
156
165
|
cp_value = ord(label[pos])
|
157
166
|
|
158
|
-
if cp_value ==
|
159
|
-
|
167
|
+
if cp_value == 0x200C:
|
160
168
|
if pos > 0:
|
161
169
|
if _combining_class(ord(label[pos - 1])) == _virama_combining_class:
|
162
170
|
return True
|
163
171
|
|
164
172
|
ok = False
|
165
|
-
for i in range(pos-1, -1, -1):
|
173
|
+
for i in range(pos - 1, -1, -1):
|
166
174
|
joining_type = idnadata.joining_types.get(ord(label[i]))
|
167
|
-
if joining_type == ord(
|
175
|
+
if joining_type == ord("T"):
|
168
176
|
continue
|
169
|
-
|
177
|
+
elif joining_type in [ord("L"), ord("D")]:
|
170
178
|
ok = True
|
171
179
|
break
|
180
|
+
else:
|
181
|
+
break
|
172
182
|
|
173
183
|
if not ok:
|
174
184
|
return False
|
175
185
|
|
176
186
|
ok = False
|
177
|
-
for i in range(pos+1, len(label)):
|
187
|
+
for i in range(pos + 1, len(label)):
|
178
188
|
joining_type = idnadata.joining_types.get(ord(label[i]))
|
179
|
-
if joining_type == ord(
|
189
|
+
if joining_type == ord("T"):
|
180
190
|
continue
|
181
|
-
|
191
|
+
elif joining_type in [ord("R"), ord("D")]:
|
182
192
|
ok = True
|
183
193
|
break
|
194
|
+
else:
|
195
|
+
break
|
184
196
|
return ok
|
185
197
|
|
186
|
-
if cp_value ==
|
187
|
-
|
198
|
+
if cp_value == 0x200D:
|
188
199
|
if pos > 0:
|
189
200
|
if _combining_class(ord(label[pos - 1])) == _virama_combining_class:
|
190
201
|
return True
|
191
202
|
return False
|
192
203
|
|
193
204
|
else:
|
194
|
-
|
195
205
|
return False
|
196
206
|
|
197
207
|
|
198
|
-
def valid_contexto(label, pos, exception=False):
|
199
|
-
|
208
|
+
def valid_contexto(label: str, pos: int, exception: bool = False) -> bool:
|
200
209
|
cp_value = ord(label[pos])
|
201
210
|
|
202
|
-
if cp_value ==
|
203
|
-
if 0 < pos < len(label)-1:
|
204
|
-
if ord(label[pos - 1]) ==
|
211
|
+
if cp_value == 0x00B7:
|
212
|
+
if 0 < pos < len(label) - 1:
|
213
|
+
if ord(label[pos - 1]) == 0x006C and ord(label[pos + 1]) == 0x006C:
|
205
214
|
return True
|
206
215
|
return False
|
207
216
|
|
208
217
|
elif cp_value == 0x0375:
|
209
|
-
if pos < len(label)-1 and len(label) > 1:
|
210
|
-
return _is_script(label[pos + 1],
|
218
|
+
if pos < len(label) - 1 and len(label) > 1:
|
219
|
+
return _is_script(label[pos + 1], "Greek")
|
211
220
|
return False
|
212
221
|
|
213
|
-
elif cp_value ==
|
222
|
+
elif cp_value == 0x05F3 or cp_value == 0x05F4:
|
214
223
|
if pos > 0:
|
215
|
-
return _is_script(label[pos - 1],
|
224
|
+
return _is_script(label[pos - 1], "Hebrew")
|
216
225
|
return False
|
217
226
|
|
218
|
-
elif cp_value ==
|
227
|
+
elif cp_value == 0x30FB:
|
219
228
|
for cp in label:
|
220
|
-
if cp ==
|
229
|
+
if cp == "\u30fb":
|
221
230
|
continue
|
222
|
-
if _is_script(cp,
|
231
|
+
if _is_script(cp, "Hiragana") or _is_script(cp, "Katakana") or _is_script(cp, "Han"):
|
223
232
|
return True
|
224
233
|
return False
|
225
234
|
|
226
235
|
elif 0x660 <= cp_value <= 0x669:
|
227
236
|
for cp in label:
|
228
|
-
if
|
237
|
+
if 0x6F0 <= ord(cp) <= 0x06F9:
|
229
238
|
return False
|
230
239
|
return True
|
231
240
|
|
232
|
-
elif
|
241
|
+
elif 0x6F0 <= cp_value <= 0x6F9:
|
233
242
|
for cp in label:
|
234
243
|
if 0x660 <= ord(cp) <= 0x0669:
|
235
244
|
return False
|
236
245
|
return True
|
237
246
|
|
247
|
+
return False
|
238
248
|
|
239
|
-
def check_label(label):
|
240
249
|
|
250
|
+
def check_label(label: Union[str, bytes, bytearray]) -> None:
|
241
251
|
if isinstance(label, (bytes, bytearray)):
|
242
|
-
label = label.decode(
|
252
|
+
label = label.decode("utf-8")
|
243
253
|
if len(label) == 0:
|
244
|
-
raise IDNAError(
|
254
|
+
raise IDNAError("Empty Label")
|
245
255
|
|
246
256
|
check_nfc(label)
|
247
257
|
check_hyphen_ok(label)
|
248
258
|
check_initial_combiner(label)
|
249
259
|
|
250
|
-
for
|
260
|
+
for pos, cp in enumerate(label):
|
251
261
|
cp_value = ord(cp)
|
252
|
-
if intranges_contain(cp_value, idnadata.codepoint_classes[
|
262
|
+
if intranges_contain(cp_value, idnadata.codepoint_classes["PVALID"]):
|
253
263
|
continue
|
254
|
-
elif intranges_contain(cp_value, idnadata.codepoint_classes[
|
264
|
+
elif intranges_contain(cp_value, idnadata.codepoint_classes["CONTEXTJ"]):
|
255
265
|
try:
|
256
266
|
if not valid_contextj(label, pos):
|
257
|
-
raise InvalidCodepointContext(
|
258
|
-
_unot(cp_value), pos+1, repr(label))
|
267
|
+
raise InvalidCodepointContext(
|
268
|
+
"Joiner {} not allowed at position {} in {}".format(_unot(cp_value), pos + 1, repr(label))
|
269
|
+
)
|
259
270
|
except ValueError:
|
260
|
-
raise IDNAError(
|
261
|
-
|
262
|
-
|
271
|
+
raise IDNAError(
|
272
|
+
"Unknown codepoint adjacent to joiner {} at position {} in {}".format(
|
273
|
+
_unot(cp_value), pos + 1, repr(label)
|
274
|
+
)
|
275
|
+
)
|
276
|
+
elif intranges_contain(cp_value, idnadata.codepoint_classes["CONTEXTO"]):
|
263
277
|
if not valid_contexto(label, pos):
|
264
|
-
raise InvalidCodepointContext(
|
278
|
+
raise InvalidCodepointContext(
|
279
|
+
"Codepoint {} not allowed at position {} in {}".format(_unot(cp_value), pos + 1, repr(label))
|
280
|
+
)
|
265
281
|
else:
|
266
|
-
raise InvalidCodepoint(
|
282
|
+
raise InvalidCodepoint(
|
283
|
+
"Codepoint {} at position {} of {} not allowed".format(_unot(cp_value), pos + 1, repr(label))
|
284
|
+
)
|
267
285
|
|
268
286
|
check_bidi(label)
|
269
287
|
|
270
288
|
|
271
|
-
def alabel(label):
|
272
|
-
|
289
|
+
def alabel(label: str) -> bytes:
|
273
290
|
try:
|
274
|
-
|
275
|
-
ulabel(
|
276
|
-
if not valid_label_length(
|
277
|
-
raise IDNAError(
|
278
|
-
return
|
291
|
+
label_bytes = label.encode("ascii")
|
292
|
+
ulabel(label_bytes)
|
293
|
+
if not valid_label_length(label_bytes):
|
294
|
+
raise IDNAError("Label too long")
|
295
|
+
return label_bytes
|
279
296
|
except UnicodeEncodeError:
|
280
297
|
pass
|
281
298
|
|
282
|
-
if not label:
|
283
|
-
raise IDNAError('No Input')
|
284
|
-
|
285
|
-
label = unicode(label)
|
286
299
|
check_label(label)
|
287
|
-
|
288
|
-
label = _alabel_prefix + label
|
300
|
+
label_bytes = _alabel_prefix + _punycode(label)
|
289
301
|
|
290
|
-
if not valid_label_length(
|
291
|
-
raise IDNAError(
|
292
|
-
|
293
|
-
return label
|
302
|
+
if not valid_label_length(label_bytes):
|
303
|
+
raise IDNAError("Label too long")
|
294
304
|
|
305
|
+
return label_bytes
|
295
306
|
|
296
|
-
def ulabel(label):
|
297
307
|
|
308
|
+
def ulabel(label: Union[str, bytes, bytearray]) -> str:
|
298
309
|
if not isinstance(label, (bytes, bytearray)):
|
299
310
|
try:
|
300
|
-
|
311
|
+
label_bytes = label.encode("ascii")
|
301
312
|
except UnicodeEncodeError:
|
302
313
|
check_label(label)
|
303
314
|
return label
|
304
|
-
|
305
|
-
label = label.lower()
|
306
|
-
if label.startswith(_alabel_prefix):
|
307
|
-
label = label[len(_alabel_prefix):]
|
308
|
-
if not label:
|
309
|
-
raise IDNAError('Malformed A-label, no Punycode eligible content found')
|
310
|
-
if label.decode('ascii')[-1] == '-':
|
311
|
-
raise IDNAError('A-label must not end with a hyphen')
|
312
315
|
else:
|
313
|
-
|
314
|
-
|
316
|
+
label_bytes = label
|
317
|
+
|
318
|
+
label_bytes = label_bytes.lower()
|
319
|
+
if label_bytes.startswith(_alabel_prefix):
|
320
|
+
label_bytes = label_bytes[len(_alabel_prefix) :]
|
321
|
+
if not label_bytes:
|
322
|
+
raise IDNAError("Malformed A-label, no Punycode eligible content found")
|
323
|
+
if label_bytes.decode("ascii")[-1] == "-":
|
324
|
+
raise IDNAError("A-label must not end with a hyphen")
|
325
|
+
else:
|
326
|
+
check_label(label_bytes)
|
327
|
+
return label_bytes.decode("ascii")
|
315
328
|
|
316
|
-
|
329
|
+
try:
|
330
|
+
label = label_bytes.decode("punycode")
|
331
|
+
except UnicodeError:
|
332
|
+
raise IDNAError("Invalid A-label")
|
317
333
|
check_label(label)
|
318
334
|
return label
|
319
335
|
|
320
336
|
|
321
|
-
def uts46_remap(domain, std3_rules=True, transitional=False):
|
337
|
+
def uts46_remap(domain: str, std3_rules: bool = True, transitional: bool = False) -> str:
|
322
338
|
"""Re-map the characters in the string according to UTS46 processing."""
|
323
339
|
from .uts46data import uts46data
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
340
|
+
|
341
|
+
output = ""
|
342
|
+
|
343
|
+
for pos, char in enumerate(domain):
|
344
|
+
code_point = ord(char)
|
345
|
+
try:
|
346
|
+
uts46row = uts46data[code_point if code_point < 256 else bisect.bisect_left(uts46data, (code_point, "Z")) - 1]
|
330
347
|
status = uts46row[1]
|
331
|
-
replacement
|
332
|
-
if (
|
333
|
-
|
334
|
-
|
348
|
+
replacement: Optional[str] = None
|
349
|
+
if len(uts46row) == 3:
|
350
|
+
replacement = uts46row[2]
|
351
|
+
if (
|
352
|
+
status == "V"
|
353
|
+
or (status == "D" and not transitional)
|
354
|
+
or (status == "3" and not std3_rules and replacement is None)
|
355
|
+
):
|
335
356
|
output += char
|
336
|
-
elif replacement is not None and (
|
337
|
-
|
338
|
-
|
357
|
+
elif replacement is not None and (
|
358
|
+
status == "M" or (status == "3" and not std3_rules) or (status == "D" and transitional)
|
359
|
+
):
|
339
360
|
output += replacement
|
340
361
|
elif status != "I":
|
341
362
|
raise IndexError()
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
363
|
+
except IndexError:
|
364
|
+
raise InvalidCodepoint(
|
365
|
+
"Codepoint {} not allowed at position {} in {}".format(_unot(code_point), pos + 1, repr(domain))
|
366
|
+
)
|
367
|
+
|
368
|
+
return unicodedata.normalize("NFC", output)
|
369
|
+
|
370
|
+
|
371
|
+
def encode(
|
372
|
+
s: Union[str, bytes, bytearray],
|
373
|
+
strict: bool = False,
|
374
|
+
uts46: bool = False,
|
375
|
+
std3_rules: bool = False,
|
376
|
+
transitional: bool = False,
|
377
|
+
) -> bytes:
|
378
|
+
if not isinstance(s, str):
|
379
|
+
try:
|
380
|
+
s = str(s, "ascii")
|
381
|
+
except UnicodeDecodeError:
|
382
|
+
raise IDNAError("should pass a unicode string to the function rather than a byte string.")
|
353
383
|
if uts46:
|
354
384
|
s = uts46_remap(s, std3_rules, transitional)
|
355
385
|
trailing_dot = False
|
356
386
|
result = []
|
357
387
|
if strict:
|
358
|
-
labels = s.split(
|
388
|
+
labels = s.split(".")
|
359
389
|
else:
|
360
390
|
labels = _unicode_dots_re.split(s)
|
361
|
-
if not labels or labels == [
|
362
|
-
raise IDNAError(
|
363
|
-
if labels[-1] ==
|
391
|
+
if not labels or labels == [""]:
|
392
|
+
raise IDNAError("Empty domain")
|
393
|
+
if labels[-1] == "":
|
364
394
|
del labels[-1]
|
365
395
|
trailing_dot = True
|
366
396
|
for label in labels:
|
@@ -368,19 +398,26 @@ def encode(s, strict=False, uts46=False, std3_rules=False, transitional=False):
|
|
368
398
|
if s:
|
369
399
|
result.append(s)
|
370
400
|
else:
|
371
|
-
raise IDNAError(
|
401
|
+
raise IDNAError("Empty label")
|
372
402
|
if trailing_dot:
|
373
|
-
result.append(b
|
374
|
-
s = b
|
403
|
+
result.append(b"")
|
404
|
+
s = b".".join(result)
|
375
405
|
if not valid_string_length(s, trailing_dot):
|
376
|
-
raise IDNAError(
|
406
|
+
raise IDNAError("Domain too long")
|
377
407
|
return s
|
378
408
|
|
379
409
|
|
380
|
-
def decode(
|
381
|
-
|
382
|
-
|
383
|
-
|
410
|
+
def decode(
|
411
|
+
s: Union[str, bytes, bytearray],
|
412
|
+
strict: bool = False,
|
413
|
+
uts46: bool = False,
|
414
|
+
std3_rules: bool = False,
|
415
|
+
) -> str:
|
416
|
+
try:
|
417
|
+
if not isinstance(s, str):
|
418
|
+
s = str(s, "ascii")
|
419
|
+
except UnicodeDecodeError:
|
420
|
+
raise IDNAError("Invalid ASCII in A-label")
|
384
421
|
if uts46:
|
385
422
|
s = uts46_remap(s, std3_rules, False)
|
386
423
|
trailing_dot = False
|
@@ -388,9 +425,9 @@ def decode(s, strict=False, uts46=False, std3_rules=False):
|
|
388
425
|
if not strict:
|
389
426
|
labels = _unicode_dots_re.split(s)
|
390
427
|
else:
|
391
|
-
labels = s.split(
|
392
|
-
if not labels or labels == [
|
393
|
-
raise IDNAError(
|
428
|
+
labels = s.split(".")
|
429
|
+
if not labels or labels == [""]:
|
430
|
+
raise IDNAError("Empty domain")
|
394
431
|
if not labels[-1]:
|
395
432
|
del labels[-1]
|
396
433
|
trailing_dot = True
|
@@ -399,7 +436,7 @@ def decode(s, strict=False, uts46=False, std3_rules=False):
|
|
399
436
|
if s:
|
400
437
|
result.append(s)
|
401
438
|
else:
|
402
|
-
raise IDNAError(
|
439
|
+
raise IDNAError("Empty label")
|
403
440
|
if trailing_dot:
|
404
|
-
result.append(
|
405
|
-
return
|
441
|
+
result.append("")
|
442
|
+
return ".".join(result)
|