raesl.utils
¶
Generic utility functions.
check_output_path
¶
Check output filepath versus force overwrite status.
Source code in src/raesl/utils.py
cleanup_path
¶
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_location
¶
get_location(
uri: str = "Unknown",
start_line: int = 0,
start_character: int = 0,
end_line: Optional[int] = None,
end_character: Optional[int] = 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
|
Optional[int]
|
Optional Location's range end line (otherwise identical to start.) |
None
|
end_character
|
Optional[int]
|
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_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, Optional[int]]
|
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
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
|
Optional[int]
|
Depth of subtree. If None, defaults to full depth. |
required |
Yields:
Type | Description |
---|---|
Node
|
Nodes in the subtree. |