targets targets.sim_params
API Reference Manual  /  Python API  /  targets  / 

targets.script_params

Name

targets.script_params

Synopsis

Python

import targets.script_params

class targets.script_params.Decl

Synopsis

class targets.script_params.Decl(
    decl_type,
    arg_validator,
    input_type,
    default,
    required,
    name,
    output,
    desc,
    values,
    advanced,
    fn,
    allow_empty=False,
    explicit_default=False,
    extra_data={},
    telemetry=False
)

Description

Declaration of a single script parameter.

It is a leaf in the declaration tree and holds what the target script says about the parameter, not its value; values are kept in targets.script_params.Param objects.

Attributes

targets.script_params.dump_declarations

Synopsis

targets.script_params.dump_declarations(
    decls: Dict[str, Union[targets.script_params.Decl, Dict]],
    advanced: Optional[int],
    prune=True
) -> Dict

Description

Return a dump tree of the declaration tree decls.

The tree has the output of dump for each targets.script_params.Decl leaf node.

targets.script_params.dump_parameters

Synopsis

targets.script_params.dump_parameters(
    decls: Dict[str, Union[targets.script_params.Decl, Dict]],
    tree: Dict[str, Union[targets.script_params.Param, Dict]],
    include_unassigned=True
) -> Dict

Description

Return a dump tree of the argument tree tree.

The tree matches the declaration tree decls and has the output of dump for each targets.script_params.Param leaf node. For unassigned parameters a similar dump structure is added.

targets.script_params.init

Synopsis

targets.script_params.init()

Description

Initialise script parameter functionality.

class targets.script_params.Param

Synopsis

class targets.script_params.Param(name, value, state, decl=None, fn=None)

Description

Value of a single script parameter.

It is a leaf in the argument tree. The declaration is kept in a targets.script_params.Decl object.

Attributes

targets.script_params.parse_script

Synopsis

targets.script_params.parse_script(
    fn: Union[pathlib.Path, str],
    lookup: Callable[[str], str],
    targets: list,
    cmdline_args: Dict[str, Union[targets.script_params.Param, Dict]] = None,
    ignore_blueprints: bool = False
) -> Optional[Dict]

Description

Parse the script file or string fn and return its meta-data.

This is the script parser entry point. The lookup function is used on all file references (import/script/target).

Return Value

A dict with the keys code, params, args, desc and blueprints. The value of code is None if the script has no code.

Exceptions

TargetParamError if fn is not a valid script.

targets.script_params.resolve_parameters

Synopsis

targets.script_params.resolve_parameters(
    fn: pathlib.Path,
    decls: Dict[str, Union[targets.script_params.Decl, Dict]],
    args: Dict[str, Union[targets.script_params.Param, Dict]],
    errors: dict,
    lookup_file: Callable[[str], str],
    logger: Callable[[str], NoneType],
    roots: Optional[Dict] = None,
    prefix=''
) -> Dict[str, Union[targets.script_params.Param, Dict]]

Description

Resolve arguments args against the declaration tree decls.

Assigned values are removed from args. Errors, such as an invalid type or a missing value for a required parameter, are added to the dict errors, with the flat parameter name as key.

Return Value

The argument tree for the script fn.

targets.script_params.save_parameters

Synopsis

targets.script_params.save_parameters(
    tree: Dict[str, Union[targets.script_params.Param, Dict]],
    user_only=True,
    resolve_refs=True
) -> Dict

Description

Return a tree of argument values from the argument tree tree.

By default, only arguments that were set explicitly by the user are included.

targets.script_params.write_parameters

Synopsis

targets.script_params.write_parameters(
    args: Dict,
    script: str,
    f: <class 'TextIO'>
)

Description

Write a preset file to f.

The preset has the arguments args and the target pointer script.

targets.script_params.write_yaml

Synopsis

targets.script_params.write_yaml(
    data: Dict,
    output_file: <class 'TextIO'>
) -> Optional[str]

Description

Encode data as YAML and write it to the stream output_file.

Return Value

The YAML text if output_file is None, otherwise None.

targets targets.sim_params