nxt.plugins.file_fallbacks module
- resolve_filepath_token(stage, node, cleaned, layer, **kwargs)[source]
Custom resolver for file:: tokens. Can resolve multiple file tokens in a single attr value. The initial raw value is NOT retrieved from the node again as fallbacks happen.
- If on layer_0 the attr value is
${file::${attr}}
- and on layer_1 the attr value is
${file::${foo}}
- This plugin will only fallback and resolve for the value:
${file::${attr}}
This is a fallback resolver for the contents of the token, not the entire attr value! :param stage: Stage instance :param node: Node object :param cleaned: String of cleaned attr value (the outer file token has been stripped off). :param layer: Layer object :param kwargs: Not used but may be passed by the Stage :return: string of resolved file path
- resolve_file_token_with_fallbacks(stage, comp_node, value, comp_layer)[source]
Given a node, who’s attr_name has a value only containing a file token we will fall back through all possible historical comps until we bottom out or find a valid file path. :param stage: Stage instance to resolve against :param comp_node: CompNode object :param value: string of attribute value :param comp_layer: CompLayer object :raises: TypeError :return: string of file path or empty string if no file found
- historical_resolve_file_ref(stage, comp_node, value, comp_layer, active_layers, token, historical_depth=0)[source]
Attempts to resolve a file token in the attribute specified at the historical depth given. See Stage.infer_lower_comp for more details on comping at a historical depth. This method is not recursive, it only checks the exact historical depth provided. :param stage: Stage instance to resolve against :param comp_node: CompNode object :param value: string of attribute value :param comp_layer: CompLayer object :param active_layers: List of at least 1 active layer :param token: tokens.Token object :param historical_depth: number of layers to step back, relative to the comp layer, that the historical comp should be built at. :return: string of the resolved attribute value
- historical_resolve_attr_ref(stage, string, comp_node, comp_layer, active_layers, historical_depth=0)[source]
Attempts to resolve an attr ref token at the historical depth given. See Stage.infer_lower_comp for more details on comping at a historical depth. This method IS recursive, BUT only checks the exact historical depth provided. :param stage: Stage instance :param string: Attr value string containing 1 or more attr ref tokens. :param comp_node: CompNode object :param comp_layer: CompLayer object :param active_layers: list of active layers :param historical_depth: number of layers to step back, relative to the comp layer, that the historical comp should be built at. :return: string of the resolved attribute token
- iter_env_roots(only_exsiting=True)[source]
Yield the roots in NXT_FILE_ROOTS, skipping any that do not exist.
Resolving one build’s file tokens calls this tens of thousands of times, and it used to stat every root every time. The usable roots are cached against the raw env var, so a graph changing NXT_FILE_ROOTS gets a fresh answer while a build that does not pays for the check once.
And against the working directory: a relative root exists or not depending on where it is looked from, and loading a graph changes into each layer’s folder. Cached without it, a relative root checked once from the wrong folder was skipped for good.
- file_root_fallback(filepath, layer_dir=None)[source]
Test a given filepath against the list of possible root paths specified in the env var NXT_FILE_ROOTS. :param filepath: string of file path :param layer_dir: optional layer dir to be tested after all possible roots fail. :return: string of valid filepath or empty string