raesl.utils
¶
Generic utility functions.
cap
¶
check_output_file_path
¶
Check output filepath versus force overwrite status.
Source code in src/raesl/utils.py
cleanup_path
¶
get_component_behaviors
¶
Get relevant behavior requirements or constraints for a component.
Source code in src/raesl/utils.py
get_component_designs
¶
Get relevant design requirements or constraints for a component.
Source code in src/raesl/utils.py
get_component_goals
¶
get_component_goals(
component: Node,
graph: Graph,
constraint: bool = True,
inherited: bool = True,
) -> list[Node]
Get relevant goal requirements or constraints for a component.
Source code in src/raesl/utils.py
get_component_needs
¶
Get relevant needs for a component.
Source code in src/raesl/utils.py
get_component_properties
¶
Get relevant properties for a component.
get_component_relations
¶
get_component_transformations
¶
get_component_transformations(
component: Node, graph: Graph, constraint: bool = True
) -> list[Node]
Get relevant transformation requirements or constraints for a component.
Source code in src/raesl/utils.py
get_design_rule_line_vars
¶
get_design_rule_line_vars(
rules: list[dict[str, Any]], g: Graph
) -> list[dict[str, Any]]
Get variables that are used within a design rule line
Source code in src/raesl/utils.py
get_esl_paths
¶
Get a sorted list of ESL file paths from multiple file or directory paths.
Source code in src/raesl/utils.py
get_first_namepart
¶
get_global_designs
¶
Get globally relevant design requirments or constraints.
Source code in src/raesl/utils.py
get_global_needs
¶
Get globally relevant needs.
Source code in src/raesl/utils.py
get_location
¶
get_location(
uri: str = "Unknown",
start_line: int = 0,
start_character: int = 0,
end_line: int | None = None,
end_character: int | None = None,
) -> Location
Generation utility to quickly drum up a location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
Location uri. |
'Unknown'
|
start_line
|
int
|
Location's range start line. |
0
|
start_character
|
int
|
Location's range start offset. |
0
|
end_line
|
int | None
|
Optional Location's range end line (otherwise identical to start.) |
None
|
end_character
|
int | None
|
Optional Location's range end offset (otherwise identical to start.) |
None
|
Returns:
| Type | Description |
|---|---|
Location
|
Newly created location instance. |
Source code in src/raesl/utils.py
get_node_tagged_comments
¶
get_node_tagged_comments(
component: Node,
) -> dict[str, str | list[str]]
get_scoped_nodes
¶
Get scoped nodes, being subtrees of the graph of varying depth.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph
|
Graph data. |
required |
scopes
|
dict[str, int | None]
|
Node names mapped to depths of the subtree to include. A depth of
:obj: |
required |
Returns:
| Type | Description |
|---|---|
list[Node]
|
List of nodes in all given scopes. |
Source code in src/raesl/utils.py
is_number
¶
is_subpath
¶
Check if a partial path is anywhere in the reference. Returns the starting integer if so.
Source code in src/raesl/utils.py
path_contents_or_str
¶
Return a file path's contents or the input string (contents) as is.
path_to_uri
¶
split_first_dot
¶
Split the provided name on the first dot if it exists, return both parts, and the length of the dot.
Source code in src/raesl/utils.py
uri_to_path
¶
Convert a file URI to a regular path.
yield_subtree
¶
Yield nodes from a given subtree starting at Node and with given depth.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Node
|
Root node of subtree. |
required |
depth
|
int | None
|
Depth of subtree. If None, defaults to full depth. |
required |
Yields:
| Type | Description |
|---|---|
Node
|
Nodes in the subtree. |