ob-metaflow 2.11.13.1__py2.py3-none-any.whl → 2.19.7.1rc0__py2.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.
- metaflow/R.py +10 -7
- metaflow/__init__.py +40 -25
- metaflow/_vendor/imghdr/__init__.py +186 -0
- metaflow/_vendor/importlib_metadata/__init__.py +1063 -0
- metaflow/_vendor/importlib_metadata/_adapters.py +68 -0
- metaflow/_vendor/importlib_metadata/_collections.py +30 -0
- metaflow/_vendor/importlib_metadata/_compat.py +71 -0
- metaflow/_vendor/importlib_metadata/_functools.py +104 -0
- metaflow/_vendor/importlib_metadata/_itertools.py +73 -0
- metaflow/_vendor/importlib_metadata/_meta.py +48 -0
- metaflow/_vendor/importlib_metadata/_text.py +99 -0
- metaflow/_vendor/importlib_metadata/py.typed +0 -0
- metaflow/_vendor/typeguard/__init__.py +48 -0
- metaflow/_vendor/typeguard/_checkers.py +1070 -0
- metaflow/_vendor/typeguard/_config.py +108 -0
- metaflow/_vendor/typeguard/_decorators.py +233 -0
- metaflow/_vendor/typeguard/_exceptions.py +42 -0
- metaflow/_vendor/typeguard/_functions.py +308 -0
- metaflow/_vendor/typeguard/_importhook.py +213 -0
- metaflow/_vendor/typeguard/_memo.py +48 -0
- metaflow/_vendor/typeguard/_pytest_plugin.py +127 -0
- metaflow/_vendor/typeguard/_suppression.py +86 -0
- metaflow/_vendor/typeguard/_transformer.py +1229 -0
- metaflow/_vendor/typeguard/_union_transformer.py +55 -0
- metaflow/_vendor/typeguard/_utils.py +173 -0
- metaflow/_vendor/typeguard/py.typed +0 -0
- metaflow/_vendor/typing_extensions.py +3641 -0
- metaflow/_vendor/v3_7/importlib_metadata/__init__.py +1063 -0
- metaflow/_vendor/v3_7/importlib_metadata/_adapters.py +68 -0
- metaflow/_vendor/v3_7/importlib_metadata/_collections.py +30 -0
- metaflow/_vendor/v3_7/importlib_metadata/_compat.py +71 -0
- metaflow/_vendor/v3_7/importlib_metadata/_functools.py +104 -0
- metaflow/_vendor/v3_7/importlib_metadata/_itertools.py +73 -0
- metaflow/_vendor/v3_7/importlib_metadata/_meta.py +48 -0
- metaflow/_vendor/v3_7/importlib_metadata/_text.py +99 -0
- metaflow/_vendor/v3_7/importlib_metadata/py.typed +0 -0
- metaflow/_vendor/v3_7/typeguard/__init__.py +48 -0
- metaflow/_vendor/v3_7/typeguard/_checkers.py +906 -0
- metaflow/_vendor/v3_7/typeguard/_config.py +108 -0
- metaflow/_vendor/v3_7/typeguard/_decorators.py +237 -0
- metaflow/_vendor/v3_7/typeguard/_exceptions.py +42 -0
- metaflow/_vendor/v3_7/typeguard/_functions.py +310 -0
- metaflow/_vendor/v3_7/typeguard/_importhook.py +213 -0
- metaflow/_vendor/v3_7/typeguard/_memo.py +48 -0
- metaflow/_vendor/v3_7/typeguard/_pytest_plugin.py +100 -0
- metaflow/_vendor/v3_7/typeguard/_suppression.py +88 -0
- metaflow/_vendor/v3_7/typeguard/_transformer.py +1207 -0
- metaflow/_vendor/v3_7/typeguard/_union_transformer.py +54 -0
- metaflow/_vendor/v3_7/typeguard/_utils.py +169 -0
- metaflow/_vendor/v3_7/typeguard/py.typed +0 -0
- metaflow/_vendor/v3_7/typing_extensions.py +3072 -0
- metaflow/_vendor/yaml/__init__.py +427 -0
- metaflow/_vendor/yaml/composer.py +139 -0
- metaflow/_vendor/yaml/constructor.py +748 -0
- metaflow/_vendor/yaml/cyaml.py +101 -0
- metaflow/_vendor/yaml/dumper.py +62 -0
- metaflow/_vendor/yaml/emitter.py +1137 -0
- metaflow/_vendor/yaml/error.py +75 -0
- metaflow/_vendor/yaml/events.py +86 -0
- metaflow/_vendor/yaml/loader.py +63 -0
- metaflow/_vendor/yaml/nodes.py +49 -0
- metaflow/_vendor/yaml/parser.py +589 -0
- metaflow/_vendor/yaml/reader.py +185 -0
- metaflow/_vendor/yaml/representer.py +389 -0
- metaflow/_vendor/yaml/resolver.py +227 -0
- metaflow/_vendor/yaml/scanner.py +1435 -0
- metaflow/_vendor/yaml/serializer.py +111 -0
- metaflow/_vendor/yaml/tokens.py +104 -0
- metaflow/cards.py +5 -0
- metaflow/cli.py +331 -785
- metaflow/cli_args.py +17 -0
- metaflow/cli_components/__init__.py +0 -0
- metaflow/cli_components/dump_cmd.py +96 -0
- metaflow/cli_components/init_cmd.py +52 -0
- metaflow/cli_components/run_cmds.py +546 -0
- metaflow/cli_components/step_cmd.py +334 -0
- metaflow/cli_components/utils.py +140 -0
- metaflow/client/__init__.py +1 -0
- metaflow/client/core.py +467 -73
- metaflow/client/filecache.py +75 -35
- metaflow/clone_util.py +7 -1
- metaflow/cmd/code/__init__.py +231 -0
- metaflow/cmd/develop/stub_generator.py +756 -288
- metaflow/cmd/develop/stubs.py +12 -28
- metaflow/cmd/main_cli.py +6 -4
- metaflow/cmd/make_wrapper.py +78 -0
- metaflow/datastore/__init__.py +1 -0
- metaflow/datastore/content_addressed_store.py +41 -10
- metaflow/datastore/datastore_set.py +11 -2
- metaflow/datastore/flow_datastore.py +156 -10
- metaflow/datastore/spin_datastore.py +91 -0
- metaflow/datastore/task_datastore.py +154 -39
- metaflow/debug.py +5 -0
- metaflow/decorators.py +404 -78
- metaflow/exception.py +8 -2
- metaflow/extension_support/__init__.py +527 -376
- metaflow/extension_support/_empty_file.py +2 -2
- metaflow/extension_support/plugins.py +49 -31
- metaflow/flowspec.py +482 -33
- metaflow/graph.py +210 -42
- metaflow/includefile.py +84 -40
- metaflow/lint.py +141 -22
- metaflow/meta_files.py +13 -0
- metaflow/{metadata → metadata_provider}/heartbeat.py +24 -8
- metaflow/{metadata → metadata_provider}/metadata.py +86 -1
- metaflow/metaflow_config.py +175 -28
- metaflow/metaflow_config_funcs.py +51 -3
- metaflow/metaflow_current.py +4 -10
- metaflow/metaflow_environment.py +139 -53
- metaflow/metaflow_git.py +115 -0
- metaflow/metaflow_profile.py +18 -0
- metaflow/metaflow_version.py +150 -66
- metaflow/mflog/__init__.py +4 -3
- metaflow/mflog/save_logs.py +2 -2
- metaflow/multicore_utils.py +31 -14
- metaflow/package/__init__.py +673 -0
- metaflow/packaging_sys/__init__.py +880 -0
- metaflow/packaging_sys/backend.py +128 -0
- metaflow/packaging_sys/distribution_support.py +153 -0
- metaflow/packaging_sys/tar_backend.py +99 -0
- metaflow/packaging_sys/utils.py +54 -0
- metaflow/packaging_sys/v1.py +527 -0
- metaflow/parameters.py +149 -28
- metaflow/plugins/__init__.py +74 -5
- metaflow/plugins/airflow/airflow.py +40 -25
- metaflow/plugins/airflow/airflow_cli.py +22 -5
- metaflow/plugins/airflow/airflow_decorator.py +1 -1
- metaflow/plugins/airflow/airflow_utils.py +5 -3
- metaflow/plugins/airflow/sensors/base_sensor.py +4 -4
- metaflow/plugins/airflow/sensors/external_task_sensor.py +2 -2
- metaflow/plugins/airflow/sensors/s3_sensor.py +2 -2
- metaflow/plugins/argo/argo_client.py +78 -33
- metaflow/plugins/argo/argo_events.py +6 -6
- metaflow/plugins/argo/argo_workflows.py +2410 -527
- metaflow/plugins/argo/argo_workflows_cli.py +571 -121
- metaflow/plugins/argo/argo_workflows_decorator.py +43 -12
- metaflow/plugins/argo/argo_workflows_deployer.py +106 -0
- metaflow/plugins/argo/argo_workflows_deployer_objects.py +453 -0
- metaflow/plugins/argo/capture_error.py +73 -0
- metaflow/plugins/argo/conditional_input_paths.py +35 -0
- metaflow/plugins/argo/exit_hooks.py +209 -0
- metaflow/plugins/argo/jobset_input_paths.py +15 -0
- metaflow/plugins/argo/param_val.py +19 -0
- metaflow/plugins/aws/aws_client.py +10 -3
- metaflow/plugins/aws/aws_utils.py +55 -2
- metaflow/plugins/aws/batch/batch.py +72 -5
- metaflow/plugins/aws/batch/batch_cli.py +33 -10
- metaflow/plugins/aws/batch/batch_client.py +4 -3
- metaflow/plugins/aws/batch/batch_decorator.py +102 -35
- metaflow/plugins/aws/secrets_manager/aws_secrets_manager_secrets_provider.py +13 -10
- metaflow/plugins/aws/step_functions/dynamo_db_client.py +0 -3
- metaflow/plugins/aws/step_functions/production_token.py +1 -1
- metaflow/plugins/aws/step_functions/step_functions.py +65 -8
- metaflow/plugins/aws/step_functions/step_functions_cli.py +101 -7
- metaflow/plugins/aws/step_functions/step_functions_decorator.py +1 -2
- metaflow/plugins/aws/step_functions/step_functions_deployer.py +97 -0
- metaflow/plugins/aws/step_functions/step_functions_deployer_objects.py +264 -0
- metaflow/plugins/azure/azure_exceptions.py +1 -1
- metaflow/plugins/azure/azure_secret_manager_secrets_provider.py +240 -0
- metaflow/plugins/azure/azure_tail.py +1 -1
- metaflow/plugins/azure/includefile_support.py +2 -0
- metaflow/plugins/cards/card_cli.py +66 -30
- metaflow/plugins/cards/card_creator.py +25 -1
- metaflow/plugins/cards/card_datastore.py +21 -49
- metaflow/plugins/cards/card_decorator.py +132 -8
- metaflow/plugins/cards/card_modules/basic.py +112 -17
- metaflow/plugins/cards/card_modules/bundle.css +1 -1
- metaflow/plugins/cards/card_modules/card.py +16 -1
- metaflow/plugins/cards/card_modules/chevron/renderer.py +1 -1
- metaflow/plugins/cards/card_modules/components.py +665 -28
- metaflow/plugins/cards/card_modules/convert_to_native_type.py +36 -7
- metaflow/plugins/cards/card_modules/json_viewer.py +232 -0
- metaflow/plugins/cards/card_modules/main.css +1 -0
- metaflow/plugins/cards/card_modules/main.js +68 -49
- metaflow/plugins/cards/card_modules/renderer_tools.py +1 -0
- metaflow/plugins/cards/card_modules/test_cards.py +26 -12
- metaflow/plugins/cards/card_server.py +39 -14
- metaflow/plugins/cards/component_serializer.py +2 -9
- metaflow/plugins/cards/metadata.py +22 -0
- metaflow/plugins/catch_decorator.py +9 -0
- metaflow/plugins/datastores/azure_storage.py +10 -1
- metaflow/plugins/datastores/gs_storage.py +6 -2
- metaflow/plugins/datastores/local_storage.py +12 -6
- metaflow/plugins/datastores/spin_storage.py +12 -0
- metaflow/plugins/datatools/local.py +2 -0
- metaflow/plugins/datatools/s3/s3.py +126 -75
- metaflow/plugins/datatools/s3/s3op.py +254 -121
- metaflow/plugins/env_escape/__init__.py +3 -3
- metaflow/plugins/env_escape/client_modules.py +102 -72
- metaflow/plugins/env_escape/server.py +7 -0
- metaflow/plugins/env_escape/stub.py +24 -5
- metaflow/plugins/events_decorator.py +343 -185
- metaflow/plugins/exit_hook/__init__.py +0 -0
- metaflow/plugins/exit_hook/exit_hook_decorator.py +46 -0
- metaflow/plugins/exit_hook/exit_hook_script.py +52 -0
- metaflow/plugins/gcp/__init__.py +1 -1
- metaflow/plugins/gcp/gcp_secret_manager_secrets_provider.py +11 -6
- metaflow/plugins/gcp/gs_tail.py +10 -6
- metaflow/plugins/gcp/includefile_support.py +3 -0
- metaflow/plugins/kubernetes/kube_utils.py +108 -0
- metaflow/plugins/kubernetes/kubernetes.py +411 -130
- metaflow/plugins/kubernetes/kubernetes_cli.py +168 -36
- metaflow/plugins/kubernetes/kubernetes_client.py +104 -2
- metaflow/plugins/kubernetes/kubernetes_decorator.py +246 -88
- metaflow/plugins/kubernetes/kubernetes_job.py +253 -581
- metaflow/plugins/kubernetes/kubernetes_jobsets.py +1071 -0
- metaflow/plugins/kubernetes/spot_metadata_cli.py +69 -0
- metaflow/plugins/kubernetes/spot_monitor_sidecar.py +109 -0
- metaflow/plugins/logs_cli.py +359 -0
- metaflow/plugins/{metadata → metadata_providers}/local.py +144 -84
- metaflow/plugins/{metadata → metadata_providers}/service.py +103 -26
- metaflow/plugins/metadata_providers/spin.py +16 -0
- metaflow/plugins/package_cli.py +36 -24
- metaflow/plugins/parallel_decorator.py +128 -11
- metaflow/plugins/parsers.py +16 -0
- metaflow/plugins/project_decorator.py +51 -5
- metaflow/plugins/pypi/bootstrap.py +357 -105
- metaflow/plugins/pypi/conda_decorator.py +82 -81
- metaflow/plugins/pypi/conda_environment.py +187 -52
- metaflow/plugins/pypi/micromamba.py +157 -47
- metaflow/plugins/pypi/parsers.py +268 -0
- metaflow/plugins/pypi/pip.py +88 -13
- metaflow/plugins/pypi/pypi_decorator.py +37 -1
- metaflow/plugins/pypi/utils.py +48 -2
- metaflow/plugins/resources_decorator.py +2 -2
- metaflow/plugins/secrets/__init__.py +3 -0
- metaflow/plugins/secrets/secrets_decorator.py +26 -181
- metaflow/plugins/secrets/secrets_func.py +49 -0
- metaflow/plugins/secrets/secrets_spec.py +101 -0
- metaflow/plugins/secrets/utils.py +74 -0
- metaflow/plugins/tag_cli.py +4 -7
- metaflow/plugins/test_unbounded_foreach_decorator.py +41 -6
- metaflow/plugins/timeout_decorator.py +3 -3
- metaflow/plugins/uv/__init__.py +0 -0
- metaflow/plugins/uv/bootstrap.py +128 -0
- metaflow/plugins/uv/uv_environment.py +72 -0
- metaflow/procpoll.py +1 -1
- metaflow/pylint_wrapper.py +5 -1
- metaflow/runner/__init__.py +0 -0
- metaflow/runner/click_api.py +717 -0
- metaflow/runner/deployer.py +470 -0
- metaflow/runner/deployer_impl.py +201 -0
- metaflow/runner/metaflow_runner.py +714 -0
- metaflow/runner/nbdeploy.py +132 -0
- metaflow/runner/nbrun.py +225 -0
- metaflow/runner/subprocess_manager.py +650 -0
- metaflow/runner/utils.py +335 -0
- metaflow/runtime.py +1078 -260
- metaflow/sidecar/sidecar_worker.py +1 -1
- metaflow/system/__init__.py +5 -0
- metaflow/system/system_logger.py +85 -0
- metaflow/system/system_monitor.py +108 -0
- metaflow/system/system_utils.py +19 -0
- metaflow/task.py +521 -225
- metaflow/tracing/__init__.py +7 -7
- metaflow/tracing/span_exporter.py +31 -38
- metaflow/tracing/tracing_modules.py +38 -43
- metaflow/tuple_util.py +27 -0
- metaflow/user_configs/__init__.py +0 -0
- metaflow/user_configs/config_options.py +563 -0
- metaflow/user_configs/config_parameters.py +598 -0
- metaflow/user_decorators/__init__.py +0 -0
- metaflow/user_decorators/common.py +144 -0
- metaflow/user_decorators/mutable_flow.py +512 -0
- metaflow/user_decorators/mutable_step.py +424 -0
- metaflow/user_decorators/user_flow_decorator.py +264 -0
- metaflow/user_decorators/user_step_decorator.py +749 -0
- metaflow/util.py +243 -27
- metaflow/vendor.py +23 -7
- metaflow/version.py +1 -1
- ob_metaflow-2.19.7.1rc0.data/data/share/metaflow/devtools/Makefile +355 -0
- ob_metaflow-2.19.7.1rc0.data/data/share/metaflow/devtools/Tiltfile +726 -0
- ob_metaflow-2.19.7.1rc0.data/data/share/metaflow/devtools/pick_services.sh +105 -0
- ob_metaflow-2.19.7.1rc0.dist-info/METADATA +87 -0
- ob_metaflow-2.19.7.1rc0.dist-info/RECORD +445 -0
- {ob_metaflow-2.11.13.1.dist-info → ob_metaflow-2.19.7.1rc0.dist-info}/WHEEL +1 -1
- {ob_metaflow-2.11.13.1.dist-info → ob_metaflow-2.19.7.1rc0.dist-info}/entry_points.txt +1 -0
- metaflow/_vendor/v3_5/__init__.py +0 -1
- metaflow/_vendor/v3_5/importlib_metadata/__init__.py +0 -644
- metaflow/_vendor/v3_5/importlib_metadata/_compat.py +0 -152
- metaflow/package.py +0 -188
- ob_metaflow-2.11.13.1.dist-info/METADATA +0 -85
- ob_metaflow-2.11.13.1.dist-info/RECORD +0 -308
- /metaflow/_vendor/{v3_5/zipp.py → zipp.py} +0 -0
- /metaflow/{metadata → metadata_provider}/__init__.py +0 -0
- /metaflow/{metadata → metadata_provider}/util.py +0 -0
- /metaflow/plugins/{metadata → metadata_providers}/__init__.py +0 -0
- {ob_metaflow-2.11.13.1.dist-info → ob_metaflow-2.19.7.1rc0.dist-info/licenses}/LICENSE +0 -0
- {ob_metaflow-2.11.13.1.dist-info → ob_metaflow-2.19.7.1rc0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
|
|
2
|
+
__all__ = ['BaseResolver', 'Resolver']
|
|
3
|
+
|
|
4
|
+
from .error import *
|
|
5
|
+
from .nodes import *
|
|
6
|
+
|
|
7
|
+
import re
|
|
8
|
+
|
|
9
|
+
class ResolverError(YAMLError):
|
|
10
|
+
pass
|
|
11
|
+
|
|
12
|
+
class BaseResolver:
|
|
13
|
+
|
|
14
|
+
DEFAULT_SCALAR_TAG = 'tag:yaml.org,2002:str'
|
|
15
|
+
DEFAULT_SEQUENCE_TAG = 'tag:yaml.org,2002:seq'
|
|
16
|
+
DEFAULT_MAPPING_TAG = 'tag:yaml.org,2002:map'
|
|
17
|
+
|
|
18
|
+
yaml_implicit_resolvers = {}
|
|
19
|
+
yaml_path_resolvers = {}
|
|
20
|
+
|
|
21
|
+
def __init__(self):
|
|
22
|
+
self.resolver_exact_paths = []
|
|
23
|
+
self.resolver_prefix_paths = []
|
|
24
|
+
|
|
25
|
+
@classmethod
|
|
26
|
+
def add_implicit_resolver(cls, tag, regexp, first):
|
|
27
|
+
if not 'yaml_implicit_resolvers' in cls.__dict__:
|
|
28
|
+
implicit_resolvers = {}
|
|
29
|
+
for key in cls.yaml_implicit_resolvers:
|
|
30
|
+
implicit_resolvers[key] = cls.yaml_implicit_resolvers[key][:]
|
|
31
|
+
cls.yaml_implicit_resolvers = implicit_resolvers
|
|
32
|
+
if first is None:
|
|
33
|
+
first = [None]
|
|
34
|
+
for ch in first:
|
|
35
|
+
cls.yaml_implicit_resolvers.setdefault(ch, []).append((tag, regexp))
|
|
36
|
+
|
|
37
|
+
@classmethod
|
|
38
|
+
def add_path_resolver(cls, tag, path, kind=None):
|
|
39
|
+
# Note: `add_path_resolver` is experimental. The API could be changed.
|
|
40
|
+
# `new_path` is a pattern that is matched against the path from the
|
|
41
|
+
# root to the node that is being considered. `node_path` elements are
|
|
42
|
+
# tuples `(node_check, index_check)`. `node_check` is a node class:
|
|
43
|
+
# `ScalarNode`, `SequenceNode`, `MappingNode` or `None`. `None`
|
|
44
|
+
# matches any kind of a node. `index_check` could be `None`, a boolean
|
|
45
|
+
# value, a string value, or a number. `None` and `False` match against
|
|
46
|
+
# any _value_ of sequence and mapping nodes. `True` matches against
|
|
47
|
+
# any _key_ of a mapping node. A string `index_check` matches against
|
|
48
|
+
# a mapping value that corresponds to a scalar key which content is
|
|
49
|
+
# equal to the `index_check` value. An integer `index_check` matches
|
|
50
|
+
# against a sequence value with the index equal to `index_check`.
|
|
51
|
+
if not 'yaml_path_resolvers' in cls.__dict__:
|
|
52
|
+
cls.yaml_path_resolvers = cls.yaml_path_resolvers.copy()
|
|
53
|
+
new_path = []
|
|
54
|
+
for element in path:
|
|
55
|
+
if isinstance(element, (list, tuple)):
|
|
56
|
+
if len(element) == 2:
|
|
57
|
+
node_check, index_check = element
|
|
58
|
+
elif len(element) == 1:
|
|
59
|
+
node_check = element[0]
|
|
60
|
+
index_check = True
|
|
61
|
+
else:
|
|
62
|
+
raise ResolverError("Invalid path element: %s" % element)
|
|
63
|
+
else:
|
|
64
|
+
node_check = None
|
|
65
|
+
index_check = element
|
|
66
|
+
if node_check is str:
|
|
67
|
+
node_check = ScalarNode
|
|
68
|
+
elif node_check is list:
|
|
69
|
+
node_check = SequenceNode
|
|
70
|
+
elif node_check is dict:
|
|
71
|
+
node_check = MappingNode
|
|
72
|
+
elif node_check not in [ScalarNode, SequenceNode, MappingNode] \
|
|
73
|
+
and not isinstance(node_check, str) \
|
|
74
|
+
and node_check is not None:
|
|
75
|
+
raise ResolverError("Invalid node checker: %s" % node_check)
|
|
76
|
+
if not isinstance(index_check, (str, int)) \
|
|
77
|
+
and index_check is not None:
|
|
78
|
+
raise ResolverError("Invalid index checker: %s" % index_check)
|
|
79
|
+
new_path.append((node_check, index_check))
|
|
80
|
+
if kind is str:
|
|
81
|
+
kind = ScalarNode
|
|
82
|
+
elif kind is list:
|
|
83
|
+
kind = SequenceNode
|
|
84
|
+
elif kind is dict:
|
|
85
|
+
kind = MappingNode
|
|
86
|
+
elif kind not in [ScalarNode, SequenceNode, MappingNode] \
|
|
87
|
+
and kind is not None:
|
|
88
|
+
raise ResolverError("Invalid node kind: %s" % kind)
|
|
89
|
+
cls.yaml_path_resolvers[tuple(new_path), kind] = tag
|
|
90
|
+
|
|
91
|
+
def descend_resolver(self, current_node, current_index):
|
|
92
|
+
if not self.yaml_path_resolvers:
|
|
93
|
+
return
|
|
94
|
+
exact_paths = {}
|
|
95
|
+
prefix_paths = []
|
|
96
|
+
if current_node:
|
|
97
|
+
depth = len(self.resolver_prefix_paths)
|
|
98
|
+
for path, kind in self.resolver_prefix_paths[-1]:
|
|
99
|
+
if self.check_resolver_prefix(depth, path, kind,
|
|
100
|
+
current_node, current_index):
|
|
101
|
+
if len(path) > depth:
|
|
102
|
+
prefix_paths.append((path, kind))
|
|
103
|
+
else:
|
|
104
|
+
exact_paths[kind] = self.yaml_path_resolvers[path, kind]
|
|
105
|
+
else:
|
|
106
|
+
for path, kind in self.yaml_path_resolvers:
|
|
107
|
+
if not path:
|
|
108
|
+
exact_paths[kind] = self.yaml_path_resolvers[path, kind]
|
|
109
|
+
else:
|
|
110
|
+
prefix_paths.append((path, kind))
|
|
111
|
+
self.resolver_exact_paths.append(exact_paths)
|
|
112
|
+
self.resolver_prefix_paths.append(prefix_paths)
|
|
113
|
+
|
|
114
|
+
def ascend_resolver(self):
|
|
115
|
+
if not self.yaml_path_resolvers:
|
|
116
|
+
return
|
|
117
|
+
self.resolver_exact_paths.pop()
|
|
118
|
+
self.resolver_prefix_paths.pop()
|
|
119
|
+
|
|
120
|
+
def check_resolver_prefix(self, depth, path, kind,
|
|
121
|
+
current_node, current_index):
|
|
122
|
+
node_check, index_check = path[depth-1]
|
|
123
|
+
if isinstance(node_check, str):
|
|
124
|
+
if current_node.tag != node_check:
|
|
125
|
+
return
|
|
126
|
+
elif node_check is not None:
|
|
127
|
+
if not isinstance(current_node, node_check):
|
|
128
|
+
return
|
|
129
|
+
if index_check is True and current_index is not None:
|
|
130
|
+
return
|
|
131
|
+
if (index_check is False or index_check is None) \
|
|
132
|
+
and current_index is None:
|
|
133
|
+
return
|
|
134
|
+
if isinstance(index_check, str):
|
|
135
|
+
if not (isinstance(current_index, ScalarNode)
|
|
136
|
+
and index_check == current_index.value):
|
|
137
|
+
return
|
|
138
|
+
elif isinstance(index_check, int) and not isinstance(index_check, bool):
|
|
139
|
+
if index_check != current_index:
|
|
140
|
+
return
|
|
141
|
+
return True
|
|
142
|
+
|
|
143
|
+
def resolve(self, kind, value, implicit):
|
|
144
|
+
if kind is ScalarNode and implicit[0]:
|
|
145
|
+
if value == '':
|
|
146
|
+
resolvers = self.yaml_implicit_resolvers.get('', [])
|
|
147
|
+
else:
|
|
148
|
+
resolvers = self.yaml_implicit_resolvers.get(value[0], [])
|
|
149
|
+
resolvers += self.yaml_implicit_resolvers.get(None, [])
|
|
150
|
+
for tag, regexp in resolvers:
|
|
151
|
+
if regexp.match(value):
|
|
152
|
+
return tag
|
|
153
|
+
implicit = implicit[1]
|
|
154
|
+
if self.yaml_path_resolvers:
|
|
155
|
+
exact_paths = self.resolver_exact_paths[-1]
|
|
156
|
+
if kind in exact_paths:
|
|
157
|
+
return exact_paths[kind]
|
|
158
|
+
if None in exact_paths:
|
|
159
|
+
return exact_paths[None]
|
|
160
|
+
if kind is ScalarNode:
|
|
161
|
+
return self.DEFAULT_SCALAR_TAG
|
|
162
|
+
elif kind is SequenceNode:
|
|
163
|
+
return self.DEFAULT_SEQUENCE_TAG
|
|
164
|
+
elif kind is MappingNode:
|
|
165
|
+
return self.DEFAULT_MAPPING_TAG
|
|
166
|
+
|
|
167
|
+
class Resolver(BaseResolver):
|
|
168
|
+
pass
|
|
169
|
+
|
|
170
|
+
Resolver.add_implicit_resolver(
|
|
171
|
+
'tag:yaml.org,2002:bool',
|
|
172
|
+
re.compile(r'''^(?:yes|Yes|YES|no|No|NO
|
|
173
|
+
|true|True|TRUE|false|False|FALSE
|
|
174
|
+
|on|On|ON|off|Off|OFF)$''', re.X),
|
|
175
|
+
list('yYnNtTfFoO'))
|
|
176
|
+
|
|
177
|
+
Resolver.add_implicit_resolver(
|
|
178
|
+
'tag:yaml.org,2002:float',
|
|
179
|
+
re.compile(r'''^(?:[-+]?(?:[0-9][0-9_]*)\.[0-9_]*(?:[eE][-+][0-9]+)?
|
|
180
|
+
|\.[0-9_]+(?:[eE][-+][0-9]+)?
|
|
181
|
+
|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*
|
|
182
|
+
|[-+]?\.(?:inf|Inf|INF)
|
|
183
|
+
|\.(?:nan|NaN|NAN))$''', re.X),
|
|
184
|
+
list('-+0123456789.'))
|
|
185
|
+
|
|
186
|
+
Resolver.add_implicit_resolver(
|
|
187
|
+
'tag:yaml.org,2002:int',
|
|
188
|
+
re.compile(r'''^(?:[-+]?0b[0-1_]+
|
|
189
|
+
|[-+]?0[0-7_]+
|
|
190
|
+
|[-+]?(?:0|[1-9][0-9_]*)
|
|
191
|
+
|[-+]?0x[0-9a-fA-F_]+
|
|
192
|
+
|[-+]?[1-9][0-9_]*(?::[0-5]?[0-9])+)$''', re.X),
|
|
193
|
+
list('-+0123456789'))
|
|
194
|
+
|
|
195
|
+
Resolver.add_implicit_resolver(
|
|
196
|
+
'tag:yaml.org,2002:merge',
|
|
197
|
+
re.compile(r'^(?:<<)$'),
|
|
198
|
+
['<'])
|
|
199
|
+
|
|
200
|
+
Resolver.add_implicit_resolver(
|
|
201
|
+
'tag:yaml.org,2002:null',
|
|
202
|
+
re.compile(r'''^(?: ~
|
|
203
|
+
|null|Null|NULL
|
|
204
|
+
| )$''', re.X),
|
|
205
|
+
['~', 'n', 'N', ''])
|
|
206
|
+
|
|
207
|
+
Resolver.add_implicit_resolver(
|
|
208
|
+
'tag:yaml.org,2002:timestamp',
|
|
209
|
+
re.compile(r'''^(?:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]
|
|
210
|
+
|[0-9][0-9][0-9][0-9] -[0-9][0-9]? -[0-9][0-9]?
|
|
211
|
+
(?:[Tt]|[ \t]+)[0-9][0-9]?
|
|
212
|
+
:[0-9][0-9] :[0-9][0-9] (?:\.[0-9]*)?
|
|
213
|
+
(?:[ \t]*(?:Z|[-+][0-9][0-9]?(?::[0-9][0-9])?))?)$''', re.X),
|
|
214
|
+
list('0123456789'))
|
|
215
|
+
|
|
216
|
+
Resolver.add_implicit_resolver(
|
|
217
|
+
'tag:yaml.org,2002:value',
|
|
218
|
+
re.compile(r'^(?:=)$'),
|
|
219
|
+
['='])
|
|
220
|
+
|
|
221
|
+
# The following resolver is only for documentation purposes. It cannot work
|
|
222
|
+
# because plain scalars cannot start with '!', '&', or '*'.
|
|
223
|
+
Resolver.add_implicit_resolver(
|
|
224
|
+
'tag:yaml.org,2002:yaml',
|
|
225
|
+
re.compile(r'^(?:!|&|\*)$'),
|
|
226
|
+
list('!&*'))
|
|
227
|
+
|