pyfect-dev 0.1.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.
- pyfect/__init__.py +729 -0
- pyfect/_all.py +242 -0
- pyfect/_background.py +28 -0
- pyfect/_binary_codecs.py +124 -0
- pyfect/_cached.py +165 -0
- pyfect/_catch.py +128 -0
- pyfect/_catch_reason.py +574 -0
- pyfect/_concurrency.py +291 -0
- pyfect/_context_effects.py +163 -0
- pyfect/_context_managers.py +76 -0
- pyfect/_core.py +368 -0
- pyfect/_digits.py +71 -0
- pyfect/_effect_args.py +46 -0
- pyfect/_effect_base.py +71 -0
- pyfect/_effect_concurrency.py +133 -0
- pyfect/_effect_eager.py +103 -0
- pyfect/_effect_errors.py +344 -0
- pyfect/_effect_folding.py +110 -0
- pyfect/_effect_hash.py +140 -0
- pyfect/_effect_logging.py +57 -0
- pyfect/_effect_metrics.py +102 -0
- pyfect/_effect_resources.py +179 -0
- pyfect/_effect_services.py +25 -0
- pyfect/_effect_timing.py +199 -0
- pyfect/_effect_tracing.py +99 -0
- pyfect/_equal.py +195 -0
- pyfect/_extras.py +43 -0
- pyfect/_fiber.py +969 -0
- pyfect/_fiber_all.py +134 -0
- pyfect/_fiber_collections.py +106 -0
- pyfect/_fn.py +706 -0
- pyfect/_hamt.py +174 -0
- pyfect/_interrupt_reason.py +33 -0
- pyfect/_isaac.py +149 -0
- pyfect/_iterables.py +231 -0
- pyfect/_js.py +263 -0
- pyfect/_js_date.py +87 -0
- pyfect/_json_text.py +286 -0
- pyfect/_json_value.py +9 -0
- pyfect/_layer_core.py +403 -0
- pyfect/_layer_for_life.py +33 -0
- pyfect/_layer_tracing.py +70 -0
- pyfect/_locked_ref.py +147 -0
- pyfect/_loop_thread.py +152 -0
- pyfect/_metric_ref.py +29 -0
- pyfect/_one_or_many.py +14 -0
- pyfect/_os_wait.py +118 -0
- pyfect/_path_posix.py +129 -0
- pyfect/_primitives.py +434 -0
- pyfect/_public.py +36 -0
- pyfect/_reasons.py +64 -0
- pyfect/_released.py +67 -0
- pyfect/_root.py +87 -0
- pyfect/_round_robin.py +73 -0
- pyfect/_some.py +17 -0
- pyfect/_stack.py +52 -0
- pyfect/_stack_frame.py +114 -0
- pyfect/_string_hash.py +35 -0
- pyfect/_subscriber_queue.py +47 -0
- pyfect/_tags.py +14 -0
- pyfect/_tracer_ref.py +21 -0
- pyfect/_tx_ops.py +77 -0
- pyfect/_unsubscripted.py +23 -0
- pyfect/_url.py +54 -0
- pyfect/_waiters.py +127 -0
- pyfect/_wake_tracking.py +98 -0
- pyfect/_wire_codec.py +123 -0
- pyfect/ai/__init__.py +73 -0
- pyfect/ai/_approvals.py +249 -0
- pyfect/ai/_decision_answers.py +185 -0
- pyfect/ai/_generated_client.py +298 -0
- pyfect/ai/_generated_support.py +84 -0
- pyfect/ai/_mcp/__init__.py +1 -0
- pyfect/ai/_mcp/batch.py +68 -0
- pyfect/ai/_mcp/client_transport.py +412 -0
- pyfect/ai/_mcp/client_wire.py +284 -0
- pyfect/ai/_mcp/core.py +490 -0
- pyfect/ai/_mcp/dispatch.py +1048 -0
- pyfect/ai/_mcp/http.py +462 -0
- pyfect/ai/_mcp/http_admission.py +269 -0
- pyfect/ai/_mcp/http_status.py +27 -0
- pyfect/ai/_mcp/input_wire.py +226 -0
- pyfect/ai/_mcp/log_levels.py +55 -0
- pyfect/ai/_mcp/param_headers.py +63 -0
- pyfect/ai/_mcp/projection.py +248 -0
- pyfect/ai/_mcp/register.py +683 -0
- pyfect/ai/_mcp/reverse_policy.py +155 -0
- pyfect/ai/_mcp/routing_header.py +24 -0
- pyfect/ai/_mcp/sessions.py +114 -0
- pyfect/ai/_mcp/stdio.py +110 -0
- pyfect/ai/_mcp/subscriptions.py +134 -0
- pyfect/ai/_mcp/tool_schema.py +35 -0
- pyfect/ai/_noul_answers.py +64 -0
- pyfect/ai/_openai_all_of.py +137 -0
- pyfect/ai/_openai_errors.py +233 -0
- pyfect/ai/_provider.py +439 -0
- pyfect/ai/_provider_tools.py +129 -0
- pyfect/ai/_stream_resolution.py +231 -0
- pyfect/ai/_structured_output_checks.py +138 -0
- pyfect/ai/_structured_output_codec.py +229 -0
- pyfect/ai/_structured_output_json.py +109 -0
- pyfect/ai/_tool_call_ids.py +80 -0
- pyfect/ai/ai_error.py +785 -0
- pyfect/ai/anthropic/__init__.py +28 -0
- pyfect/ai/anthropic/_errors.py +164 -0
- pyfect/ai/anthropic/_prompt.py +375 -0
- pyfect/ai/anthropic/_response.py +443 -0
- pyfect/ai/anthropic/_schema.py +206 -0
- pyfect/ai/anthropic/_stream.py +377 -0
- pyfect/ai/anthropic/_tools.py +248 -0
- pyfect/ai/anthropic/client.py +289 -0
- pyfect/ai/anthropic/config.py +32 -0
- pyfect/ai/anthropic/error.py +27 -0
- pyfect/ai/anthropic/language_model.py +366 -0
- pyfect/ai/anthropic/telemetry.py +51 -0
- pyfect/ai/anthropic/tool.py +570 -0
- pyfect/ai/anthropic_structured_output.py +138 -0
- pyfect/ai/chat.py +548 -0
- pyfect/ai/cloudflare/__init__.py +15 -0
- pyfect/ai/cloudflare/_errors.py +108 -0
- pyfect/ai/cloudflare/client.py +174 -0
- pyfect/ai/cloudflare/decision_model.py +117 -0
- pyfect/ai/cloudflare/schema.py +144 -0
- pyfect/ai/decision.py +290 -0
- pyfect/ai/decision_model.py +283 -0
- pyfect/ai/embedding_model.py +177 -0
- pyfect/ai/id_generator.py +79 -0
- pyfect/ai/language_model.py +1077 -0
- pyfect/ai/mcp_client.py +682 -0
- pyfect/ai/mcp_client_error.py +223 -0
- pyfect/ai/mcp_protocol.py +205 -0
- pyfect/ai/mcp_schema.py +1300 -0
- pyfect/ai/mcp_server.py +404 -0
- pyfect/ai/model.py +56 -0
- pyfect/ai/openai/__init__.py +49 -0
- pyfect/ai/openai/_errors.py +89 -0
- pyfect/ai/openai/_prompt.py +527 -0
- pyfect/ai/openai/_requests.py +34 -0
- pyfect/ai/openai/_response.py +569 -0
- pyfect/ai/openai/_schema.py +769 -0
- pyfect/ai/openai/_stream.py +771 -0
- pyfect/ai/openai/_tools.py +128 -0
- pyfect/ai/openai/_web_socket.py +295 -0
- pyfect/ai/openai/client.py +296 -0
- pyfect/ai/openai/client_generated.py +123 -0
- pyfect/ai/openai/config.py +34 -0
- pyfect/ai/openai/decision_model.py +177 -0
- pyfect/ai/openai/embedding_model.py +116 -0
- pyfect/ai/openai/error.py +8 -0
- pyfect/ai/openai/generated/__init__.py +7213 -0
- pyfect/ai/openai/generated/_recursive.py +18 -0
- pyfect/ai/openai/generated/_schemas_0.py +1015 -0
- pyfect/ai/openai/generated/_schemas_1.py +1016 -0
- pyfect/ai/openai/generated/_schemas_2.py +1017 -0
- pyfect/ai/openai/generated/_schemas_3.py +615 -0
- pyfect/ai/openai/generated/client.py +5298 -0
- pyfect/ai/openai/generated/types.py +8123 -0
- pyfect/ai/openai/language_model.py +304 -0
- pyfect/ai/openai/telemetry.py +19 -0
- pyfect/ai/openai/tool.py +391 -0
- pyfect/ai/openai_compat/__init__.py +25 -0
- pyfect/ai/openai_compat/_prompt.py +191 -0
- pyfect/ai/openai_compat/_request.py +153 -0
- pyfect/ai/openai_compat/_response.py +407 -0
- pyfect/ai/openai_compat/_schema.py +97 -0
- pyfect/ai/openai_compat/client.py +234 -0
- pyfect/ai/openai_compat/config.py +32 -0
- pyfect/ai/openai_compat/embedding_model.py +139 -0
- pyfect/ai/openai_compat/error.py +7 -0
- pyfect/ai/openai_compat/language_model.py +245 -0
- pyfect/ai/openai_compat/telemetry.py +51 -0
- pyfect/ai/openai_structured_output.py +118 -0
- pyfect/ai/openrouter/__init__.py +36 -0
- pyfect/ai/openrouter/_errors.py +186 -0
- pyfect/ai/openrouter/_prompt.py +272 -0
- pyfect/ai/openrouter/_response.py +226 -0
- pyfect/ai/openrouter/_stream.py +320 -0
- pyfect/ai/openrouter/client.py +283 -0
- pyfect/ai/openrouter/config.py +36 -0
- pyfect/ai/openrouter/decision_model.py +161 -0
- pyfect/ai/openrouter/error.py +23 -0
- pyfect/ai/openrouter/generated/__init__.py +3029 -0
- pyfect/ai/openrouter/generated/_recursive.py +15 -0
- pyfect/ai/openrouter/generated/_schemas_0.py +1015 -0
- pyfect/ai/openrouter/generated/_schemas_1.py +522 -0
- pyfect/ai/openrouter/generated/client.py +1445 -0
- pyfect/ai/openrouter/generated/types.py +4769 -0
- pyfect/ai/openrouter/language_model.py +345 -0
- pyfect/ai/openrouter/schema.py +165 -0
- pyfect/ai/prompt.py +664 -0
- pyfect/ai/response.py +768 -0
- pyfect/ai/response_id_tracker.py +82 -0
- pyfect/ai/telemetry.py +126 -0
- pyfect/ai/tokenizer.py +61 -0
- pyfect/ai/tool.py +536 -0
- pyfect/ai/toolkit.py +490 -0
- pyfect/ai/typesafe/__init__.py +17 -0
- pyfect/ai/typesafe/_errors.py +120 -0
- pyfect/ai/typesafe/client.py +146 -0
- pyfect/ai/typesafe/config.py +34 -0
- pyfect/ai/typesafe/decision_model.py +90 -0
- pyfect/ai/typesafe/schema.py +140 -0
- pyfect/batching/__init__.py +58 -0
- pyfect/batching/_api.py +71 -0
- pyfect/batching/_engine.py +229 -0
- pyfect/batching/_from_effect.py +76 -0
- pyfect/batching/_persisted.py +98 -0
- pyfect/batching/_request.py +133 -0
- pyfect/batching/_resolver.py +477 -0
- pyfect/batching/_with_cache.py +90 -0
- pyfect/big_decimal.py +500 -0
- pyfect/brand.py +114 -0
- pyfect/byte_size.py +354 -0
- pyfect/cache/__init__.py +29 -0
- pyfect/cache/_cache.py +426 -0
- pyfect/cache/_expiry.py +69 -0
- pyfect/cache/_scoped_cache.py +546 -0
- pyfect/case.py +174 -0
- pyfect/cause.py +462 -0
- pyfect/channel/__init__.py +155 -0
- pyfect/channel/_base.py +92 -0
- pyfect/channel/_catch.py +158 -0
- pyfect/channel/_catch_reason.py +572 -0
- pyfect/channel/_channel.py +158 -0
- pyfect/channel/_combinators.py +220 -0
- pyfect/channel/_concurrency_methods.py +217 -0
- pyfect/channel/_concurrent_map.py +118 -0
- pyfect/channel/_constructors.py +349 -0
- pyfect/channel/_context.py +232 -0
- pyfect/channel/_error_methods.py +336 -0
- pyfect/channel/_errors.py +180 -0
- pyfect/channel/_filters.py +225 -0
- pyfect/channel/_lifecycle.py +71 -0
- pyfect/channel/_lifecycle_methods.py +206 -0
- pyfect/channel/_loop.py +100 -0
- pyfect/channel/_merge.py +246 -0
- pyfect/channel/_repeat.py +154 -0
- pyfect/channel/_run.py +149 -0
- pyfect/channel/_run_methods.py +341 -0
- pyfect/channel/_sinks.py +88 -0
- pyfect/channel/_sources.py +238 -0
- pyfect/channel/_text.py +176 -0
- pyfect/channel/_transform_methods.py +415 -0
- pyfect/channel/_upstream.py +67 -0
- pyfect/channel_schema.py +131 -0
- pyfect/cli/__init__.py +79 -0
- pyfect/cli/_ansi.py +82 -0
- pyfect/cli/_command.py +469 -0
- pyfect/cli/_config.py +164 -0
- pyfect/cli/_environment.py +10 -0
- pyfect/cli/_help.py +195 -0
- pyfect/cli/_lexer.py +81 -0
- pyfect/cli/_parser.py +465 -0
- pyfect/cli/_settings.py +85 -0
- pyfect/cli/_suggest.py +33 -0
- pyfect/cli/_width.py +134 -0
- pyfect/cli/_wizard.py +317 -0
- pyfect/cli/argument.py +212 -0
- pyfect/cli/cli_config.py +40 -0
- pyfect/cli/cli_error.py +242 -0
- pyfect/cli/cli_output.py +305 -0
- pyfect/cli/command.py +440 -0
- pyfect/cli/completions/__init__.py +50 -0
- pyfect/cli/completions/_completer.ps1 +190 -0
- pyfect/cli/completions/_descriptor.py +182 -0
- pyfect/cli/completions/bash.py +300 -0
- pyfect/cli/completions/fish.py +164 -0
- pyfect/cli/completions/powershell.py +156 -0
- pyfect/cli/completions/zsh.py +189 -0
- pyfect/cli/flag.py +246 -0
- pyfect/cli/global_flag.py +99 -0
- pyfect/cli/help_doc.py +63 -0
- pyfect/cli/param.py +789 -0
- pyfect/cli/primitive.py +308 -0
- pyfect/cli/prompt/__init__.py +75 -0
- pyfect/cli/prompt/_auto_complete.py +205 -0
- pyfect/cli/prompt/_choices.py +104 -0
- pyfect/cli/prompt/_confirm.py +195 -0
- pyfect/cli/prompt/_core.py +512 -0
- pyfect/cli/prompt/_date.py +173 -0
- pyfect/cli/prompt/_date_parts.py +387 -0
- pyfect/cli/prompt/_file.py +372 -0
- pyfect/cli/prompt/_multi_select.py +204 -0
- pyfect/cli/prompt/_number.py +257 -0
- pyfect/cli/prompt/_select.py +117 -0
- pyfect/cli/prompt/_text.py +239 -0
- pyfect/cli/terminal_capabilities.py +118 -0
- pyfect/clock.py +150 -0
- pyfect/cluster/__init__.py +155 -0
- pyfect/cluster/_cluster_abandon.py +36 -0
- pyfect/cluster/_cluster_layer.py +122 -0
- pyfect/cluster/_entity_activation.py +16 -0
- pyfect/cluster/_entity_manager/__init__.py +22 -0
- pyfect/cluster/_entity_manager/_activation.py +540 -0
- pyfect/cluster/_entity_manager/_core.py +186 -0
- pyfect/cluster/_entity_manager/_decode.py +60 -0
- pyfect/cluster/_entity_manager/_manager.py +423 -0
- pyfect/cluster/_entity_manager/_state.py +113 -0
- pyfect/cluster/_entity_reaper.py +94 -0
- pyfect/cluster/_hash.py +13 -0
- pyfect/cluster/_interruptors.py +88 -0
- pyfect/cluster/_resource_map.py +179 -0
- pyfect/cluster/_resource_ref.py +266 -0
- pyfect/cluster/_shard_lock.py +14 -0
- pyfect/cluster/cluster_cron.py +230 -0
- pyfect/cluster/cluster_error.py +81 -0
- pyfect/cluster/cluster_http.py +210 -0
- pyfect/cluster/cluster_metrics.py +54 -0
- pyfect/cluster/cluster_schema.py +137 -0
- pyfect/cluster/cluster_socket.py +197 -0
- pyfect/cluster/cluster_workflow_engine/__init__.py +24 -0
- pyfect/cluster/cluster_workflow_engine/_engine.py +1099 -0
- pyfect/cluster/cluster_workflow_engine/_entities.py +298 -0
- pyfect/cluster/deliver_at.py +31 -0
- pyfect/cluster/entity/__init__.py +39 -0
- pyfect/cluster/entity/_entity.py +332 -0
- pyfect/cluster/entity/_handlers.py +168 -0
- pyfect/cluster/entity/_keep_alive.py +74 -0
- pyfect/cluster/entity/_queue.py +103 -0
- pyfect/cluster/entity/_request.py +34 -0
- pyfect/cluster/entity/_services.py +23 -0
- pyfect/cluster/entity/_test_client.py +237 -0
- pyfect/cluster/entity_address.py +25 -0
- pyfect/cluster/entity_id.py +20 -0
- pyfect/cluster/entity_proxy.py +161 -0
- pyfect/cluster/entity_proxy_server.py +103 -0
- pyfect/cluster/entity_resource.py +122 -0
- pyfect/cluster/entity_type.py +20 -0
- pyfect/cluster/envelope.py +307 -0
- pyfect/cluster/http_runner.py +254 -0
- pyfect/cluster/k8s_http_client.py +281 -0
- pyfect/cluster/k8s_types.py +1394 -0
- pyfect/cluster/machine_id.py +21 -0
- pyfect/cluster/message.py +219 -0
- pyfect/cluster/message_storage/__init__.py +67 -0
- pyfect/cluster/message_storage/_encoded.py +393 -0
- pyfect/cluster/message_storage/_memory.py +386 -0
- pyfect/cluster/message_storage/_noop.py +109 -0
- pyfect/cluster/message_storage/_service.py +388 -0
- pyfect/cluster/reply.py +236 -0
- pyfect/cluster/runner.py +32 -0
- pyfect/cluster/runner_address.py +23 -0
- pyfect/cluster/runner_health.py +93 -0
- pyfect/cluster/runner_server.py +286 -0
- pyfect/cluster/runner_storage.py +212 -0
- pyfect/cluster/runners/__init__.py +55 -0
- pyfect/cluster/runners/_local.py +460 -0
- pyfect/cluster/runners/_noop.py +57 -0
- pyfect/cluster/runners/_rpc.py +290 -0
- pyfect/cluster/runners/_service.py +113 -0
- pyfect/cluster/shard_id.py +39 -0
- pyfect/cluster/sharding/__init__.py +12 -0
- pyfect/cluster/sharding/_acquisition.py +490 -0
- pyfect/cluster/sharding/_clients.py +271 -0
- pyfect/cluster/sharding/_make.py +388 -0
- pyfect/cluster/sharding/_routing.py +296 -0
- pyfect/cluster/sharding/_runners_sync.py +198 -0
- pyfect/cluster/sharding/_service.py +91 -0
- pyfect/cluster/sharding/_singletons.py +183 -0
- pyfect/cluster/sharding/_state.py +296 -0
- pyfect/cluster/sharding/_storage_loop.py +421 -0
- pyfect/cluster/sharding_config.py +230 -0
- pyfect/cluster/sharding_registration_event.py +28 -0
- pyfect/cluster/single_runner.py +49 -0
- pyfect/cluster/singleton.py +36 -0
- pyfect/cluster/singleton_address.py +20 -0
- pyfect/cluster/snowflake.py +133 -0
- pyfect/cluster/socket_runner.py +67 -0
- pyfect/cluster/sql_message_storage.py +1001 -0
- pyfect/cluster/sql_runner_storage.py +841 -0
- pyfect/cluster/test_runner.py +23 -0
- pyfect/config/__init__.py +93 -0
- pyfect/config/_all.py +96 -0
- pyfect/config/_collections.py +291 -0
- pyfect/config/_config.py +261 -0
- pyfect/config/_constructors.py +106 -0
- pyfect/config/_error.py +27 -0
- pyfect/config/_leaf.py +92 -0
- pyfect/config/_scalars.py +193 -0
- pyfect/config/_schema.py +340 -0
- pyfect/config_provider/__init__.py +60 -0
- pyfect/config_provider/_dir.py +84 -0
- pyfect/config_provider/_dotenv.py +127 -0
- pyfect/config_provider/_env.py +79 -0
- pyfect/config_provider/_layers.py +80 -0
- pyfect/config_provider/_node.py +90 -0
- pyfect/config_provider/_provider.py +118 -0
- pyfect/config_provider/_unknown.py +62 -0
- pyfect/console/__init__.py +63 -0
- pyfect/console/_effects.py +134 -0
- pyfect/console/_live.py +156 -0
- pyfect/console/_service.py +49 -0
- pyfect/console/_table.py +90 -0
- pyfect/context.py +414 -0
- pyfect/cron/__init__.py +30 -0
- pyfect/cron/_model.py +183 -0
- pyfect/cron/_search.py +268 -0
- pyfect/cron/_text.py +202 -0
- pyfect/cron/_wall.py +42 -0
- pyfect/crypto.py +257 -0
- pyfect/date_time/__init__.py +77 -0
- pyfect/date_time/_calendar.py +209 -0
- pyfect/date_time/_current.py +118 -0
- pyfect/date_time/_epoch.py +22 -0
- pyfect/date_time/_iso.py +80 -0
- pyfect/date_time/_zones.py +135 -0
- pyfect/date_time/intl.py +144 -0
- pyfect/deferred.py +145 -0
- pyfect/devtools/__init__.py +24 -0
- pyfect/devtools/client.py +323 -0
- pyfect/devtools/layers.py +32 -0
- pyfect/devtools/schema.py +301 -0
- pyfect/devtools/server.py +72 -0
- pyfect/duration.py +295 -0
- pyfect/effect.py +565 -0
- pyfect/effectable.py +37 -0
- pyfect/encoding/__init__.py +62 -0
- pyfect/encoding/_archive.py +197 -0
- pyfect/encoding/_json_array_scanner.py +477 -0
- pyfect/encoding/base64.py +23 -0
- pyfect/encoding/base64_url.py +19 -0
- pyfect/encoding/encoding_error.py +17 -0
- pyfect/encoding/hex.py +28 -0
- pyfect/encoding/ini.py +188 -0
- pyfect/encoding/json_array.py +246 -0
- pyfect/encoding/ndjson.py +461 -0
- pyfect/encoding/schema_binary/__init__.py +257 -0
- pyfect/encoding/schema_binary/_channels.py +173 -0
- pyfect/encoding/schema_binary/_compile.py +584 -0
- pyfect/encoding/schema_binary/_decode.py +848 -0
- pyfect/encoding/schema_binary/_dictionary.py +90 -0
- pyfect/encoding/schema_binary/_encode.py +838 -0
- pyfect/encoding/schema_binary/_fingerprint.py +168 -0
- pyfect/encoding/schema_binary/_layout.py +350 -0
- pyfect/encoding/schema_binary/_literals.py +47 -0
- pyfect/encoding/schema_binary/_parser.py +163 -0
- pyfect/encoding/schema_binary/_reader.py +148 -0
- pyfect/encoding/schema_binary/_target.py +310 -0
- pyfect/encoding/schema_binary/_values.py +133 -0
- pyfect/encoding/schema_binary/_wire.py +253 -0
- pyfect/encoding/sse.py +476 -0
- pyfect/encoding/tar/__init__.py +396 -0
- pyfect/encoding/tar/_decoder.py +220 -0
- pyfect/encoding/tar/_encoder.py +83 -0
- pyfect/encoding/tar/_header.py +494 -0
- pyfect/encoding/tar/_model.py +82 -0
- pyfect/encoding/toml.py +375 -0
- pyfect/encoding/xml/__init__.py +222 -0
- pyfect/encoding/xml/_chars.py +119 -0
- pyfect/encoding/xml/_collector.py +106 -0
- pyfect/encoding/xml/_inputs.py +126 -0
- pyfect/encoding/xml/_model.py +114 -0
- pyfect/encoding/xml/_parser.py +694 -0
- pyfect/encoding/xml/_scanner.py +180 -0
- pyfect/encoding/xml/_writer.py +238 -0
- pyfect/encoding/yaml.py +739 -0
- pyfect/encoding/zip/__init__.py +392 -0
- pyfect/encoding/zip/_decoder.py +378 -0
- pyfect/encoding/zip/_format.py +122 -0
- pyfect/encoding/zip/_inflate.py +65 -0
- pyfect/encoding/zip/_model.py +86 -0
- pyfect/encoding/zip/_writer.py +311 -0
- pyfect/error_reporter.py +240 -0
- pyfect/errors.py +321 -0
- pyfect/eventlog/__init__.py +77 -0
- pyfect/eventlog/_conflicts.py +94 -0
- pyfect/eventlog/_crypto.py +64 -0
- pyfect/eventlog/_identity.py +26 -0
- pyfect/eventlog/_identity_derivation.py +79 -0
- pyfect/eventlog/_transferable_bytes.py +55 -0
- pyfect/eventlog/_uuid.py +33 -0
- pyfect/eventlog/event.py +115 -0
- pyfect/eventlog/event_group.py +55 -0
- pyfect/eventlog/event_journal.py +630 -0
- pyfect/eventlog/event_log.py +1039 -0
- pyfect/eventlog/event_log_encryption.py +219 -0
- pyfect/eventlog/event_log_message.py +357 -0
- pyfect/eventlog/event_log_remote.py +465 -0
- pyfect/eventlog/event_log_server.py +442 -0
- pyfect/eventlog/event_log_server_encrypted.py +322 -0
- pyfect/eventlog/event_log_server_unencrypted.py +814 -0
- pyfect/eventlog/event_log_session_auth.py +250 -0
- pyfect/eventlog/event_row.py +423 -0
- pyfect/eventlog/sql_event_journal.py +692 -0
- pyfect/eventlog/sql_event_log_server_encrypted.py +440 -0
- pyfect/eventlog/sql_event_log_server_unencrypted.py +568 -0
- pyfect/execution_plan/__init__.py +42 -0
- pyfect/execution_plan/_events.py +128 -0
- pyfect/execution_plan/_model.py +108 -0
- pyfect/execution_plan/_run.py +176 -0
- pyfect/exit.py +205 -0
- pyfect/fiber_handle.py +305 -0
- pyfect/fiber_map.py +350 -0
- pyfect/fiber_set.py +232 -0
- pyfect/file_system/__init__.py +69 -0
- pyfect/file_system/_copy.py +116 -0
- pyfect/file_system/_errors.py +32 -0
- pyfect/file_system/_file.py +177 -0
- pyfect/file_system/_live.py +351 -0
- pyfect/file_system/_model.py +72 -0
- pyfect/file_system/_noop.py +189 -0
- pyfect/file_system/_service.py +336 -0
- pyfect/file_system/_stat.py +69 -0
- pyfect/file_system/_watch.py +107 -0
- pyfect/filters.py +245 -0
- pyfect/graph/__init__.py +101 -0
- pyfect/graph/_all_pairs.py +150 -0
- pyfect/graph/_combine.py +259 -0
- pyfect/graph/_compact.py +143 -0
- pyfect/graph/_components.py +200 -0
- pyfect/graph/_cycles.py +144 -0
- pyfect/graph/_enumerate.py +168 -0
- pyfect/graph/_errors.py +51 -0
- pyfect/graph/_flow.py +164 -0
- pyfect/graph/_forest.py +109 -0
- pyfect/graph/_graph.py +269 -0
- pyfect/graph/_lowlink.py +98 -0
- pyfect/graph/_matching.py +101 -0
- pyfect/graph/_mutate.py +211 -0
- pyfect/graph/_query.py +138 -0
- pyfect/graph/_records.py +119 -0
- pyfect/graph/_render.py +109 -0
- pyfect/graph/_shortest.py +274 -0
- pyfect/graph/_snapshot.py +50 -0
- pyfect/graph/_store.py +136 -0
- pyfect/graph/_traverse.py +289 -0
- pyfect/graph/_view.py +384 -0
- pyfect/graph/_walker.py +70 -0
- pyfect/graphql/__init__.py +87 -0
- pyfect/graphql/_codec.py +117 -0
- pyfect/graphql/_http.py +309 -0
- pyfect/graphql/_schemas.py +39 -0
- pyfect/graphql/_slices.py +110 -0
- pyfect/graphql/_template.py +111 -0
- pyfect/graphql/_types.py +115 -0
- pyfect/graphql/_ws.py +395 -0
- pyfect/graphql/_ws_messages.py +120 -0
- pyfect/graphql/client.py +428 -0
- pyfect/graphql/client_error.py +285 -0
- pyfect/graphql/group.py +142 -0
- pyfect/graphql/middleware.py +98 -0
- pyfect/graphql/operation.py +409 -0
- pyfect/graphql/protocol.py +119 -0
- pyfect/graphql/resolver.py +574 -0
- pyfect/graphql/template.py +61 -0
- pyfect/hash_map.py +317 -0
- pyfect/hash_ring.py +206 -0
- pyfect/hash_set.py +163 -0
- pyfect/http/__init__.py +125 -0
- pyfect/http/_asgi_listener.py +272 -0
- pyfect/http/_authority.py +63 -0
- pyfect/http/_brotli.py +27 -0
- pyfect/http/_compression.py +52 -0
- pyfect/http/_field.py +18 -0
- pyfect/http/_foreign_path.py +27 -0
- pyfect/http/_form_data.py +34 -0
- pyfect/http/_httpx_options.py +120 -0
- pyfect/http/_in_memory.py +76 -0
- pyfect/http/_request_state.py +59 -0
- pyfect/http/_vary.py +14 -0
- pyfect/http/abort.py +65 -0
- pyfect/http/asgi/__init__.py +59 -0
- pyfect/http/asgi/_app.py +155 -0
- pyfect/http/asgi/_http.py +201 -0
- pyfect/http/asgi/_mount.py +263 -0
- pyfect/http/asgi/_scope.py +86 -0
- pyfect/http/asgi/_serve.py +72 -0
- pyfect/http/asgi/_types.py +13 -0
- pyfect/http/asgi/_web_socket.py +325 -0
- pyfect/http/body.py +437 -0
- pyfect/http/client/__init__.py +111 -0
- pyfect/http/client/_circuit_breaker.py +113 -0
- pyfect/http/client/_cookie_jar.py +120 -0
- pyfect/http/client/_make.py +252 -0
- pyfect/http/client/_rate_limit.py +423 -0
- pyfect/http/client/_redirects.py +93 -0
- pyfect/http/client/_retry.py +115 -0
- pyfect/http/client/_service.py +497 -0
- pyfect/http/cookies.py +444 -0
- pyfect/http/error.py +188 -0
- pyfect/http/etag.py +96 -0
- pyfect/http/file_like.py +49 -0
- pyfect/http/find_my_way/__init__.py +10 -0
- pyfect/http/find_my_way/_nodes.py +186 -0
- pyfect/http/find_my_way/_paths.py +43 -0
- pyfect/http/find_my_way/_query_string.py +67 -0
- pyfect/http/find_my_way/_router.py +401 -0
- pyfect/http/headers.py +343 -0
- pyfect/http/http_effect.py +198 -0
- pyfect/http/httpx_client.py +291 -0
- pyfect/http/hypercorn_server.py +122 -0
- pyfect/http/incoming_message.py +140 -0
- pyfect/http/live_server/__init__.py +191 -0
- pyfect/http/live_server/_body.py +164 -0
- pyfect/http/live_server/_exchange.py +321 -0
- pyfect/http/live_server/_head.py +194 -0
- pyfect/http/live_server/_inbound.py +156 -0
- pyfect/http/live_server/_listener.py +211 -0
- pyfect/http/live_server/_serve.py +225 -0
- pyfect/http/live_server/_timers.py +20 -0
- pyfect/http/live_server/_upgrade.py +108 -0
- pyfect/http/live_server/_websocket.py +286 -0
- pyfect/http/live_server/_ws_frames.py +242 -0
- pyfect/http/method.py +30 -0
- pyfect/http/middleware/__init__.py +61 -0
- pyfect/http/middleware/_compression.py +156 -0
- pyfect/http/middleware/_cors.py +129 -0
- pyfect/http/middleware/_decompression.py +274 -0
- pyfect/http/middleware/_forwarded.py +113 -0
- pyfect/http/middleware/_logger.py +73 -0
- pyfect/http/middleware/_search_params.py +34 -0
- pyfect/http/middleware/_tracer.py +153 -0
- pyfect/http/middleware/_types.py +16 -0
- pyfect/http/mime/__init__.py +69 -0
- pyfect/http/mime/_types.py +361 -0
- pyfect/http/multipart.py +613 -0
- pyfect/http/multipart_parser/__init__.py +348 -0
- pyfect/http/multipart_parser/_content_type.py +109 -0
- pyfect/http/multipart_parser/_headers.py +206 -0
- pyfect/http/multipart_parser/_search.py +85 -0
- pyfect/http/origin.py +146 -0
- pyfect/http/platform.py +593 -0
- pyfect/http/prometheus.py +34 -0
- pyfect/http/request.py +384 -0
- pyfect/http/response.py +474 -0
- pyfect/http/router/__init__.py +82 -0
- pyfect/http/router/_api.py +462 -0
- pyfect/http/router/_in_memory.py +76 -0
- pyfect/http/router/_markers.py +47 -0
- pyfect/http/router/_middleware.py +181 -0
- pyfect/http/router/_middleware_stack.py +51 -0
- pyfect/http/router/_provided.py +31 -0
- pyfect/http/router/_route.py +114 -0
- pyfect/http/router/_router.py +308 -0
- pyfect/http/schema.py +276 -0
- pyfect/http/server.py +199 -0
- pyfect/http/server_error.py +261 -0
- pyfect/http/server_request.py +729 -0
- pyfect/http/server_respondable.py +77 -0
- pyfect/http/server_response.py +569 -0
- pyfect/http/static_server/__init__.py +257 -0
- pyfect/http/static_server/_conditional.py +72 -0
- pyfect/http/static_server/_mime.py +55 -0
- pyfect/http/static_server/_range.py +53 -0
- pyfect/http/status.py +51 -0
- pyfect/http/template.py +161 -0
- pyfect/http/trace_context.py +91 -0
- pyfect/http/url.py +442 -0
- pyfect/http/url_params.py +304 -0
- pyfect/http/uvicorn_server.py +119 -0
- pyfect/http/web.py +171 -0
- pyfect/http/web_handler.py +463 -0
- pyfect/http/wire.py +209 -0
- pyfect/http_api/__init__.py +83 -0
- pyfect/http_api/_assets/scalar.js +8 -0
- pyfect/http_api/_assets/swagger-ui.css +3 -0
- pyfect/http_api/_assets/swagger-ui.js +4 -0
- pyfect/http_api/_client_method.py +220 -0
- pyfect/http_api/_client_payload.py +144 -0
- pyfect/http_api/_client_response.py +377 -0
- pyfect/http_api/_handlers.py +282 -0
- pyfect/http_api/_html.py +38 -0
- pyfect/http_api/_media_type.py +6 -0
- pyfect/http_api/_openapi_responses.py +164 -0
- pyfect/http_api/_openapi_schemas.py +163 -0
- pyfect/http_api/_path.py +102 -0
- pyfect/http_api/_payload.py +260 -0
- pyfect/http_api/_response.py +363 -0
- pyfect/http_api/_security.py +174 -0
- pyfect/http_api/api.py +265 -0
- pyfect/http_api/builder.py +447 -0
- pyfect/http_api/client.py +474 -0
- pyfect/http_api/endpoint.py +969 -0
- pyfect/http_api/error.py +280 -0
- pyfect/http_api/group.py +215 -0
- pyfect/http_api/middleware.py +232 -0
- pyfect/http_api/openapi.py +396 -0
- pyfect/http_api/scalar.py +143 -0
- pyfect/http_api/schema.py +713 -0
- pyfect/http_api/security.py +91 -0
- pyfect/http_api/swagger.py +69 -0
- pyfect/http_api/test.py +105 -0
- pyfect/json_patch.py +255 -0
- pyfect/json_pointer.py +100 -0
- pyfect/json_schema/__init__.py +66 -0
- pyfect/json_schema/_api.py +96 -0
- pyfect/json_schema/_converter.py +258 -0
- pyfect/json_schema/_draft04.py +198 -0
- pyfect/json_schema/_draft07.py +203 -0
- pyfect/json_schema/_keywords.py +202 -0
- pyfect/json_schema/_model.py +201 -0
- pyfect/json_schema/_openapi.py +208 -0
- pyfect/latch.py +127 -0
- pyfect/layer.py +479 -0
- pyfect/layer_map.py +279 -0
- pyfect/layer_ref.py +208 -0
- pyfect/logger/__init__.py +91 -0
- pyfect/logger/_batched.py +49 -0
- pyfect/logger/_console.py +116 -0
- pyfect/logger/_file.py +31 -0
- pyfect/logger/_formats.py +104 -0
- pyfect/logger/_layer.py +50 -0
- pyfect/logger/_level.py +53 -0
- pyfect/logger/_log.py +142 -0
- pyfect/logger/_model.py +163 -0
- pyfect/logger/_refs.py +78 -0
- pyfect/logger/_stdlib.py +54 -0
- pyfect/logger/_text.py +263 -0
- pyfect/logger/_tracer.py +35 -0
- pyfect/managed_runtime.py +393 -0
- pyfect/metric/__init__.py +119 -0
- pyfect/metric/_boundaries.py +27 -0
- pyfect/metric/_kinds.py +417 -0
- pyfect/metric/_metric.py +302 -0
- pyfect/metric/_prometheus.py +150 -0
- pyfect/metric/_refs.py +78 -0
- pyfect/metric/_runtime.py +75 -0
- pyfect/metric/_snapshot.py +97 -0
- pyfect/metric/_state.py +74 -0
- pyfect/msgspec.py +98 -0
- pyfect/mutable_hash_map.py +140 -0
- pyfect/mutable_hash_set.py +95 -0
- pyfect/net/__init__.py +18 -0
- pyfect/net/_errors.py +29 -0
- pyfect/net/address_resolver.py +179 -0
- pyfect/net/dns/__init__.py +92 -0
- pyfect/net/dns/_error.py +43 -0
- pyfect/net/dns/_records.py +335 -0
- pyfect/net/dns/_service.py +287 -0
- pyfect/net/dns/_system.py +89 -0
- pyfect/net/host.py +311 -0
- pyfect/net/ip_interface.py +202 -0
- pyfect/net/ip_network.py +250 -0
- pyfect/net/net_address/__init__.py +245 -0
- pyfect/net/net_address/_inet.py +412 -0
- pyfect/net/net_address/_ip.py +348 -0
- pyfect/net/net_address/_mac.py +119 -0
- pyfect/optic/__init__.py +50 -0
- pyfect/optic/_builtins.py +90 -0
- pyfect/optic/_data.py +97 -0
- pyfect/optic/_optic.py +422 -0
- pyfect/optic/_steps.py +151 -0
- pyfect/option.py +362 -0
- pyfect/otel/__init__.py +22 -0
- pyfect/otel/_attributes.py +67 -0
- pyfect/otel/_producer.py +322 -0
- pyfect/otel/_shutdown.py +26 -0
- pyfect/otel/_span.py +292 -0
- pyfect/otel/_wrapper.py +92 -0
- pyfect/otel/logger.py +154 -0
- pyfect/otel/metrics.py +126 -0
- pyfect/otel/resource.py +111 -0
- pyfect/otel/sdk.py +195 -0
- pyfect/otel/tracer.py +157 -0
- pyfect/partitioned_semaphore.py +211 -0
- pyfect/path.py +304 -0
- pyfect/persistence/__init__.py +77 -0
- pyfect/persistence/_columns.py +32 -0
- pyfect/persistence/_error.py +14 -0
- pyfect/persistence/_seconds.py +68 -0
- pyfect/persistence/_sql_keys.py +47 -0
- pyfect/persistence/circuit_breaker/__init__.py +120 -0
- pyfect/persistence/circuit_breaker/_breaker.py +317 -0
- pyfect/persistence/circuit_breaker/_errors.py +67 -0
- pyfect/persistence/circuit_breaker/_memory.py +243 -0
- pyfect/persistence/circuit_breaker/_redis.py +509 -0
- pyfect/persistence/circuit_breaker/_store.py +60 -0
- pyfect/persistence/circuit_breaker/_types.py +191 -0
- pyfect/persistence/key_value_store/__init__.py +51 -0
- pyfect/persistence/key_value_store/_layers.py +216 -0
- pyfect/persistence/key_value_store/_schema_store.py +91 -0
- pyfect/persistence/key_value_store/_sql.py +197 -0
- pyfect/persistence/key_value_store/_store.py +212 -0
- pyfect/persistence/persistable.py +164 -0
- pyfect/persistence/persisted_cache.py +159 -0
- pyfect/persistence/persisted_queue/__init__.py +75 -0
- pyfect/persistence/persisted_queue/_error.py +42 -0
- pyfect/persistence/persisted_queue/_mailbox.py +101 -0
- pyfect/persistence/persisted_queue/_memory.py +182 -0
- pyfect/persistence/persisted_queue/_queue.py +272 -0
- pyfect/persistence/persisted_queue/_redis.py +455 -0
- pyfect/persistence/persisted_queue/_redis_scripts.py +395 -0
- pyfect/persistence/persisted_queue/_sql.py +334 -0
- pyfect/persistence/persisted_queue/_sql_migrations.py +319 -0
- pyfect/persistence/persisted_queue/_sql_statements.py +441 -0
- pyfect/persistence/persisted_queue/_store.py +147 -0
- pyfect/persistence/persistence/__init__.py +84 -0
- pyfect/persistence/persistence/_kvs.py +135 -0
- pyfect/persistence/persistence/_memory.py +62 -0
- pyfect/persistence/persistence/_redis.py +162 -0
- pyfect/persistence/persistence/_service.py +276 -0
- pyfect/persistence/persistence/_sql.py +499 -0
- pyfect/persistence/rate_limiter/__init__.py +82 -0
- pyfect/persistence/rate_limiter/_errors.py +59 -0
- pyfect/persistence/rate_limiter/_limiter.py +325 -0
- pyfect/persistence/rate_limiter/_memory.py +217 -0
- pyfect/persistence/rate_limiter/_redis.py +485 -0
- pyfect/persistence/rate_limiter/_store.py +89 -0
- pyfect/persistence/redis/__init__.py +52 -0
- pyfect/persistence/redis/_error.py +12 -0
- pyfect/persistence/redis/_make.py +234 -0
- pyfect/persistence/redis/_script.py +78 -0
- pyfect/persistence/redis/_service.py +104 -0
- pyfect/persistence/redis_py.py +303 -0
- pyfect/persistence/user_directories.py +195 -0
- pyfect/platform.py +26 -0
- pyfect/platform_error.py +256 -0
- pyfect/pool/__init__.py +36 -0
- pyfect/pool/_pool.py +707 -0
- pyfect/pool/_state.py +161 -0
- pyfect/pool/_ttl.py +105 -0
- pyfect/pool/_waiters.py +116 -0
- pyfect/primary_key.py +35 -0
- pyfect/process/__init__.py +82 -0
- pyfect/process/_child.py +213 -0
- pyfect/process/_command.py +358 -0
- pyfect/process/_handle.py +77 -0
- pyfect/process/_live.py +455 -0
- pyfect/process/_os.py +78 -0
- pyfect/process/_pipes.py +291 -0
- pyfect/process/_spawner.py +75 -0
- pyfect/pubsub/__init__.py +33 -0
- pyfect/pubsub/_atomic.py +181 -0
- pyfect/pubsub/_hub.py +214 -0
- pyfect/pubsub/_pubsub.py +214 -0
- pyfect/pubsub/_replay.py +107 -0
- pyfect/pubsub/_subscription.py +226 -0
- pyfect/pull.py +132 -0
- pyfect/py.typed +0 -0
- pyfect/pydantic.py +188 -0
- pyfect/queue/__init__.py +33 -0
- pyfect/queue/_queue.py +525 -0
- pyfect/queue/_state.py +111 -0
- pyfect/queue/_views.py +55 -0
- pyfect/random.py +146 -0
- pyfect/rc_map.py +363 -0
- pyfect/rc_ref.py +271 -0
- pyfect/reactivity/__init__.py +53 -0
- pyfect/reactivity/_async_result_schema.py +227 -0
- pyfect/reactivity/_hydration.py +18 -0
- pyfect/reactivity/_live.py +21 -0
- pyfect/reactivity/_reactivity.py +256 -0
- pyfect/reactivity/_result_effect.py +17 -0
- pyfect/reactivity/_time.py +11 -0
- pyfect/reactivity/async_result.py +679 -0
- pyfect/reactivity/atom/__init__.py +143 -0
- pyfect/reactivity/atom/_combinators.py +223 -0
- pyfect/reactivity/atom/_constructors.py +80 -0
- pyfect/reactivity/atom/_conversions.py +79 -0
- pyfect/reactivity/atom/_effect.py +252 -0
- pyfect/reactivity/atom/_fn.py +341 -0
- pyfect/reactivity/atom/_kvs.py +101 -0
- pyfect/reactivity/atom/_optimistic.py +162 -0
- pyfect/reactivity/atom/_runtime.py +323 -0
- pyfect/reactivity/atom/_serializable.py +65 -0
- pyfect/reactivity/atom/_subscription_ref.py +102 -0
- pyfect/reactivity/atom/_swr.py +69 -0
- pyfect/reactivity/atom/_types.py +435 -0
- pyfect/reactivity/atom_http_api.py +667 -0
- pyfect/reactivity/atom_ref.py +260 -0
- pyfect/reactivity/atom_registry/__init__.py +219 -0
- pyfect/reactivity/atom_registry/_batch.py +96 -0
- pyfect/reactivity/atom_registry/_dispatcher.py +60 -0
- pyfect/reactivity/atom_registry/_lifetime.py +202 -0
- pyfect/reactivity/atom_registry/_node.py +423 -0
- pyfect/reactivity/atom_registry/_registry.py +380 -0
- pyfect/reactivity/atom_rpc.py +283 -0
- pyfect/reactivity/hydration.py +200 -0
- pyfect/redacted.py +83 -0
- pyfect/ref.py +129 -0
- pyfect/resource.py +98 -0
- pyfect/result.py +306 -0
- pyfect/rpc/__init__.py +64 -0
- pyfect/rpc/_encoded_schema.py +86 -0
- pyfect/rpc/_json_rpc.py +246 -0
- pyfect/rpc/_methods.py +177 -0
- pyfect/rpc/_rpc.py +498 -0
- pyfect/rpc/client/__init__.py +100 -0
- pyfect/rpc/client/_core.py +449 -0
- pyfect/rpc/client/_http.py +257 -0
- pyfect/rpc/client/_protocol.py +171 -0
- pyfect/rpc/client/_serialized.py +321 -0
- pyfect/rpc/client/_transports.py +328 -0
- pyfect/rpc/client/_worker.py +283 -0
- pyfect/rpc/client_error.py +35 -0
- pyfect/rpc/group.py +296 -0
- pyfect/rpc/message.py +299 -0
- pyfect/rpc/middleware.py +182 -0
- pyfect/rpc/schema.py +89 -0
- pyfect/rpc/serialization.py +366 -0
- pyfect/rpc/server/__init__.py +181 -0
- pyfect/rpc/server/_core.py +549 -0
- pyfect/rpc/server/_protocol.py +123 -0
- pyfect/rpc/server/_serialized.py +363 -0
- pyfect/rpc/server/_stdio.py +101 -0
- pyfect/rpc/server/_transports.py +427 -0
- pyfect/rpc/server/_worker.py +108 -0
- pyfect/rpc/test.py +74 -0
- pyfect/rpc/worker.py +92 -0
- pyfect/run.py +393 -0
- pyfect/schedule/__init__.py +91 -0
- pyfect/schedule/_combinators.py +168 -0
- pyfect/schedule/_constructors.py +223 -0
- pyfect/schedule/_cron.py +49 -0
- pyfect/schedule/_drive.py +191 -0
- pyfect/schedule/_model.py +405 -0
- pyfect/scheduler.py +575 -0
- pyfect/schema/__init__.py +866 -0
- pyfect/schema/_adapters.py +39 -0
- pyfect/schema/_arbitrary_constraint.py +242 -0
- pyfect/schema/_arbitrary_graph.py +325 -0
- pyfect/schema/_arbitrary_links.py +179 -0
- pyfect/schema/_arbitrary_number.py +112 -0
- pyfect/schema/_arrays.py +287 -0
- pyfect/schema/_assignable.py +118 -0
- pyfect/schema/_boolean_literals.py +31 -0
- pyfect/schema/_checks_number.py +216 -0
- pyfect/schema/_checks_order.py +140 -0
- pyfect/schema/_checks_size.py +277 -0
- pyfect/schema/_checks_string.py +241 -0
- pyfect/schema/_class.py +569 -0
- pyfect/schema/_codec_derivation.py +227 -0
- pyfect/schema/_codec_links.py +221 -0
- pyfect/schema/_codecs.py +316 -0
- pyfect/schema/_collections.py +172 -0
- pyfect/schema/_constructor_default.py +89 -0
- pyfect/schema/_data.py +440 -0
- pyfect/schema/_data_codecs.py +145 -0
- pyfect/schema/_decimal_regexp.py +243 -0
- pyfect/schema/_declare.py +68 -0
- pyfect/schema/_derive.py +292 -0
- pyfect/schema/_duration_codecs.py +27 -0
- pyfect/schema/_ecma_pattern.py +416 -0
- pyfect/schema/_error.py +26 -0
- pyfect/schema/_error_instance.py +222 -0
- pyfect/schema/_graph.py +271 -0
- pyfect/schema/_instances.py +240 -0
- pyfect/schema/_jsonschema/__init__.py +90 -0
- pyfect/schema/_jsonschema/_annotations.py +114 -0
- pyfect/schema/_jsonschema/_checks.py +253 -0
- pyfect/schema/_jsonschema/_compile.py +346 -0
- pyfect/schema/_jsonschema/_exact.py +19 -0
- pyfect/schema/_jsonschema/_merge.py +211 -0
- pyfect/schema/_jsonschema/_objects.py +231 -0
- pyfect/schema/_jsonschema/_references.py +221 -0
- pyfect/schema/_jsonschema/_template.py +69 -0
- pyfect/schema/_literals.py +147 -0
- pyfect/schema/_middleware.py +209 -0
- pyfect/schema/_net.py +522 -0
- pyfect/schema/_options.py +49 -0
- pyfect/schema/_parse.py +351 -0
- pyfect/schema/_parsed_text.py +37 -0
- pyfect/schema/_primitives.py +48 -0
- pyfect/schema/_record.py +41 -0
- pyfect/schema/_refine.py +81 -0
- pyfect/schema/_schema.py +158 -0
- pyfect/schema/_semver.py +144 -0
- pyfect/schema/_strategy/__init__.py +258 -0
- pyfect/schema/_strategy/_big_decimal.py +203 -0
- pyfect/schema/_strategy/_composites.py +119 -0
- pyfect/schema/_strategy/_leaves.py +94 -0
- pyfect/schema/_strategy/_net.py +133 -0
- pyfect/schema/_struct.py +87 -0
- pyfect/schema/_struct_keys.py +128 -0
- pyfect/schema/_tagged.py +254 -0
- pyfect/schema/_template_literal.py +172 -0
- pyfect/schema/_to_codec_array_from_single.py +115 -0
- pyfect/schema/_to_codec_go_json.py +174 -0
- pyfect/schema/_to_codec_json.py +73 -0
- pyfect/schema/_to_codec_string_tree.py +115 -0
- pyfect/schema/_to_differ_json_patch.py +44 -0
- pyfect/schema/_to_encoder_xml.py +119 -0
- pyfect/schema/_to_equivalence.py +186 -0
- pyfect/schema/_to_formatter.py +180 -0
- pyfect/schema/_to_iso.py +73 -0
- pyfect/schema/_to_strategy.py +31 -0
- pyfect/schema/_transform.py +210 -0
- pyfect/schema/_tree.py +27 -0
- pyfect/schema/_type_walk.py +53 -0
- pyfect/schema/_undefined.py +58 -0
- pyfect/schema/_value_codecs.py +84 -0
- pyfect/schema/_values.py +123 -0
- pyfect/schema/_void.py +86 -0
- pyfect/schema/ast/__init__.py +227 -0
- pyfect/schema/ast/_annotations.py +43 -0
- pyfect/schema/ast/_arrays.py +210 -0
- pyfect/schema/ast/_base.py +295 -0
- pyfect/schema/ast/_candidates.py +309 -0
- pyfect/schema/ast/_check.py +181 -0
- pyfect/schema/ast/_class.py +159 -0
- pyfect/schema/ast/_constructors.py +65 -0
- pyfect/schema/ast/_declaration.py +97 -0
- pyfect/schema/ast/_encoding.py +111 -0
- pyfect/schema/ast/_json.py +129 -0
- pyfect/schema/ast/_keywords.py +125 -0
- pyfect/schema/ast/_literal.py +157 -0
- pyfect/schema/ast/_objects.py +356 -0
- pyfect/schema/ast/_record.py +36 -0
- pyfect/schema/ast/_result.py +116 -0
- pyfect/schema/ast/_steps.py +209 -0
- pyfect/schema/ast/_suspend.py +65 -0
- pyfect/schema/ast/_template_literal.py +256 -0
- pyfect/schema/ast/_union.py +172 -0
- pyfect/schema/getter/__init__.py +136 -0
- pyfect/schema/getter/_binary.py +104 -0
- pyfect/schema/getter/_coerce.py +196 -0
- pyfect/schema/getter/_getter.py +243 -0
- pyfect/schema/getter/_make.py +151 -0
- pyfect/schema/getter/_text.py +141 -0
- pyfect/schema/getter/_tree_record.py +170 -0
- pyfect/schema/issue.py +420 -0
- pyfect/schema/model/__init__.py +120 -0
- pyfect/schema/model/_class.py +245 -0
- pyfect/schema/model/_dates.py +103 -0
- pyfect/schema/model/_fields.py +77 -0
- pyfect/schema/model/_toolkit.py +114 -0
- pyfect/schema/model/_uuid.py +69 -0
- pyfect/schema/representation/__init__.py +424 -0
- pyfect/schema/representation/_builtin_revivers.py +331 -0
- pyfect/schema/representation/_code.py +106 -0
- pyfect/schema/representation/_code_builtins.py +281 -0
- pyfect/schema/representation/_code_document.py +563 -0
- pyfect/schema/representation/_code_sort.py +111 -0
- pyfect/schema/representation/_from.py +278 -0
- pyfect/schema/representation/_import/__init__.py +78 -0
- pyfect/schema/representation/_import/_finalize.py +121 -0
- pyfect/schema/representation/_import/_intersect.py +467 -0
- pyfect/schema/representation/_import/_js_order.py +66 -0
- pyfect/schema/representation/_import/_keywords.py +224 -0
- pyfect/schema/representation/_import/_nodes.py +199 -0
- pyfect/schema/representation/_import/_translate.py +455 -0
- pyfect/schema/representation/_json.py +520 -0
- pyfect/schema/representation/_json_schema.py +178 -0
- pyfect/schema/representation/_model.py +284 -0
- pyfect/schema/representation/_revivers.py +89 -0
- pyfect/schema/representation/_to.py +249 -0
- pyfect/schema/transformation/__init__.py +99 -0
- pyfect/schema/transformation/_builtins.py +314 -0
- pyfect/schema/transformation/_durations.py +150 -0
- pyfect/schema/transformation/_transformation.py +177 -0
- pyfect/schema/variant_schema/__init__.py +69 -0
- pyfect/schema/variant_schema/_class.py +188 -0
- pyfect/schema/variant_schema/_defaults.py +30 -0
- pyfect/schema/variant_schema/_field.py +32 -0
- pyfect/schema/variant_schema/_struct.py +130 -0
- pyfect/schema/variant_schema/_toolkit.py +160 -0
- pyfect/scope.py +374 -0
- pyfect/scoped_ref.py +124 -0
- pyfect/semaphore.py +276 -0
- pyfect/semver.py +403 -0
- pyfect/semver_range.py +420 -0
- pyfect/sink/__init__.py +131 -0
- pyfect/sink/_combinators.py +151 -0
- pyfect/sink/_constructors.py +187 -0
- pyfect/sink/_context.py +87 -0
- pyfect/sink/_folds.py +336 -0
- pyfect/sink/_for_each.py +87 -0
- pyfect/sink/_sink.py +265 -0
- pyfect/sink/_steps.py +34 -0
- pyfect/sink/_taking.py +183 -0
- pyfect/socket/__init__.py +146 -0
- pyfect/socket/_accepted.py +65 -0
- pyfect/socket/_connection.py +384 -0
- pyfect/socket/_errors.py +135 -0
- pyfect/socket/_loop.py +66 -0
- pyfect/socket/_net.py +281 -0
- pyfect/socket/_socket.py +245 -0
- pyfect/socket/_tls.py +88 -0
- pyfect/socket/_tls_session.py +117 -0
- pyfect/socket/_web_socket.py +555 -0
- pyfect/socket/datagram/__init__.py +110 -0
- pyfect/socket/datagram/_core.py +460 -0
- pyfect/socket/datagram/_errors.py +102 -0
- pyfect/socket/datagram/_live.py +675 -0
- pyfect/socket/datagram/_model.py +217 -0
- pyfect/socket/server.py +258 -0
- pyfect/socket/ws.py +484 -0
- pyfect/sql/__init__.py +60 -0
- pyfect/sql/_loop.py +134 -0
- pyfect/sql/clickhouse/__init__.py +74 -0
- pyfect/sql/clickhouse/_connection.py +237 -0
- pyfect/sql/clickhouse/_rows.py +87 -0
- pyfect/sql/clickhouse/client.py +322 -0
- pyfect/sql/clickhouse/config.py +241 -0
- pyfect/sql/clickhouse/driver.py +434 -0
- pyfect/sql/clickhouse/error.py +106 -0
- pyfect/sql/clickhouse/migrator.py +47 -0
- pyfect/sql/clickhouse/params.py +168 -0
- pyfect/sql/client/__init__.py +35 -0
- pyfect/sql/client/_client.py +309 -0
- pyfect/sql/client/_sqlite_acquirers.py +130 -0
- pyfect/sql/client/_transaction.py +410 -0
- pyfect/sql/connection.py +87 -0
- pyfect/sql/d1/__init__.py +48 -0
- pyfect/sql/d1/api.py +270 -0
- pyfect/sql/d1/client.py +344 -0
- pyfect/sql/d1/config.py +55 -0
- pyfect/sql/error.py +311 -0
- pyfect/sql/libsql/__init__.py +58 -0
- pyfect/sql/libsql/_connection.py +110 -0
- pyfect/sql/libsql/_hrana.py +258 -0
- pyfect/sql/libsql/_local.py +251 -0
- pyfect/sql/libsql/_targets.py +28 -0
- pyfect/sql/libsql/_values.py +46 -0
- pyfect/sql/libsql/client.py +225 -0
- pyfect/sql/libsql/config.py +170 -0
- pyfect/sql/libsql/migrator.py +43 -0
- pyfect/sql/libsql/sdk.py +123 -0
- pyfect/sql/migrator.py +434 -0
- pyfect/sql/model.py +324 -0
- pyfect/sql/mssql/__init__.py +79 -0
- pyfect/sql/mssql/_connection.py +169 -0
- pyfect/sql/mssql/_driver.py +103 -0
- pyfect/sql/mssql/_names.py +9 -0
- pyfect/sql/mssql/_pool.py +125 -0
- pyfect/sql/mssql/_tds.py +447 -0
- pyfect/sql/mssql/_tds_params.py +155 -0
- pyfect/sql/mssql/_worker.py +155 -0
- pyfect/sql/mssql/client.py +344 -0
- pyfect/sql/mssql/config.py +118 -0
- pyfect/sql/mssql/error.py +111 -0
- pyfect/sql/mssql/migrator.py +43 -0
- pyfect/sql/mssql/parameter.py +44 -0
- pyfect/sql/mssql/procedure.py +119 -0
- pyfect/sql/mssql/types.py +137 -0
- pyfect/sql/mysql/__init__.py +60 -0
- pyfect/sql/mysql/_asyncmy.py +168 -0
- pyfect/sql/mysql/_bind.py +76 -0
- pyfect/sql/mysql/_connection.py +156 -0
- pyfect/sql/mysql/_pool.py +63 -0
- pyfect/sql/mysql/_session.py +262 -0
- pyfect/sql/mysql/client.py +244 -0
- pyfect/sql/mysql/config.py +108 -0
- pyfect/sql/mysql/error.py +104 -0
- pyfect/sql/mysql/migrator.py +44 -0
- pyfect/sql/pg/__init__.py +82 -0
- pyfect/sql/pg/_resolve.py +284 -0
- pyfect/sql/pg/_session.py +380 -0
- pyfect/sql/pg/client.py +398 -0
- pyfect/sql/pg/config.py +142 -0
- pyfect/sql/pg/connection.py +585 -0
- pyfect/sql/pg/error.py +131 -0
- pyfect/sql/pg/migrator.py +139 -0
- pyfect/sql/pg/pool.py +265 -0
- pyfect/sql/resolver.py +294 -0
- pyfect/sql/result.py +24 -0
- pyfect/sql/schema.py +116 -0
- pyfect/sql/sqlite/__init__.py +26 -0
- pyfect/sql/sqlite/_connection.py +230 -0
- pyfect/sql/sqlite/_worker.py +71 -0
- pyfect/sql/sqlite/client.py +248 -0
- pyfect/sql/sqlite/migrator.py +43 -0
- pyfect/sql/statement/__init__.py +144 -0
- pyfect/sql/statement/_compiler.py +384 -0
- pyfect/sql/statement/_segments.py +487 -0
- pyfect/sql/statement/_statement.py +526 -0
- pyfect/sql/statement/_transforms.py +93 -0
- pyfect/sql/stream.py +88 -0
- pyfect/stdio.py +206 -0
- pyfect/stream/__init__.py +151 -0
- pyfect/stream/_async_iterable.py +129 -0
- pyfect/stream/_base.py +69 -0
- pyfect/stream/_bridge_methods.py +139 -0
- pyfect/stream/_catch.py +135 -0
- pyfect/stream/_catch_reason.py +558 -0
- pyfect/stream/_channel_methods.py +61 -0
- pyfect/stream/_chunk_methods.py +169 -0
- pyfect/stream/_chunking.py +310 -0
- pyfect/stream/_concat.py +65 -0
- pyfect/stream/_constructors.py +341 -0
- pyfect/stream/_context.py +147 -0
- pyfect/stream/_error_methods.py +254 -0
- pyfect/stream/_execution_plan.py +199 -0
- pyfect/stream/_fanout.py +154 -0
- pyfect/stream/_fanout_methods.py +183 -0
- pyfect/stream/_filter_methods.py +203 -0
- pyfect/stream/_grouping.py +168 -0
- pyfect/stream/_many.py +65 -0
- pyfect/stream/_map_methods.py +233 -0
- pyfect/stream/_mapping.py +126 -0
- pyfect/stream/_run.py +114 -0
- pyfect/stream/_run_methods.py +114 -0
- pyfect/stream/_service_methods.py +36 -0
- pyfect/stream/_sink_methods.py +151 -0
- pyfect/stream/_sinking.py +277 -0
- pyfect/stream/_sources.py +124 -0
- pyfect/stream/_stream.py +162 -0
- pyfect/stream/_taking.py +330 -0
- pyfect/stream/_text.py +43 -0
- pyfect/stream/_timing.py +294 -0
- pyfect/stream/_timing_methods.py +252 -0
- pyfect/stream/_zip_methods.py +279 -0
- pyfect/stream/_zipping.py +213 -0
- pyfect/subscription_ref.py +66 -0
- pyfect/synchronized_ref.py +38 -0
- pyfect/take.py +36 -0
- pyfect/terminal/__init__.py +41 -0
- pyfect/terminal/_keys.py +113 -0
- pyfect/terminal/_live.py +223 -0
- pyfect/terminal/_service.py +73 -0
- pyfect/testing/__init__.py +122 -0
- pyfect/testing/_assertions.py +92 -0
- pyfect/testing/_clock.py +309 -0
- pyfect/testing/_console.py +164 -0
- pyfect/testing/_crypto.py +44 -0
- pyfect/testing/_decorators.py +211 -0
- pyfect/testing/_flaky.py +34 -0
- pyfect/testing/_layers.py +153 -0
- pyfect/testing/_prop.py +255 -0
- pyfect/testing/_runners.py +84 -0
- pyfect/testing/_runtime.py +174 -0
- pyfect/testing/_schema.py +238 -0
- pyfect/testing/plugin.py +59 -0
- pyfect/tracer/__init__.py +107 -0
- pyfect/tracer/_model.py +176 -0
- pyfect/tracer/_native.py +172 -0
- pyfect/tracer/_refs.py +87 -0
- pyfect/tracer/_spans.py +269 -0
- pyfect/transaction.py +340 -0
- pyfect/trie.py +317 -0
- pyfect/tx_chunk.py +127 -0
- pyfect/tx_deferred.py +75 -0
- pyfect/tx_hash_map.py +265 -0
- pyfect/tx_hash_set.py +151 -0
- pyfect/tx_priority_queue.py +224 -0
- pyfect/tx_pubsub.py +194 -0
- pyfect/tx_queue/__init__.py +27 -0
- pyfect/tx_queue/_queue.py +359 -0
- pyfect/tx_queue/_views.py +60 -0
- pyfect/tx_reentrant_lock.py +201 -0
- pyfect/tx_ref.py +79 -0
- pyfect/tx_semaphore.py +136 -0
- pyfect/tx_subscription_ref.py +118 -0
- pyfect/workers/__init__.py +62 -0
- pyfect/workers/_frames.py +82 -0
- pyfect/workers/_mailbox.py +51 -0
- pyfect/workers/_port.py +106 -0
- pyfect/workers/_process.py +155 -0
- pyfect/workers/_thread.py +100 -0
- pyfect/workers/python_worker.py +133 -0
- pyfect/workers/python_worker_runner.py +112 -0
- pyfect/workers/transferable.py +103 -0
- pyfect/workers/worker.py +273 -0
- pyfect/workers/worker_error.py +86 -0
- pyfect/workers/worker_runner.py +85 -0
- pyfect/workflow/__init__.py +78 -0
- pyfect/workflow/_crypto.py +23 -0
- pyfect/workflow/_encoded.py +381 -0
- pyfect/workflow/_memory.py +424 -0
- pyfect/workflow/_result.py +43 -0
- pyfect/workflow/_services.py +241 -0
- pyfect/workflow/_suspension.py +153 -0
- pyfect/workflow/activity.py +427 -0
- pyfect/workflow/durable_clock.py +72 -0
- pyfect/workflow/durable_deferred.py +403 -0
- pyfect/workflow/durable_queue.py +259 -0
- pyfect/workflow/workflow.py +509 -0
- pyfect/workflow/workflow_engine.py +42 -0
- pyfect/workflow/workflow_proxy.py +161 -0
- pyfect/workflow/workflow_proxy_server.py +146 -0
- pyfect_dev-0.1.0.dist-info/METADATA +296 -0
- pyfect_dev-0.1.0.dist-info/RECORD +1265 -0
- pyfect_dev-0.1.0.dist-info/WHEEL +4 -0
- pyfect_dev-0.1.0.dist-info/entry_points.txt +3 -0
- pyfect_dev-0.1.0.dist-info/licenses/LICENSE +21 -0
pyfect/cli/_width.py
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"""How many terminal columns text takes (Effect's ``CliOutput.displayWidth``):
|
|
2
|
+
ANSI styles take none, a grapheme of marks, controls and default-ignorable
|
|
3
|
+
code points takes none, emoji and East Asian wide characters take two."""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import re
|
|
8
|
+
import unicodedata
|
|
9
|
+
from bisect import bisect_right
|
|
10
|
+
from collections.abc import Iterator
|
|
11
|
+
|
|
12
|
+
_ANSI = re.compile(r"\x1b\[[0-9;]*m")
|
|
13
|
+
|
|
14
|
+
_DEFAULT_IGNORABLE = (
|
|
15
|
+
(0x00AD, 0x00AD),
|
|
16
|
+
(0x034F, 0x034F),
|
|
17
|
+
(0x061C, 0x061C),
|
|
18
|
+
(0x115F, 0x1160),
|
|
19
|
+
(0x17B4, 0x17B5),
|
|
20
|
+
(0x180B, 0x180F),
|
|
21
|
+
(0x200B, 0x200F),
|
|
22
|
+
(0x202A, 0x202E),
|
|
23
|
+
(0x2060, 0x206F),
|
|
24
|
+
(0x3164, 0x3164),
|
|
25
|
+
(0xFE00, 0xFE0F),
|
|
26
|
+
(0xFEFF, 0xFEFF),
|
|
27
|
+
(0xFFA0, 0xFFA0),
|
|
28
|
+
(0xFFF0, 0xFFF8),
|
|
29
|
+
(0x1BCA0, 0x1BCA3),
|
|
30
|
+
(0x1D173, 0x1D17A),
|
|
31
|
+
(0xE0000, 0xE0FFF),
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
_EMOJI_PRESENTATION = (
|
|
35
|
+
(0x231A, 0x231B), (0x23E9, 0x23EC), (0x23F0, 0x23F0), (0x23F3, 0x23F3),
|
|
36
|
+
(0x25FD, 0x25FE), (0x2614, 0x2615), (0x2648, 0x2653), (0x267F, 0x267F),
|
|
37
|
+
(0x2693, 0x2693), (0x26A1, 0x26A1), (0x26AA, 0x26AB), (0x26BD, 0x26BE),
|
|
38
|
+
(0x26C4, 0x26C5), (0x26CE, 0x26CE), (0x26D4, 0x26D4), (0x26EA, 0x26EA),
|
|
39
|
+
(0x26F2, 0x26F3), (0x26F5, 0x26F5), (0x26FA, 0x26FA), (0x26FD, 0x26FD),
|
|
40
|
+
(0x2705, 0x2705), (0x270A, 0x270B), (0x2728, 0x2728), (0x274C, 0x274C),
|
|
41
|
+
(0x274E, 0x274E), (0x2753, 0x2755), (0x2757, 0x2757), (0x2795, 0x2797),
|
|
42
|
+
(0x27B0, 0x27B0), (0x27BF, 0x27BF), (0x2B1B, 0x2B1C), (0x2B50, 0x2B50),
|
|
43
|
+
(0x2B55, 0x2B55), (0x1F004, 0x1F004), (0x1F0CF, 0x1F0CF), (0x1F18E, 0x1F18E),
|
|
44
|
+
(0x1F191, 0x1F19A), (0x1F1E6, 0x1F1FF), (0x1F201, 0x1F201), (0x1F21A, 0x1F21A),
|
|
45
|
+
(0x1F22F, 0x1F22F), (0x1F232, 0x1F236), (0x1F238, 0x1F23A), (0x1F250, 0x1F251),
|
|
46
|
+
(0x1F300, 0x1F320), (0x1F32D, 0x1F335), (0x1F337, 0x1F37C), (0x1F37E, 0x1F393),
|
|
47
|
+
(0x1F3A0, 0x1F3CA), (0x1F3CF, 0x1F3D3), (0x1F3E0, 0x1F3F0), (0x1F3F4, 0x1F3F4),
|
|
48
|
+
(0x1F3F8, 0x1F43E), (0x1F440, 0x1F440), (0x1F442, 0x1F4FC), (0x1F4FF, 0x1F53D),
|
|
49
|
+
(0x1F54B, 0x1F54E), (0x1F550, 0x1F567), (0x1F57A, 0x1F57A), (0x1F595, 0x1F596),
|
|
50
|
+
(0x1F5A4, 0x1F5A4), (0x1F5FB, 0x1F64F), (0x1F680, 0x1F6C5), (0x1F6CC, 0x1F6CC),
|
|
51
|
+
(0x1F6D0, 0x1F6D2), (0x1F6D5, 0x1F6D7), (0x1F6DC, 0x1F6DF), (0x1F6EB, 0x1F6EC),
|
|
52
|
+
(0x1F6F4, 0x1F6FC), (0x1F7E0, 0x1F7EB), (0x1F7F0, 0x1F7F0), (0x1F90C, 0x1F93A),
|
|
53
|
+
(0x1F93C, 0x1F945), (0x1F947, 0x1F9FF), (0x1FA70, 0x1FA7C), (0x1FA80, 0x1FA89),
|
|
54
|
+
(0x1FA8F, 0x1FAC6), (0x1FACE, 0x1FADC), (0x1FADF, 0x1FAE9), (0x1FAF0, 0x1FAF8),
|
|
55
|
+
) # fmt: skip
|
|
56
|
+
|
|
57
|
+
_FULL_WIDTH = (
|
|
58
|
+
(0x1100, 0x115F), (0x2329, 0x232A), (0x2E80, 0x303E), (0x3040, 0xA4CF),
|
|
59
|
+
(0xAC00, 0xD7A3), (0xF900, 0xFAFF), (0xFE10, 0xFE19), (0xFE30, 0xFE6F),
|
|
60
|
+
(0xFF00, 0xFF60), (0xFFE0, 0xFFE6), (0x1B000, 0x1B2FF), (0x1F200, 0x1F251),
|
|
61
|
+
(0x20000, 0x3FFFD),
|
|
62
|
+
) # fmt: skip
|
|
63
|
+
|
|
64
|
+
_ZWJ = 0x200D
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _in(ranges: tuple[tuple[int, int], ...], code: int) -> bool:
|
|
68
|
+
index = bisect_right(ranges, (code, 0x10FFFF)) - 1
|
|
69
|
+
return index >= 0 and ranges[index][0] <= code <= ranges[index][1]
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _regional(code: int) -> bool:
|
|
73
|
+
return 0x1F1E6 <= code <= 0x1F1FF
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _extends(code: int) -> bool:
|
|
77
|
+
return (
|
|
78
|
+
unicodedata.category(chr(code)).startswith("M")
|
|
79
|
+
or code == _ZWJ
|
|
80
|
+
or 0xFE00 <= code <= 0xFE0F
|
|
81
|
+
or 0x1F3FB <= code <= 0x1F3FF
|
|
82
|
+
or 0xE0020 <= code <= 0xE007F
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _graphemes(text: str) -> Iterator[str]:
|
|
87
|
+
"""Extended grapheme clusters, for the rules terminal text needs:
|
|
88
|
+
marks, joiners, variation selectors, skin tones, tags and flag pairs
|
|
89
|
+
attach to what they follow."""
|
|
90
|
+
cluster = ""
|
|
91
|
+
regional_run = 0
|
|
92
|
+
for char in text:
|
|
93
|
+
code = ord(char)
|
|
94
|
+
previous = ord(cluster[-1]) if cluster else None
|
|
95
|
+
joins = previous is not None and (
|
|
96
|
+
_extends(code)
|
|
97
|
+
or previous == _ZWJ
|
|
98
|
+
or (_regional(code) and _regional(previous) and regional_run % 2 == 1)
|
|
99
|
+
)
|
|
100
|
+
if joins:
|
|
101
|
+
cluster += char
|
|
102
|
+
else:
|
|
103
|
+
if cluster:
|
|
104
|
+
yield cluster
|
|
105
|
+
cluster = char
|
|
106
|
+
regional_run = regional_run + 1 if _regional(code) else 0
|
|
107
|
+
if cluster:
|
|
108
|
+
yield cluster
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def _zero_width(char: str) -> bool:
|
|
112
|
+
code = ord(char)
|
|
113
|
+
category = unicodedata.category(char)
|
|
114
|
+
return category.startswith("M") or category == "Cc" or _in(_DEFAULT_IGNORABLE, code)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _grapheme_width(grapheme: str) -> int:
|
|
118
|
+
visible = "".join(char for char in grapheme if not _zero_width(char))
|
|
119
|
+
if not visible:
|
|
120
|
+
return 0
|
|
121
|
+
if any(_in(_EMOJI_PRESENTATION, ord(char)) for char in grapheme) or "️" in grapheme:
|
|
122
|
+
return 2
|
|
123
|
+
return 2 if _in(_FULL_WIDTH, ord(visible[0])) else 1
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def strip_ansi(text: str) -> str:
|
|
127
|
+
return _ANSI.sub("", text)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def display_width(text: str) -> int:
|
|
131
|
+
return sum(_grapheme_width(grapheme) for grapheme in _graphemes(strip_ansi(text)))
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
__all__ = ["display_width", "strip_ansi"]
|
pyfect/cli/_wizard.py
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
"""``--wizard``: builds a command line by asking for each flag, argument
|
|
2
|
+
and subcommand (Effect's internal ``cli/internal/wizard``)."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import math
|
|
7
|
+
import re
|
|
8
|
+
from dataclasses import dataclass
|
|
9
|
+
from datetime import UTC, datetime
|
|
10
|
+
from typing import Any, Never
|
|
11
|
+
|
|
12
|
+
from pyfect import console, redacted
|
|
13
|
+
from pyfect._js import js_number
|
|
14
|
+
from pyfect.cli import _ansi as ansi
|
|
15
|
+
from pyfect.cli import prompt
|
|
16
|
+
from pyfect.cli._command import Command
|
|
17
|
+
from pyfect.cli._environment import Environment
|
|
18
|
+
from pyfect.cli.cli_error import CliError
|
|
19
|
+
from pyfect.cli.param import (
|
|
20
|
+
ARGUMENT,
|
|
21
|
+
FLAG,
|
|
22
|
+
Param,
|
|
23
|
+
ParsedArgs,
|
|
24
|
+
Single,
|
|
25
|
+
get_underlying_single_or_throw,
|
|
26
|
+
)
|
|
27
|
+
from pyfect.effect import Effect, gen
|
|
28
|
+
from pyfect.terminal import QuitError
|
|
29
|
+
|
|
30
|
+
type AnyCommand = Command[Any, Any, Any, Any]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclass(frozen=True, slots=True)
|
|
34
|
+
class Arg:
|
|
35
|
+
value: str
|
|
36
|
+
display: str
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@dataclass(frozen=True, slots=True)
|
|
40
|
+
class WizardResult:
|
|
41
|
+
args: tuple[str, ...]
|
|
42
|
+
display_args: tuple[str, ...]
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _arg(value: str, display: str | None = None) -> Arg:
|
|
46
|
+
return Arg(value, value if display is None else display)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def run(
|
|
50
|
+
command: AnyCommand,
|
|
51
|
+
*,
|
|
52
|
+
command_path: tuple[str, ...] | None = None,
|
|
53
|
+
prefix: tuple[str, ...] | None = None,
|
|
54
|
+
) -> Effect[WizardResult, CliError | QuitError, Environment]:
|
|
55
|
+
path = command_path or (command.name,)
|
|
56
|
+
|
|
57
|
+
def body():
|
|
58
|
+
selected = _command_at(command, path)
|
|
59
|
+
line = [_arg(value) for value in (prefix or path)]
|
|
60
|
+
theme = yield from prompt.PromptTheme()
|
|
61
|
+
yield from _log_current(line, theme.colors)
|
|
62
|
+
section = "ROOT" if selected is command else selected.name
|
|
63
|
+
yield from _prompt_command(selected, line, section, theme.colors)
|
|
64
|
+
return WizardResult(tuple(arg.value for arg in line), tuple(arg.display for arg in line))
|
|
65
|
+
|
|
66
|
+
return gen(body)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _command_at(command: AnyCommand, path: tuple[str, ...]) -> AnyCommand:
|
|
70
|
+
current = command
|
|
71
|
+
for name in path[1:]:
|
|
72
|
+
child = next(
|
|
73
|
+
(
|
|
74
|
+
sub
|
|
75
|
+
for group in current.subcommands
|
|
76
|
+
for sub in group.commands
|
|
77
|
+
if name in (sub.name, sub.alias)
|
|
78
|
+
),
|
|
79
|
+
None,
|
|
80
|
+
)
|
|
81
|
+
if child is None:
|
|
82
|
+
break
|
|
83
|
+
current = child
|
|
84
|
+
return current
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def _visible(command: AnyCommand) -> list[AnyCommand]:
|
|
88
|
+
return [sub for group in command.subcommands for sub in group.commands if not sub.unlisted]
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _prompt_command(
|
|
92
|
+
command: AnyCommand, line: list[Arg], section: str, colors: bool
|
|
93
|
+
) -> Effect[None, CliError | QuitError, Environment]:
|
|
94
|
+
def body():
|
|
95
|
+
visible = _visible(command)
|
|
96
|
+
state = command.state
|
|
97
|
+
config = state.context_config if visible else state.config
|
|
98
|
+
if config.flags:
|
|
99
|
+
yield from console.log(_section(section, "FLAGS", colors))
|
|
100
|
+
for param in config.flags:
|
|
101
|
+
line.extend((yield from _prompt_param(param)))
|
|
102
|
+
if config.arguments or visible:
|
|
103
|
+
yield from _log_current(line, colors)
|
|
104
|
+
if config.arguments:
|
|
105
|
+
yield from console.log(_section(section, "ARGUMENTS", colors))
|
|
106
|
+
for param in config.arguments:
|
|
107
|
+
line.extend((yield from _prompt_param(param)))
|
|
108
|
+
if visible:
|
|
109
|
+
yield from _log_current(line, colors)
|
|
110
|
+
if not visible:
|
|
111
|
+
return
|
|
112
|
+
choices = [
|
|
113
|
+
prompt.Choice(
|
|
114
|
+
sub.name,
|
|
115
|
+
sub,
|
|
116
|
+
sub.short_description if sub.short_description is not None else sub.description,
|
|
117
|
+
)
|
|
118
|
+
for sub in visible
|
|
119
|
+
]
|
|
120
|
+
child = yield from prompt.run(prompt.select(choices, message="Command"))
|
|
121
|
+
yield from console.log()
|
|
122
|
+
line.append(_arg(child.name))
|
|
123
|
+
if _has_steps(child):
|
|
124
|
+
yield from _log_current(line, colors)
|
|
125
|
+
yield from _prompt_command(child, line, child.name, colors)
|
|
126
|
+
|
|
127
|
+
return gen(body)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _has_steps(command: AnyCommand) -> bool:
|
|
131
|
+
return bool(_visible(command)) or bool(command.state.config.ordered_params)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def _prompt_param(param: Param[Any]) -> Effect[list[Arg], CliError | QuitError, Environment]:
|
|
135
|
+
def body():
|
|
136
|
+
single = get_underlying_single_or_throw(param)
|
|
137
|
+
metadata = param.metadata()
|
|
138
|
+
if metadata.is_optional:
|
|
139
|
+
include = yield from prompt.run(prompt.confirm(f"Set {_label(single)}?"))
|
|
140
|
+
if not include:
|
|
141
|
+
yield from console.log()
|
|
142
|
+
return list[Arg]()
|
|
143
|
+
minimum = metadata.variadic_min or 0
|
|
144
|
+
count = (
|
|
145
|
+
(
|
|
146
|
+
yield from prompt.run(
|
|
147
|
+
prompt.integer(
|
|
148
|
+
f"{_label(single)} count",
|
|
149
|
+
default=minimum,
|
|
150
|
+
min=minimum,
|
|
151
|
+
max=math.inf if metadata.variadic_max is None else metadata.variadic_max,
|
|
152
|
+
)
|
|
153
|
+
)
|
|
154
|
+
)
|
|
155
|
+
if metadata.is_variadic
|
|
156
|
+
else 1
|
|
157
|
+
)
|
|
158
|
+
values: list[Arg] = []
|
|
159
|
+
while len(values) < count:
|
|
160
|
+
values.append((yield from _prompt_single(single)))
|
|
161
|
+
raw = tuple(value.value for value in values)
|
|
162
|
+
parsed = ParsedArgs({single.name: raw}, ()) if single.kind == FLAG else ParsedArgs({}, raw)
|
|
163
|
+
yield from param.parse(parsed)
|
|
164
|
+
yield from console.log()
|
|
165
|
+
if single.kind == ARGUMENT:
|
|
166
|
+
return values
|
|
167
|
+
result: list[Arg] = []
|
|
168
|
+
for value in values:
|
|
169
|
+
if single.optional_value is not None or (
|
|
170
|
+
value.value.startswith("-") and len(value.value) > 1
|
|
171
|
+
):
|
|
172
|
+
result.append(
|
|
173
|
+
_arg(f"--{single.name}={value.value}", f"--{single.name}={value.display}")
|
|
174
|
+
)
|
|
175
|
+
else:
|
|
176
|
+
result += [_arg(f"--{single.name}"), value]
|
|
177
|
+
return result
|
|
178
|
+
|
|
179
|
+
return gen(body)
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def _iso(value: datetime) -> str:
|
|
183
|
+
utc = value.astimezone(UTC)
|
|
184
|
+
return utc.strftime("%Y-%m-%dT%H:%M:%S.") + f"{utc.microsecond // 1000:03d}Z"
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def _js_bool(value: bool) -> str:
|
|
188
|
+
return "true" if value else "false"
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def _prompt_single(single: Single[Any]) -> Effect[Arg, QuitError, Environment]: # noqa: PLR0911 - one return per type
|
|
192
|
+
message = _label(single)
|
|
193
|
+
match single.primitive.tag:
|
|
194
|
+
case "Boolean":
|
|
195
|
+
return prompt.run(
|
|
196
|
+
prompt.confirm(
|
|
197
|
+
message,
|
|
198
|
+
confirm_label="true",
|
|
199
|
+
deny_label="false",
|
|
200
|
+
default_confirm="(T/f)",
|
|
201
|
+
default_deny="(t/F)",
|
|
202
|
+
)
|
|
203
|
+
).map(lambda value: _arg(_js_bool(value)))
|
|
204
|
+
case "Choice":
|
|
205
|
+
keys = single.primitive.choice_keys or ()
|
|
206
|
+
choices = [prompt.Choice(key, key) for key in keys]
|
|
207
|
+
return prompt.run(prompt.select(choices, message=message)).map(_arg)
|
|
208
|
+
case "Date":
|
|
209
|
+
return prompt.run(prompt.date(message)).map(lambda value: _arg(_iso(value)))
|
|
210
|
+
case "Finite":
|
|
211
|
+
return prompt.run(prompt.number(message)).map(lambda value: _arg(js_number(value)))
|
|
212
|
+
case "Int":
|
|
213
|
+
return prompt.run(prompt.integer(message)).map(lambda value: _arg(str(value)))
|
|
214
|
+
case "Redacted":
|
|
215
|
+
return prompt.run(prompt.password(message)).map(
|
|
216
|
+
lambda value: _arg(redacted.value(value), "<redacted>")
|
|
217
|
+
)
|
|
218
|
+
case _:
|
|
219
|
+
return prompt.run(prompt.string(message)).map(_arg)
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def _name(single: Single[Any]) -> str:
|
|
223
|
+
return f"--{single.name}" if single.kind == FLAG else single.name
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def _label(single: Single[Any]) -> str:
|
|
227
|
+
description = single.description.strip() if single.description is not None else None
|
|
228
|
+
label = (
|
|
229
|
+
description
|
|
230
|
+
if single.kind == FLAG and description is not None and len(description) <= 32
|
|
231
|
+
else _humanize(single.name)
|
|
232
|
+
)
|
|
233
|
+
return f"{label} ({_name(single)})" if single.kind == FLAG else label
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
def _humanize(name: str) -> str:
|
|
237
|
+
words = [word for word in re.split(r"[-_]+", name) if word]
|
|
238
|
+
if not words:
|
|
239
|
+
return name
|
|
240
|
+
return " ".join([words[0][0].upper() + words[0][1:], *words[1:]])
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def _log_current(line: list[Arg], colors: bool) -> Effect[None, Never]:
|
|
244
|
+
block = _command_block("Current command", [arg.display for arg in line], colors, ansi.magenta)
|
|
245
|
+
return console.log(block)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def _section(command: str, section: str, colors: bool) -> str:
|
|
249
|
+
return (
|
|
250
|
+
f"{ansi.annotate(colors, command.upper(), ansi.bold, ansi.cyan_bright)} "
|
|
251
|
+
f"{ansi.annotate(colors, '·', ansi.black_bright)} "
|
|
252
|
+
f"{ansi.annotate(colors, section, ansi.bold, ansi.white)}"
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def render_introduction(name: str, version: str, summary: str | None, colors: bool) -> str:
|
|
257
|
+
title = (
|
|
258
|
+
f"{ansi.annotate(colors, name, ansi.bold, ansi.cyan_bright)} "
|
|
259
|
+
f"{ansi.annotate(colors, f'v{version}', ansi.white)} "
|
|
260
|
+
f"{ansi.annotate(colors, '· Command wizard', ansi.bold, ansi.white)}"
|
|
261
|
+
)
|
|
262
|
+
hint = ansi.annotate(
|
|
263
|
+
colors, "Build a command interactively. Press Ctrl+C to cancel.", ansi.black_bright
|
|
264
|
+
)
|
|
265
|
+
return "\n".join([title, *([summary] if summary else []), hint, ""])
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
def render_completion(line: list[str] | tuple[str, ...], colors: bool) -> str:
|
|
269
|
+
return _command_block("Command ready", line, colors, ansi.cyan_bright, ansi.green)
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
def render_quit(colors: bool) -> str:
|
|
273
|
+
return f"\n{ansi.annotate(colors, 'Wizard cancelled.', ansi.red)}"
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
def _command_block(
|
|
277
|
+
label: str,
|
|
278
|
+
line: list[str] | tuple[str, ...],
|
|
279
|
+
colors: bool,
|
|
280
|
+
command_color: str,
|
|
281
|
+
label_color: str = ansi.white,
|
|
282
|
+
) -> str:
|
|
283
|
+
lines = [ansi.annotate(colors, label, ansi.bold, label_color)]
|
|
284
|
+
lines += [ansi.annotate(colors, wrapped, command_color) for wrapped in _wrap(line)]
|
|
285
|
+
return "\n".join([*lines, ""])
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
_WIDTH = 88
|
|
289
|
+
_FIRST = " $ "
|
|
290
|
+
_CONTINUATION = " "
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
def _wrap(line: list[str] | tuple[str, ...]) -> list[str]:
|
|
294
|
+
lines: list[str] = []
|
|
295
|
+
current = _FIRST
|
|
296
|
+
for arg in map(_shell_arg, line):
|
|
297
|
+
separator = "" if current in (_FIRST, _CONTINUATION) else " "
|
|
298
|
+
if len(current) + len(separator) + len(arg) > _WIDTH and current != _FIRST:
|
|
299
|
+
lines.append(f"{current} \\")
|
|
300
|
+
current = f"{_CONTINUATION}{arg}"
|
|
301
|
+
else:
|
|
302
|
+
current += f"{separator}{arg}"
|
|
303
|
+
if current != _FIRST:
|
|
304
|
+
lines.append(current)
|
|
305
|
+
return lines
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
_SAFE_SHELL = re.compile(r"[A-Za-z0-9_./:@%+=,-]+")
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
def _shell_arg(arg: str) -> str:
|
|
312
|
+
if _SAFE_SHELL.fullmatch(arg):
|
|
313
|
+
return arg
|
|
314
|
+
return "'" + arg.replace("'", "'\"'\"'") + "'"
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
__all__ = ["WizardResult", "render_completion", "render_introduction", "render_quit", "run"]
|
pyfect/cli/argument.py
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"""Positional command-line arguments (Effect's ``Argument``).
|
|
2
|
+
|
|
3
|
+
An ``Argument[A]`` takes the next positional value(s) and parses an ``A``.
|
|
4
|
+
Declare arguments as attributes of a ``Config`` class, in order::
|
|
5
|
+
|
|
6
|
+
class Copy(Config):
|
|
7
|
+
source = Argument.file("source", must_exist=True)
|
|
8
|
+
targets = Argument.string("target").variadic(min=1)
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
from collections.abc import Callable, Sequence
|
|
14
|
+
from dataclasses import dataclass
|
|
15
|
+
from datetime import datetime
|
|
16
|
+
from typing import TYPE_CHECKING, Any, Never, Self, overload
|
|
17
|
+
|
|
18
|
+
from pyfect import config as config_
|
|
19
|
+
from pyfect.cli import param as p
|
|
20
|
+
from pyfect.cli._environment import Environment
|
|
21
|
+
from pyfect.cli.cli_error import CliError
|
|
22
|
+
from pyfect.cli.primitive import FileFormat, PathType
|
|
23
|
+
from pyfect.effect import Effect
|
|
24
|
+
from pyfect.option import Some
|
|
25
|
+
from pyfect.redacted import Redacted
|
|
26
|
+
from pyfect.result import Result
|
|
27
|
+
from pyfect.schema import Codec
|
|
28
|
+
from pyfect.schema.issue import Issue
|
|
29
|
+
|
|
30
|
+
if TYPE_CHECKING:
|
|
31
|
+
from pyfect.cli.prompt import Prompt
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@dataclass(frozen=True, eq=False, slots=True)
|
|
35
|
+
class Argument[A]:
|
|
36
|
+
"""A positional argument parsing an ``A``. Read on a parsed ``Config``
|
|
37
|
+
it is the value."""
|
|
38
|
+
|
|
39
|
+
param: p.Param[A]
|
|
40
|
+
|
|
41
|
+
@overload
|
|
42
|
+
def __get__(self, instance: None, owner: type[object]) -> Self: ...
|
|
43
|
+
@overload
|
|
44
|
+
def __get__(self, instance: object, owner: type[object]) -> A: ...
|
|
45
|
+
def __get__(self, instance: object, owner: type[object]) -> Self | A:
|
|
46
|
+
if instance is None:
|
|
47
|
+
return self
|
|
48
|
+
raise AttributeError(f"{owner.__name__} has no parsed value for this argument")
|
|
49
|
+
|
|
50
|
+
def parse(self, args: p.ParsedArgs) -> p.Parsed[A]:
|
|
51
|
+
return self.param.parse(args)
|
|
52
|
+
|
|
53
|
+
# --- constructors ---------------------------------------------------------
|
|
54
|
+
|
|
55
|
+
@staticmethod
|
|
56
|
+
def string(name: str) -> Argument[str]:
|
|
57
|
+
return Argument(p.string(p.ARGUMENT, name))
|
|
58
|
+
|
|
59
|
+
@staticmethod
|
|
60
|
+
def integer(name: str) -> Argument[int]:
|
|
61
|
+
return Argument(p.integer(p.ARGUMENT, name))
|
|
62
|
+
|
|
63
|
+
@staticmethod
|
|
64
|
+
def finite(name: str) -> Argument[float]:
|
|
65
|
+
"""A float (``129.99``, ``-1e3``); ``nan`` and ``inf`` are refused."""
|
|
66
|
+
return Argument(p.finite(p.ARGUMENT, name))
|
|
67
|
+
|
|
68
|
+
@staticmethod
|
|
69
|
+
def date(name: str) -> Argument[datetime]:
|
|
70
|
+
return Argument(p.date(p.ARGUMENT, name))
|
|
71
|
+
|
|
72
|
+
@staticmethod
|
|
73
|
+
def choice_with_value[B](name: str, choices: Sequence[tuple[str, B]]) -> Argument[B]:
|
|
74
|
+
return Argument(p.choice_with_value(p.ARGUMENT, name, choices))
|
|
75
|
+
|
|
76
|
+
@staticmethod
|
|
77
|
+
def literals[L: str](name: str, choices: Sequence[L]) -> Argument[L]:
|
|
78
|
+
"""One of ``choices``; a tuple (``("text", "json")``) keeps the
|
|
79
|
+
literal type, a list widens it to ``str``."""
|
|
80
|
+
return Argument(p.literals(p.ARGUMENT, name, choices))
|
|
81
|
+
|
|
82
|
+
@staticmethod
|
|
83
|
+
def path(
|
|
84
|
+
name: str,
|
|
85
|
+
*,
|
|
86
|
+
path_type: PathType = "either",
|
|
87
|
+
must_exist: bool = False,
|
|
88
|
+
type_name: str | None = None,
|
|
89
|
+
) -> Argument[str]:
|
|
90
|
+
return Argument(
|
|
91
|
+
p.path(
|
|
92
|
+
p.ARGUMENT, name, path_type=path_type, must_exist=must_exist, type_name=type_name
|
|
93
|
+
)
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
@staticmethod
|
|
97
|
+
def file(name: str, *, must_exist: bool = False) -> Argument[str]:
|
|
98
|
+
return Argument(p.file(p.ARGUMENT, name, must_exist=must_exist))
|
|
99
|
+
|
|
100
|
+
@staticmethod
|
|
101
|
+
def directory(name: str, *, must_exist: bool = False) -> Argument[str]:
|
|
102
|
+
return Argument(p.directory(p.ARGUMENT, name, must_exist=must_exist))
|
|
103
|
+
|
|
104
|
+
@staticmethod
|
|
105
|
+
def redacted(name: str) -> Argument[Redacted[str]]:
|
|
106
|
+
return Argument(p.redacted(p.ARGUMENT, name))
|
|
107
|
+
|
|
108
|
+
@staticmethod
|
|
109
|
+
def file_text(name: str) -> Argument[str]:
|
|
110
|
+
return Argument(p.file_text(p.ARGUMENT, name))
|
|
111
|
+
|
|
112
|
+
@staticmethod
|
|
113
|
+
def file_parse(name: str, *, format: FileFormat | None = None) -> Argument[object]:
|
|
114
|
+
return Argument(p.file_parse(p.ARGUMENT, name, format=format))
|
|
115
|
+
|
|
116
|
+
@staticmethod
|
|
117
|
+
def file_schema[B](
|
|
118
|
+
name: str,
|
|
119
|
+
schema: Codec[B, object, Environment, object],
|
|
120
|
+
*,
|
|
121
|
+
format: FileFormat | None = None,
|
|
122
|
+
error_formatter: Callable[[Issue], str] | None = None,
|
|
123
|
+
) -> Argument[B]:
|
|
124
|
+
return Argument(
|
|
125
|
+
p.file_schema(p.ARGUMENT, name, schema, format=format, error_formatter=error_formatter)
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
@staticmethod
|
|
129
|
+
def never() -> Argument[Never]:
|
|
130
|
+
"""An argument that never parses."""
|
|
131
|
+
return Argument(p.never(p.ARGUMENT))
|
|
132
|
+
|
|
133
|
+
# --- metadata -------------------------------------------------------------
|
|
134
|
+
|
|
135
|
+
def with_description(self, description: str) -> Argument[A]:
|
|
136
|
+
return Argument(p.with_description(self.param, description))
|
|
137
|
+
|
|
138
|
+
def with_metavar(self, metavar: str) -> Argument[A]:
|
|
139
|
+
"""The value's name in help, in place of its type."""
|
|
140
|
+
return Argument(p.with_metavar(self.param, metavar))
|
|
141
|
+
|
|
142
|
+
# --- values ---------------------------------------------------------------
|
|
143
|
+
|
|
144
|
+
def optional(self) -> Argument[A | None]:
|
|
145
|
+
return Argument(p.optional(self.param))
|
|
146
|
+
|
|
147
|
+
@overload
|
|
148
|
+
def with_default(self, default: Effect[A, CliError, Environment]) -> Argument[A]: ...
|
|
149
|
+
@overload
|
|
150
|
+
def with_default(self, default: A) -> Argument[A]: ...
|
|
151
|
+
@overload
|
|
152
|
+
def with_default[B](self, default: Effect[B, CliError, Environment]) -> Argument[A | B]: ...
|
|
153
|
+
@overload
|
|
154
|
+
def with_default[B](self, default: B) -> Argument[A | B]: ...
|
|
155
|
+
def with_default(self, default: Any) -> Argument[Any]:
|
|
156
|
+
"""``default`` (or the effect's value) when the argument is missing."""
|
|
157
|
+
return Argument(p.with_default(self.param, default))
|
|
158
|
+
|
|
159
|
+
def with_fallback_config[B](self, config: config_.Config[B]) -> Argument[A | B]:
|
|
160
|
+
return Argument(p.with_fallback_config(self.param, config))
|
|
161
|
+
|
|
162
|
+
def with_fallback_prompt[B](
|
|
163
|
+
self, prompt: Prompt[B] | Effect[Prompt[B], CliError, Environment]
|
|
164
|
+
) -> Argument[A | B]:
|
|
165
|
+
p.require_prompt(prompt)
|
|
166
|
+
return Argument(p.with_fallback_prompt(self.param, prompt))
|
|
167
|
+
|
|
168
|
+
def variadic(
|
|
169
|
+
self, *, min: int | None = None, max: int | None = None
|
|
170
|
+
) -> Argument[tuple[A, ...]]:
|
|
171
|
+
"""Every remaining value (between ``min`` and ``max`` of them)."""
|
|
172
|
+
return Argument(p.variadic(self.param, min, max))
|
|
173
|
+
|
|
174
|
+
def at_least(self, min: int) -> Argument[tuple[A, ...]]:
|
|
175
|
+
return Argument(p.at_least(self.param, min))
|
|
176
|
+
|
|
177
|
+
def at_most(self, max: int) -> Argument[tuple[A, ...]]:
|
|
178
|
+
return Argument(p.at_most(self.param, max))
|
|
179
|
+
|
|
180
|
+
def between(self, min: int, max: int) -> Argument[tuple[A, ...]]:
|
|
181
|
+
return Argument(p.between(self.param, min, max))
|
|
182
|
+
|
|
183
|
+
def map[B](self, f: Callable[[A], B]) -> Argument[B]:
|
|
184
|
+
return Argument(p.map(self.param, f))
|
|
185
|
+
|
|
186
|
+
def map_effect[B](self, f: Callable[[A], Effect[B, CliError, Environment]]) -> Argument[B]:
|
|
187
|
+
return Argument(p.map_effect(self.param, f))
|
|
188
|
+
|
|
189
|
+
def map_try_catch[B](
|
|
190
|
+
self, f: Callable[[A], B], on_error: Callable[[Exception], str]
|
|
191
|
+
) -> Argument[B]:
|
|
192
|
+
return Argument(p.map_try_catch(self.param, f, on_error))
|
|
193
|
+
|
|
194
|
+
def filter_map[B](
|
|
195
|
+
self, f: Callable[[A], Some[B] | None], on_none: Callable[[A], str]
|
|
196
|
+
) -> Argument[B]:
|
|
197
|
+
return Argument(p.filter_map(self.param, f, on_none))
|
|
198
|
+
|
|
199
|
+
def filter(self, predicate: Callable[[A], bool], on_false: Callable[[A], str]) -> Argument[A]:
|
|
200
|
+
return Argument(p.filter(self.param, predicate, on_false))
|
|
201
|
+
|
|
202
|
+
def with_schema[B](self, schema: Codec[B, A, Environment, object]) -> Argument[B]:
|
|
203
|
+
return Argument(p.with_schema(self.param, schema))
|
|
204
|
+
|
|
205
|
+
def or_else[B](self, alternative: Callable[[], Argument[B]]) -> Argument[A | B]:
|
|
206
|
+
return Argument(p.or_else(self.param, lambda: alternative().param))
|
|
207
|
+
|
|
208
|
+
def or_else_result[B](self, alternative: Callable[[], Argument[B]]) -> Argument[Result[A, B]]:
|
|
209
|
+
return Argument(p.or_else_result(self.param, lambda: alternative().param))
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
__all__ = ["Argument"]
|
pyfect/cli/cli_config.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""Settings of the CLI runner (Effect's ``CliConfig``): which built-in
|
|
2
|
+
global flags every command gets."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from collections.abc import Sequence
|
|
7
|
+
from dataclasses import dataclass
|
|
8
|
+
|
|
9
|
+
from pyfect.cli import global_flag
|
|
10
|
+
from pyfect.cli._settings import GlobalFlag
|
|
11
|
+
from pyfect.context import Reference
|
|
12
|
+
from pyfect.layer import Layer
|
|
13
|
+
from pyfect.layer import succeed as layer_succeed
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass(frozen=True, slots=True)
|
|
17
|
+
class Settings:
|
|
18
|
+
built_ins: tuple[GlobalFlag, ...] = global_flag.built_ins
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
defaults = Settings()
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class CliConfig(Reference[Settings]):
|
|
25
|
+
"""The runner's settings; defaults to ``defaults``."""
|
|
26
|
+
|
|
27
|
+
@classmethod
|
|
28
|
+
def default(cls) -> Settings:
|
|
29
|
+
return defaults
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def make(*, built_ins: Sequence[GlobalFlag] | None = None) -> Settings:
|
|
33
|
+
return Settings(defaults.built_ins if built_ins is None else tuple(built_ins))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def layer(*, built_ins: Sequence[GlobalFlag] | None = None) -> Layer[CliConfig]:
|
|
37
|
+
return layer_succeed(CliConfig, make(built_ins=built_ins))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
__all__ = ["CliConfig", "Settings", "defaults", "layer", "make"]
|